re

2018-06-02 Thread Ms. Ella Golan
I am Ms.Ella Golan, I am the Executive Vice President Banking Division with 
FIRST INTERNATIONAL BANK OF ISRAEL LTD (FIBI). I am getting in touch with you 
regarding an extremely important and urgent matter. If you would oblige me the 
opportunity, I shall provide you with details upon your response.

Faithfully,
Ms.Ella Golan


Re: [Patch v2 13/15] CIFS: Add support for direct I/O read

2018-06-02 Thread kbuild test robot
Hi Long,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on v4.17-rc6]
[cannot apply to cifs/for-next next-20180601]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Long-Li/CIFS-Add-direct-I-O-support/20180602-130240
config: i386-randconfig-x008-201821 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:14:0,
from include/linux/list.h:9,
from include/linux/wait.h:7,
from include/linux/wait_bit.h:8,
from include/linux/fs.h:6,
from fs//cifs/file.c:24:
   fs//cifs/file.c: In function 'cifs_direct_readv':
   include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of 
type 'long unsigned int', but argument 5 has type 'size_t {aka unsigned int}' 
[-Wformat=]
#define KERN_SOH "\001"  /* ASCII Start Of Header */
 ^
   include/linux/printk.h:136:10: note: in definition of macro 'no_printk'
  printk(fmt, ##__VA_ARGS__);  \
 ^~~
   include/linux/kern_levels.h:15:20: note: in expansion of macro 'KERN_SOH'
#define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
   ^~~~
   include/linux/printk.h:410:12: note: in expansion of macro 'KERN_DEBUG'
 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
   ^~
   fs//cifs/cifs_debug.h:54:3: note: in expansion of macro 'pr_debug_once'
  pr_debug_ ## ratefunc("%s: "   \
  ^
   fs//cifs/cifs_debug.h:67:3: note: in expansion of macro 'cifs_dbg_func'
  cifs_dbg_func(once,   \
  ^
>> fs//cifs/file.c:3346:4: note: in expansion of macro 'cifs_dbg'
   cifs_dbg(VFS,
   ^~~~
   fs//cifs/file.c:3348:20: note: format string is defined here
" iov_offset %lu count %lu\n",
 ~~^
 %u
   In file included from include/linux/kernel.h:14:0,
from include/linux/list.h:9,
from include/linux/wait.h:7,
from include/linux/wait_bit.h:8,
from include/linux/fs.h:6,
from fs//cifs/file.c:24:
   include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of 
type 'long unsigned int', but argument 6 has type 'size_t {aka unsigned int}' 
[-Wformat=]
#define KERN_SOH "\001"  /* ASCII Start Of Header */
 ^
   include/linux/printk.h:136:10: note: in definition of macro 'no_printk'
  printk(fmt, ##__VA_ARGS__);  \
 ^~~
   include/linux/kern_levels.h:15:20: note: in expansion of macro 'KERN_SOH'
#define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
   ^~~~
   include/linux/printk.h:410:12: note: in expansion of macro 'KERN_DEBUG'
 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
   ^~
   fs//cifs/cifs_debug.h:54:3: note: in expansion of macro 'pr_debug_once'
  pr_debug_ ## ratefunc("%s: "   \
  ^
   fs//cifs/cifs_debug.h:67:3: note: in expansion of macro 'cifs_dbg_func'
  cifs_dbg_func(once,   \
  ^
>> fs//cifs/file.c:3346:4: note: in expansion of macro 'cifs_dbg'
   cifs_dbg(VFS,
   ^~~~
   fs//cifs/file.c:3348:30: note: format string is defined here
" iov_offset %lu count %lu\n",
   ~~^
   %u
   In file included from include/linux/kernel.h:14:0,
from include/linux/list.h:9,
from include/linux/wait.h:7,
from include/linux/wait_bit.h:8,
from include/linux/fs.h:6,
from fs//cifs/file.c:24:
   include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of 
type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' 
[-Wformat=]
#define KERN_SOH "\001"  /* ASCII Start Of Header */
 ^
   include/linux/printk.h:357:10: note: in definition of macro 'printk_once'
  printk(fmt, ##__VA_ARGS__);   \
 ^~~
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */
 ^~~~
   include/linux/printk.h:386:14: note: in expansion of macro 'KERN_ERR'
 printk_once(KER

[PATCH] clk: qcom: Export clk_fabia_pll_configure()

2018-06-02 Thread sboyd
From: Stephen Boyd 

This is used by the video clk driver on sdm845 and that's a module.
Export it to prevent module build failures.

Cc: Amit Nischal 
Signed-off-by: Stephen Boyd 
---
 drivers/clk/qcom/clk-alpha-pll.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clk/qcom/clk-alpha-pll.c b/drivers/clk/qcom/clk-alpha-pll.c
index 9722b701fbdb..3c49a60072f1 100644
--- a/drivers/clk/qcom/clk-alpha-pll.c
+++ b/drivers/clk/qcom/clk-alpha-pll.c
@@ -885,6 +885,7 @@ void clk_fabia_pll_configure(struct clk_alpha_pll *pll, 
struct regmap *regmap,
 
regmap_update_bits(regmap, PLL_MODE(pll), PLL_RESET_N, PLL_RESET_N);
 }
+EXPORT_SYMBOL_GPL(clk_fabia_pll_configure);
 
 static int alpha_pll_fabia_enable(struct clk_hw *hw)
 {
-- 
Sent by a computer through tubes



linux-next: Signed-off-by missing for commit in the vfs-fixes tree

2018-06-02 Thread Stephen Rothwell
Hi Al,

Commit

  9b8a76714b3d ("Revert "fs: fold open_check_o_direct into do_dentry_open"")

is missing a Signed-off-by from its author and committer.

Reverts are commits as well ;-)

-- 
Cheers,
Stephen Rothwell


pgpk9K03zjGlG.pgp
Description: OpenPGP digital signature


Re: Kconfig warnings with GCC 8.1.0

2018-06-02 Thread Masahiro Yamada
Hi.


2018-05-31 13:18 GMT+09:00 Nathan Chancellor :
> Hi everyone,
>
> My apologies if this has already been reported in some capacity, I
> searched the mailing list and patchwork but I didn't see anything.


I think you are the first reporter.


> With GCC 8.1.0, I am starting to see the following warnings from
> Kconfig:
>
>   CCscripts/kconfig/zconf.tab.c
>   LEX scripts/kconfig/zconf.lex.c
>   HOSTCC  scripts/kconfig/zconf.tab.o
> In file included from scripts/kconfig/zconf.tab.c:2496:
> scripts/kconfig/confdata.c: In function ‘conf_write’:
> scripts/kconfig/confdata.c:748:22: warning: ‘%s’ directive writing likely 7 
> or more bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
>   sprintf(newname, "%s%s", dirname, basename);
>   ^~
> scripts/kconfig/confdata.c:748:19: note: assuming directive output of 7 bytes
>   sprintf(newname, "%s%s", dirname, basename);
>^~
> scripts/kconfig/confdata.c:748:2: note: ‘sprintf’ output 1 or more bytes 
> (assuming 4104) into a destination of size 4097
>   sprintf(newname, "%s%s", dirname, basename);
>   ^~~
> scripts/kconfig/confdata.c:751:23: warning: ‘.tmpconfig.’ directive writing 
> 11 bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
>sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
>^~~
> scripts/kconfig/confdata.c:751:3: note: ‘sprintf’ output between 13 and 4119 
> bytes into a destination of size 4097
>sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
>^~~
>   HOSTCC  scripts/kconfig/conf.o
>   HOSTLD  scripts/kconfig/conf
>
> I am not sure if this is a false positive or not, otherwise I would have
> sent a patch. I tested on the latest linux-next with Masahiro's for-next
> branch, currently at commit 57282f7da50c ("Merge branch 'kconfig' into
> for-next").


I think these are legitimate warnings.

A patch is welcome.



-- 
Best Regards
Masahiro Yamada


[PATCH] clk: davinci: cfgchip: testing the wrong variable

2018-06-02 Thread Dan Carpenter
There is a copy and paste bug here.  We should be testing "usb1" instead
of "usb0".

Fixes: 58e1e2d2cd89 ("clk: davinci: cfgchip: Add TI DA8XX USB PHY clocks")
Signed-off-by: Dan Carpenter 

diff --git a/drivers/clk/davinci/da8xx-cfgchip.c 
b/drivers/clk/davinci/da8xx-cfgchip.c
index c97d2601..20a120aa147e 100644
--- a/drivers/clk/davinci/da8xx-cfgchip.c
+++ b/drivers/clk/davinci/da8xx-cfgchip.c
@@ -672,7 +672,7 @@ static int of_da8xx_usb_phy_clk_init(struct device *dev, 
struct regmap *regmap)
 
usb1 = da8xx_cfgchip_register_usb1_clk48(dev, regmap);
if (IS_ERR(usb1)) {
-   if (PTR_ERR(usb0) == -EPROBE_DEFER)
+   if (PTR_ERR(usb1) == -EPROBE_DEFER)
return -EPROBE_DEFER;
 
dev_warn(dev, "Failed to register usb1_clk48 (%ld)\n",


Lucrative Business Proposal

2018-06-02 Thread Adrien Saif




--
Dear Friend,

I would like to discuss a very important issue with you. I am writing 
to find out if this is your valid email. Please, let me know if this 
email is valid


Kind regards
Adrien Saif
Attorney to Quatif Group of Companies


Re: [PATCH v3 2/5] gpio: syscon: rockchip: add GPIO_MUTE support for rk3328

2018-06-02 Thread Levin Du



Rob Herring  writes:

On Thu, May 31, 2018 at 9:05 PM, Levin  
wrote:

Hi Rob,


On 2018-05-31 10:45 PM, Rob Herring wrote:


On Wed, May 30, 2018 at 10:27 PM,   wrote:


From: Levin Du 

In Rockchip RK3328, the output only GPIO_MUTE pin, originally 
for codec
mute control, can also be used for general purpose. It is 
manipulated by

the GRF_SOC_CON10 register.

Signed-off-by: Levin Du 

---

Changes in v3:
- Change from general gpio-syscon to specific 
rk3328-gpio-mute


Changes in v2:
- Rename gpio_syscon10 to gpio_mute in doc

Changes in v1:
- Refactured for general gpio-syscon usage for Rockchip SoCs.
- Add doc rockchip,gpio-syscon.txt

  .../bindings/gpio/rockchip,rk3328-gpio-mute.txt| 28
+++
  drivers/gpio/gpio-syscon.c | 31
++
  2 files changed, 59 insertions(+)
  create mode 100644
Documentation/devicetree/bindings/gpio/rockchip,rk3328-gpio-mute.txt

diff --git
a/Documentation/devicetree/bindings/gpio/rockchip,rk3328-gpio-mute.txt
b/Documentation/devicetree/bindings/gpio/rockchip,rk3328-gpio-mute.txt
new file mode 100644
index 000..10bc632
--- /dev/null
+++
b/Documentation/devicetree/bindings/gpio/rockchip,rk3328-gpio-mute.txt
@@ -0,0 +1,28 @@
+Rockchip RK3328 GPIO controller dedicated for the GPIO_MUTE 
pin.

+
+In Rockchip RK3328, the output only GPIO_MUTE pin, 
originally for codec

mute
+control, can also be used for general purpose. It is 
manipulated by the

+GRF_SOC_CON10 register.
+
+Required properties:
+- compatible: Should contain "rockchip,rk3328-gpio-mute".
+- gpio-controller: Marks the device node as a gpio 
controller.
+- #gpio-cells: Should be 2. The first cell is the pin number 
and

+  the second cell is used to specify the gpio polarity:
+0 = Active high,
+1 = Active low.
+
+Example:
+
+   grf: syscon@ff10 {
+   compatible = "rockchip,rk3328-grf", "syscon",
"simple-mfd";
+
+   gpio_mute: gpio-mute {


Node names should be generic:

gpio {

This also means you can't add another GPIO node in the future 
and
you'll have to live with "rockchip,rk3328-gpio-mute" covering 
more

than 1 GPIO if you do need to add more GPIOs.



As the first line describes, this GPIO controller is dedicated 
for the

GPIO_MUTE pin.
There's only one GPIO pin in the GRF_SOC_CON10 register. 
Therefore the

gpio_mute
name is proper IMHO.


It's how many GPIOs in the GRF, not this register. What I'm 
saying is
when you come along later to add another GPIO in the GRF, you 
had
better just add it to this same node. I'm not going to accept 
another
GPIO controller node within the GRF. You have the cells to 
support

more than 1, so it would only be a driver change. The compatible
string would then not be ideally named at that point. But 
compatible
strings are just unique identifiers, so it doesn't really matter 
what

the string is.



I'll try my best to introduce the situation here. The GRF, 
GPIO0~GPIO3
are register blocks in the RK3328 Soc. The GPIO0~GPIO3 contain 
registers

for GPIO operations like reading/writing data, setting direction,
interruption etc, which corresponds to the GPIO banks 
(gpio0~gpio3)

defined in rk3328.dtsi:

pinctrl: pinctrl {
compatible = "rockchip,rk3328-pinctrl";
rockchip,grf = <&grf>;
#address-cells = <2>;
#size-cells = <2>;
ranges;

gpio0: gpio0@ff21 {
compatible = "rockchip,gpio-bank";
reg = <0x0 0xff21 0x0 0x100>;
			interrupts = 			IRQ_TYPE_LEVEL_HIGH>;

clocks = <&cru PCLK_GPIO0>;

gpio-controller;
#gpio-cells = <2>;

interrupt-controller;
#interrupt-cells = <2>;
};

gpio1: gpio1@ff22 {
   //...
};

gpio2: gpio2@ff23 {
   //...
};

gpio3: gpio3@ff24 {
   //...
};
}

However, these general GPIO pins has multiplexed functions and 
their
pull up/down and driving strength can also be configured. These 
settings
are manipulated by the GRF registers in pinctrl driver. Quoted 
from the

TRM, the GRF has the following function:

- IOMUX control
- Control the state of GPIO in power-down mode
- GPIO PAD pull down and pull up control
- Used for common system control
- Used to record the system state

Therefore the functions of the GRF are messy and scattered in 
different
nodes. The so-called GPIO_MUTE does not belong to GPIO0~GPIO3. It 
is

manipulated by the GRF_SOC_CON10 register in the GRF block.

I'm being told both "this is the only GPIO" and "the GRF has too 
many
different functions for us to tell you what they all are". So 
which is

it?

Rob


They are both true, but lack of context. See the above 
description.


Thanks,
Levi

Re: [PATCH 1/6] arm64: dts: amlogic: Add missing cooling device properties for CPUs

2018-06-02 Thread Olof Johansson
On Mon, May 28, 2018 at 04:43:58PM +0530, Viresh Kumar wrote:
> On 25-05-18, 14:10, Olof Johansson wrote:
> > On Fri, May 25, 2018 at 11:10:01AM +0530, Viresh Kumar wrote:
> > > The cooling device properties, like "#cooling-cells" and
> > > "dynamic-power-coefficient", should either be present for all the CPUs
> > > of a cluster or none. If these are present only for a subset of CPUs of
> > > a cluster then things will start falling apart as soon as the CPUs are
> > > brought online in a different order. For example, this will happen
> > > because the operating system looks for such properties in the CPU node
> > > it is trying to bring up, so that it can register a cooling device.
> > > 
> > > Add such missing properties.
> > 
> > This seems awkward compared to just having one cooling-cells in the /cpus 
> > node
> > instead.
> 
> Well, we don't allow that property to be present in /cpus node right
> now and it is per device. And then we may not want all the CPUs to be
> cooling devices really.

And what I am saying is that it sounds like a broken binding if you don't allow
that, especially since it'll be a super common case that all CPUs will specify
the same cooling-device specifier.

> > What's it used for? I don't see any properties in the device nodes on 
> > meson-gxm
> > that have any cooling-foo cells in them? So why should #cooling-cells be
> > needed?
> 
> This property is required to declare a device as a cooling-device and
> the device here is CPU. We use it as a cooling device by limiting its
> higher range of frequencies, so that it doesn't generate too much
> heat.
> 
> It is already there for CPU0 and CPU4, but it should really be there
> for all the CPUs, like we have clock, supply, caches, etc.

You have #cooling-cells in the cpu node, but the actual data is in the
thermal-zones nodes. Why isn't #cooling-cells under thermal-zones, next to
cooling-maps?


-Olof


Re: [PATCH] ARM: tegra: fix compile-testing PCI host driver

2018-06-02 Thread Olof Johansson
On Mon, May 28, 2018 at 05:55:29PM +0200, Arnd Bergmann wrote:
> The tegra_cpuidle_pcie_irqs_in_use() function is stubbed out for non-ARM
> builds, but now we can compile-test the Tegra pci driver on non-Tegra
> ARM platforms as well, which results in a new link error:
> 
> drivers/pci/host/pci-tegra.o: In function `tegra_pcie_map_irq':
> pci-tegra.c:(.text+0x288): undefined reference to 
> `tegra_cpuidle_pcie_irqs_in_use'
> drivers/pci/host/pci-tegra.o: In function `tegra_msi_map':
> pci-tegra.c:(.text+0xba0): undefined reference to 
> `tegra_cpuidle_pcie_irqs_in_use'
> 
> This adapts the #ifdef statement to match the exact condition under which
> the function can be called.
> 
> Fixes: 51bc085d6454 ("PCI: Improve host drivers compile test coverage")
> Cc: Rob Herring 
> Cc: Lorenzo Pieralisi 
> Signed-off-by: Arnd Bergmann 

Applied, thanks!


-Olof


Lucrative Business Proposal

2018-06-02 Thread Adrien Saif




--
Dear Friend,

I would like to discuss a very important issue with you. I am writing 
to find out if this is your valid email. Please, let me know if this 
email is valid


Kind regards
Adrien Saif
Attorney to Quatif Group of Companies


[PATCH v2 1/3] staging: rtlwifi: Fix "Trafic"->"Traffic"

2018-06-02 Thread Sabin Mihai Rapan
Trivial fix to spelling mistake in comment text.

Signed-off-by: Sabin Mihai Rapan 
---
Changes in v2:
 - Added proper to and cc fields to the patch series.

 drivers/staging/rtlwifi/phydm/phydm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtlwifi/phydm/phydm.c 
b/drivers/staging/rtlwifi/phydm/phydm.c
index 985978d3decc..27635feedba2 100644
--- a/drivers/staging/rtlwifi/phydm/phydm.c
+++ b/drivers/staging/rtlwifi/phydm/phydm.c
@@ -149,7 +149,7 @@ static void phydm_traffic_load_decision(void *dm_void)
 {
struct phy_dm_struct *dm = (struct phy_dm_struct *)dm_void;
 
-   /*---TP & Trafic-load calculation---*/
+   /*---TP & Traffic-load calculation---*/
 
if (dm->last_tx_ok_cnt > *dm->num_tx_bytes_unicast)
dm->last_tx_ok_cnt = *dm->num_tx_bytes_unicast;
-- 
2.17.0



[PATCH v2 2/3] staging: rtlwifi: Fix "writen"->"written"

2018-06-02 Thread Sabin Mihai Rapan
Trivial fix to spelling mistake in comment text.

Signed-off-by: Sabin Mihai Rapan 
---
Changes in v2:
 - Added proper to and cc fields to the patch series.

 drivers/staging/rtlwifi/rtl8822be/fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtlwifi/rtl8822be/fw.c 
b/drivers/staging/rtlwifi/rtl8822be/fw.c
index efec7281511c..a40396614814 100644
--- a/drivers/staging/rtlwifi/rtl8822be/fw.c
+++ b/drivers/staging/rtlwifi/rtl8822be/fw.c
@@ -82,7 +82,7 @@ static void _rtl8822be_fill_h2c_command(struct ieee80211_hw 
*hw, u8 element_id,
}
 
while (!bwrite_success) {
-   /* 2. Find the last BOX number which has been writen. */
+   /* 2. Find the last BOX number which has been written. */
boxnum = rtlhal->last_hmeboxnum;
switch (boxnum) {
case 0:
-- 
2.17.0



[PATCH v2 3/3] staging: rtlwifi: Fix "Alwyas"->"Always"

2018-06-02 Thread Sabin Mihai Rapan
Trivial fix to spelling mistake in comment text.

Signed-off-by: Sabin Mihai Rapan 
---
Changes in v2:
 - Added proper to and cc fields to the patch series.

 drivers/staging/rtlwifi/rtl8822be/sw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtlwifi/rtl8822be/sw.c 
b/drivers/staging/rtlwifi/rtl8822be/sw.c
index 7825e85ed091..a2ab19fa94f2 100644
--- a/drivers/staging/rtlwifi/rtl8822be/sw.c
+++ b/drivers/staging/rtlwifi/rtl8822be/sw.c
@@ -43,7 +43,7 @@ static void rtl8822be_init_aspm_vars(struct ieee80211_hw *hw)
 * 0 - Disable ASPM,
 * 1 - Enable ASPM without Clock Req,
 * 2 - Enable ASPM with Clock Req,
-* 3 - Alwyas Enable ASPM with Clock Req,
+* 3 - Always Enable ASPM with Clock Req,
 * 4 - Always Enable ASPM without Clock Req.
 * set default to RTL8822BE:3 RTL8822B:2
 *
-- 
2.17.0



Re: [PATCH v2 16/17] signal: make security_task_kill() return bool

2018-06-02 Thread Christian Brauner
On Fri, Jun 01, 2018 at 06:26:25PM +0200, Oleg Nesterov wrote:
> On 06/01, Christian Brauner wrote:
> >
> > security_task_kill() already behaves like a boolean function. Let's
> > actually declare it as such too.
> 
> The subject/changelog is wrong, this patch changes sigkill_pending()

Ah yes, s/security_task_kill()/sigkill_pending()

Thanks!
Christian

> 
> > Signed-off-by: Christian Brauner 
> > ---
> > v1->v2:
> > * unchanged
> > v0->v1:
> > * patch added
> > ---
> >  kernel/signal.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/kernel/signal.c b/kernel/signal.c
> > index 515fa59a0e9c..d5f9472a0935 100644
> > --- a/kernel/signal.c
> > +++ b/kernel/signal.c
> > @@ -1922,10 +1922,10 @@ static inline bool may_ptrace_stop(void)
> >   * Return non-zero if there is a SIGKILL that should be waking us up.
> >   * Called with the siglock held.
> >   */
> > -static int sigkill_pending(struct task_struct *tsk)
> > +static bool sigkill_pending(struct task_struct *tsk)
> >  {
> > -   return  sigismember(&tsk->pending.signal, SIGKILL) ||
> > -   sigismember(&tsk->signal->shared_pending.signal, SIGKILL);
> > +   return sigismember(&tsk->pending.signal, SIGKILL) ||
> > +  sigismember(&tsk->signal->shared_pending.signal, SIGKILL);
> >  }
> >  
> >  /*
> > -- 
> > 2.17.0
> > 
> 


Re: [PATCH] clkdev: Remove duplicated negative index check from __of_clk_get()

2018-06-02 Thread Geert Uytterhoeven
Hi Stephen,

On Sat, Jun 2, 2018 at 6:47 AM, Stephen Boyd  wrote:
> Quoting Geert Uytterhoeven (2018-06-01 12:22:33)
>> On Fri, Jun 1, 2018 at 9:20 PM, Stephen Boyd  wrote:
>> > Quoting Geert Uytterhoeven (2018-05-18 03:58:40)
>> >> __of_clk_get() calls of_parse_phandle_with_args(), which rejects
>> >> negative indices since commit bd69f73f2c81eed9 ("of: Create function for
>> >> counting number of phandles in a property").
>> >>
>> >> Signed-off-by: Geert Uytterhoeven 
>> >> ---
>> >> Commit bd69f73f2c81eed9 is in v3.9.
>> >
>> > Did you send this to Russell's patch tracker? Otherwise I can pick it up
>>
>> Not yet. The patch tracker is for reviewed patches, AFAIK.
>>
>> > to clk-next.
>>
>> Thanks!
>>
>
> Ok. If you need my reviewed-by to add it to the tracker feel free to
> have:
>
> Reviewed-by: Stephen Boyd 

Thanks, but it's much easier if you would take it, and I can avoid looking
up again how to submit it properly to the patch tracker.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[PATCH v3 08/17] signal: make sig_task_ignored() return bool

2018-06-02 Thread Christian Brauner
sig_task_ignored() already behaves like a boolean function. Let's actually
declare it as such too.

Signed-off-by: Christian Brauner 
---
v2->v3:
* unchanged
v1->v2:
* unchanged
v0->v1:
* patch added
---
 kernel/signal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 13061f388042..ff2ea82e376b 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -72,7 +72,7 @@ static inline bool sig_handler_ignored(void __user *handler, 
int sig)
   (handler == SIG_DFL && sig_kernel_ignore(sig));
 }
 
-static int sig_task_ignored(struct task_struct *t, int sig, bool force)
+static bool sig_task_ignored(struct task_struct *t, int sig, bool force)
 {
void __user *handler;
 
@@ -80,7 +80,7 @@ static int sig_task_ignored(struct task_struct *t, int sig, 
bool force)
 
if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) &&
handler == SIG_DFL && !(force && sig_kernel_only(sig)))
-   return 1;
+   return true;
 
return sig_handler_ignored(handler, sig);
 }
-- 
2.17.0



[PATCH v3 00/17] signal: refactor some functions

2018-06-02 Thread Christian Brauner
Hey,

This series refactors a bunch of functions in signal.c to simplify parts
of the code.
As requested, v3 drops all 3 commits that were pure coding-style
changes.
The greatest single change is declaring the static do_sigpending()
helper as void which makes it possible to remove a bunch of unnecessary
checks in the syscalls later on.

Thanks!
Christian

Christian Brauner (17):
  signal: make force_sigsegv() void
  signal: make kill_as_cred_perm() return bool
  signal: make may_ptrace_stop() return bool
  signal: make do_sigpending() void
  signal: simplify rt_sigaction()
  signal: make kill_ok_by_cred() return bool
  signal: make sig_handler_ignored() return bool
  signal: make sig_task_ignored() return bool
  signal: make sig_ignored() return bool
  signal: make has_pending_signals() return bool
  signal: make recalc_sigpending_tsk() return bool
  signal: make unhandled_signal() return bool
  signal: make flush_sigqueue_mask() void
  signal: make wants_signal() return bool
  signal: make legacy_queue() return bool
  signal: make sigkill_pending() return bool
  signal: make get_signal() return bool

 include/linux/sched/signal.h |   2 +-
 include/linux/signal.h   |   4 +-
 kernel/signal.c  | 170 +--
 3 files changed, 86 insertions(+), 90 deletions(-)

-- 
2.17.0



[PATCH v3 10/17] signal: make has_pending_signals() return bool

2018-06-02 Thread Christian Brauner
has_pending_signals() already behaves like a boolean function. Let's
actually declare it as such too.

Signed-off-by: Christian Brauner 
---
v2->v3:
* [Oleg Nestorov] remove other non-functional changes
v1->v2:
* unchanged
v0->v1:
* patch added
---
 kernel/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index fed938c2e273..c2af9a7f73b3 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -110,7 +110,7 @@ static bool sig_ignored(struct task_struct *t, int sig, 
bool force)
  * Re-calculate pending state from the set of locally pending
  * signals, globally pending signals, and blocked signals.
  */
-static inline int has_pending_signals(sigset_t *signal, sigset_t *blocked)
+static inline bool has_pending_signals(sigset_t *signal, sigset_t *blocked)
 {
unsigned long ready;
long i;
-- 
2.17.0



[PATCH v3 01/17] signal: make force_sigsegv() void

2018-06-02 Thread Christian Brauner
force_sigsegv() returned 0 unconditionally so it doesn't make sense to have
it return at all. In addition, there are no callers that check
force_sigsegv()'s return value.

Signed-off-by: Christian Brauner 
---
v2->v3:
* unchanged
v1->v2:
* unchanged
v0->v1:
* unchanged
---
 include/linux/sched/signal.h | 2 +-
 kernel/signal.c  | 7 ++-
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index 113d1ad1ced7..e138ac16c650 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -314,7 +314,7 @@ int force_sig_pkuerr(void __user *addr, u32 pkey);
 int force_sig_ptrace_errno_trap(int errno, void __user *addr);
 
 extern int send_sig_info(int, struct siginfo *, struct task_struct *);
-extern int force_sigsegv(int, struct task_struct *);
+extern void force_sigsegv(int sig, struct task_struct *p);
 extern int force_sig_info(int, struct siginfo *, struct task_struct *);
 extern int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp);
 extern int kill_pid_info(int sig, struct siginfo *info, struct pid *pid);
diff --git a/kernel/signal.c b/kernel/signal.c
index 9c33163a6165..c756008d589e 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1468,8 +1468,7 @@ send_sig(int sig, struct task_struct *p, int priv)
return send_sig_info(sig, __si_special(priv), p);
 }
 
-void
-force_sig(int sig, struct task_struct *p)
+void force_sig(int sig, struct task_struct *p)
 {
force_sig_info(sig, SEND_SIG_PRIV, p);
 }
@@ -1480,8 +1479,7 @@ force_sig(int sig, struct task_struct *p)
  * the problem was already a SIGSEGV, we'll want to
  * make sure we don't even try to deliver the signal..
  */
-int
-force_sigsegv(int sig, struct task_struct *p)
+void force_sigsegv(int sig, struct task_struct *p)
 {
if (sig == SIGSEGV) {
unsigned long flags;
@@ -1490,7 +1488,6 @@ force_sigsegv(int sig, struct task_struct *p)
spin_unlock_irqrestore(&p->sighand->siglock, flags);
}
force_sig(SIGSEGV, p);
-   return 0;
 }
 
 int force_sig_fault(int sig, int code, void __user *addr
-- 
2.17.0



[PATCH v3 06/17] signal: make kill_ok_by_cred() return bool

2018-06-02 Thread Christian Brauner
kill_ok_by_cred() already behaves like a boolean function. Let's actually
declare it as such too.

Signed-off-by: Christian Brauner 
---
v2->v3:
* unchanged
v1->v2:
* unchanged
v0->v1:
* unchanged
---
 kernel/signal.c | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 21508900805b..dd239a8d7d2c 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -717,21 +717,16 @@ static inline bool si_fromuser(const struct siginfo *info)
 /*
  * called with RCU read lock from check_kill_permission()
  */
-static int kill_ok_by_cred(struct task_struct *t)
+static bool kill_ok_by_cred(struct task_struct *t)
 {
const struct cred *cred = current_cred();
const struct cred *tcred = __task_cred(t);
 
-   if (uid_eq(cred->euid, tcred->suid) ||
-   uid_eq(cred->euid, tcred->uid)  ||
-   uid_eq(cred->uid,  tcred->suid) ||
-   uid_eq(cred->uid,  tcred->uid))
-   return 1;
-
-   if (ns_capable(tcred->user_ns, CAP_KILL))
-   return 1;
-
-   return 0;
+   return uid_eq(cred->euid, tcred->suid) ||
+  uid_eq(cred->euid, tcred->uid) ||
+  uid_eq(cred->uid, tcred->suid) ||
+  uid_eq(cred->uid, tcred->uid) ||
+  ns_capable(tcred->user_ns, CAP_KILL);
 }
 
 /*
-- 
2.17.0



[PATCH v3 11/17] signal: make recalc_sigpending_tsk() return bool

2018-06-02 Thread Christian Brauner
recalc_sigpending_tsk() already behaves like a boolean function. Let's
actually declare it as such too.

Signed-off-by: Christian Brauner 
---
v2->v3:
* unchanged
v1->v2:
* unchanged
v0->v1:
* patch added
---
 kernel/signal.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index c2af9a7f73b3..41f9b91db209 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -138,20 +138,21 @@ static inline bool has_pending_signals(sigset_t *signal, 
sigset_t *blocked)
 
 #define PENDING(p,b) has_pending_signals(&(p)->signal, (b))
 
-static int recalc_sigpending_tsk(struct task_struct *t)
+static bool recalc_sigpending_tsk(struct task_struct *t)
 {
if ((t->jobctl & JOBCTL_PENDING_MASK) ||
PENDING(&t->pending, &t->blocked) ||
PENDING(&t->signal->shared_pending, &t->blocked)) {
set_tsk_thread_flag(t, TIF_SIGPENDING);
-   return 1;
+   return true;
}
+
/*
 * We must never clear the flag in another thread, or in current
 * when it's possible the current syscall is returning -ERESTART*.
 * So we don't clear it here, and only callers who know they should do.
 */
-   return 0;
+   return false;
 }
 
 /*
-- 
2.17.0



[PATCH v3 05/17] signal: simplify rt_sigaction()

2018-06-02 Thread Christian Brauner
The goto is not needed and does not add any clarity. Simply return -EINVAL
on unexpected sigset_t struct size directly.

Signed-off-by: Christian Brauner 
Acked-by: Oleg Nesterov 
---
v2->v3:
* added Oleg's Acked-by
v1->v2:
* [Christoph Hellwig] additional cleanups
v0->v1:
* unchanged
---
 kernel/signal.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index e17ae40ee6bd..21508900805b 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -3735,25 +3735,23 @@ SYSCALL_DEFINE4(rt_sigaction, int, sig,
size_t, sigsetsize)
 {
struct k_sigaction new_sa, old_sa;
-   int ret = -EINVAL;
+   int ret;
 
/* XXX: Don't preclude handling different sized sigset_t's.  */
if (sigsetsize != sizeof(sigset_t))
-   goto out;
+   return -EINVAL;
 
-   if (act) {
-   if (copy_from_user(&new_sa.sa, act, sizeof(new_sa.sa)))
-   return -EFAULT;
-   }
+   if (act && copy_from_user(&new_sa.sa, act, sizeof(new_sa.sa)))
+   return -EFAULT;
 
ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL);
+   if (ret)
+   return ret;
 
-   if (!ret && oact) {
-   if (copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
-   return -EFAULT;
-   }
-out:
-   return ret;
+   if (oact && copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
+   return -EFAULT;
+
+   return 0;
 }
 #ifdef CONFIG_COMPAT
 COMPAT_SYSCALL_DEFINE4(rt_sigaction, int, sig,
-- 
2.17.0



[PATCH v3 04/17] signal: make do_sigpending() void

2018-06-02 Thread Christian Brauner
do_sigpending() returned 0 unconditionally so it doesn't make sense to have
it return at all. This allows us to simplify a bunch of syscall callers.

Signed-off-by: Christian Brauner 
Acked-by: Al Viro 
Acked-by: Oleg Nesterov 
---
v2->v3:
* added Oleg's Acked-by
v1->v2:
* unchanged
v0->v1:
* unchanged
---
 kernel/signal.c | 41 -
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 1848959a3b72..e17ae40ee6bd 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2767,7 +2767,7 @@ COMPAT_SYSCALL_DEFINE4(rt_sigprocmask, int, how, 
compat_sigset_t __user *, nset,
 }
 #endif
 
-static int do_sigpending(sigset_t *set)
+static void do_sigpending(sigset_t *set)
 {
spin_lock_irq(¤t->sighand->siglock);
sigorsets(set, ¤t->pending.signal,
@@ -2776,7 +2776,6 @@ static int do_sigpending(sigset_t *set)
 
/* Outside the lock because only this thread touches it.  */
sigandsets(set, ¤t->blocked, set);
-   return 0;
 }
 
 /**
@@ -2788,15 +2787,16 @@ static int do_sigpending(sigset_t *set)
 SYSCALL_DEFINE2(rt_sigpending, sigset_t __user *, uset, size_t, sigsetsize)
 {
sigset_t set;
-   int err;
 
if (sigsetsize > sizeof(*uset))
return -EINVAL;
 
-   err = do_sigpending(&set);
-   if (!err && copy_to_user(uset, &set, sigsetsize))
-   err = -EFAULT;
-   return err;
+   do_sigpending(&set);
+
+   if (copy_to_user(uset, &set, sigsetsize))
+   return -EFAULT;
+
+   return 0;
 }
 
 #ifdef CONFIG_COMPAT
@@ -2804,15 +2804,13 @@ COMPAT_SYSCALL_DEFINE2(rt_sigpending, compat_sigset_t 
__user *, uset,
compat_size_t, sigsetsize)
 {
sigset_t set;
-   int err;
 
if (sigsetsize > sizeof(*uset))
return -EINVAL;
 
-   err = do_sigpending(&set);
-   if (!err)
-   err = put_compat_sigset(uset, &set, sigsetsize);
-   return err;
+   do_sigpending(&set);
+
+   return put_compat_sigset(uset, &set, sigsetsize);
 }
 #endif
 
@@ -3647,25 +3645,26 @@ int __compat_save_altstack(compat_stack_t __user *uss, 
unsigned long sp)
 SYSCALL_DEFINE1(sigpending, old_sigset_t __user *, uset)
 {
sigset_t set;
-   int err;
 
if (sizeof(old_sigset_t) > sizeof(*uset))
return -EINVAL;
 
-   err = do_sigpending(&set);
-   if (!err && copy_to_user(uset, &set, sizeof(old_sigset_t)))
-   err = -EFAULT;
-   return err;
+   do_sigpending(&set);
+
+   if (copy_to_user(uset, &set, sizeof(old_sigset_t)))
+   return -EFAULT;
+
+   return 0;
 }
 
 #ifdef CONFIG_COMPAT
 COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set32)
 {
sigset_t set;
-   int err = do_sigpending(&set);
-   if (!err)
-   err = put_user(set.sig[0], set32);
-   return err;
+
+   do_sigpending(&set);
+
+   return put_user(set.sig[0], set32);
 }
 #endif
 
-- 
2.17.0



[PATCH v3 07/17] signal: make sig_handler_ignored() return bool

2018-06-02 Thread Christian Brauner
sig_handler_ignored() already behaves like a boolean function. Let's
actually declare it as such too.

Signed-off-by: Christian Brauner 
---
v2->v3:
* unchanged
v1->v2:
* unchanged
v0->v1:
* patch added
---
 kernel/signal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index dd239a8d7d2c..13061f388042 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -65,11 +65,11 @@ static void __user *sig_handler(struct task_struct *t, int 
sig)
return t->sighand->action[sig - 1].sa.sa_handler;
 }
 
-static int sig_handler_ignored(void __user *handler, int sig)
+static inline bool sig_handler_ignored(void __user *handler, int sig)
 {
/* Is it explicitly or implicitly ignored? */
return handler == SIG_IGN ||
-   (handler == SIG_DFL && sig_kernel_ignore(sig));
+  (handler == SIG_DFL && sig_kernel_ignore(sig));
 }
 
 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
-- 
2.17.0



[PATCH v3 09/17] signal: make sig_ignored() return bool

2018-06-02 Thread Christian Brauner
sig_ignored() already behaves like a boolean function. Let's actually
declare it as such too.

Signed-off-by: Christian Brauner 
---
v2->v3:
* unchanged
v1->v2:
* unchanged
v0->v1:
* patch added
---
 kernel/signal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index ff2ea82e376b..fed938c2e273 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -85,7 +85,7 @@ static bool sig_task_ignored(struct task_struct *t, int sig, 
bool force)
return sig_handler_ignored(handler, sig);
 }
 
-static int sig_ignored(struct task_struct *t, int sig, bool force)
+static bool sig_ignored(struct task_struct *t, int sig, bool force)
 {
/*
 * Blocked signals are never ignored, since the
@@ -93,7 +93,7 @@ static int sig_ignored(struct task_struct *t, int sig, bool 
force)
 * unblocked.
 */
if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
-   return 0;
+   return false;
 
/*
 * Tracers may want to know about even ignored signal unless it
@@ -101,7 +101,7 @@ static int sig_ignored(struct task_struct *t, int sig, bool 
force)
 * by SIGNAL_UNKILLABLE task.
 */
if (t->ptrace && sig != SIGKILL)
-   return 0;
+   return false;
 
return sig_task_ignored(t, sig, force);
 }
-- 
2.17.0



[PATCH v3 03/17] signal: make may_ptrace_stop() return bool

2018-06-02 Thread Christian Brauner
may_ptrace_stop() already behaves like a boolean function. Let's actually
declare it as such too.

Signed-off-by: Christian Brauner 
---
v2->v3:
* [Oleg Nestorov] s/likely/unlikely logic
v1->v2:
* unchanged
v0->v1:
* unchanged
---
 kernel/signal.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 6c71d6b8d2b8..1848959a3b72 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1889,10 +1889,10 @@ static void do_notify_parent_cldstop(struct task_struct 
*tsk,
spin_unlock_irqrestore(&sighand->siglock, flags);
 }
 
-static inline int may_ptrace_stop(void)
+static inline bool may_ptrace_stop(void)
 {
if (!likely(current->ptrace))
-   return 0;
+   return false;
/*
 * Are we in the middle of do_coredump?
 * If so and our tracer is also part of the coredump stopping
@@ -1908,9 +1908,9 @@ static inline int may_ptrace_stop(void)
 */
if (unlikely(current->mm->core_state) &&
unlikely(current->mm == current->parent->mm))
-   return 0;
+   return false;
 
-   return 1;
+   return true;
 }
 
 /*
-- 
2.17.0



[PATCH v3 16/17] signal: make sigkill_pending() return bool

2018-06-02 Thread Christian Brauner
sigkill_pending() already behaves like a boolean function. Let's actually
declare it as such too.

Signed-off-by: Christian Brauner 
---
v2->v3:
* [Oleg Nestorov] fix wrong function name in commit message
v1->v2:
* unchanged
v0->v1:
* patch added
---
 kernel/signal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 50255b6a3124..8d57a64abe52 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1918,10 +1918,10 @@ static inline bool may_ptrace_stop(void)
  * Return non-zero if there is a SIGKILL that should be waking us up.
  * Called with the siglock held.
  */
-static int sigkill_pending(struct task_struct *tsk)
+static bool sigkill_pending(struct task_struct *tsk)
 {
-   return  sigismember(&tsk->pending.signal, SIGKILL) ||
-   sigismember(&tsk->signal->shared_pending.signal, SIGKILL);
+   return sigismember(&tsk->pending.signal, SIGKILL) ||
+  sigismember(&tsk->signal->shared_pending.signal, SIGKILL);
 }
 
 /*
-- 
2.17.0



[PATCH v3 17/17] signal: make get_signal() return bool

2018-06-02 Thread Christian Brauner
make get_signal() already behaves like a boolean function. Let's actually
declare it as such too.

Signed-off-by: Christian Brauner 
---
v2->v3:
* unchanged
v1->v2:
* unchanged
v0->v1:
* patch added
---
 include/linux/signal.h | 2 +-
 kernel/signal.c| 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/signal.h b/include/linux/signal.h
index 1145d7061ed9..97d5ff809716 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -262,7 +262,7 @@ extern void set_current_blocked(sigset_t *);
 extern void __set_current_blocked(const sigset_t *);
 extern int show_unhandled_signals;
 
-extern int get_signal(struct ksignal *ksig);
+extern bool get_signal(struct ksignal *ksig);
 extern void signal_setup_done(int failed, struct ksignal *ksig, int stepping);
 extern void exit_signals(struct task_struct *tsk);
 extern void kernel_sigaction(int, __sighandler_t);
diff --git a/kernel/signal.c b/kernel/signal.c
index 8d57a64abe52..47d0e3a9b166 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2301,7 +2301,7 @@ static int ptrace_signal(int signr, siginfo_t *info)
return signr;
 }
 
-int get_signal(struct ksignal *ksig)
+bool get_signal(struct ksignal *ksig)
 {
struct sighand_struct *sighand = current->sighand;
struct signal_struct *signal = current->signal;
@@ -2311,7 +2311,7 @@ int get_signal(struct ksignal *ksig)
task_work_run();
 
if (unlikely(uprobe_deny_signal()))
-   return 0;
+   return false;
 
/*
 * Do this once, we can't return to user-mode if freezing() == T.
-- 
2.17.0



[PATCH v3 02/17] signal: make kill_as_cred_perm() return bool

2018-06-02 Thread Christian Brauner
kill_as_cred_perm() already behaves like a boolean function. Let's actually
declare it as such too.

Signed-off-by: Christian Brauner 
---
v2->v3:
* unchanged
v1->v2:
* unchanged
v0->v1:
* simplify to use a single return
---
 kernel/signal.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index c756008d589e..6c71d6b8d2b8 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1349,14 +1349,15 @@ static int kill_proc_info(int sig, struct siginfo 
*info, pid_t pid)
return error;
 }
 
-static int kill_as_cred_perm(const struct cred *cred,
-struct task_struct *target)
+static inline bool kill_as_cred_perm(const struct cred *cred,
+struct task_struct *target)
 {
const struct cred *pcred = __task_cred(target);
-   if (!uid_eq(cred->euid, pcred->suid) && !uid_eq(cred->euid, pcred->uid) 
&&
-   !uid_eq(cred->uid,  pcred->suid) && !uid_eq(cred->uid,  pcred->uid))
-   return 0;
-   return 1;
+
+   return uid_eq(cred->euid, pcred->suid) ||
+  uid_eq(cred->euid, pcred->uid) ||
+  uid_eq(cred->uid, pcred->suid) ||
+  uid_eq(cred->uid, pcred->uid);
 }
 
 /* like kill_pid_info(), but doesn't use uid/euid of "current" */
-- 
2.17.0



[PATCH v3 12/17] signal: make unhandled_signal() return bool

2018-06-02 Thread Christian Brauner
unhandled_signal() already behaves like a boolean function. Let's actually
declare it as such too.
All callers treat it as such too.

Signed-off-by: Christian Brauner 
---
v2->v3:
* unchanged
v1->v2:
* unchanged
v0->v1:
* patch added
---
 include/linux/signal.h | 2 +-
 kernel/signal.c| 8 +---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/linux/signal.h b/include/linux/signal.h
index a9bc7e1b077e..1145d7061ed9 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -284,7 +284,7 @@ static inline void disallow_signal(int sig)
 
 extern struct kmem_cache *sighand_cachep;
 
-int unhandled_signal(struct task_struct *tsk, int sig);
+extern bool unhandled_signal(struct task_struct *tsk, int sig);
 
 /*
  * In POSIX a signal is sent either to a specific thread (Linux task)
diff --git a/kernel/signal.c b/kernel/signal.c
index 41f9b91db209..70680dd8b588 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -505,13 +505,15 @@ flush_signal_handlers(struct task_struct *t, int 
force_default)
}
 }
 
-int unhandled_signal(struct task_struct *tsk, int sig)
+bool unhandled_signal(struct task_struct *tsk, int sig)
 {
void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
if (is_global_init(tsk))
-   return 1;
+   return true;
+
if (handler != SIG_IGN && handler != SIG_DFL)
-   return 0;
+   return false;
+
/* if ptraced, let the tracer determine */
return !tsk->ptrace;
 }
-- 
2.17.0



[PATCH v3 14/17] signal: make wants_signal() return bool

2018-06-02 Thread Christian Brauner
wants_signal() already behaves like a boolean function. Let's actually
declare it as such too.

Signed-off-by: Christian Brauner 
---
v2->v3:
* unchanged
v1->v2:
* unchanged
v0->v1:
* patch added
---
 kernel/signal.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 100f2cb29fd8..3a12d3b25584 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -879,16 +879,20 @@ static bool prepare_signal(int sig, struct task_struct 
*p, bool force)
  * as soon as they're available, so putting the signal on the shared queue
  * will be equivalent to sending it to one such thread.
  */
-static inline int wants_signal(int sig, struct task_struct *p)
+static inline bool wants_signal(int sig, struct task_struct *p)
 {
if (sigismember(&p->blocked, sig))
-   return 0;
+   return false;
+
if (p->flags & PF_EXITING)
-   return 0;
+   return false;
+
if (sig == SIGKILL)
-   return 1;
+   return true;
+
if (task_is_stopped_or_traced(p))
-   return 0;
+   return false;
+
return task_curr(p) || !signal_pending(p);
 }
 
-- 
2.17.0



[PATCH v3 15/17] signal: make legacy_queue() return bool

2018-06-02 Thread Christian Brauner
legacy_queue() already behaves like a boolean function. Let's actually
declare it as such too.

Signed-off-by: Christian Brauner 
---
v2->v3:
* unchanged
v1->v2:
* unchanged
v0->v1:
* patch added
---
 kernel/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 3a12d3b25584..50255b6a3124 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -972,7 +972,7 @@ static void complete_signal(int sig, struct task_struct *p, 
int group)
return;
 }
 
-static inline int legacy_queue(struct sigpending *signals, int sig)
+static inline bool legacy_queue(struct sigpending *signals, int sig)
 {
return (sig < SIGRTMIN) && sigismember(&signals->signal, sig);
 }
-- 
2.17.0



[PATCH v3 13/17] signal: make flush_sigqueue_mask() void

2018-06-02 Thread Christian Brauner
The return value of flush_sigqueue_mask() is never checked anywhere.

Signed-off-by: Christian Brauner 
---
v2->v3:
* unchanged
v1->v2:
* unchanged
v0->v1:
* patch added
---
 kernel/signal.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 70680dd8b588..100f2cb29fd8 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -687,14 +687,14 @@ void signal_wake_up_state(struct task_struct *t, unsigned 
int state)
  *
  * All callers must be holding the siglock.
  */
-static int flush_sigqueue_mask(sigset_t *mask, struct sigpending *s)
+static void flush_sigqueue_mask(sigset_t *mask, struct sigpending *s)
 {
struct sigqueue *q, *n;
sigset_t m;
 
sigandsets(&m, mask, &s->signal);
if (sigisemptyset(&m))
-   return 0;
+   return;
 
sigandnsets(&s->signal, &s->signal, mask);
list_for_each_entry_safe(q, n, &s->list, list) {
@@ -703,7 +703,6 @@ static int flush_sigqueue_mask(sigset_t *mask, struct 
sigpending *s)
__sigqueue_free(q);
}
}
-   return 1;
 }
 
 static inline int is_si_special(const struct siginfo *info)
-- 
2.17.0



bisected 4.17-rc - BUG: Bad page state in process qemu-system-x86 pfn:7178f3

2018-06-02 Thread Amadeusz Sławiński
Hey,

so I've been getting system instability problems after shutting down
virtual machine with GPU pass-through in 4.17-rc series and I finally
got around to bisecting it.

Seems to be caused by 356e88ebe4473a3663cf3d14727ce293a4526d34
and problem seems to be gone after reverting it.

trce from /varlog/messages:

Jun  1 22:47:23 milkyway kernel: BUG: Bad page state in process qemu-system-x86 
 pfn:7178f3
Jun  1 22:47:23 milkyway kernel: page:fbfddc5e3cc0 count:0 mapcount:1 
mapping: index:0x1
Jun  1 22:47:23 milkyway kernel: flags: 0x200()
Jun  1 22:47:23 milkyway kernel: raw: 0200  
0001 
Jun  1 22:47:23 milkyway kernel: raw: dead0100 dead0200 
 
Jun  1 22:47:23 milkyway kernel: page dumped because: nonzero mapcount
Jun  1 22:47:23 milkyway kernel: Modules linked in: x86_pkg_temp_thermal 
coretemp crc32_pclmul crc32c_intel ghash_clmulni_intel pcbc aesni_intel 
eeepc_wmi asus_wmi wmi_bmof aes_x86_64 crypto_simd cryptd wmi glue_helper
Jun  1 22:47:23 milkyway kernel: CPU: 4 PID: 4303 Comm: qemu-system-x86 Not 
tainted 4.16.0+ #26
Jun  1 22:47:23 milkyway kernel: Hardware name: ASUS All Series/SABERTOOTH Z97 
MARK 2, BIOS 3503 04/18/2018
Jun  1 22:47:23 milkyway kernel: Call Trace:
Jun  1 22:47:23 milkyway kernel:  dump_stack+0x46/0x5b
Jun  1 22:47:23 milkyway kernel:  bad_page+0xbf/0x120
Jun  1 22:47:23 milkyway kernel:  free_pcppages_bulk+0x434/0x500
Jun  1 22:47:23 milkyway kernel:  free_unref_page+0x33/0x40
Jun  1 22:47:23 milkyway kernel:  dma_free_pagelist+0x27/0x40
Jun  1 22:47:23 milkyway kernel:  intel_iommu_unmap+0x114/0x150
Jun  1 22:47:23 milkyway kernel:  __iommu_unmap+0xe4/0x130
Jun  1 22:47:23 milkyway kernel:  vfio_unmap_unpin+0x13f/0x330
Jun  1 22:47:23 milkyway kernel:  vfio_remove_dma+0x12/0x40
Jun  1 22:47:23 milkyway kernel:  vfio_iommu_unmap_unpin_all+0x16/0x30
Jun  1 22:47:23 milkyway kernel:  vfio_iommu_type1_detach_group+0x2b3/0x2c0
Jun  1 22:47:23 milkyway kernel:  __vfio_group_unset_container+0x4d/0x180
Jun  1 22:47:23 milkyway kernel:  vfio_group_put_external_user+0x9/0x20
Jun  1 22:47:23 milkyway kernel:  kvm_vfio_group_put_external_user+0x1d/0x30
Jun  1 22:47:23 milkyway kernel:  kvm_vfio_destroy+0x4a/0xc0
Jun  1 22:47:23 milkyway kernel:  kvm_put_kvm+0x1a1/0x290
Jun  1 22:47:23 milkyway kernel:  kvm_vm_release+0x18/0x20
Jun  1 22:47:23 milkyway kernel:  __fput+0xcd/0x1f0
Jun  1 22:47:23 milkyway kernel:  task_work_run+0x8d/0xb0
Jun  1 22:47:23 milkyway kernel:  do_exit+0x2d9/0xbe0
Jun  1 22:47:23 milkyway kernel:  ? hrtimer_init+0x10/0x10
Jun  1 22:47:23 milkyway kernel:  do_group_exit+0x31/0xb0
Jun  1 22:47:23 milkyway kernel:  get_signal+0x12d/0x570
Jun  1 22:47:23 milkyway kernel:  do_signal+0x3e/0x5d0
Jun  1 22:47:23 milkyway kernel:  exit_to_usermode_loop+0x46/0x80
Jun  1 22:47:23 milkyway kernel:  do_syscall_64+0xe0/0xf0
Jun  1 22:47:23 milkyway kernel:  entry_SYSCALL_64_after_hwframe+0x3d/0xa2
Jun  1 22:47:23 milkyway kernel: RIP: 0033:0x7e7c7512750f
Jun  1 22:47:23 milkyway kernel: RSP: 002b:7e77df3f29d0 EFLAGS: 0246 
ORIG_RAX: 00ca
Jun  1 22:47:23 milkyway kernel: RAX: fdfc RBX: 0189 
RCX: 7e7c7512750f
Jun  1 22:47:23 milkyway kernel: RDX:  RSI: 0189 
RDI: 57066f99c0a8
Jun  1 22:47:23 milkyway kernel: RBP:  R08:  
R09: 
Jun  1 22:47:23 milkyway kernel: R10: 7e77df3f2a80 R11: 0246 
R12: 7e77df3f2a80
Jun  1 22:47:23 milkyway kernel: R13: 57066f99c0a8 R14: 7e77df3f2a80 
R15: 7fff7e253a30
Jun  1 22:47:23 milkyway kernel: Disabling lock debugging due to kernel taint



git bisect log

git bisect start
# good: [0adb32858b0bddf4ada5f364a84ed60b196dbcda] Linux 4.16
git bisect good 0adb32858b0bddf4ada5f364a84ed60b196dbcda
# bad: [60cc43fc888428bb2f18f08997432d426a243338] Linux 4.17-rc1
git bisect bad 60cc43fc888428bb2f18f08997432d426a243338
# good: [ac9053d2dcb9e8c3fa35ce458dfca8fddc141680] Merge tag 'usb-4.17-rc1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
git bisect good ac9053d2dcb9e8c3fa35ce458dfca8fddc141680
# good: [38c23685b273cfb4ccf31a199feccce3bdcb5d83] Merge tag 'armsoc-drivers' 
of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
git bisect good 38c23685b273cfb4ccf31a199feccce3bdcb5d83
# bad: [fbe173e3ffbd897b5a859020d714c0eaf4af2a1a] Merge tag 'rtc-4.17' of 
git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
git bisect bad fbe173e3ffbd897b5a859020d714c0eaf4af2a1a
# bad: [299f89d53e61c0b17479cc7d6f3b5382d5e83f28] Merge tag 'leaks-4.17-rc1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/tobin/leaks
git bisect bad 299f89d53e61c0b17479cc7d6f3b5382d5e83f28
# good: [28da7be5ebc096ada5e6bc526c623bdd8c47800a] Merge tag 'mailbox-v4.17' of 
git://git.linaro.org/landing-teams/working/fujitsu/integration
git bisect good 28da7be5ebc096ada5e6bc526c

Re: [PATCH v1 3/4] clk: tegra20: Turn EMC clock gate into divider

2018-06-02 Thread Dmitry Osipenko
On 02.06.2018 09:37, Stephen Boyd wrote:
> Quoting Dmitry Osipenko (2018-05-30 08:06:45)
>> Kernel should never gate the EMC clock as it causes immediate lockup, so
>> removing clk-gate functionality doesn't affect anything. Turning EMC clk
>> gate into divider allows to implement glitch-less EMC scaling, avoiding
>> reparenting to a backup clock.
>>
>> Signed-off-by: Dmitry Osipenko 
> 
> Looks ok to me, but I'm waiting for someone from Tegra side to ack it or
> review it.
> 

I've already prepared v2 with some minor cleanups and additional clk patch. For
now waiting for Peter's review comments to v1.


[PATCH v7 1/2] Add an array of const char and enum oom_constraint in memcontrol.h

2018-06-02 Thread 禹舟键
From: yuzhoujian 

This patch will make some preparation for the follow-up patch: Refactor
part of the oom report in dump_header. It puts enum oom_constraint in
memcontrol.h and adds an array of const char for each constraint.

Signed-off-by: yuzhoujian 
---
 include/linux/memcontrol.h | 14 ++
 mm/oom_kill.c  |  7 ---
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index d99b71bc2c66..57311b6c4d67 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -62,6 +62,20 @@ struct mem_cgroup_reclaim_cookie {
  unsigned int generation;
 };

+enum oom_constraint {
+ CONSTRAINT_NONE,
+ CONSTRAINT_CPUSET,
+ CONSTRAINT_MEMORY_POLICY,
+ CONSTRAINT_MEMCG,
+};
+
+static const char * const oom_constraint_text[] = {
+ [CONSTRAINT_NONE] = "CONSTRAINT_NONE",
+ [CONSTRAINT_CPUSET] = "CONSTRAINT_CPUSET",
+ [CONSTRAINT_MEMORY_POLICY] = "CONSTRAINT_MEMORY_POLICY",
+ [CONSTRAINT_MEMCG] = "CONSTRAINT_MEMCG",
+};
+
 #ifdef CONFIG_MEMCG

 #define MEM_CGROUP_ID_SHIFT 16
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 8ba6cb88cf58..c806cd656af6 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -237,13 +237,6 @@ unsigned long oom_badness(struct task_struct *p,
struct mem_cgroup *memcg,
  return points > 0 ? points : 1;
 }

-enum oom_constraint {
- CONSTRAINT_NONE,
- CONSTRAINT_CPUSET,
- CONSTRAINT_MEMORY_POLICY,
- CONSTRAINT_MEMCG,
-};
-
 /*
  * Determine the type of allocation constraint.
  */
-- 
2.14.1


[PATCH 2/2] tsens: Get rid of unused fields in structure

2018-06-02 Thread Amit Kucheria
status_field and trdy are unused in any of the tsens drivers. Remove them.

Signed-off-by: Amit Kucheria 
---
 drivers/thermal/qcom/tsens.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h
index f15660d..77ed8dc 100644
--- a/drivers/thermal/qcom/tsens.h
+++ b/drivers/thermal/qcom/tsens.h
@@ -77,9 +77,7 @@ struct tsens_device {
struct device   *dev;
u32 num_sensors;
struct regmap   *map;
-   struct regmap_field *status_field;
struct tsens_contextctx;
-   booltrdy;
const struct tsens_ops  *ops;
struct tsens_sensor sensor[0];
 };
-- 
2.7.4



[PATCH 0/2] thermal: tsens: SDM845 support

2018-06-02 Thread Amit Kucheria
Add SDM845 support in the tsens driver. I've create a separate file
(tsens-sdm845.c) because I expect it to diverge from the other drivers.

Cleanup the tsens_device structure while we're at it.


Amit Kucheria (2):
  thermal: tsens: Add support for SDM845 platform
  tsens: Get rid of unused fields in structure

 .../devicetree/bindings/thermal/qcom-tsens.txt |  1 +
 drivers/thermal/qcom/Makefile  |  2 +-
 drivers/thermal/qcom/tsens-sdm845.c| 98 ++
 drivers/thermal/qcom/tsens.c   |  3 +
 drivers/thermal/qcom/tsens.h   |  3 +-
 5 files changed, 104 insertions(+), 3 deletions(-)
 create mode 100644 drivers/thermal/qcom/tsens-sdm845.c

-- 
2.7.4



[PATCH 1/2] thermal: tsens: Add support for SDM845 platform

2018-06-02 Thread Amit Kucheria
There are two tsens blocks on the SDM845. These will be configured through
the devicetree.

Signed-off-by: Amit Kucheria 
---
 .../devicetree/bindings/thermal/qcom-tsens.txt |  1 +
 drivers/thermal/qcom/Makefile  |  2 +-
 drivers/thermal/qcom/tsens-sdm845.c| 98 ++
 drivers/thermal/qcom/tsens.c   |  3 +
 drivers/thermal/qcom/tsens.h   |  1 +
 5 files changed, 104 insertions(+), 1 deletion(-)
 create mode 100644 drivers/thermal/qcom/tsens-sdm845.c

diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.txt 
b/Documentation/devicetree/bindings/thermal/qcom-tsens.txt
index 292ed89..8652499 100644
--- a/Documentation/devicetree/bindings/thermal/qcom-tsens.txt
+++ b/Documentation/devicetree/bindings/thermal/qcom-tsens.txt
@@ -5,6 +5,7 @@ Required properties:
  - "qcom,msm8916-tsens" : For 8916 Family of SoCs
  - "qcom,msm8974-tsens" : For 8974 Family of SoCs
  - "qcom,msm8996-tsens" : For 8996 Family of SoCs
+ - "qcom,sdm845-tsens"  : For SDM845 Family of SoCs
 
 - reg: Address range of the thermal registers
 - #thermal-sensor-cells : Should be 1. See ./thermal.txt for a description.
diff --git a/drivers/thermal/qcom/Makefile b/drivers/thermal/qcom/Makefile
index 2cc2193..dc9f169 100644
--- a/drivers/thermal/qcom/Makefile
+++ b/drivers/thermal/qcom/Makefile
@@ -1,2 +1,2 @@
 obj-$(CONFIG_QCOM_TSENS)   += qcom_tsens.o
-qcom_tsens-y   += tsens.o tsens-common.o tsens-8916.o 
tsens-8974.o tsens-8960.o tsens-8996.o
+qcom_tsens-y   += tsens.o tsens-common.o tsens-8916.o 
tsens-8974.o tsens-8960.o tsens-8996.o tsens-sdm845.o
diff --git a/drivers/thermal/qcom/tsens-sdm845.c 
b/drivers/thermal/qcom/tsens-sdm845.c
new file mode 100644
index 000..5d78f0b
--- /dev/null
+++ b/drivers/thermal/qcom/tsens-sdm845.c
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, Linaro Limited
+ */
+
+#include 
+#include 
+#include 
+#include "tsens.h"
+
+#define CNTL_OFFSET4
+/* CNTL_OFFSET bitmasks */
+#define EN BIT(0)
+#define SW_RST BIT(1)
+
+#define SENSOR0_SHIFT  3
+
+#define TRDY_OFFSET 0xe4
+#define TRDY_READY_BIT  BIT(1)
+
+#define STATUS_OFFSET  0xa0
+#define LAST_TEMP_MASK 0xfff
+#define STATUS_VALID_BIT   BIT(21)
+#define CODE_SIGN_BIT  BIT(11)
+
+static int get_temp_sdm845(struct tsens_device *tmdev, int id, int *temp)
+{
+   struct tsens_sensor *s = &tmdev->sensor[id];
+   u32 code;
+   unsigned int sensor_addr;
+   int last_temp = 0, last_temp2 = 0, last_temp3 = 0, ret;
+
+   ret = regmap_read(tmdev->map, TRDY_OFFSET, &code);
+   if (ret)
+   return ret;
+   if (code & TRDY_READY_BIT)
+   return -ENODATA;
+
+   sensor_addr = STATUS_OFFSET + s->hw_id * 4;
+   ret = regmap_read(tmdev->map, sensor_addr, &code);
+   if (ret)
+   return ret;
+   last_temp = code & LAST_TEMP_MASK;
+   if (code & STATUS_VALID_BIT)
+   goto done;
+
+   /* Try a second time */
+   ret = regmap_read(tmdev->map, sensor_addr, &code);
+   if (ret)
+   return ret;
+   if (code & STATUS_VALID_BIT) {
+   last_temp = code & LAST_TEMP_MASK;
+   goto done;
+   } else {
+   last_temp2 = code & LAST_TEMP_MASK;
+   }
+
+   /* Try a third/last time */
+   ret = regmap_read(tmdev->map, sensor_addr, &code);
+   if (ret)
+   return ret;
+   if (code & STATUS_VALID_BIT) {
+   last_temp = code & LAST_TEMP_MASK;
+   goto done;
+   } else {
+   last_temp3 = code & LAST_TEMP_MASK;
+   }
+
+   if (last_temp == last_temp2)
+   last_temp = last_temp2;
+   else if (last_temp2 == last_temp3)
+   last_temp = last_temp3;
+done:
+   /* Code sign bit is the sign extension for a negative value */
+   if (last_temp & CODE_SIGN_BIT)
+   last_temp |= ~CODE_SIGN_BIT;
+
+   /* Temperatures are in deciCelicius */
+   *temp = last_temp * 100;
+
+   return 0;
+}
+
+static const struct regmap_config tsens_config = {
+   .reg_bits   = 32,
+   .val_bits   = 32,
+   .reg_stride = 4,
+};
+
+
+static const struct tsens_ops ops_sdm845 = {
+   .init   = init_common,
+   .get_temp   = get_temp_sdm845,
+};
+
+const struct tsens_data data_sdm845 = {
+   .ops= &ops_sdm845,
+};
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index 3f9fe6a..314a20f 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -72,6 +72,9 @@ static const struct of_device_id tsens_table[] = {
}, {
.compatible = "qcom,msm8996-tsens",
.data = &data_8996,
+   }, {
+   .compatible = "qcom,sdm845-tsens",
+   .data = &data_sdm845,
},
 

Re: [PATCH v7 1/2] Add an array of const char and enum oom_constraint in memcontrol.h

2018-06-02 Thread Matthew Wilcox
On Sat, Jun 02, 2018 at 07:06:44PM +0800, 禹舟键 wrote:
> From: yuzhoujian 
> 
> This patch will make some preparation for the follow-up patch: Refactor
> part of the oom report in dump_header. It puts enum oom_constraint in
> memcontrol.h and adds an array of const char for each constraint.

This patch is whitespace damaged.  See the instructions for using git
send-email with gmail: https://git-scm.com/docs/git-send-email

> +static const char * const oom_constraint_text[] = {
> + [CONSTRAINT_NONE] = "CONSTRAINT_NONE",
> + [CONSTRAINT_CPUSET] = "CONSTRAINT_CPUSET",
> + [CONSTRAINT_MEMORY_POLICY] = "CONSTRAINT_MEMORY_POLICY",
> + [CONSTRAINT_MEMCG] = "CONSTRAINT_MEMCG",
> +};
> +

Um, isn't this going to put the strings in every file which includes
memcontrol.h?


Re: PROBLEM: [kernel BUG at fs/fat/inode.c:162] when writing to a broken VFAT

2018-06-02 Thread OGAWA Hirofumi
Anatoly Trosinenko  writes:

> Description:
>
> Writing to some file on a broken VFAT partition causes kernel bug

Thanks. This patch should fix this issue.
-- 
OGAWA Hirofumi 


[PATCH] fat: Use fat_fs_error() instead of BUG_ON() in __fat_get_block()

If file size and FAT cluster chain is not matched (corrupted image),
we can hit BUG_ON(!phys) in __fat_get_block().

So, use fat_fs_error() instead.

Signed-off-by: OGAWA Hirofumi 
---

 fs/fat/inode.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff -puN fs/fat/inode.c~vfat-dont-bugon fs/fat/inode.c
--- linux/fs/fat/inode.c~vfat-dont-bugon2018-06-02 20:15:04.441920069 
+0900
+++ linux-hirofumi/fs/fat/inode.c   2018-06-02 20:15:04.442920067 +0900
@@ -158,8 +158,13 @@ static inline int __fat_get_block(struct
err = fat_bmap(inode, iblock, &phys, &mapped_blocks, create, false);
if (err)
return err;
+   if (!phys) {
+   fat_fs_error(sb,
+"invalid FAT chain (i_pos %lld, last_block %ld)",
+MSDOS_I(inode)->i_pos, last_block);
+   return -EIO;
+   }
 
-   BUG_ON(!phys);
BUG_ON(*max_blocks != mapped_blocks);
set_buffer_new(bh_result);
map_bh(bh_result, sb, phys);
_


Re: [PATCH] rcu: Check the range of jiffies_till_{first,next}_fqs when setting them

2018-06-02 Thread Paul E. McKenney
On Fri, Jun 01, 2018 at 11:03:09AM +0900, Byungchul Park wrote:
> Currently, the range of jiffies_till_{first,next}_fqs are checked and
> adjusted on and on in the loop of rcu_gp_kthread on runtime.
> 
> However, it's enough to check them only when setting them, not every
> time in the loop. So make them handled on a setting time via sysfs.
> 
> Signed-off-by: Byungchul Park 

Applied for further review and testing, thank you!

Thanx, Paul

> ---
>  kernel/rcu/tree.c | 45 -
>  1 file changed, 32 insertions(+), 13 deletions(-)
> 
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index 4e96761..eb54d7d 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -518,8 +518,38 @@ void rcu_all_qs(void)
>  static ulong jiffies_till_next_fqs = ULONG_MAX;
>  static bool rcu_kick_kthreads;
> 
> -module_param(jiffies_till_first_fqs, ulong, 0644);
> -module_param(jiffies_till_next_fqs, ulong, 0644);
> +static int param_set_first_fqs_jiffies(const char *val, const struct 
> kernel_param *kp)
> +{
> + ulong j;
> + int ret = kstrtoul(val, 0, &j);
> +
> + if (!ret)
> + WRITE_ONCE(*(ulong *)kp->arg, (j > HZ) ? HZ : j);
> + return ret;
> +}
> +
> +static int param_set_next_fqs_jiffies(const char *val, const struct 
> kernel_param *kp)
> +{
> + ulong j;
> + int ret = kstrtoul(val, 0, &j);
> +
> + if (!ret)
> + WRITE_ONCE(*(ulong *)kp->arg, (j > HZ) ? HZ : (j ?: 1));
> + return ret;
> +}
> +
> +static struct kernel_param_ops first_fqs_jiffies_ops = {
> + .set = param_set_first_fqs_jiffies,
> + .get = param_get_ulong,
> +};
> +
> +static struct kernel_param_ops next_fqs_jiffies_ops = {
> + .set = param_set_next_fqs_jiffies,
> + .get = param_get_ulong,
> +};
> +
> +module_param_cb(jiffies_till_first_fqs, &first_fqs_jiffies_ops, 
> &jiffies_till_first_fqs, 0644);
> +module_param_cb(jiffies_till_next_fqs, &next_fqs_jiffies_ops, 
> &jiffies_till_next_fqs, 0644);
>  module_param(rcu_kick_kthreads, bool, 0644);
> 
>  /*
> @@ -2129,10 +2159,6 @@ static int __noreturn rcu_gp_kthread(void *arg)
>   /* Handle quiescent-state forcing. */
>   first_gp_fqs = true;
>   j = jiffies_till_first_fqs;
> - if (j > HZ) {
> - j = HZ;
> - jiffies_till_first_fqs = HZ;
> - }
>   ret = 0;
>   for (;;) {
>   if (!ret) {
> @@ -2167,13 +2193,6 @@ static int __noreturn rcu_gp_kthread(void *arg)
>   WRITE_ONCE(rsp->gp_activity, jiffies);
>   ret = 0; /* Force full wait till next FQS. */
>   j = jiffies_till_next_fqs;
> - if (j > HZ) {
> - j = HZ;
> - jiffies_till_next_fqs = HZ;
> - } else if (j < 1) {
> - j = 1;
> - jiffies_till_next_fqs = 1;
> - }
>   } else {
>   /* Deal with stray signal. */
>   cond_resched_tasks_rcu_qs();
> -- 
> 1.9.1
> 



Re: [PATCH -tip v4 24/27] bpf: error-inject: kprobes: Clear current_kprobe and enable preempt in kprobe

2018-06-02 Thread Naveen N. Rao

Masami Hiramatsu wrote:

On Thu, 31 May 2018 16:25:38 +0530
"Naveen N. Rao"  wrote:


Masami Hiramatsu wrote:
> Clear current_kprobe and enable preemption in kprobe
> even if pre_handler returns !0.
> 
> This simplifies function override using kprobes.
> 
> Jprobe used to require to keep the preemption disabled and

> keep current_kprobe until it returned to original function
> entry. For this reason kprobe_int3_handler() and similar
> arch dependent kprobe handers checks pre_handler result
> and exit without enabling preemption if the result is !0.
> 
> After removing the jprobe, Kprobes does not need to

> keep preempt disabled even if user handler returns !0
> anymore.

I think the reason jprobes did it that way is to address architecture 
specific requirements when changing a function. So, without that 
infrastructure, I am not sure if we will be able to claim support for 
over-riding functions with kprobes. I am not sure if we want to claim 
that, but this is something we need to be clear on.


Really? as far as I can see, there seems no such architecture.
The keeping preempt disabled is corresponding to keeping current_kprobe
since the current_kprobe is per-cpu.


Right, and the reason for not resetting current_kprobe after kprobe 
handling is done is primarily for jprobes. 


This means if it is preempted
before hitting break_handler and changed cpu core, we missed to
handle current_kprobe and goes to panic. But if we don't need
such "break back" (removing break_handler), we don't need to
keep current_kprobe (because it is not handled afterwards).


Agreed.



Anyway, changing function execution path is a "one-way" change.


This is the problem. With jprobes, over-riding a function was not a 
"one-way" change because it involves more than just changing the [n]ip.  
That is the reason we had setjmp/longjmp (aka break_handler).



We don't have a chance to fixup that disabled preemption and current_kprobe
after returning to the new function. So current error-inject clears
current_kprobe and enable preemption before returning !0 from its
kprobe pre_handler.

This is just moving such needless operation from user-pre_handler to
kprobes itself. 

For powerpc, the current function override in error-inject works fine 
since the new function does nothing. But, if anyone wants to do more 
work in the replacement function, it won't work with the current 
approach.


If you are considering about TOC change etc. yes, it depends on
the archtecture. As far as I know IA64 and powerpc will not allow
to support changing execution path without special care.
Other "flat and simple" function call architectures like x86, arm
can change execution path without special care. 


Yes, that's the concern. As I stated earlier, the only user seems to be 
error-injection where this is not a concern. I wanted this to be made 
clear.


I've since noticed that you are updating Documentation/kprobes.txt to 
make this clear in patch 24/27 in this series. So, I'm ok with the 
changes in this series.



Thanks,
Naveen




[PATCH v7 1/2] Add an array of const char and enum oom_constraint in memcontrol.h

2018-06-02 Thread ufo19890607
From: yuzhoujian 

This patch will make some preparation for the follow-up patch: Refactor
part of the oom report in dump_header. It puts enum oom_constraint in
memcontrol.h and adds an array of const char for each constraint.

Signed-off-by: yuzhoujian 
---
 include/linux/memcontrol.h | 14 ++
 mm/oom_kill.c  |  7 ---
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index d99b71bc2c66..57311b6c4d67 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -62,6 +62,20 @@ struct mem_cgroup_reclaim_cookie {
unsigned int generation;
 };
 
+enum oom_constraint {
+   CONSTRAINT_NONE,
+   CONSTRAINT_CPUSET,
+   CONSTRAINT_MEMORY_POLICY,
+   CONSTRAINT_MEMCG,
+};
+
+static const char * const oom_constraint_text[] = {
+   [CONSTRAINT_NONE] = "CONSTRAINT_NONE",
+   [CONSTRAINT_CPUSET] = "CONSTRAINT_CPUSET",
+   [CONSTRAINT_MEMORY_POLICY] = "CONSTRAINT_MEMORY_POLICY",
+   [CONSTRAINT_MEMCG] = "CONSTRAINT_MEMCG",
+};
+
 #ifdef CONFIG_MEMCG
 
 #define MEM_CGROUP_ID_SHIFT16
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 8ba6cb88cf58..c806cd656af6 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -237,13 +237,6 @@ unsigned long oom_badness(struct task_struct *p, struct 
mem_cgroup *memcg,
return points > 0 ? points : 1;
 }
 
-enum oom_constraint {
-   CONSTRAINT_NONE,
-   CONSTRAINT_CPUSET,
-   CONSTRAINT_MEMORY_POLICY,
-   CONSTRAINT_MEMCG,
-};
-
 /*
  * Determine the type of allocation constraint.
  */
-- 
2.14.1



[PATCH v7 2/2] Refactor part of the oom report in dump_header

2018-06-02 Thread ufo19890607
From: yuzhoujian 

The dump_header does not print the memcg's name when the system
oom happened, so users cannot locate the certain container which
contains the task that has been killed by the oom killer.

I follow the advices of David Rientjes and Michal Hocko, and refactor
part of the oom report in a backwards compatible way. After this patch,
users can get the memcg's path from the oom report and check the certain
container more quickly.

Below is the part of the oom report in the dmesg
...
[  142.158316] panic cpuset=/ mems_allowed=0-1
[  142.158983] CPU: 15 PID: 8682 Comm: panic Not tainted 4.17.0-rc6+ #13
[  142.159659] Hardware name: Inspur SA5212M4/YZMB-00370-107, BIOS 4.1.10 
11/14/2016
[  142.160342] Call Trace:
[  142.161037]  dump_stack+0x78/0xb3
[  142.161734]  dump_header+0x7d/0x334
[  142.162433]  oom_kill_process+0x228/0x490
[  142.163126]  ? oom_badness+0x2a/0x130
[  142.163821]  out_of_memory+0xf0/0x280
[  142.164532]  __alloc_pages_slowpath+0x711/0xa07
[  142.165241]  __alloc_pages_nodemask+0x23f/0x260
[  142.165947]  alloc_pages_vma+0x73/0x180
[  142.15]  do_anonymous_page+0xed/0x4e0
[  142.167388]  __handle_mm_fault+0xbd2/0xe00
[  142.168114]  handle_mm_fault+0x116/0x250
[  142.168841]  __do_page_fault+0x233/0x4d0
[  142.169567]  do_page_fault+0x32/0x130
[  142.170303]  ? page_fault+0x8/0x30
[  142.171036]  page_fault+0x1e/0x30
[  142.171764] RIP: 0033:0x7f403000a860
[  142.172517] RSP: 002b:7ffc9f745c28 EFLAGS: 00010206
[  142.173268] RAX: 7f3f6fd7d000 RBX:  RCX: 7f3f7f5cd000
[  142.174040] RDX: 7f3fafd7d000 RSI:  RDI: 7f3f6fd7d000
[  142.174806] RBP: 7ffc9f745c50 R08:  R09: 
[  142.175623] R10: 0022 R11: 0246 R12: 00400490
[  142.176542] R13: 7ffc9f745d30 R14:  R15: 
[  142.177709] 
oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),origin_memcg=(null),kill_memcg=/test/test1/test2,task=panic,pid=
 8622,uid=0
...

Changes since v6:
- divide the patch v5 into two parts. One part is to add an array of const char 
and
put enum oom_constraint into the memcontrol.h; the other is will refactor the 
output
in the dump_header.
- limit the memory usage for the static char array by using NAME_MAX in the 
mem_cgroup_print_oom_context.
- eliminate the spurious spaces in the oom's output and fix the spelling of 
"constrain".

Changes since v5:
- add an array of const char for each constraint.
- replace all of the pr_cont with a single line print of the pr_info.
- put enum oom_constraint into the memcontrol.c file for printing oom 
constraint.

Changes since v4:
- rename the helper's name to mem_cgroup_print_oom_context.
- rename the mem_cgroup_print_oom_info to mem_cgroup_print_oom_meminfo.
- add the constrain info in the dump_header.

Changes since v3:
- rename the helper's name to mem_cgroup_print_oom_memcg_name.
- add the rcu lock held to the helper.
- remove the print info of memcg's name in mem_cgroup_print_oom_info.

Changes since v2:
- add the mem_cgroup_print_memcg_name helper to print the memcg's
  name which contains the task that will be killed by the oom-killer.

Changes since v1:
- replace adding mem_cgroup_print_oom_info with printing the memcg's
  name only.

Signed-off-by: yuzhoujian 
---
 include/linux/memcontrol.h | 15 ++---
 mm/memcontrol.c| 55 --
 mm/oom_kill.c  |  5 +++--
 3 files changed, 53 insertions(+), 22 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 57311b6c4d67..1c7d5da1c827 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -478,8 +478,11 @@ void mem_cgroup_handle_over_high(void);
 
 unsigned long mem_cgroup_get_limit(struct mem_cgroup *memcg);
 
-void mem_cgroup_print_oom_info(struct mem_cgroup *memcg,
-   struct task_struct *p);
+void mem_cgroup_print_oom_context(struct mem_cgroup *memcg,
+   struct task_struct *p, enum oom_constraint constraint,
+   nodemask_t *nodemask);
+
+void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg);
 
 static inline void mem_cgroup_oom_enable(void)
 {
@@ -873,7 +876,13 @@ static inline unsigned long mem_cgroup_get_limit(struct 
mem_cgroup *memcg)
 }
 
 static inline void
-mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
+mem_cgroup_print_oom_context(struct mem_cgroup *memcg, struct task_struct *p,
+   enum oom_constraint constraint, nodemask_t *nodemask)
+{
+}
+
+static inline void
+mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg)
 {
 }
 
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2bd3df3d101a..fd1172938c8e 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1118,33 +1118,54 @@ static const char *const memcg1_stat_names[] = {
 };
 
 #define K(x) ((x) << (PAGE_SHIFT-10))
-/**
- * mem_cgroup_print_oom_info: Print 

[PATCH v7 2/2] Refactor part of the oom report in dump_header

2018-06-02 Thread ufo19890607
From: yuzhoujian 

The dump_header does not print the memcg's name when the system
oom happened, so users cannot locate the certain container which
contains the task that has been killed by the oom killer.

I follow the advices of David Rientjes and Michal Hocko, and refactor
part of the oom report in a backwards compatible way. After this patch,
users can get the memcg's path from the oom report and check the certain
container more quickly.

Below is the part of the oom report in the dmesg
...
[  142.158316] panic cpuset=/ mems_allowed=0-1
[  142.158983] CPU: 15 PID: 8682 Comm: panic Not tainted 4.17.0-rc6+ #13
[  142.159659] Hardware name: Inspur SA5212M4/YZMB-00370-107, BIOS 4.1.10 
11/14/2016
[  142.160342] Call Trace:
[  142.161037]  dump_stack+0x78/0xb3
[  142.161734]  dump_header+0x7d/0x334
[  142.162433]  oom_kill_process+0x228/0x490
[  142.163126]  ? oom_badness+0x2a/0x130
[  142.163821]  out_of_memory+0xf0/0x280
[  142.164532]  __alloc_pages_slowpath+0x711/0xa07
[  142.165241]  __alloc_pages_nodemask+0x23f/0x260
[  142.165947]  alloc_pages_vma+0x73/0x180
[  142.15]  do_anonymous_page+0xed/0x4e0
[  142.167388]  __handle_mm_fault+0xbd2/0xe00
[  142.168114]  handle_mm_fault+0x116/0x250
[  142.168841]  __do_page_fault+0x233/0x4d0
[  142.169567]  do_page_fault+0x32/0x130
[  142.170303]  ? page_fault+0x8/0x30
[  142.171036]  page_fault+0x1e/0x30
[  142.171764] RIP: 0033:0x7f403000a860
[  142.172517] RSP: 002b:7ffc9f745c28 EFLAGS: 00010206
[  142.173268] RAX: 7f3f6fd7d000 RBX:  RCX: 7f3f7f5cd000
[  142.174040] RDX: 7f3fafd7d000 RSI:  RDI: 7f3f6fd7d000
[  142.174806] RBP: 7ffc9f745c50 R08:  R09: 
[  142.175623] R10: 0022 R11: 0246 R12: 00400490
[  142.176542] R13: 7ffc9f745d30 R14:  R15: 
[  142.177709] 
oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),origin_memcg=(null),kill_memcg=/test/test1/test2,task=panic,pid=
 8622,uid=0
...

Changes since v6:
- divide the patch v5 into two parts. One part is to add an array of const char 
and
put enum oom_constraint into the memcontrol.h; the other is will refactor the 
output
in the dump_header.
- limit the memory usage for the static char array by using NAME_MAX in the 
mem_cgroup_print_oom_context.
- eliminate the spurious spaces in the oom's output and fix the spelling of 
"constrain".

Changes since v5:
- add an array of const char for each constraint.
- replace all of the pr_cont with a single line print of the pr_info.
- put enum oom_constraint into the memcontrol.c file for printing oom 
constraint.

Changes since v4:
- rename the helper's name to mem_cgroup_print_oom_context.
- rename the mem_cgroup_print_oom_info to mem_cgroup_print_oom_meminfo.
- add the constrain info in the dump_header.

Changes since v3:
- rename the helper's name to mem_cgroup_print_oom_memcg_name.
- add the rcu lock held to the helper.
- remove the print info of memcg's name in mem_cgroup_print_oom_info.

Changes since v2:
- add the mem_cgroup_print_memcg_name helper to print the memcg's
  name which contains the task that will be killed by the oom-killer.

Changes since v1:
- replace adding mem_cgroup_print_oom_info with printing the memcg's
  name only.

Signed-off-by: yuzhoujian 
---
 include/linux/memcontrol.h | 15 ++---
 mm/memcontrol.c| 55 --
 mm/oom_kill.c  |  5 +++--
 3 files changed, 53 insertions(+), 22 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 57311b6c4d67..1c7d5da1c827 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -478,8 +478,11 @@ void mem_cgroup_handle_over_high(void);
 
 unsigned long mem_cgroup_get_limit(struct mem_cgroup *memcg);
 
-void mem_cgroup_print_oom_info(struct mem_cgroup *memcg,
-   struct task_struct *p);
+void mem_cgroup_print_oom_context(struct mem_cgroup *memcg,
+   struct task_struct *p, enum oom_constraint constraint,
+   nodemask_t *nodemask);
+
+void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg);
 
 static inline void mem_cgroup_oom_enable(void)
 {
@@ -873,7 +876,13 @@ static inline unsigned long mem_cgroup_get_limit(struct 
mem_cgroup *memcg)
 }
 
 static inline void
-mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
+mem_cgroup_print_oom_context(struct mem_cgroup *memcg, struct task_struct *p,
+   enum oom_constraint constraint, nodemask_t *nodemask)
+{
+}
+
+static inline void
+mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg)
 {
 }
 
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2bd3df3d101a..fd1172938c8e 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1118,33 +1118,54 @@ static const char *const memcg1_stat_names[] = {
 };
 
 #define K(x) ((x) << (PAGE_SHIFT-10))
-/**
- * mem_cgroup_print_oom_info: Print 

[PATCH v7 1/2] Add an array of const char and enum oom_constraint in memcontrol.h

2018-06-02 Thread ufo19890607
From: yuzhoujian 

This patch will make some preparation for the follow-up patch: Refactor
part of the oom report in dump_header. It puts enum oom_constraint in
memcontrol.h and adds an array of const char for each constraint.

Signed-off-by: yuzhoujian 
---
 include/linux/memcontrol.h | 14 ++
 mm/oom_kill.c  |  7 ---
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index d99b71bc2c66..57311b6c4d67 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -62,6 +62,20 @@ struct mem_cgroup_reclaim_cookie {
unsigned int generation;
 };
 
+enum oom_constraint {
+   CONSTRAINT_NONE,
+   CONSTRAINT_CPUSET,
+   CONSTRAINT_MEMORY_POLICY,
+   CONSTRAINT_MEMCG,
+};
+
+static const char * const oom_constraint_text[] = {
+   [CONSTRAINT_NONE] = "CONSTRAINT_NONE",
+   [CONSTRAINT_CPUSET] = "CONSTRAINT_CPUSET",
+   [CONSTRAINT_MEMORY_POLICY] = "CONSTRAINT_MEMORY_POLICY",
+   [CONSTRAINT_MEMCG] = "CONSTRAINT_MEMCG",
+};
+
 #ifdef CONFIG_MEMCG
 
 #define MEM_CGROUP_ID_SHIFT16
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 8ba6cb88cf58..c806cd656af6 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -237,13 +237,6 @@ unsigned long oom_badness(struct task_struct *p, struct 
mem_cgroup *memcg,
return points > 0 ? points : 1;
 }
 
-enum oom_constraint {
-   CONSTRAINT_NONE,
-   CONSTRAINT_CPUSET,
-   CONSTRAINT_MEMORY_POLICY,
-   CONSTRAINT_MEMCG,
-};
-
 /*
  * Determine the type of allocation constraint.
  */
-- 
2.14.1



Re: [PATCH v3 12/17] signal: make unhandled_signal() return bool

2018-06-02 Thread Alexey Dobriyan
> -int unhandled_signal(struct task_struct *tsk, int sig)
> +bool unhandled_signal(struct task_struct *tsk, int sig)

This most likely makes code generation worse on embedded arhcs
which will '& 0xFF" internally.


Donation!!!

2018-06-02 Thread Mr Mikhail Fridman
Charitable Donation for you, Respond for further directives.

Mr. Mikhail Fridman

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



[GIT PULL] IIO driver fixes for 4.17-rc8

2018-06-02 Thread Greg KH
The following changes since commit 6da6c0db5316275015e8cc2959f12a17584aeb64:

  Linux v4.17-rc3 (2018-04-29 14:17:42 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/ 
tags/staging-4.17-rc8

for you to fetch changes up to 9d569b1cf7a2a385770835df15f77dde587b58a3:

  Merge tag 'iio-fixes-for-4.17a' of 
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus 
(2018-05-09 17:08:29 +0200)


IIO driver fixes for 4.17-rc8

Here are some old IIO driver fixes that were sitting in my tree for a
few weeks.  Sorry about not getting them to you sooner.  They fix a
number of small IIO driver issues that have been reported.

All of these have been in linux-next for a while with no reported
problems.

Signed-off-by: Greg Kroah-Hartman 


Eugen Hristev (2):
  iio: adc: at91-sama5d2_adc: fix channel configuration for differential 
channels
  iio: adc: select buffer for at91-sama5d2_adc

Fabrice Gasnier (2):
  iio: adc: stm32-dfsdm: fix successive oversampling settings
  iio: adc: stm32-dfsdm: fix sample rate for div2 spi clock

Greg Kroah-Hartman (1):
  Merge tag 'iio-fixes-for-4.17a' of git://git.kernel.org/.../jic23/iio 
into staging-linus

Hans de Goede (1):
  iio: hid-sensor-trigger: Fix sometimes not powering up the sensor after 
resume

Martin Kelly (2):
  iio:buffer: make length types match kfifo types
  iio:kfifo_buf: check for uint overflow

Michael Nosthoff (1):
  iio: ad7793: implement IIO_CHAN_INFO_SAMP_FREQ

 drivers/iio/adc/Kconfig|  1 +
 drivers/iio/adc/ad7793.c   | 75 +++---
 drivers/iio/adc/at91-sama5d2_adc.c | 41 ++--
 drivers/iio/adc/stm32-dfsdm-adc.c  | 17 -
 drivers/iio/buffer/industrialio-buffer-dma.c   |  2 +-
 drivers/iio/buffer/kfifo_buf.c | 11 +++-
 .../iio/common/hid-sensors/hid-sensor-trigger.c|  8 +--
 include/linux/iio/buffer_impl.h|  6 +-
 8 files changed, 93 insertions(+), 68 deletions(-)


[GIT PULL] Char/Misc driver fixes for 4.17-rc8

2018-06-02 Thread Greg KH
The following changes since commit 6da6c0db5316275015e8cc2959f12a17584aeb64:

  Linux v4.17-rc3 (2018-04-29 14:17:42 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/ 
tags/char-misc-4.17-rc8

for you to fetch changes up to 806e30873f0e74d9d41b0ef761bd4d3e55c7d510:

  hwtracing: stm: fix build error on some arches (2018-05-26 08:49:24 +0200)


Char/Misc driver fixes for 4.17-rc8

Here are 4 small bugfixes for some char/misc drivers.  Well, really 3
fixes and one fix for one of those fixes due to problems found by 0-day.

This resolves some reported issues with the hwtracing drivers, and a
reported regression for the thunderbolt subsystem.  All of these have
been in linux-next for a while now with no reported problems.

Signed-off-by: Greg Kroah-Hartman 


Alexander Shishkin (2):
  stm class: Use vmalloc for the master map
  intel_th: Use correct device when freeing buffers

Greg Kroah-Hartman (1):
  hwtracing: stm: fix build error on some arches

Mika Westerberg (1):
  thunderbolt: Handle NULL boot ACL entries properly

 drivers/hwtracing/intel_th/msu.c | 6 +++---
 drivers/hwtracing/stm/core.c | 7 ---
 drivers/thunderbolt/icm.c| 2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)


[RFC PATCH for 4.18 01/16] uapi headers: Provide types_32_64.h (v2)

2018-06-02 Thread Mathieu Desnoyers
Provide helper macros for fields which represent pointers in
kernel-userspace ABI. This facilitates handling of 32-bit
user-space by 64-bit kernels by defining those fields as
32-bit 0-padding and 32-bit integer on 32-bit architectures,
which allows the kernel to treat those as 64-bit integers.
The order of padding and 32-bit integer depends on the
endianness.

Signed-off-by: Mathieu Desnoyers 
CC: "Paul E. McKenney" 
CC: Peter Zijlstra 
CC: Paul Turner 
CC: Thomas Gleixner 
CC: Andrew Hunter 
CC: Andy Lutomirski 
CC: Andi Kleen 
CC: Dave Watson 
CC: Chris Lameter 
CC: Ingo Molnar 
CC: "H. Peter Anvin" 
CC: Ben Maurer 
CC: Steven Rostedt 
CC: Josh Triplett 
CC: Linus Torvalds 
CC: Andrew Morton 
CC: Russell King 
CC: Catalin Marinas 
CC: Will Deacon 
CC: Michael Kerrisk 
CC: Boqun Feng 
CC: linux-...@vger.kernel.org

---

Changes since v1:
- Public uapi headers use __u32 and __u64 rather than uint32_t and
  uint64_t.
---
 include/uapi/linux/types_32_64.h | 50 
 1 file changed, 50 insertions(+)
 create mode 100644 include/uapi/linux/types_32_64.h

diff --git a/include/uapi/linux/types_32_64.h b/include/uapi/linux/types_32_64.h
new file mode 100644
index ..0a87ace34a57
--- /dev/null
+++ b/include/uapi/linux/types_32_64.h
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
+#ifndef _UAPI_LINUX_TYPES_32_64_H
+#define _UAPI_LINUX_TYPES_32_64_H
+
+/*
+ * linux/types_32_64.h
+ *
+ * Integer type declaration for pointers across 32-bit and 64-bit systems.
+ *
+ * Copyright (c) 2015-2018 Mathieu Desnoyers 
+ */
+
+#ifdef __KERNEL__
+# include 
+#else
+# include 
+#endif
+
+#include 
+
+#ifdef __BYTE_ORDER
+# if (__BYTE_ORDER == __BIG_ENDIAN)
+#  define LINUX_BYTE_ORDER_BIG_ENDIAN
+# else
+#  define LINUX_BYTE_ORDER_LITTLE_ENDIAN
+# endif
+#else
+# ifdef __BIG_ENDIAN
+#  define LINUX_BYTE_ORDER_BIG_ENDIAN
+# else
+#  define LINUX_BYTE_ORDER_LITTLE_ENDIAN
+# endif
+#endif
+
+#ifdef __LP64__
+# define LINUX_FIELD_u32_u64(field)__u64 field
+# define LINUX_FIELD_u32_u64_INIT_ONSTACK(field, v)field = (intptr_t)v
+#else
+# ifdef LINUX_BYTE_ORDER_BIG_ENDIAN
+#  define LINUX_FIELD_u32_u64(field)   __u32 field ## _padding, field
+#  define LINUX_FIELD_u32_u64_INIT_ONSTACK(field, v)   \
+   field ## _padding = 0, field = (intptr_t)v
+# else
+#  define LINUX_FIELD_u32_u64(field)   __u32 field, field ## _padding
+#  define LINUX_FIELD_u32_u64_INIT_ONSTACK(field, v)   \
+   field = (intptr_t)v, field ## _padding = 0
+# endif
+#endif
+
+#endif /* _UAPI_LINUX_TYPES_32_64_H */
-- 
2.11.0



[RFC PATCH for 4.18 07/16] x86: Wire up restartable sequence system call

2018-06-02 Thread Mathieu Desnoyers
Wire up the rseq system call on x86 32/64.

This provides an ABI improving the speed of a user-space getcpu
operation on x86 by removing the need to perform a function call, "lsl"
instruction, or system call on the fast path, as well as improving the
speed of user-space operations on per-cpu data.

Signed-off-by: Mathieu Desnoyers 
Reviewed-by: Thomas Gleixner 
CC: Russell King 
CC: Catalin Marinas 
CC: Will Deacon 
CC: Paul Turner 
CC: Andrew Hunter 
CC: Peter Zijlstra 
CC: Andy Lutomirski 
CC: Andi Kleen 
CC: Dave Watson 
CC: Chris Lameter 
CC: Ingo Molnar 
CC: "H. Peter Anvin" 
CC: Ben Maurer 
CC: Steven Rostedt 
CC: "Paul E. McKenney" 
CC: Josh Triplett 
CC: Linus Torvalds 
CC: Andrew Morton 
CC: Boqun Feng 
CC: linux-...@vger.kernel.org
---
 arch/x86/entry/syscalls/syscall_32.tbl | 1 +
 arch/x86/entry/syscalls/syscall_64.tbl | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/x86/entry/syscalls/syscall_32.tbl 
b/arch/x86/entry/syscalls/syscall_32.tbl
index d6b27dab1b30..db346da64947 100644
--- a/arch/x86/entry/syscalls/syscall_32.tbl
+++ b/arch/x86/entry/syscalls/syscall_32.tbl
@@ -396,3 +396,4 @@
 382i386pkey_free   sys_pkey_free   
__ia32_sys_pkey_free
 383i386statx   sys_statx   
__ia32_sys_statx
 384i386arch_prctl  sys_arch_prctl  
__ia32_compat_sys_arch_prctl
+385i386rseqsys_rseq
__ia32_sys_rseq
diff --git a/arch/x86/entry/syscalls/syscall_64.tbl 
b/arch/x86/entry/syscalls/syscall_64.tbl
index 4dfe42666d0c..41b082b125c3 100644
--- a/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/arch/x86/entry/syscalls/syscall_64.tbl
@@ -341,6 +341,7 @@
 330common  pkey_alloc  __x64_sys_pkey_alloc
 331common  pkey_free   __x64_sys_pkey_free
 332common  statx   __x64_sys_statx
+333common  rseq__x64_sys_rseq
 
 #
 # x32-specific system call numbers start at 512 to avoid cache impact
-- 
2.11.0



[RFC PATCH for 4.18 06/16] x86: Add support for restartable sequences (v2)

2018-06-02 Thread Mathieu Desnoyers
Call the rseq_handle_notify_resume() function on return to userspace if
TIF_NOTIFY_RESUME thread flag is set.

Perform fixup on the pre-signal frame when a signal is delivered on top
of a restartable sequence critical section.

Check that system calls are not invoked from within rseq critical
sections by invoking rseq_signal() from syscall_return_slowpath().
With CONFIG_DEBUG_RSEQ, such behavior results in termination of the
process with SIGSEGV.

Signed-off-by: Mathieu Desnoyers 
Reviewed-by: Thomas Gleixner 
CC: Russell King 
CC: Catalin Marinas 
CC: Will Deacon 
CC: Paul Turner 
CC: Andrew Hunter 
CC: Peter Zijlstra 
CC: Andy Lutomirski 
CC: Andi Kleen 
CC: Dave Watson 
CC: Chris Lameter 
CC: Ingo Molnar 
CC: "H. Peter Anvin" 
CC: Ben Maurer 
CC: Steven Rostedt 
CC: "Paul E. McKenney" 
CC: Josh Triplett 
CC: Linus Torvalds 
CC: Andrew Morton 
CC: Boqun Feng 
CC: linux-...@vger.kernel.org

---

Changes since v1:
- Call rseq_signal() when returning from a system call.
---
 arch/x86/Kconfig | 1 +
 arch/x86/entry/common.c  | 3 +++
 arch/x86/kernel/signal.c | 6 ++
 3 files changed, 10 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index c07f492b871a..62e00a1a7cf7 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -180,6 +180,7 @@ config X86
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_RELIABLE_STACKTRACE if X86_64 && 
UNWINDER_FRAME_POINTER && STACK_VALIDATION
select HAVE_STACK_VALIDATIONif X86_64
+   select HAVE_RSEQ
select HAVE_SYSCALL_TRACEPOINTS
select HAVE_UNSTABLE_SCHED_CLOCK
select HAVE_USER_RETURN_NOTIFIER
diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index fbf6a6c3fd2d..92190879b228 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -164,6 +164,7 @@ static void exit_to_usermode_loop(struct pt_regs *regs, u32 
cached_flags)
if (cached_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
+   rseq_handle_notify_resume(regs);
}
 
if (cached_flags & _TIF_USER_RETURN_NOTIFY)
@@ -254,6 +255,8 @@ __visible inline void syscall_return_slowpath(struct 
pt_regs *regs)
WARN(irqs_disabled(), "syscall %ld left IRQs disabled", 
regs->orig_ax))
local_irq_enable();
 
+   rseq_syscall(regs);
+
/*
 * First do one-time work.  If these work items are enabled, we
 * want to run them exactly once per syscall exit with IRQs on.
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index da270b95fe4d..445ca11ff863 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -688,6 +688,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
sigset_t *set = sigmask_to_save();
compat_sigset_t *cset = (compat_sigset_t *) set;
 
+   /*
+* Increment event counter and perform fixup for the pre-signal
+* frame.
+*/
+   rseq_signal_deliver(regs);
+
/* Set up the stack frame */
if (is_ia32_frame(ksig)) {
if (ksig->ka.sa.sa_flags & SA_SIGINFO)
-- 
2.11.0



[RFC PATCH for 4.18 10/16] powerpc: Wire up restartable sequences system call

2018-06-02 Thread Mathieu Desnoyers
From: Boqun Feng 

Wire up the rseq system call on powerpc.

This provides an ABI improving the speed of a user-space getcpu
operation on powerpc by skipping the getcpu system call on the fast
path, as well as improving the speed of user-space operations on per-cpu
data compared to using load-reservation/store-conditional atomics.

Signed-off-by: Boqun Feng 
Signed-off-by: Mathieu Desnoyers 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Michael Ellerman 
CC: Peter Zijlstra 
CC: "Paul E. McKenney" 
CC: linuxppc-...@lists.ozlabs.org
---
 arch/powerpc/include/asm/systbl.h  | 1 +
 arch/powerpc/include/asm/unistd.h  | 2 +-
 arch/powerpc/include/uapi/asm/unistd.h | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/systbl.h 
b/arch/powerpc/include/asm/systbl.h
index d61f9c96d916..45d4d37495fd 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -392,3 +392,4 @@ SYSCALL(statx)
 SYSCALL(pkey_alloc)
 SYSCALL(pkey_free)
 SYSCALL(pkey_mprotect)
+SYSCALL(rseq)
diff --git a/arch/powerpc/include/asm/unistd.h 
b/arch/powerpc/include/asm/unistd.h
index daf1ba97a00c..1e9708632dce 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -12,7 +12,7 @@
 #include 
 
 
-#define NR_syscalls387
+#define NR_syscalls388
 
 #define __NR__exit __NR_exit
 
diff --git a/arch/powerpc/include/uapi/asm/unistd.h 
b/arch/powerpc/include/uapi/asm/unistd.h
index 389c36fd8299..ac5ba55066dd 100644
--- a/arch/powerpc/include/uapi/asm/unistd.h
+++ b/arch/powerpc/include/uapi/asm/unistd.h
@@ -398,5 +398,6 @@
 #define __NR_pkey_alloc384
 #define __NR_pkey_free 385
 #define __NR_pkey_mprotect 386
+#define __NR_rseq  387
 
 #endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
-- 
2.11.0



[RFC PATCH for 4.18 08/16] powerpc: Add support for restartable sequences

2018-06-02 Thread Mathieu Desnoyers
From: Boqun Feng 

Call the rseq_handle_notify_resume() function on return to userspace if
TIF_NOTIFY_RESUME thread flag is set.

Perform fixup on the pre-signal when a signal is delivered on top of a
restartable sequence critical section.

Signed-off-by: Boqun Feng 
Signed-off-by: Mathieu Desnoyers 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Michael Ellerman 
CC: Peter Zijlstra 
CC: "Paul E. McKenney" 
CC: linuxppc-...@lists.ozlabs.org
---
 arch/powerpc/Kconfig | 1 +
 arch/powerpc/kernel/signal.c | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index c32a181a7cbb..ed21a777e8c6 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -223,6 +223,7 @@ config PPC
select HAVE_SYSCALL_TRACEPOINTS
select HAVE_VIRT_CPU_ACCOUNTING
select HAVE_IRQ_TIME_ACCOUNTING
+   select HAVE_RSEQ
select IRQ_DOMAIN
select IRQ_FORCED_THREADING
select MODULES_USE_ELF_RELA
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index 61db86ecd318..d3bb3aaaf5ac 100644
--- a/arch/powerpc/kernel/signal.c
+++ b/arch/powerpc/kernel/signal.c
@@ -133,6 +133,8 @@ static void do_signal(struct task_struct *tsk)
/* Re-enable the breakpoints for the signal stack */
thread_change_pc(tsk, tsk->thread.regs);
 
+   rseq_signal_deliver(tsk->thread.regs);
+
if (is32) {
if (ksig.ka.sa.sa_flags & SA_SIGINFO)
ret = handle_rt_signal32(&ksig, oldset, tsk);
@@ -164,6 +166,7 @@ void do_notify_resume(struct pt_regs *regs, unsigned long 
thread_info_flags)
if (thread_info_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
+   rseq_handle_notify_resume(regs);
}
 
user_enter();
-- 
2.11.0



[RFC PATCH for 4.18 05/16] arm: Wire up restartable sequences system call

2018-06-02 Thread Mathieu Desnoyers
Wire up the rseq system call on 32-bit ARM.

This provides an ABI improving the speed of a user-space getcpu
operation on ARM by skipping the getcpu system call on the fast path, as
well as improving the speed of user-space operations on per-cpu data
compared to using load-linked/store-conditional.

Signed-off-by: Mathieu Desnoyers 
CC: Russell King 
CC: Catalin Marinas 
CC: Will Deacon 
CC: Thomas Gleixner 
CC: Paul Turner 
CC: Andrew Hunter 
CC: Peter Zijlstra 
CC: Andy Lutomirski 
CC: Andi Kleen 
CC: Dave Watson 
CC: Chris Lameter 
CC: Ingo Molnar 
CC: Ben Maurer 
CC: Steven Rostedt 
CC: "Paul E. McKenney" 
CC: Josh Triplett 
CC: Linus Torvalds 
CC: Andrew Morton 
CC: Boqun Feng 
CC: linux-...@vger.kernel.org
---
 arch/arm/tools/syscall.tbl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/tools/syscall.tbl b/arch/arm/tools/syscall.tbl
index 0bb0e9c6376c..fbc74b5fa3ed 100644
--- a/arch/arm/tools/syscall.tbl
+++ b/arch/arm/tools/syscall.tbl
@@ -412,3 +412,4 @@
 395common  pkey_alloc  sys_pkey_alloc
 396common  pkey_free   sys_pkey_free
 397common  statx   sys_statx
+398common  rseqsys_rseq
-- 
2.11.0



[RFC PATCH for 4.18 16/16] rseq: selftests: Provide Makefile, scripts, gitignore (v2)

2018-06-02 Thread Mathieu Desnoyers
A run_param_test.sh script runs many variants of the parametrizable
tests.

Wire up the rseq Makefile, add directory entry into MAINTAINERS file.

Signed-off-by: Mathieu Desnoyers 
CC: Shuah Khan 
CC: Russell King 
CC: Catalin Marinas 
CC: Will Deacon 
CC: Thomas Gleixner 
CC: Paul Turner 
CC: Andrew Hunter 
CC: Peter Zijlstra 
CC: Andy Lutomirski 
CC: Andi Kleen 
CC: Dave Watson 
CC: Chris Lameter 
CC: Ingo Molnar 
CC: "H. Peter Anvin" 
CC: Ben Maurer 
CC: Steven Rostedt 
CC: "Paul E. McKenney" 
CC: Josh Triplett 
CC: Linus Torvalds 
CC: Andrew Morton 
CC: Boqun Feng 
CC: linux-kselft...@vger.kernel.org
CC: linux-...@vger.kernel.org
---
Changes since v1:
- Use only rseq, remove use of cpu_opv.
---
 MAINTAINERS|   1 +
 tools/testing/selftests/Makefile   |   1 +
 tools/testing/selftests/rseq/.gitignore|   6 ++
 tools/testing/selftests/rseq/Makefile  |  30 ++
 tools/testing/selftests/rseq/run_param_test.sh | 121 +
 5 files changed, 159 insertions(+)
 create mode 100644 tools/testing/selftests/rseq/.gitignore
 create mode 100644 tools/testing/selftests/rseq/Makefile
 create mode 100755 tools/testing/selftests/rseq/run_param_test.sh

diff --git a/MAINTAINERS b/MAINTAINERS
index be42f5bfc0c9..720b57fac5db 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11982,6 +11982,7 @@ S:  Supported
 F: kernel/rseq.c
 F: include/uapi/linux/rseq.h
 F: include/trace/events/rseq.h
+F: tools/testing/selftests/rseq/
 
 RFKILL
 M: Johannes Berg 
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 32aafa92074c..593fb44c9cd4 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -28,6 +28,7 @@ TARGETS += powerpc
 TARGETS += proc
 TARGETS += pstore
 TARGETS += ptrace
+TARGETS += rseq
 TARGETS += seccomp
 TARGETS += sigaltstack
 TARGETS += size
diff --git a/tools/testing/selftests/rseq/.gitignore 
b/tools/testing/selftests/rseq/.gitignore
new file mode 100644
index ..cc610da7e369
--- /dev/null
+++ b/tools/testing/selftests/rseq/.gitignore
@@ -0,0 +1,6 @@
+basic_percpu_ops_test
+basic_test
+basic_rseq_op_test
+param_test
+param_test_benchmark
+param_test_compare_twice
diff --git a/tools/testing/selftests/rseq/Makefile 
b/tools/testing/selftests/rseq/Makefile
new file mode 100644
index ..c30c52e1d0d2
--- /dev/null
+++ b/tools/testing/selftests/rseq/Makefile
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: GPL-2.0+ OR MIT
+CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./
+LDLIBS += -lpthread
+
+# Own dependencies because we only want to build against 1st prerequisite, but
+# still track changes to header files and depend on shared object.
+OVERRIDE_TARGETS = 1
+
+TEST_GEN_PROGS = basic_test basic_percpu_ops_test param_test \
+   param_test_benchmark param_test_compare_twice
+
+TEST_GEN_PROGS_EXTENDED = librseq.so
+
+TEST_PROGS = run_param_test.sh
+
+include ../lib.mk
+
+$(OUTPUT)/librseq.so: rseq.c rseq.h rseq-*.h
+   $(CC) $(CFLAGS) -shared -fPIC $< $(LDLIBS) -o $@
+
+$(OUTPUT)/%: %.c $(TEST_GEN_PROGS_EXTENDED) rseq.h rseq-*.h
+   $(CC) $(CFLAGS) $< $(LDLIBS) -lrseq -o $@
+
+$(OUTPUT)/param_test_benchmark: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
+   rseq.h rseq-*.h
+   $(CC) $(CFLAGS) -DBENCHMARK $< $(LDLIBS) -lrseq -o $@
+
+$(OUTPUT)/param_test_compare_twice: param_test.c $(TEST_GEN_PROGS_EXTENDED) \
+   rseq.h rseq-*.h
+   $(CC) $(CFLAGS) -DRSEQ_COMPARE_TWICE $< $(LDLIBS) -lrseq -o $@
diff --git a/tools/testing/selftests/rseq/run_param_test.sh 
b/tools/testing/selftests/rseq/run_param_test.sh
new file mode 100755
index ..3acd6d75ff9f
--- /dev/null
+++ b/tools/testing/selftests/rseq/run_param_test.sh
@@ -0,0 +1,121 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+ or MIT
+
+EXTRA_ARGS=${@}
+
+OLDIFS="$IFS"
+IFS=$'\n'
+TEST_LIST=(
+   "-T s"
+   "-T l"
+   "-T b"
+   "-T b -M"
+   "-T m"
+   "-T m -M"
+   "-T i"
+)
+
+TEST_NAME=(
+   "spinlock"
+   "list"
+   "buffer"
+   "buffer with barrier"
+   "memcpy"
+   "memcpy with barrier"
+   "increment"
+)
+IFS="$OLDIFS"
+
+REPS=1000
+SLOW_REPS=100
+
+function do_tests()
+{
+   local i=0
+   while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
+   echo "Running test ${TEST_NAME[$i]}"
+   ./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || 
exit 1
+   echo "Running compare-twice test ${TEST_NAME[$i]}"
+   ./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} 
${EXTRA_ARGS} || exit 1
+   let "i++"
+   done
+}
+
+echo "Default parameters"
+do_tests
+
+echo "Loop injection: 1 loops"
+
+OLDIFS="$IFS"
+IFS=$'\n'
+INJECT_LIST=(
+   "1"
+   "2"
+   "3"
+   "4"
+   "5"
+   "6"
+   "7"
+   "8"
+  

[RFC PATCH for 4.18 15/16] rseq: selftests: Provide parametrized tests (v2)

2018-06-02 Thread Mathieu Desnoyers
"param_test" is a parametrizable restartable sequences test. See
the "--help" output for usage.

"param_test_benchmark" is the same as "param_test", but it removes
testing book-keeping code to allow accurate benchmarks.

"param_test_compare_twice" is the same as "param_test", but it performs
each comparison within rseq critical section twice, thus validating
invariants. If any of the second comparisons fails, an error message
is printed and the test aborts.

Signed-off-by: Mathieu Desnoyers 
CC: Shuah Khan 
CC: Russell King 
CC: Catalin Marinas 
CC: Will Deacon 
CC: Thomas Gleixner 
CC: Paul Turner 
CC: Andrew Hunter 
CC: Peter Zijlstra 
CC: Andy Lutomirski 
CC: Andi Kleen 
CC: Dave Watson 
CC: Chris Lameter 
CC: Ingo Molnar 
CC: "H. Peter Anvin" 
CC: Ben Maurer 
CC: Steven Rostedt 
CC: "Paul E. McKenney" 
CC: Josh Triplett 
CC: Linus Torvalds 
CC: Andrew Morton 
CC: Boqun Feng 
CC: linux-kselft...@vger.kernel.org
CC: linux-...@vger.kernel.org
---
Changes since v1:
- Use only rseq, remove use of cpu_opv.
---
 tools/testing/selftests/rseq/param_test.c | 1260 +
 1 file changed, 1260 insertions(+)
 create mode 100644 tools/testing/selftests/rseq/param_test.c

diff --git a/tools/testing/selftests/rseq/param_test.c 
b/tools/testing/selftests/rseq/param_test.c
new file mode 100644
index ..6a9f602a8718
--- /dev/null
+++ b/tools/testing/selftests/rseq/param_test.c
@@ -0,0 +1,1260 @@
+// SPDX-License-Identifier: LGPL-2.1
+#define _GNU_SOURCE
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static inline pid_t gettid(void)
+{
+   return syscall(__NR_gettid);
+}
+
+#define NR_INJECT  9
+static int loop_cnt[NR_INJECT + 1];
+
+static int loop_cnt_1 asm("asm_loop_cnt_1") __attribute__((used));
+static int loop_cnt_2 asm("asm_loop_cnt_2") __attribute__((used));
+static int loop_cnt_3 asm("asm_loop_cnt_3") __attribute__((used));
+static int loop_cnt_4 asm("asm_loop_cnt_4") __attribute__((used));
+static int loop_cnt_5 asm("asm_loop_cnt_5") __attribute__((used));
+static int loop_cnt_6 asm("asm_loop_cnt_6") __attribute__((used));
+
+static int opt_modulo, verbose;
+
+static int opt_yield, opt_signal, opt_sleep,
+   opt_disable_rseq, opt_threads = 200,
+   opt_disable_mod = 0, opt_test = 's', opt_mb = 0;
+
+#ifndef RSEQ_SKIP_FASTPATH
+static long long opt_reps = 5000;
+#else
+static long long opt_reps = 100;
+#endif
+
+static __thread __attribute__((tls_model("initial-exec")))
+unsigned int signals_delivered;
+
+#ifndef BENCHMARK
+
+static __thread __attribute__((tls_model("initial-exec"), unused))
+unsigned int yield_mod_cnt, nr_abort;
+
+#define printf_verbose(fmt, ...)   \
+   do {\
+   if (verbose)\
+   printf(fmt, ## __VA_ARGS__);\
+   } while (0)
+
+#if defined(__x86_64__) || defined(__i386__)
+
+#define INJECT_ASM_REG "eax"
+
+#define RSEQ_INJECT_CLOBBER \
+   , INJECT_ASM_REG
+
+#ifdef __i386__
+
+#define RSEQ_INJECT_ASM(n) \
+   "mov asm_loop_cnt_" #n ", %%" INJECT_ASM_REG "\n\t" \
+   "test %%" INJECT_ASM_REG ",%%" INJECT_ASM_REG "\n\t" \
+   "jz 333f\n\t" \
+   "222:\n\t" \
+   "dec %%" INJECT_ASM_REG "\n\t" \
+   "jnz 222b\n\t" \
+   "333:\n\t"
+
+#elif defined(__x86_64__)
+
+#define RSEQ_INJECT_ASM(n) \
+   "lea asm_loop_cnt_" #n "(%%rip), %%" INJECT_ASM_REG "\n\t" \
+   "mov (%%" INJECT_ASM_REG "), %%" INJECT_ASM_REG "\n\t" \
+   "test %%" INJECT_ASM_REG ",%%" INJECT_ASM_REG "\n\t" \
+   "jz 333f\n\t" \
+   "222:\n\t" \
+   "dec %%" INJECT_ASM_REG "\n\t" \
+   "jnz 222b\n\t" \
+   "333:\n\t"
+
+#else
+#error "Unsupported architecture"
+#endif
+
+#elif defined(__ARMEL__)
+
+#define RSEQ_INJECT_INPUT \
+   , [loop_cnt_1]"m"(loop_cnt[1]) \
+   , [loop_cnt_2]"m"(loop_cnt[2]) \
+   , [loop_cnt_3]"m"(loop_cnt[3]) \
+   , [loop_cnt_4]"m"(loop_cnt[4]) \
+   , [loop_cnt_5]"m"(loop_cnt[5]) \
+   , [loop_cnt_6]"m"(loop_cnt[6])
+
+#define INJECT_ASM_REG "r4"
+
+#define RSEQ_INJECT_CLOBBER \
+   , INJECT_ASM_REG
+
+#define RSEQ_INJECT_ASM(n) \
+   "ldr " INJECT_ASM_REG ", %[loop_cnt_" #n "]\n\t" \
+   "cmp " INJECT_ASM_REG ", #0\n\t" \
+   "beq 333f\n\t" \
+   "222:\n\t" \
+   "subs " INJECT_ASM_REG ", #1\n\t" \
+   "bne 222b\n\t" \
+   "333:\n\t"
+
+#elif __PPC__
+
+#define RSEQ_INJECT_INPUT \
+   , [loop_cnt_1]"m"(loop_cnt[1]) \
+   , [loop_cnt_2]"m"(loop_cnt[2]) \
+   , [loop_cnt_3]"m"(loop_cnt[3]) \
+   , [loop_cnt_4]"m"(loop_cnt[4]) \
+   , [loop_cnt_5]"m"(loop_cnt[5]) \
+   , [loop_cnt_6]"m"(loop_cnt[6])
+
+#define INJECT_ASM_REG "r18"
+
+#define RSEQ_INJECT_CLOBBER \
+   , INJECT_ASM_REG
+
+#define RSEQ_INJECT_ASM(n) \
+   "lwz %%" INJECT_ASM_REG ", %[loop_

[RFC PATCH for 4.18 12/16] rseq: selftests: Provide rseq library (v5)

2018-06-02 Thread Mathieu Desnoyers
This rseq helper library provides a user-space API to the rseq()
system call.

The rseq fast-path exposes the instruction pointer addresses where the
rseq assembly blocks begin and end, as well as the associated abort
instruction pointer, in the __rseq_table section. This section allows
debuggers may know where to place breakpoints when single-stepping
through assembly blocks which may be aborted at any point by the kernel.

Signed-off-by: Mathieu Desnoyers 
CC: Shuah Khan 
CC: Russell King 
CC: Catalin Marinas 
CC: Will Deacon 
CC: Thomas Gleixner 
CC: Paul Turner 
CC: Andrew Hunter 
CC: Peter Zijlstra 
CC: Andy Lutomirski 
CC: Andi Kleen 
CC: Dave Watson 
CC: Chris Lameter 
CC: Ingo Molnar 
CC: "H. Peter Anvin" 
CC: Ben Maurer 
CC: Steven Rostedt 
CC: "Paul E. McKenney" 
CC: Josh Triplett 
CC: Linus Torvalds 
CC: Andrew Morton 
CC: Boqun Feng 
CC: linux-kselft...@vger.kernel.org
CC: linux-...@vger.kernel.org
---
Changes since v1:
- Provide abort-ip signature: The abort-ip signature is located just
  before the abort-ip target. It is currently hardcoded, but a
  user-space application could use the __rseq_table to iterate on all
  abort-ip targets and use a random value as signature if needed in the
  future.
- Add rseq_prepare_unload(): Libraries and JIT code using rseq critical
  sections need to issue rseq_prepare_unload() on each thread at least
  once before reclaim of struct rseq_cs.
- Use initial-exec TLS model, non-weak symbol: The initial-exec model is
  signal-safe, whereas the global-dynamic model is not.  Remove the
  "weak" symbol attribute from the __rseq_abi in rseq.c. The rseq.so
  library will have ownership of that symbol, and there is not reason for
  an application or user library to try to define that symbol.
  The expected use is to link against libreq.so, which owns and provide
  that symbol.
- Set cpu_id to -2 on register error
- Add rseq_len syscall parameter, rseq_cs version
- Ensure disassember-friendly signature: x86 32/64 disassembler have a
  hard time decoding the instruction stream after a bad instruction. Use
  a nopl instruction to encode the signature. Suggested by Andy Lutomirski.
- Exercise parametrized tests variants in a shell scripts.
- Restartable sequences selftests: Remove use of event counter.
- Use cpu_id_start field:  With the cpu_id_start field, the C
  preparation phase of the fast-path does not need to compare cpu_id < 0
  anymore.
- Signal-safe registration and refcounting: Allow libraries using
  librseq.so to register it from signal handlers.
- Use OVERRIDE_TARGETS in makefile.
- Use "m" constraints for rseq_cs field.

Changes since v2:
- Update based on Thomas Gleixner's comments.

Changes since v3:
- Generate param_test_skip_fastpath and param_test_benchmark with
  -DSKIP_FASTPATH and -DBENCHMARK (respectively). Add param_test_fastpath
  to run_param_test.sh.

Changes since v4:
- Fold arm: workaround gcc asm size guess,
- Namespace barrier() -> rseq_barrier() in library header,
- Take into account coding style feedback from Peter Zijlstra,
- Split rseq selftests into logical commits.
---
 tools/testing/selftests/rseq/rseq-arm.h  |  715 +++
 tools/testing/selftests/rseq/rseq-ppc.h  |  671 ++
 tools/testing/selftests/rseq/rseq-skip.h |   65 ++
 tools/testing/selftests/rseq/rseq-x86.h  | 1132 ++
 tools/testing/selftests/rseq/rseq.c  |  117 +++
 tools/testing/selftests/rseq/rseq.h  |  147 
 6 files changed, 2847 insertions(+)
 create mode 100644 tools/testing/selftests/rseq/rseq-arm.h
 create mode 100644 tools/testing/selftests/rseq/rseq-ppc.h
 create mode 100644 tools/testing/selftests/rseq/rseq-skip.h
 create mode 100644 tools/testing/selftests/rseq/rseq-x86.h
 create mode 100644 tools/testing/selftests/rseq/rseq.c
 create mode 100644 tools/testing/selftests/rseq/rseq.h

diff --git a/tools/testing/selftests/rseq/rseq-arm.h 
b/tools/testing/selftests/rseq/rseq-arm.h
new file mode 100644
index ..3b055f9aeaab
--- /dev/null
+++ b/tools/testing/selftests/rseq/rseq-arm.h
@@ -0,0 +1,715 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * rseq-arm.h
+ *
+ * (C) Copyright 2016-2018 - Mathieu Desnoyers 
+ */
+
+#define RSEQ_SIG   0x53053053
+
+#define rseq_smp_mb()  __asm__ __volatile__ ("dmb" ::: "memory", "cc")
+#define rseq_smp_rmb() __asm__ __volatile__ ("dmb" ::: "memory", "cc")
+#define rseq_smp_wmb() __asm__ __volatile__ ("dmb" ::: "memory", "cc")
+
+#define rseq_smp_load_acquire(p)   \
+__extension__ ({   \
+   __typeof(*p) p1 = RSEQ_READ_ONCE(*p);   \
+   rseq_smp_mb();  \
+   p1; \
+})
+
+#define rseq_smp_acquire__after_ctrl_dep() rseq_smp_rmb()
+
+#define rseq_smp_store_release(p, v)   \
+do {

[RFC PATCH for 4.18 11/16] selftests: lib.mk: Introduce OVERRIDE_TARGETS

2018-06-02 Thread Mathieu Desnoyers
Introduce OVERRIDE_TARGETS to allow tests to express dependencies on
header files and .so, which require to override the selftests lib.mk
targets.

Signed-off-by: Mathieu Desnoyers 
Acked-by: Shuah Khan 
CC: Russell King 
CC: Catalin Marinas 
CC: Will Deacon 
CC: Thomas Gleixner 
CC: Paul Turner 
CC: Andrew Hunter 
CC: Peter Zijlstra 
CC: Andy Lutomirski 
CC: Andi Kleen 
CC: Dave Watson 
CC: Chris Lameter 
CC: Ingo Molnar 
CC: "H. Peter Anvin" 
CC: Ben Maurer 
CC: Steven Rostedt 
CC: "Paul E. McKenney" 
CC: Josh Triplett 
CC: Linus Torvalds 
CC: Andrew Morton 
CC: Boqun Feng 
CC: linux-kselft...@vger.kernel.org
CC: linux-...@vger.kernel.org
---
 tools/testing/selftests/lib.mk | 4 
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index c1b1a4dc6a96..ceb6c7c48547 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -106,6 +106,9 @@ COMPILE.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
 LINK.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
 endif
 
+# Selftest makefiles can override those targets by setting
+# OVERRIDE_TARGETS = 1.
+ifeq ($(OVERRIDE_TARGETS),)
 $(OUTPUT)/%:%.c
$(LINK.c) $^ $(LDLIBS) -o $@
 
@@ -114,5 +117,6 @@ $(OUTPUT)/%.o:%.S
 
 $(OUTPUT)/%:%.S
$(LINK.S) $^ $(LDLIBS) -o $@
+endif
 
 .PHONY: run_tests all clean install emit_tests
-- 
2.11.0



[RFC PATCH for 4.18 13/16] rseq: selftests: Provide basic test

2018-06-02 Thread Mathieu Desnoyers
"basic_test" only asserts that RSEQ works moderately correctly. E.g.
that the CPUID pointer works.

Signed-off-by: Mathieu Desnoyers 
CC: Shuah Khan 
CC: Russell King 
CC: Catalin Marinas 
CC: Will Deacon 
CC: Thomas Gleixner 
CC: Paul Turner 
CC: Andrew Hunter 
CC: Peter Zijlstra 
CC: Andy Lutomirski 
CC: Andi Kleen 
CC: Dave Watson 
CC: Chris Lameter 
CC: Ingo Molnar 
CC: "H. Peter Anvin" 
CC: Ben Maurer 
CC: Steven Rostedt 
CC: "Paul E. McKenney" 
CC: Josh Triplett 
CC: Linus Torvalds 
CC: Andrew Morton 
CC: Boqun Feng 
CC: linux-kselft...@vger.kernel.org
CC: linux-...@vger.kernel.org
---
 tools/testing/selftests/rseq/basic_test.c | 56 +++
 1 file changed, 56 insertions(+)
 create mode 100644 tools/testing/selftests/rseq/basic_test.c

diff --git a/tools/testing/selftests/rseq/basic_test.c 
b/tools/testing/selftests/rseq/basic_test.c
new file mode 100644
index ..d8efbfb89193
--- /dev/null
+++ b/tools/testing/selftests/rseq/basic_test.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: LGPL-2.1
+/*
+ * Basic test coverage for critical regions and rseq_current_cpu().
+ */
+
+#define _GNU_SOURCE
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "rseq.h"
+
+void test_cpu_pointer(void)
+{
+   cpu_set_t affinity, test_affinity;
+   int i;
+
+   sched_getaffinity(0, sizeof(affinity), &affinity);
+   CPU_ZERO(&test_affinity);
+   for (i = 0; i < CPU_SETSIZE; i++) {
+   if (CPU_ISSET(i, &affinity)) {
+   CPU_SET(i, &test_affinity);
+   sched_setaffinity(0, sizeof(test_affinity),
+   &test_affinity);
+   assert(sched_getcpu() == i);
+   assert(rseq_current_cpu() == i);
+   assert(rseq_current_cpu_raw() == i);
+   assert(rseq_cpu_start() == i);
+   CPU_CLR(i, &test_affinity);
+   }
+   }
+   sched_setaffinity(0, sizeof(affinity), &affinity);
+}
+
+int main(int argc, char **argv)
+{
+   if (rseq_register_current_thread()) {
+   fprintf(stderr, "Error: rseq_register_current_thread(...) 
failed(%d): %s\n",
+   errno, strerror(errno));
+   goto init_thread_error;
+   }
+   printf("testing current cpu\n");
+   test_cpu_pointer();
+   if (rseq_unregister_current_thread()) {
+   fprintf(stderr, "Error: rseq_unregister_current_thread(...) 
failed(%d): %s\n",
+   errno, strerror(errno));
+   goto init_thread_error;
+   }
+   return 0;
+
+init_thread_error:
+   return -1;
+}
-- 
2.11.0



[RFC PATCH for 4.18 02/16] rseq: Introduce restartable sequences system call (v13)

2018-06-02 Thread Mathieu Desnoyers
Expose a new system call allowing each thread to register one userspace
memory area to be used as an ABI between kernel and user-space for two
purposes: user-space restartable sequences and quick access to read the
current CPU number value from user-space.

* Restartable sequences (per-cpu atomics)

Restartables sequences allow user-space to perform update operations on
per-cpu data without requiring heavy-weight atomic operations.

The restartable critical sections (percpu atomics) work has been started
by Paul Turner and Andrew Hunter. It lets the kernel handle restart of
critical sections. [1] [2] The re-implementation proposed here brings a
few simplifications to the ABI which facilitates porting to other
architectures and speeds up the user-space fast path.

Here are benchmarks of various rseq use-cases.

Test hardware:

arm32: ARMv7 Processor rev 4 (v7l) "Cubietruck", 2-core
x86-64: Intel E5-2630 v3@2.40GHz, 16-core, hyperthreading

The following benchmarks were all performed on a single thread.

* Per-CPU statistic counter increment

getcpu+atomic (ns/op)rseq (ns/op)speedup
arm32:344.0 31.4  11.0
x86-64:15.3  2.0   7.7

* LTTng-UST: write event 32-bit header, 32-bit payload into tracer
 per-cpu buffer

getcpu+atomic (ns/op)rseq (ns/op)speedup
arm32:   2502.0 2250.0 1.1
x86-64:   117.4   98.0 1.2

* liburcu percpu: lock-unlock pair, dereference, read/compare word

getcpu+atomic (ns/op)rseq (ns/op)speedup
arm32:751.0 128.5  5.8
x86-64:53.4  28.6  1.9

* jemalloc memory allocator adapted to use rseq

Using rseq with per-cpu memory pools in jemalloc at Facebook (based on
rseq 2016 implementation):

The production workload response-time has 1-2% gain avg. latency, and
the P99 overall latency drops by 2-3%.

* Reading the current CPU number

Speeding up reading the current CPU number on which the caller thread is
running is done by keeping the current CPU number up do date within the
cpu_id field of the memory area registered by the thread. This is done
by making scheduler preemption set the TIF_NOTIFY_RESUME flag on the
current thread. Upon return to user-space, a notify-resume handler
updates the current CPU value within the registered user-space memory
area. User-space can then read the current CPU number directly from
memory.

Keeping the current cpu id in a memory area shared between kernel and
user-space is an improvement over current mechanisms available to read
the current CPU number, which has the following benefits over
alternative approaches:

- 35x speedup on ARM vs system call through glibc
- 20x speedup on x86 compared to calling glibc, which calls vdso
  executing a "lsl" instruction,
- 14x speedup on x86 compared to inlined "lsl" instruction,
- Unlike vdso approaches, this cpu_id value can be read from an inline
  assembly, which makes it a useful building block for restartable
  sequences.
- The approach of reading the cpu id through memory mapping shared
  between kernel and user-space is portable (e.g. ARM), which is not the
  case for the lsl-based x86 vdso.

On x86, yet another possible approach would be to use the gs segment
selector to point to user-space per-cpu data. This approach performs
similarly to the cpu id cache, but it has two disadvantages: it is
not portable, and it is incompatible with existing applications already
using the gs segment selector for other purposes.

Benchmarking various approaches for reading the current CPU number:

ARMv7 Processor rev 4 (v7l)
Machine model: Cubietruck
- Baseline (empty loop):8.4 ns
- Read CPU from rseq cpu_id:   16.7 ns
- Read CPU from rseq cpu_id (lazy register):   19.8 ns
- glibc 2.19-0ubuntu6.6 getcpu:   301.8 ns
- getcpu system call: 234.9 ns

x86-64 Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz:
- Baseline (empty loop):0.8 ns
- Read CPU from rseq cpu_id:0.8 ns
- Read CPU from rseq cpu_id (lazy register):0.8 ns
- Read using gs segment selector:   0.8 ns
- "lsl" inline assembly:   13.0 ns
- glibc 2.19-0ubuntu6 getcpu:  16.6 ns
- getcpu system call:  53.9 ns

- Speed (benchmark taken on v8 of patchset)

Running 10 runs of hackbench -l 10 seems to indicate, contrary to
expectations, that enabling CONFIG_RSEQ slightly accelerates the
scheduler:

Configuration: 2 sockets * 8-core Intel(R) Xeon(R) CPU E5-2630 v3 @
2.40GHz (directly on hardware, hyperthreading disabled in BIOS, energy
saving dis

[RFC PATCH for 4.18 03/16] arm: Add restartable sequences support

2018-06-02 Thread Mathieu Desnoyers
Call the rseq_handle_notify_resume() function on return to
userspace if TIF_NOTIFY_RESUME thread flag is set.

Perform fixup on the pre-signal frame when a signal is delivered on top
of a restartable sequence critical section.

Signed-off-by: Mathieu Desnoyers 
CC: Russell King 
CC: Catalin Marinas 
CC: Will Deacon 
CC: Thomas Gleixner 
CC: Paul Turner 
CC: Andrew Hunter 
CC: Peter Zijlstra 
CC: Andy Lutomirski 
CC: Andi Kleen 
CC: Dave Watson 
CC: Chris Lameter 
CC: Ingo Molnar 
CC: Ben Maurer 
CC: Steven Rostedt 
CC: "Paul E. McKenney" 
CC: Josh Triplett 
CC: Linus Torvalds 
CC: Andrew Morton 
CC: Boqun Feng 
CC: linux-...@vger.kernel.org
---
 arch/arm/Kconfig | 1 +
 arch/arm/kernel/signal.c | 7 +++
 2 files changed, 8 insertions(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a7f8e7f4b88f..4f5c386631d4 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -91,6 +91,7 @@ config ARM
select HAVE_PERF_USER_STACK_DUMP
select HAVE_RCU_TABLE_FREE if (SMP && ARM_LPAE)
select HAVE_REGS_AND_STACK_ACCESS_API
+   select HAVE_RSEQ
select HAVE_SYSCALL_TRACEPOINTS
select HAVE_UID16
select HAVE_VIRT_CPU_ACCOUNTING_GEN
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index bd8810d4acb3..5879ab3f53c1 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -541,6 +541,12 @@ static void handle_signal(struct ksignal *ksig, struct 
pt_regs *regs)
int ret;
 
/*
+* Increment event counter and perform fixup for the pre-signal
+* frame.
+*/
+   rseq_signal_deliver(regs);
+
+   /*
 * Set up the stack frame
 */
if (ksig->ka.sa.sa_flags & SA_SIGINFO)
@@ -660,6 +666,7 @@ do_work_pending(struct pt_regs *regs, unsigned int 
thread_flags, int syscall)
} else {
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
+   rseq_handle_notify_resume(regs);
}
}
local_irq_disable();
-- 
2.11.0



[RFC PATCH for 4.18 04/16] arm: Add syscall detection for restartable sequences

2018-06-02 Thread Mathieu Desnoyers
Syscalls are not allowed inside restartable sequences, so add a call to
rseq_syscall() at the very beginning of system call exiting path for
CONFIG_DEBUG_RSEQ=y kernel. This could help us to detect whether there
is a syscall issued inside restartable sequences.

Signed-off-by: Mathieu Desnoyers 
CC: Russell King 
CC: Catalin Marinas 
CC: Will Deacon 
CC: Thomas Gleixner 
CC: Paul Turner 
CC: Andrew Hunter 
CC: Peter Zijlstra 
CC: Andy Lutomirski 
CC: Andi Kleen 
CC: Dave Watson 
CC: Chris Lameter 
CC: Ingo Molnar 
CC: Ben Maurer 
CC: Steven Rostedt 
CC: "Paul E. McKenney" 
CC: Josh Triplett 
CC: Linus Torvalds 
CC: Andrew Morton 
CC: Boqun Feng 
CC: linux-...@vger.kernel.org
---
 arch/arm/kernel/entry-common.S | 25 +++--
 arch/arm/kernel/signal.c   |  7 +++
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 3c4f88701f22..b427ef8ec8c6 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -39,12 +39,13 @@ saved_pc.reqlr
 
.section .entry.text,"ax",%progbits
.align  5
-#if !(IS_ENABLED(CONFIG_TRACE_IRQFLAGS) || IS_ENABLED(CONFIG_CONTEXT_TRACKING))
+#if !(IS_ENABLED(CONFIG_TRACE_IRQFLAGS) || IS_ENABLED(CONFIG_CONTEXT_TRACKING) 
|| \
+   IS_ENABLED(CONFIG_DEBUG_RSEQ))
 /*
  * This is the fast syscall return path.  We do as little as possible here,
  * such as avoiding writing r0 to the stack.  We only use this path if we
- * have tracing and context tracking disabled - the overheads from those
- * features make this path too inefficient.
+ * have tracing, context tracking and rseq debug disabled - the overheads
+ * from those features make this path too inefficient.
  */
 ret_fast_syscall:
  UNWIND(.fnstart   )
@@ -71,14 +72,20 @@ fast_work_pending:
/* fall through to work_pending */
 #else
 /*
- * The "replacement" ret_fast_syscall for when tracing or context tracking
- * is enabled.  As we will need to call out to some C functions, we save
- * r0 first to avoid needing to save registers around each C function call.
+ * The "replacement" ret_fast_syscall for when tracing, context tracking,
+ * or rseq debug is enabled.  As we will need to call out to some C functions,
+ * we save r0 first to avoid needing to save registers around each C function
+ * call.
  */
 ret_fast_syscall:
  UNWIND(.fnstart   )
  UNWIND(.cantunwind)
str r0, [sp, #S_R0 + S_OFF]!@ save returned r0
+#if IS_ENABLED(CONFIG_DEBUG_RSEQ)
+   /* do_rseq_syscall needs interrupts enabled. */
+   mov r0, sp  @ 'regs'
+   bl  do_rseq_syscall
+#endif
disable_irq_notrace @ disable interrupts
ldr r2, [tsk, #TI_ADDR_LIMIT]
cmp r2, #TASK_SIZE
@@ -113,6 +120,12 @@ ENDPROC(ret_fast_syscall)
  */
 ENTRY(ret_to_user)
 ret_slow_syscall:
+#if IS_ENABLED(CONFIG_DEBUG_RSEQ)
+   /* do_rseq_syscall needs interrupts enabled. */
+   enable_irq_notrace  @ enable interrupts
+   mov r0, sp  @ 'regs'
+   bl  do_rseq_syscall
+#endif
disable_irq_notrace @ disable interrupts
 ENTRY(ret_to_user_from_irq)
ldr r2, [tsk, #TI_ADDR_LIMIT]
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index 5879ab3f53c1..f09e9d66d605 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -710,3 +710,10 @@ asmlinkage void addr_limit_check_failed(void)
 {
addr_limit_user_check();
 }
+
+#ifdef CONFIG_DEBUG_RSEQ
+asmlinkage void do_rseq_syscall(struct pt_regs *regs)
+{
+   rseq_syscall(regs);
+}
+#endif
-- 
2.11.0



[RFC PATCH for 4.18 00/16] Restartable Sequences

2018-06-02 Thread Mathieu Desnoyers
Hi,

Here is an updated RFC of the rseq patchset. It only includes rseq.
Further improvements are kept for later.

Compared to the previous version of this series, CONFIG_DEBUG_RSEQ=y now
ensures that system calls are not issued within a rseq critical section,
else the process is killed. This check, performed by rseq_syscall(), has
been wired up and tested on x86 32/64, arm 32, and powerpc 64. It has
only been wired up on powerpc 32 (still needs to be tested).

This enables speeding up the Facebook jemalloc and arm64 PMC read from
user-space use-cases, as well as speedup of use-cases relying on getting
the current cpu number from user-space. We'll have to wait until a more
complete solution is introduced before the LTTng-UST tracer can replace
its ring buffer atomic instructions with rseq though. But let's proceed
one step at a time.

The main change introduced by the removal of cpu_opv from this series
compared to the prior versions of this series in terms of library use
from user-space is that APIs that previously took a CPU number as
argument now only act on the current CPU.

So for instance, this turns:

  int cpu = rseq_per_cpu_lock(lock, target_cpu);
  [...]
  rseq_per_cpu_unlock(lock, cpu);

into

  int cpu = rseq_this_cpu_lock(lock);
  [...]
  rseq_per_cpu_unlock(lock, cpu);

and:

  per_cpu_list_push(list, node, target_cpu);
  [...]
  per_cpu_list_pop(list, node, target_cpu);

into

  this_cpu_list_push(list, node, &cpu);  /* cpu is an output parameter. */
  [...]
  node = this_cpu_list_pop(list, &cpu);  /* cpu is an output parameter. */

Eventually integrating cpu_opv or some alternative will allow passing
the cpu number as parameter rather than requiring the algorithm to work
on the current CPU.

The second effect of not having the cpu_opv fallback is that
line and instruction single-stepping with a debugger transforms rseq
critical sections based on retry loops into never-ending loops.
Debuggers need to use the __rseq_table section to skip those critical
sections in order to correctly behave when single-stepping a thread
which uses rseq in a retry loop. However, applications which use an
alternative fallback method rather than retrying on rseq fast-path abort
won't be affected by this kind of single-stepping issue.

Thanks for your feedback!

Mathieu

Boqun Feng (3):
  powerpc: Add support for restartable sequences
  powerpc: Add syscall detection for restartable sequences
  powerpc: Wire up restartable sequences system call

Mathieu Desnoyers (13):
  uapi headers: Provide types_32_64.h (v2)
  rseq: Introduce restartable sequences system call (v13)
  arm: Add restartable sequences support
  arm: Add syscall detection for restartable sequences
  arm: Wire up restartable sequences system call
  x86: Add support for restartable sequences (v2)
  x86: Wire up restartable sequence system call
  selftests: lib.mk: Introduce OVERRIDE_TARGETS
  rseq: selftests: Provide rseq library (v5)
  rseq: selftests: Provide basic test
  rseq: selftests: Provide basic percpu ops test (v2)
  rseq: selftests: Provide parametrized tests (v2)
  rseq: selftests: Provide Makefile, scripts, gitignore (v2)

 MAINTAINERS|   12 +
 arch/Kconfig   |7 +
 arch/arm/Kconfig   |1 +
 arch/arm/kernel/entry-common.S |   25 +-
 arch/arm/kernel/signal.c   |   14 +
 arch/arm/tools/syscall.tbl |1 +
 arch/powerpc/Kconfig   |1 +
 arch/powerpc/include/asm/systbl.h  |1 +
 arch/powerpc/include/asm/unistd.h  |2 +-
 arch/powerpc/include/uapi/asm/unistd.h |1 +
 arch/powerpc/kernel/entry_32.S |7 +
 arch/powerpc/kernel/entry_64.S |8 +
 arch/powerpc/kernel/signal.c   |3 +
 arch/x86/Kconfig   |1 +
 arch/x86/entry/common.c|3 +
 arch/x86/entry/syscalls/syscall_32.tbl |1 +
 arch/x86/entry/syscalls/syscall_64.tbl |1 +
 arch/x86/kernel/signal.c   |6 +
 fs/exec.c  |1 +
 include/linux/sched.h  |  134 +++
 include/linux/syscalls.h   |4 +-
 include/trace/events/rseq.h|   57 +
 include/uapi/linux/rseq.h  |  133 +++
 include/uapi/linux/types_32_64.h   |   50 +
 init/Kconfig   |   23 +
 kernel/Makefile|1 +
 kernel/fork.c  |2 +
 kernel/rseq.c  |  357 ++
 kernel/sched/core.c|2 +
 kernel/sys_ni.c|3 +
 tools/te

[RFC PATCH for 4.18 14/16] rseq: selftests: Provide basic percpu ops test (v2)

2018-06-02 Thread Mathieu Desnoyers
"basic_percpu_ops_test" is a slightly more "realistic" variant,
implementing a few simple per-cpu operations and testing their
correctness.

Signed-off-by: Mathieu Desnoyers 
CC: Shuah Khan 
CC: Russell King 
CC: Catalin Marinas 
CC: Will Deacon 
CC: Thomas Gleixner 
CC: Paul Turner 
CC: Andrew Hunter 
CC: Peter Zijlstra 
CC: Andy Lutomirski 
CC: Andi Kleen 
CC: Dave Watson 
CC: Chris Lameter 
CC: Ingo Molnar 
CC: "H. Peter Anvin" 
CC: Ben Maurer 
CC: Steven Rostedt 
CC: "Paul E. McKenney" 
CC: Josh Triplett 
CC: Linus Torvalds 
CC: Andrew Morton 
CC: Boqun Feng 
CC: linux-kselft...@vger.kernel.org
CC: linux-...@vger.kernel.org
---
Changes since v1:
- Use only rseq, remove use of cpu_opv system call.
---
 .../testing/selftests/rseq/basic_percpu_ops_test.c | 313 +
 1 file changed, 313 insertions(+)
 create mode 100644 tools/testing/selftests/rseq/basic_percpu_ops_test.c

diff --git a/tools/testing/selftests/rseq/basic_percpu_ops_test.c 
b/tools/testing/selftests/rseq/basic_percpu_ops_test.c
new file mode 100644
index ..96ef27905879
--- /dev/null
+++ b/tools/testing/selftests/rseq/basic_percpu_ops_test.c
@@ -0,0 +1,313 @@
+// SPDX-License-Identifier: LGPL-2.1
+#define _GNU_SOURCE
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "rseq.h"
+
+#define ARRAY_SIZE(arr)(sizeof(arr) / sizeof((arr)[0]))
+
+struct percpu_lock_entry {
+   intptr_t v;
+} __attribute__((aligned(128)));
+
+struct percpu_lock {
+   struct percpu_lock_entry c[CPU_SETSIZE];
+};
+
+struct test_data_entry {
+   intptr_t count;
+} __attribute__((aligned(128)));
+
+struct spinlock_test_data {
+   struct percpu_lock lock;
+   struct test_data_entry c[CPU_SETSIZE];
+   int reps;
+};
+
+struct percpu_list_node {
+   intptr_t data;
+   struct percpu_list_node *next;
+};
+
+struct percpu_list_entry {
+   struct percpu_list_node *head;
+} __attribute__((aligned(128)));
+
+struct percpu_list {
+   struct percpu_list_entry c[CPU_SETSIZE];
+};
+
+/* A simple percpu spinlock.  Returns the cpu lock was acquired on. */
+int rseq_this_cpu_lock(struct percpu_lock *lock)
+{
+   int cpu;
+
+   for (;;) {
+   int ret;
+
+   cpu = rseq_cpu_start();
+   ret = rseq_cmpeqv_storev(&lock->c[cpu].v,
+0, 1, cpu);
+   if (rseq_likely(!ret))
+   break;
+   /* Retry if comparison fails or rseq aborts. */
+   }
+   /*
+* Acquire semantic when taking lock after control dependency.
+* Matches rseq_smp_store_release().
+*/
+   rseq_smp_acquire__after_ctrl_dep();
+   return cpu;
+}
+
+void rseq_percpu_unlock(struct percpu_lock *lock, int cpu)
+{
+   assert(lock->c[cpu].v == 1);
+   /*
+* Release lock, with release semantic. Matches
+* rseq_smp_acquire__after_ctrl_dep().
+*/
+   rseq_smp_store_release(&lock->c[cpu].v, 0);
+}
+
+void *test_percpu_spinlock_thread(void *arg)
+{
+   struct spinlock_test_data *data = arg;
+   int i, cpu;
+
+   if (rseq_register_current_thread()) {
+   fprintf(stderr, "Error: rseq_register_current_thread(...) 
failed(%d): %s\n",
+   errno, strerror(errno));
+   abort();
+   }
+   for (i = 0; i < data->reps; i++) {
+   cpu = rseq_this_cpu_lock(&data->lock);
+   data->c[cpu].count++;
+   rseq_percpu_unlock(&data->lock, cpu);
+   }
+   if (rseq_unregister_current_thread()) {
+   fprintf(stderr, "Error: rseq_unregister_current_thread(...) 
failed(%d): %s\n",
+   errno, strerror(errno));
+   abort();
+   }
+
+   return NULL;
+}
+
+/*
+ * A simple test which implements a sharded counter using a per-cpu
+ * lock.  Obviously real applications might prefer to simply use a
+ * per-cpu increment; however, this is reasonable for a test and the
+ * lock can be extended to synchronize more complicated operations.
+ */
+void test_percpu_spinlock(void)
+{
+   const int num_threads = 200;
+   int i;
+   uint64_t sum;
+   pthread_t test_threads[num_threads];
+   struct spinlock_test_data data;
+
+   memset(&data, 0, sizeof(data));
+   data.reps = 5000;
+
+   for (i = 0; i < num_threads; i++)
+   pthread_create(&test_threads[i], NULL,
+  test_percpu_spinlock_thread, &data);
+
+   for (i = 0; i < num_threads; i++)
+   pthread_join(test_threads[i], NULL);
+
+   sum = 0;
+   for (i = 0; i < CPU_SETSIZE; i++)
+   sum += data.c[i].count;
+
+   assert(sum == (uint64_t)data.reps * num_threads);
+}
+
+void this_cpu_list_push(struct percpu_list *list,
+   struct percpu_list_node *node,
+   int *_cpu)
+{
+   int cpu;
+
+   for (;;) {
+  

[GIT PULL] tpmdd 4.17 fixes

2018-06-02 Thread Jarkko Sakkinen
The following changes since commit 424eaf910c329ab06ad03a527ef45dcf6a328f00:

  tpm: reduce polling time to usecs for even finer granularity (2018-05-18 
10:00:01 +0300)

are available in the Git repository at:

  git://git.infradead.org/users/jjs/linux-tpmdd.git tags/tpmdd-next-20180602

for you to fetch changes up to 3ab2011ea368ec3433ad49e1b9e1c7b70d2e65df:

  tpm: fix race condition in tpm_common_write() (2018-05-30 20:11:31 +0300)


tpmdd fixes for Linux 4.17


Tadeusz Struk (1):
  tpm: fix race condition in tpm_common_write()

 drivers/char/tpm/tpm-dev-common.c | 40 ++-
 drivers/char/tpm/tpm-dev.h|  2 +-
 2 files changed, 19 insertions(+), 23 deletions(-)


Re: [PATCH v3 4/4] seccomp: add support for passing fds via USER_NOTIF

2018-06-02 Thread Jann Horn
On Sat, Jun 2, 2018 at 2:58 PM Tycho Andersen  wrote:
> The idea here is that the userspace handler should be able to pass an fd
> back to the trapped task, for example so it can be returned from socket().
>
> I've proposed one API here, but I'm open to other options. In particular,
> this only lets you return an fd from a syscall, which may not be enough in
> all cases. For example, if an fd is written to an output parameter instead
> of returned, the current API can't handle this. Another case is that
> netlink takes as input fds sometimes (IFLA_NET_NS_FD, e.g.). If netlink
> ever decides to install an fd and output it, we wouldn't be able to handle
> this either.
>
> Still, the vast majority of interesting cases are covered by this API, so
> perhaps it is Enough.
>
> I've left it as a separate commit for two reasons:
>   * It illustrates the way in which we would grow struct seccomp_notif and
> struct seccomp_notif_resp without using netlink
>   * It shows just how little code is needed to accomplish this :)
[...]
> +   fd = get_unused_fd_flags(n.flags);

Here, you're using n.flags in a context where it will be tested
against O_CLOEXEC to determine whether the new fd should be
close-on-exec.

[...]
> +   /*
> +* This is a little hokey: we need a real fget() (i.e. not
> +* __fget_light(), which is what fdget does), but we also need
> +* the flags from strcut fd. So, we get it, put it, and get it
> +* again for real.
> +*/
> +   fd = fdget(resp.fd);
> +   knotif->flags = fd.flags;
> +   fdput(fd);
> +
> +   knotif->file = fget(resp.fd);
> +   if (!knotif->file) {
> +   ret = -EBADF;
> +   goto out;
> +   }

But here fd.flags contains the low 2 bits of the return value of
__fget_light, which are either 0 or FDPUT_FPUT (encoded as 1). This
flag states whether fdget() took a reference on the file, which is
mostly equivalent to "is the current process multithreaded?". (This is
the reason why fdget returns flags and fget doesn't - the flag from
fdget is to decide whether you'll need an fput(), which is
unconditional for fget().)

Apart from this issue, I think that in general, it's probably not a
good idea to copy the close-on-exec flag from the fd in the
supervising process - the supervising process might want all the fds
it is working with to be O_CLOEXEC independent of whether the
supervised process wants an O_CLOEXEC fd. It might make sense to add a
field for this to struct seccomp_notif_resp instead.


Re: [PATCH] Make elf2ecoff work on 64bit host machines

2018-06-02 Thread Thomas Bogendoerfer
On Thu, 31 May 2018 17:03:11 -0700
Paul Burton  wrote:


> Perhaps we should #include  before making use of the types it
> provides?

good point, will send a new version.

> > @@ -518,7 +518,7 @@ int main(int argc, char *argv[])
> >  
> > for (i = 0; i < nosecs; i++) {
> > printf
> > -   ("Section %d: %s phys %lx  size %lx  file offset 
> > %lx\n",
> > +   ("Section %d: %s phys %x  size %xfile offset 
> > %x\n",
> 
> Maybe #include , then use PRIx32 & co here & below?

I'll have look.

Thomas.


Re: [PATCH 1/2] clk: imx6ul: add GPIO clock gates

2018-06-02 Thread Fabio Estevam
Hi Stefan,

On Tue, May 22, 2018 at 9:25 AM, Stefan Wahren  wrote:

>> --- a/include/dt-bindings/clock/imx6ul-clock.h
>> +++ b/include/dt-bindings/clock/imx6ul-clock.h
>> @@ -242,20 +242,25 @@
>>  #define IMX6UL_CLK_CKO2_PODF 229
>>  #define IMX6UL_CLK_CKO2  230
>>  #define IMX6UL_CLK_CKO   231
>> +#define IMX6UL_CLK_GPIO1 232
>> +#define IMX6UL_CLK_GPIO2 233
>> +#define IMX6UL_CLK_GPIO3 234
>> +#define IMX6UL_CLK_GPIO4 235
>> +#define IMX6UL_CLK_GPIO5 236
>
> this change looks like a breakage of devicetree ABI. You are changing the 
> mean of the existing clock IDs on i.MX6ULL, which probably regress the 
> combination of older DTBs with newer kernel.

Good point! I will send a fix for f5a4670de96678 ("clk: imx: Add new
clo01 and clo2 controlled
by CCOSR") which did the same reordering.

Thanks


Re: [PATCH 1/2] clk: imx6ul: add GPIO clock gates

2018-06-02 Thread Michael Nazzareno Trimarchi
Hi

On Sat, Jun 2, 2018 at 3:48 PM, Fabio Estevam  wrote:
> Hi Stefan,
>
> On Tue, May 22, 2018 at 9:25 AM, Stefan Wahren  wrote:
>
>>> --- a/include/dt-bindings/clock/imx6ul-clock.h
>>> +++ b/include/dt-bindings/clock/imx6ul-clock.h
>>> @@ -242,20 +242,25 @@
>>>  #define IMX6UL_CLK_CKO2_PODF 229
>>>  #define IMX6UL_CLK_CKO2  230
>>>  #define IMX6UL_CLK_CKO   231
>>> +#define IMX6UL_CLK_GPIO1 232
>>> +#define IMX6UL_CLK_GPIO2 233
>>> +#define IMX6UL_CLK_GPIO3 234
>>> +#define IMX6UL_CLK_GPIO4 235
>>> +#define IMX6UL_CLK_GPIO5 236
>>
>> this change looks like a breakage of devicetree ABI. You are changing the 
>> mean of the existing clock IDs on i.MX6ULL, which probably regress the 
>> combination of older DTBs with newer kernel.
>
> Good point! I will send a fix for f5a4670de96678 ("clk: imx: Add new
> clo01 and clo2 controlled
> by CCOSR") which did the same reordering.
>

ull is a preatty new platform so one board was listed. Are you sure
that we need?

Michael

> Thanks



-- 
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO  -  Founder  Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
|  [`as] http://www.amarulasolutions.com   |


Re: [PATCH 1/2] clk: imx6ul: add GPIO clock gates

2018-06-02 Thread Fabio Estevam
Hi Michael,

On Sat, Jun 2, 2018 at 11:04 AM, Michael Nazzareno Trimarchi
 wrote:

> ull is a preatty new platform so one board was listed. Are you sure
> that we need?

There are several imx6ul based dts in mainline and it is better if we
can avoid dtb breakage when possible.

In this case we can avoid the dtb breakage by adding the new clock
definitions at the end of the file, just like we do for all the other
imx devices.


Re: [RESEND] [PATCH] platform/x86: dell-wmi: Ignore new rfkill and fn-lock events

2018-06-02 Thread Andy Shevchenko
On Fri, Jun 1, 2018 at 7:47 PM, Darren Hart  wrote:
> On Fri, Jun 01, 2018 at 11:20:39AM +0300, Andy Shevchenko wrote:
>> On Fri, Jun 1, 2018 at 6:23 AM, Kai-Heng Feng
>>  wrote:

>> Pushed to my review and testing queue, thanks!
>>
>> P.S. There are some patches under Darren's queue, but for some reason
>> didn't processed yet.
>
> Thanks for getting this one Andy. I'm traveling, but am working through these
> currently. I'll assume you are handling this one.

Correct.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 1/2] clk: imx6ul: add GPIO clock gates

2018-06-02 Thread Michael Nazzareno Trimarchi
Hi Fabio

On Sat, Jun 2, 2018 at 4:07 PM, Fabio Estevam  wrote:
> Hi Michael,
>
> On Sat, Jun 2, 2018 at 11:04 AM, Michael Nazzareno Trimarchi
>  wrote:
>
>> ull is a preatty new platform so one board was listed. Are you sure
>> that we need?
>
> There are several imx6ul based dts in mainline and it is better if we
> can avoid dtb breakage when possible.
>
> In this case we can avoid the dtb breakage by adding the new clock
> definitions at the end of the file, just like we do for all the other
> imx devices.

Yes, when I add new ul clock I move down ull (that is new), but agree
that this is not possible in general.

Michael


[PATCH] DMA: OMAP: fix OMAP1510 incorrect residue_granularity

2018-06-02 Thread Janusz Krzysztofik
Commit 0198d7bb8a0c ("ASoC: omap-mcbsp: Convert to use the sdma-pcm
instead of omap-pcm") resulted in broken audio playback on OMAP1510
(discovered on Amstrad Delta).

When running on OMAP1510, omap-pcm used to obtain DMA offset from
snd_dmaengine_pcm_pointer_no_residue() based on DMA interrupt triggered
software calculations instead of snd_dmaengine_pcm_pointer() which
depended on residue value calculated from omap_dma_get_src_pos().
Similar code path is still available in now used
sound/soc/soc-generic-dmaengine-pcm.c but it is not triggered.

It was verified already before that omap_get_dma_src_pos() from
arch/arm/plat-omap/dma.c didn't work correctly for OMAP1510 - see
commit 1bdd7419910c ("ASoC: OMAP: fix OMAP1510 broken PCM pointer
callback") for details.  Apparently the same applies to its successor,
omap_dma_get_src_pos() from drivers/dma/omap-dma.c.

On the other hand, snd_dmaengine_pcm_pointer_no_residue() is described
as depreciated and discouraged for use in new drivers because of its
unreliable accuracy.  However, it seems the only working option for
OPAM1510 now, as long as a software calculated residue is not
implemented as OMAP1510 fallback in omap-dma.

Using snd_dmaengine_pcm_pointer_no_residue() code path instead of
snd_dmaengine_pcm_pointer() in sound/soc/soc-generic-dmaengine-pcm.c
can be triggered in two ways:
- by passing pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE from
  sound/soc/omap/sdma-pcm.c,
- by passing dma_caps.residue_granularity =
  DMA_RESIDUE_GRANULARITY_DESCRIPTOR from drivers/dma/omap-dma.c.

Let's do the latter.

Created and tested against next-20180531 tag from linux-next tree.

Signed-off-by: Janusz Krzysztofik 
---
 drivers/dma/omap-dma.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index d21c19822feb..56399bd45179 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -1485,7 +1485,11 @@ static int omap_dma_probe(struct platform_device *pdev)
od->ddev.src_addr_widths = OMAP_DMA_BUSWIDTHS;
od->ddev.dst_addr_widths = OMAP_DMA_BUSWIDTHS;
od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
-   od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
+   if (__dma_omap15xx(od->plat->dma_attr))
+   od->ddev.residue_granularity =
+   DMA_RESIDUE_GRANULARITY_DESCRIPTOR;
+   else
+   od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
od->ddev.max_burst = SZ_16M - 1; /* CCEN: 24bit unsigned */
od->ddev.dev = &pdev->dev;
INIT_LIST_HEAD(&od->ddev.channels);
-- 
2.16.1



[PATCH v2 0/5] staging: mt7621-spi: Fix Coding style issues.

2018-06-02 Thread Sankalp Negi
This patch series lists different changes for coding style fixes
as reported by checkpatch.pl, changes can be broken down as :

1. Indent switch and case labels at the same level
2. Fix a line over 80 columns
3. Place tabs for indentation instead of spaces
4. Add a space before open paranthesis in switch 
5. Remove unnecessary braces {} from single statement if

version 2 changes
- segregated changes in individual commits as per fix category

Sankalp Negi (5):
  staging: mt7621-spi: Fix Coding style issues reported by
checkpatch.pl.
  staging: mt7621-spi: Fix Coding style issues reported by
checkpatch.pl.
  staging: mt7621-spi: Fix Coding style issues reported by
checkpatch.pl.
  staging: mt7621-spi: Fix Coding style issues reported by
checkpatch.pl.
  staging: mt7621-spi: Fix Coding style issues reported by
checkpatch.pl.

 drivers/staging/mt7621-spi/spi-mt7621.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

-- 
2.11.0



[PATCH v2 1/5] staging: mt7621-spi: Fix Coding style issues reported by checkpatch.pl.

2018-06-02 Thread Sankalp Negi
The patch fixes following checkpatch.pl issue:
ERROR : switch and case should be at the same indent

Signed-off-by: Sankalp Negi 
---
 drivers/staging/mt7621-spi/spi-mt7621.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c 
b/drivers/staging/mt7621-spi/spi-mt7621.c
index 37f299080410..b268084b6cd1 100644
--- a/drivers/staging/mt7621-spi/spi-mt7621.c
+++ b/drivers/staging/mt7621-spi/spi-mt7621.c
@@ -138,17 +138,17 @@ static int mt7621_spi_prepare(struct spi_device *spi, 
unsigned int speed)
 
reg &= ~(MT7621_CPHA | MT7621_CPOL);
switch(spi->mode & (SPI_CPOL | SPI_CPHA)) {
-   case SPI_MODE_0:
-   break;
-   case SPI_MODE_1:
-   reg |= MT7621_CPHA;
-   break;
-   case SPI_MODE_2:
-   reg |= MT7621_CPOL;
-   break;
-   case SPI_MODE_3:
-   reg |= MT7621_CPOL | MT7621_CPHA;
-   break;
+   case SPI_MODE_0:
+   break;
+   case SPI_MODE_1:
+   reg |= MT7621_CPHA;
+   break;
+   case SPI_MODE_2:
+   reg |= MT7621_CPOL;
+   break;
+   case SPI_MODE_3:
+   reg |= MT7621_CPOL | MT7621_CPHA;
+   break;
}
mt7621_spi_write(rs, MT7621_SPI_MASTER, reg);
 
-- 
2.11.0



[PATCH v2 5/5] staging: mt7621-spi: Fix Coding style issues reported by checkpatch.pl.

2018-06-02 Thread Sankalp Negi
The patch fixes following checkpatch.pl issue:
WARNING : braces {} are not necessary for single statement blocks

Signed-off-by: Sankalp Negi 
---
 drivers/staging/mt7621-spi/spi-mt7621.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c 
b/drivers/staging/mt7621-spi/spi-mt7621.c
index 472f72479162..cf5b5d7c3cf9 100644
--- a/drivers/staging/mt7621-spi/spi-mt7621.c
+++ b/drivers/staging/mt7621-spi/spi-mt7621.c
@@ -165,9 +165,8 @@ static inline int mt7621_spi_wait_till_ready(struct 
spi_device *spi)
u32 status;
 
status = mt7621_spi_read(rs, MT7621_SPI_TRANS);
-   if ((status & SPITRANS_BUSY) == 0) {
+   if ((status & SPITRANS_BUSY) == 0)
return 0;
-   }
cpu_relax();
udelay(1);
}
-- 
2.11.0



[PATCH v2 4/5] staging: mt7621-spi: Fix Coding style issues reported by checkpatch.pl.

2018-06-02 Thread Sankalp Negi
The patch fixes following checkpatch.pl issue:
ERROR : space required before the open parenthesis

Signed-off-by: Sankalp Negi 
---
 drivers/staging/mt7621-spi/spi-mt7621.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c 
b/drivers/staging/mt7621-spi/spi-mt7621.c
index f7620a988a08..472f72479162 100644
--- a/drivers/staging/mt7621-spi/spi-mt7621.c
+++ b/drivers/staging/mt7621-spi/spi-mt7621.c
@@ -138,7 +138,7 @@ static int mt7621_spi_prepare(struct spi_device *spi, 
unsigned int speed)
reg |= MT7621_LSB_FIRST;
 
reg &= ~(MT7621_CPHA | MT7621_CPOL);
-   switch(spi->mode & (SPI_CPOL | SPI_CPHA)) {
+   switch (spi->mode & (SPI_CPOL | SPI_CPHA)) {
case SPI_MODE_0:
break;
case SPI_MODE_1:
-- 
2.11.0



[PATCH v2 3/5] staging: mt7621-spi: Fix Coding style issues reported by checkpatch.pl.

2018-06-02 Thread Sankalp Negi
The patch fixes following checkpatch.pl issue:
ERROR : code indent should use tabs where possible

Signed-off-by: Sankalp Negi 
---
 drivers/staging/mt7621-spi/spi-mt7621.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c 
b/drivers/staging/mt7621-spi/spi-mt7621.c
index 910dbdb8a003..f7620a988a08 100644
--- a/drivers/staging/mt7621-spi/spi-mt7621.c
+++ b/drivers/staging/mt7621-spi/spi-mt7621.c
@@ -105,7 +105,7 @@ static void mt7621_spi_set_cs(struct spi_device *spi, int 
enable)
int cs = spi->chip_select;
u32 polar = 0;
 
-mt7621_spi_reset(rs, cs);
+   mt7621_spi_reset(rs, cs);
if (enable)
polar = BIT(cs);
mt7621_spi_write(rs, MT7621_SPI_POLAR, polar);
-- 
2.11.0



[PATCH v2 2/5] staging: mt7621-spi: Fix Coding style issues reported by checkpatch.pl.

2018-06-02 Thread Sankalp Negi
The patch fixes following checkpatch.pl issue:
WARNING : line over 80 characters

Signed-off-by: Sankalp Negi 
---
 drivers/staging/mt7621-spi/spi-mt7621.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c 
b/drivers/staging/mt7621-spi/spi-mt7621.c
index b268084b6cd1..910dbdb8a003 100644
--- a/drivers/staging/mt7621-spi/spi-mt7621.c
+++ b/drivers/staging/mt7621-spi/spi-mt7621.c
@@ -55,7 +55,8 @@
 #define MT7621_CPOLBIT(4)
 #define MT7621_LSB_FIRST   BIT(3)
 
-#define RT2880_SPI_MODE_BITS   (SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST | 
SPI_CS_HIGH)
+#define RT2880_SPI_MODE_BITS   (SPI_CPOL | SPI_CPHA |  \
+SPI_LSB_FIRST | SPI_CS_HIGH)
 
 struct mt7621_spi;
 
-- 
2.11.0



Re: [PATCH] clk: Return void from debug_init op

2018-06-02 Thread David Lechner

On 06/02/2018 12:06 AM, sb...@kernel.org wrote:

From: Stephen Boyd 

We only have two users of the debug_init hook, and we recently stopped
caring about the return value from that op. Finish that off by changing
the clk_op to return void instead of int because it doesn't matter if
debugfs fails or not.

Cc: Eric Anholt 
Cc: David Lechner 
Cc: Sekhar Nori 
Cc: Greg Kroah-Hartman 
Signed-off-by: Stephen Boyd 
---


Acked-by: David Lechner 



Re: [PATCH] clk: davinci: cfgchip: testing the wrong variable

2018-06-02 Thread David Lechner

On 06/02/2018 02:52 AM, Dan Carpenter wrote:

There is a copy and paste bug here.  We should be testing "usb1" instead
of "usb0".

Fixes: 58e1e2d2cd89 ("clk: davinci: cfgchip: Add TI DA8XX USB PHY clocks")
Signed-off-by: Dan Carpenter 

diff --git a/drivers/clk/davinci/da8xx-cfgchip.c 
b/drivers/clk/davinci/da8xx-cfgchip.c
index c97d2601..20a120aa147e 100644
--- a/drivers/clk/davinci/da8xx-cfgchip.c
+++ b/drivers/clk/davinci/da8xx-cfgchip.c
@@ -672,7 +672,7 @@ static int of_da8xx_usb_phy_clk_init(struct device *dev, 
struct regmap *regmap)
  
  	usb1 = da8xx_cfgchip_register_usb1_clk48(dev, regmap);

if (IS_ERR(usb1)) {
-   if (PTR_ERR(usb0) == -EPROBE_DEFER)
+   if (PTR_ERR(usb1) == -EPROBE_DEFER)
return -EPROBE_DEFER;
  
  		dev_warn(dev, "Failed to register usb1_clk48 (%ld)\n",




Reviewed-by: David Lechner 



Re: [PATCH] DMA: OMAP: fix OMAP1510 incorrect residue_granularity

2018-06-02 Thread Janusz Krzysztofik
On Saturday, June 2, 2018 4:22:04 PM CEST Janusz Krzysztofik wrote:
> - by passing dma_caps.residue_granularity =
>   DMA_RESIDUE_GRANULARITY_DESCRIPTOR from drivers/dma/omap-dma.c.
> 
> Let's do the latter.
> 
> Created and tested against next-20180531 tag from linux-next tree.

I'm sorry, I missed 'git bisect reset' before testing the patch, it seems 
drivers/dma/omap-dma.c disappeared from next-20180531. I'll rework it and send 
again.

Thanks,
Janusz





Re: LKMM litmus test for Roman Penyaev's rcu-rr

2018-06-02 Thread Paul E. McKenney
On Thu, May 31, 2018 at 10:27:33AM -0400, Alan Stern wrote:
> On Wed, 30 May 2018, Paul E. McKenney wrote:
> 
> > On Wed, May 30, 2018 at 05:01:01PM -0500, Linus Torvalds wrote:
> > > On Wed, May 30, 2018 at 2:08 PM Alan Stern  
> > > wrote:
> > > >
> > > > Indeed.  The very first line Linus quoted in his first reply to me
> > > > (elided above) was:
> > > >
> > > > Putting this into herd would be extremely difficult, if not 
> > > > impossible,
> > > > because it involves analyzing code that was not executed.
> > > >
> > > > It should be clear from this that I was talking about herd.  Not gcc or
> > > > real hardware.
> > > 
> > > So what does herd actually work on? The source code or the executable,
> > > or a trace?
> > 
> > The source code, that is, the source code of the litmus test.
> > There are definitions for the various Linux operations, partly within
> > the herd tool and partly in the linux.def file in tools/memory-model.
> > The problem we are having is nailing down control dependencies and
> > compiler optimizations.  The bit about limiting control dependencies
> > through the end of "if" statement itself works well in a great many cases,
> > but this clearly is not one of them.
> > 
> > > I found the herd paper, but I'm on the road helping my daughter in
> > > college move, and I don't have the background to skim the paper
> > > quickly and come up with the obvious answer, so I'l just ask.
> > 
> > It is not a short learning curve.
> > 
> > > Because I really think that from our memory model standpoint, we
> > > really do have the rule that
> > > 
> > >load -> cond -> store
> > > 
> > > is ordered - even if the store address and store data is in no way
> > > dependent on the load. The only thing that matters is that there's a
> > > conditional that is dependent on the load in between the load and the
> > > store.
> 
> This is true for all the architectures supported by the Linux kernel.  
> However, in the future it might not always hold.  I can imagine that
> CPU designers would want to include an optimization that checks a
> conditional branch to see if it skips over only the following
> instruction (and the following instruction can't affect the flow of
> control); in that situation, they might decide there doesn't need to be
> a control dependency to future stores.  Such an optimization would not
> violate the C11 memory model.
> 
> Of course, this is purely theoretical.  And if anybody does decide to
> try doing that, the memory-model people might scream at them so hard
> they change their minds.  :-)
> 
> ...
> 
> > > But I don't know what level 'herd' works on. If it doesn't see
> > > compiler barriers (eg our own "barrier()" macro that literally is just
> > > that), only sees the generated code, then it really has no other
> > > information than what he compiler _happened_ to do - it doesn't know
> > > if the compiler did the store after the conditional because it *had*
> > > to do so, or whether it was just a random instruction scheduling
> > > decision.
> > 
> > The 'herd' tool works on litmus-test source, and has almost no idea of
> > what compilers get up to.  In this particular case, it would be better
> > off being even more ignorant of what compilers get up to.  ;-)
> 
> In more detail, herd analyzes the source code and constructs a set of
> all possible candidate executions.  herd then checks each execution to
> see if it violates the rules of the memory model as expressed in the
> .bell and .cat files.  If any of the non-violating executions satisfies
> the litmus test's final "exists" condition, herd reports that the test
> is allowed.
> 
> The point here is that when herd checks any one particular execution, 
> it pays attention _only_ to the statements which are part of that 
> execution.  Statements belonging to an untaken "if" branch are ignored 
> completely.  That's why I think it would be difficult to make herd do 
> exactly what we want in this case.

One crude but effective workaround is to replicate the code following the
"if" statement into both legs of the "if" statement.  This has the effect
of extending the control dependency to cover all of the code that used to
follow the "if" statement, leveraging herd's current limited knowledge of
compiler optimization.  This workaround would of course be hopeless for
general Linux-kernel code, but should be at least semi-acceptable for the
very small snippets of code that can be accommodated within litmus tests.

Please see the litmus test shown below, which uses this workaround,
allowing the smp_store_release() to be downgraded to WRITE_ONCE().

Given this workaround, crude though it might be, I believe that we can
take a more measured approach to identifying a longer-term solution.

Thoughts?

Thanx, Paul



--

Re: [PATCH] mm: Change return type to vm_fault_t

2018-06-02 Thread Souptick Joarder
On Wed, May 30, 2018 at 4:46 PM, Matthew Wilcox  wrote:
> On Wed, May 30, 2018 at 09:10:47AM +0530, Souptick Joarder wrote:
>> On Tue, May 29, 2018 at 11:04 PM, Matthew Wilcox  wrote:
>> > I see:
>> >
>> > mm/gup.c:817:15: warning: invalid assignment: |=
>> > mm/gup.c:817:15:left side has type int
>> > mm/gup.c:817:15:right side has type restricted vm_fault_t
>> >
>> > are you building with 'c=2' or 'C=2'?
>>
>> Building with C=2.
>> Do I need to enable any separate FLAG ?
>
> Nope.  Here's what I have:
>
> willy@bobo:~/kernel/souptick$ make C=2 mm/gup.o
>   CHK include/config/kernel.release
>   CHK include/generated/uapi/linux/version.h
>   CHK include/generated/utsrelease.h
>   CHECK   arch/x86/purgatory/purgatory.c
>   CHECK   arch/x86/purgatory/sha256.c
>   CHECK   arch/x86/purgatory/string.c
> arch/x86/purgatory/../boot/string.c:134:6: warning: symbol 'simple_strtol' 
> was not declared. Should it be static?
>   CHK include/generated/bounds.h
>   CHK include/generated/timeconst.h
>   CHK include/generated/asm-offsets.h
>   CALLscripts/checksyscalls.sh
>   DESCEND  objtool
>   CHECK   scripts/mod/empty.c
>   CHK scripts/mod/devicetable-offsets.h
>   CHECK   mm/gup.c
> mm/gup.c:817:15: warning: invalid assignment: |=
> mm/gup.c:817:15:left side has type int
> mm/gup.c:817:15:right side has type restricted vm_fault_t
>   CC  mm/gup.o
>

Matthew,

Due to some unidentified error still not able to catch this warning
in (X86_64 + sparse) compilation. It is constantly showing below error.

Documents/linux-4.17-rc7$ make C=2 -j4 mm/gup.o
  CHK include/config/kernel.release
  CHK include/generated/uapi/linux/version.h
  DESCEND  objtool
  CHK include/generated/utsrelease.h
  CHECK   scripts/mod/empty.c
  CHK scripts/mod/devicetable-offsets.h
  CHK include/generated/bounds.h
  CHK include/generated/timeconst.h
  CHK include/generated/asm-offsets.h
  CALLscripts/checksyscalls.sh
  CHECK   mm/gup.c
mm/gup.c:394:17: error: undefined identifier '__COUNTER__'
mm/gup.c:439:9: error: undefined identifier '__COUNTER__'
mm/gup.c:441:9: error: undefined identifier '__COUNTER__'
mm/gup.c:443:9: error: undefined identifier '__COUNTER__'
mm/gup.c:508:17: error: undefined identifier '__COUNTER__'
mm/gup.c:716:25: error: undefined identifier '__COUNTER__'
mm/gup.c:826:17: error: undefined identifier '__COUNTER__'
mm/gup.c:863:17: error: undefined identifier '__COUNTER__'
mm/gup.c:865:17: error: undefined identifier '__COUNTER__'
mm/gup.c:882:25: error: undefined identifier '__COUNTER__'
mm/gup.c:883:25: error: undefined identifier '__COUNTER__'
mm/gup.c:920:25: error: undefined identifier '__COUNTER__'
./include/linux/hugetlb.h:239:9: error: undefined identifier '__COUNTER__'


But able to capture it in (powerpc + sparse) compilation.
I will fix it in v2.

/Documents/linux-4.17-rc7$ make C=2 ARCH=powerpc
CROSS_COMPILE=powerpc-linux-gnu- mm/gup.o
  CHK include/config/kernel.release
  CHK include/generated/uapi/linux/version.h
  CHK include/generated/utsrelease.h
  CHK include/generated/bounds.h
  CHK include/generated/timeconst.h
  CHK include/generated/asm-offsets.h
  CALLscripts/checksyscalls.sh
  CHECK   scripts/mod/empty.c
  CHK scripts/mod/devicetable-offsets.h
  CHECK   mm/gup.c
./arch/powerpc/include/asm/book3s/64/pgtable.h:669:24: warning:
restricted __be64 degrades to integer
mm/gup.c:820:15: warning: incorrect type in assignment (different base types)
mm/gup.c:820:15:expected int [signed] major
mm/gup.c:820:15:got restricted vm_fault_t
mm/gup.c:1247:24: warning: expression using sizeof bool
mm/gup.c:1247:24: warning: expression using sizeof(void)
mm/gup.c:1247:24: warning: expression using sizeof(void)
./arch/powerpc/include/asm/book3s/64/pgtable.h:667:20: warning:
incorrect type in initializer (different base types)
./arch/powerpc/include/asm/book3s/64/pgtable.h:667:20:expected
unsigned long long [unsigned] [usertype] mask
./arch/powerpc/include/asm/book3s/64/pgtable.h:667:20:got
restricted __be64 [usertype] 
mm/gup.c:1735:6: warning: symbol 'gup_fast_permitted' was not
declared. Should it be static?
  CC  mm/gup.o


Sparse is throwing below warning ->

/Documents/linux-4.17-rc7$ make C=2 ARCH=powerpc
CROSS_COMPILE=powerpc-linux-gnu- mm/hugetlb.o
  CHK include/config/kernel.release
  CHK include/generated/uapi/linux/version.h
  CHK include/generated/utsrelease.h
  CHK include/generated/bounds.h
  CHK include/generated/timeconst.h
  CHK include/generated/asm-offsets.h
  CALLscripts/checksyscalls.sh
  CHECK   scripts/mod/empty.c
  CHK scripts/mod/devicetable-offsets.h
  CHECK   mm/hugetlb.c
mm/hugetlb.c:3778:33: warning: restricted vm_fault_t degrades to integer
mm/hugetlb.c:3777:31: warning: restricted vm_fault_t degrades to integer
mm/hugetlb.c:3777:29: warning: incorrect type in assignment (different
base types)
mm/hugetlb.c:3777:29:expected restr

Re: [PATCH] mm: Change return type to vm_fault_t

2018-06-02 Thread Souptick Joarder
Please ignoe this mail. I send it by mistake.

On Sat, Jun 2, 2018 at 8:14 PM, Souptick Joarder  wrote:
> On Wed, May 30, 2018 at 4:46 PM, Matthew Wilcox  wrote:
>> On Wed, May 30, 2018 at 09:10:47AM +0530, Souptick Joarder wrote:
>>> On Tue, May 29, 2018 at 11:04 PM, Matthew Wilcox  
>>> wrote:
>>> > I see:
>>> >
>>> > mm/gup.c:817:15: warning: invalid assignment: |=
>>> > mm/gup.c:817:15:left side has type int
>>> > mm/gup.c:817:15:right side has type restricted vm_fault_t
>>> >
>>> > are you building with 'c=2' or 'C=2'?
>>>
>>> Building with C=2.
>>> Do I need to enable any separate FLAG ?
>>
>> Nope.  Here's what I have:
>>
>> willy@bobo:~/kernel/souptick$ make C=2 mm/gup.o
>>   CHK include/config/kernel.release
>>   CHK include/generated/uapi/linux/version.h
>>   CHK include/generated/utsrelease.h
>>   CHECK   arch/x86/purgatory/purgatory.c
>>   CHECK   arch/x86/purgatory/sha256.c
>>   CHECK   arch/x86/purgatory/string.c
>> arch/x86/purgatory/../boot/string.c:134:6: warning: symbol 'simple_strtol' 
>> was not declared. Should it be static?
>>   CHK include/generated/bounds.h
>>   CHK include/generated/timeconst.h
>>   CHK include/generated/asm-offsets.h
>>   CALLscripts/checksyscalls.sh
>>   DESCEND  objtool
>>   CHECK   scripts/mod/empty.c
>>   CHK scripts/mod/devicetable-offsets.h
>>   CHECK   mm/gup.c
>> mm/gup.c:817:15: warning: invalid assignment: |=
>> mm/gup.c:817:15:left side has type int
>> mm/gup.c:817:15:right side has type restricted vm_fault_t
>>   CC  mm/gup.o
>>
>
> Matthew,
>
> Due to some unidentified error still not able to catch this warning
> in (X86_64 + sparse) compilation. It is constantly showing below error.
>
> Documents/linux-4.17-rc7$ make C=2 -j4 mm/gup.o
>   CHK include/config/kernel.release
>   CHK include/generated/uapi/linux/version.h
>   DESCEND  objtool
>   CHK include/generated/utsrelease.h
>   CHECK   scripts/mod/empty.c
>   CHK scripts/mod/devicetable-offsets.h
>   CHK include/generated/bounds.h
>   CHK include/generated/timeconst.h
>   CHK include/generated/asm-offsets.h
>   CALLscripts/checksyscalls.sh
>   CHECK   mm/gup.c
> mm/gup.c:394:17: error: undefined identifier '__COUNTER__'
> mm/gup.c:439:9: error: undefined identifier '__COUNTER__'
> mm/gup.c:441:9: error: undefined identifier '__COUNTER__'
> mm/gup.c:443:9: error: undefined identifier '__COUNTER__'
> mm/gup.c:508:17: error: undefined identifier '__COUNTER__'
> mm/gup.c:716:25: error: undefined identifier '__COUNTER__'
> mm/gup.c:826:17: error: undefined identifier '__COUNTER__'
> mm/gup.c:863:17: error: undefined identifier '__COUNTER__'
> mm/gup.c:865:17: error: undefined identifier '__COUNTER__'
> mm/gup.c:882:25: error: undefined identifier '__COUNTER__'
> mm/gup.c:883:25: error: undefined identifier '__COUNTER__'
> mm/gup.c:920:25: error: undefined identifier '__COUNTER__'
> ./include/linux/hugetlb.h:239:9: error: undefined identifier '__COUNTER__'
>
>
> But able to capture it in (powerpc + sparse) compilation.
> I will fix it in v2.
>
> /Documents/linux-4.17-rc7$ make C=2 ARCH=powerpc
> CROSS_COMPILE=powerpc-linux-gnu- mm/gup.o
>   CHK include/config/kernel.release
>   CHK include/generated/uapi/linux/version.h
>   CHK include/generated/utsrelease.h
>   CHK include/generated/bounds.h
>   CHK include/generated/timeconst.h
>   CHK include/generated/asm-offsets.h
>   CALLscripts/checksyscalls.sh
>   CHECK   scripts/mod/empty.c
>   CHK scripts/mod/devicetable-offsets.h
>   CHECK   mm/gup.c
> ./arch/powerpc/include/asm/book3s/64/pgtable.h:669:24: warning:
> restricted __be64 degrades to integer
> mm/gup.c:820:15: warning: incorrect type in assignment (different base types)
> mm/gup.c:820:15:expected int [signed] major
> mm/gup.c:820:15:got restricted vm_fault_t
> mm/gup.c:1247:24: warning: expression using sizeof bool
> mm/gup.c:1247:24: warning: expression using sizeof(void)
> mm/gup.c:1247:24: warning: expression using sizeof(void)
> ./arch/powerpc/include/asm/book3s/64/pgtable.h:667:20: warning:
> incorrect type in initializer (different base types)
> ./arch/powerpc/include/asm/book3s/64/pgtable.h:667:20:expected
> unsigned long long [unsigned] [usertype] mask
> ./arch/powerpc/include/asm/book3s/64/pgtable.h:667:20:got
> restricted __be64 [usertype] 
> mm/gup.c:1735:6: warning: symbol 'gup_fast_permitted' was not
> declared. Should it be static?
>   CC  mm/gup.o
>
>
> Sparse is throwing below warning ->
>
> /Documents/linux-4.17-rc7$ make C=2 ARCH=powerpc
> CROSS_COMPILE=powerpc-linux-gnu- mm/hugetlb.o
>   CHK include/config/kernel.release
>   CHK include/generated/uapi/linux/version.h
>   CHK include/generated/utsrelease.h
>   CHK include/generated/bounds.h
>   CHK include/generated/timeconst.h
>   CHK include/generated/asm-offsets.h
>   CALLscripts/checksyscalls.sh
>   CHECK   scripts/mod/empty.c
>   CHK scripts/mod/devicetable-of

Re: [PATCH] mm: Change return type to vm_fault_t

2018-06-02 Thread Souptick Joarder
On Wed, May 30, 2018 at 4:46 PM, Matthew Wilcox  wrote:
> On Wed, May 30, 2018 at 09:10:47AM +0530, Souptick Joarder wrote:
>> On Tue, May 29, 2018 at 11:04 PM, Matthew Wilcox  wrote:
>> > I see:
>> >
>> > mm/gup.c:817:15: warning: invalid assignment: |=
>> > mm/gup.c:817:15:left side has type int
>> > mm/gup.c:817:15:right side has type restricted vm_fault_t
>> >
>> > are you building with 'c=2' or 'C=2'?
>>
>> Building with C=2.
>> Do I need to enable any separate FLAG ?
>
> Nope.  Here's what I have:
>
> willy@bobo:~/kernel/souptick$ make C=2 mm/gup.o
>   CHK include/config/kernel.release
>   CHK include/generated/uapi/linux/version.h
>   CHK include/generated/utsrelease.h
>   CHECK   arch/x86/purgatory/purgatory.c
>   CHECK   arch/x86/purgatory/sha256.c
>   CHECK   arch/x86/purgatory/string.c
> arch/x86/purgatory/../boot/string.c:134:6: warning: symbol 'simple_strtol' 
> was not declared. Should it be static?
>   CHK include/generated/bounds.h
>   CHK include/generated/timeconst.h
>   CHK include/generated/asm-offsets.h
>   CALLscripts/checksyscalls.sh
>   DESCEND  objtool
>   CHECK   scripts/mod/empty.c
>   CHK scripts/mod/devicetable-offsets.h
>   CHECK   mm/gup.c
> mm/gup.c:817:15: warning: invalid assignment: |=
> mm/gup.c:817:15:left side has type int
> mm/gup.c:817:15:right side has type restricted vm_fault_t
>   CC  mm/gup.o
>

Matthew,

Due to some unidentified error still not able to catch this warning
in (X86_64 + sparse) compilation. It is constantly showing below error.

Documents/linux-4.17-rc7$ make C=2 -j4 mm/gup.o

CHK include/config/kernel.release
  CHK include/generated/uapi/linux/version.h
  DESCEND  objtool
  CHK include/generated/utsrelease.h
  CHECK   scripts/mod/empty.c
  CHK scripts/mod/devicetable-offsets.h
  CHK include/generated/bounds.h
  CHK include/generated/timeconst.h
  CHK include/generated/asm-offsets.h
  CALLscripts/checksyscalls.sh
  CHECK   mm/gup.c
mm/gup.c:394:17: error: undefined identifier '__COUNTER__'
mm/gup.c:439:9: error: undefined identifier '__COUNTER__'
mm/gup.c:441:9: error: undefined identifier '__COUNTER__'
mm/gup.c:443:9: error: undefined identifier '__COUNTER__'
mm/gup.c:508:17: error: undefined identifier '__COUNTER__'
mm/gup.c:716:25: error: undefined identifier '__COUNTER__'
mm/gup.c:826:17: error: undefined identifier '__COUNTER__'
mm/gup.c:863:17: error: undefined identifier '__COUNTER__'
mm/gup.c:865:17: error: undefined identifier '__COUNTER__'
mm/gup.c:882:25: error: undefined identifier '__COUNTER__'
mm/gup.c:883:25: error: undefined identifier '__COUNTER__'
mm/gup.c:920:25: error: undefined identifier '__COUNTER__'
./include/linux/hugetlb.h:239:9: error: undefined identifier '__COUNTER__'

But able to capture it in (powerpc + sparse) compilation.
I will fix it in v2.

/Documents/linux-4.17-rc7$ make C=2 ARCH=powerpc
CROSS_COMPILE=powerpc-linux-gnu- mm/gup.o

  CHK include/config/kernel.release
  CHK include/generated/uapi/linux/version.h
  CHK include/generated/utsrelease.h
  CHK include/generated/bounds.h
  CHK include/generated/timeconst.h
  CHK include/generated/asm-offsets.h
  CALLscripts/checksyscalls.sh
  CHECK   scripts/mod/empty.c
  CHK scripts/mod/devicetable-offsets.h
  CHECK   mm/gup.c
./arch/powerpc/include/asm/book3s/64/pgtable.h:669:24: warning:
restricted __be64 degrades to integer
mm/gup.c:820:15: warning: incorrect type in assignment (different base types)
mm/gup.c:820:15:expected int [signed] major
mm/gup.c:820:15:got restricted vm_fault_t
mm/gup.c:1247:24: warning: expression using sizeof bool
mm/gup.c:1247:24: warning: expression using sizeof(void)
mm/gup.c:1247:24: warning: expression using sizeof(void)
./arch/powerpc/include/asm/book3s/64/pgtable.h:667:20: warning:
incorrect type in initializer (different base types)
./arch/powerpc/include/asm/book3s/64/pgtable.h:667:20:expected
unsigned long long [unsigned] [usertype] mask
./arch/powerpc/include/asm/book3s/64/pgtable.h:667:20:got
restricted __be64 [usertype] 
mm/gup.c:1735:6: warning: symbol 'gup_fast_permitted' was not
declared. Should it be static?
  CC  mm/gup.o


Also Sparse is throwing below warning ->

/Documents/linux-4.17-rc7$ make C=2 ARCH=powerpc
CROSS_COMPILE=powerpc-linux-gnu- mm/hugetlb.o

 CHK include/config/kernel.release
  CHK include/generated/uapi/linux/version.h
  CHK include/generated/utsrelease.h
  CHK include/generated/bounds.h
  CHK include/generated/timeconst.h
  CHK include/generated/asm-offsets.h
  CALLscripts/checksyscalls.sh
  CHECK   scripts/mod/empty.c
  CHK scripts/mod/devicetable-offsets.h
  CHECK   mm/hugetlb.c
mm/hugetlb.c:3778:33: warning: restricted vm_fault_t degrades to integer
mm/hugetlb.c:3777:31: warning: restricted vm_fault_t degrades to integer
mm/hugetlb.c:3777:29: warning: incorrect type in assignment (different
base types)
mm/hugetlb.c:3777:29:expected r

[PATCH 3/4] tools headers: Sync x86 cpufeatures.h with the kernel sources

2018-06-02 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

To pick up changes found in these csets:

 11fb0683493b x86/speculation: Add virtualized speculative store bypass disable 
support
 d1035d971829 x86/cpufeatures: Add FEATURE_ZEN
 52817587e706 x86/cpufeatures: Disentangle SSBD enumeration
 7eb8956a7fec x86/cpufeatures: Disentangle MSR_SPEC_CTRL enumeration from IBRS
 e7c587da1252 x86/speculation: Use synthetic bits for IBRS/IBPB/STIBP
 9f65fb29374e x86/bugs: Rename _RDS to _SSBD
 764f3c21588a x86/bugs/AMD: Add support to disable RDS on Fam[15,16,17]h if 
requested
 24f7fc83b920 x86/bugs: Provide boot parameters for the 
spec_store_bypass_disable mitigation
 0cc5fa00b0a8 x86/cpufeatures: Add X86_FEATURE_RDS
 c456442cd3a5 x86/bugs: Expose /sys/../spec_store_bypass

The usage of this file in tools doesn't use the newly added X86_FEATURE_
defines:

  CC   /tmp/build/perf/bench/mem-memcpy-x86-64-asm.o
  CC   /tmp/build/perf/bench/mem-memset-x86-64-asm.o
  LD   /tmp/build/perf/bench/perf-in.o
  LD   /tmp/build/perf/perf-in.o

Silencing this perf build warning:

  Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' 
differs from latest version at 'arch/x86/include/asm/cpufeatures.h'

Cc: Adrian Hunter 
Cc: Borislav Petkov 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Konrad Rzeszutek Wilk 
Cc: Namhyung Kim 
Cc: Thomas Gleixner 
Cc: Tom Lendacky 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-mrwyauyov8c7s048abg26...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/arch/x86/include/asm/cpufeatures.h | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/tools/arch/x86/include/asm/cpufeatures.h 
b/tools/arch/x86/include/asm/cpufeatures.h
index 578793e97431..fb00a2fca990 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -198,7 +198,6 @@
 #define X86_FEATURE_CAT_L2 ( 7*32+ 5) /* Cache Allocation 
Technology L2 */
 #define X86_FEATURE_CDP_L3 ( 7*32+ 6) /* Code and Data 
Prioritization L3 */
 #define X86_FEATURE_INVPCID_SINGLE ( 7*32+ 7) /* Effectively INVPCID && 
CR4.PCIDE=1 */
-
 #define X86_FEATURE_HW_PSTATE  ( 7*32+ 8) /* AMD HW-PState */
 #define X86_FEATURE_PROC_FEEDBACK  ( 7*32+ 9) /* AMD ProcFeedbackInterface 
*/
 #define X86_FEATURE_SME( 7*32+10) /* AMD Secure Memory 
Encryption */
@@ -207,13 +206,19 @@
 #define X86_FEATURE_RETPOLINE_AMD  ( 7*32+13) /* "" AMD Retpoline 
mitigation for Spectre variant 2 */
 #define X86_FEATURE_INTEL_PPIN ( 7*32+14) /* Intel Processor Inventory 
Number */
 #define X86_FEATURE_CDP_L2 ( 7*32+15) /* Code and Data 
Prioritization L2 */
-
+#define X86_FEATURE_MSR_SPEC_CTRL  ( 7*32+16) /* "" MSR SPEC_CTRL is 
implemented */
+#define X86_FEATURE_SSBD   ( 7*32+17) /* Speculative Store Bypass 
Disable */
 #define X86_FEATURE_MBA( 7*32+18) /* Memory Bandwidth 
Allocation */
 #define X86_FEATURE_RSB_CTXSW  ( 7*32+19) /* "" Fill RSB on context 
switches */
 #define X86_FEATURE_SEV( 7*32+20) /* AMD Secure 
Encrypted Virtualization */
-
 #define X86_FEATURE_USE_IBPB   ( 7*32+21) /* "" Indirect Branch 
Prediction Barrier enabled */
 #define X86_FEATURE_USE_IBRS_FW( 7*32+22) /* "" Use IBRS 
during runtime firmware calls */
+#define X86_FEATURE_SPEC_STORE_BYPASS_DISABLE  ( 7*32+23) /* "" Disable 
Speculative Store Bypass. */
+#define X86_FEATURE_LS_CFG_SSBD( 7*32+24)  /* "" AMD SSBD 
implementation via LS_CFG MSR */
+#define X86_FEATURE_IBRS   ( 7*32+25) /* Indirect Branch 
Restricted Speculation */
+#define X86_FEATURE_IBPB   ( 7*32+26) /* Indirect Branch 
Prediction Barrier */
+#define X86_FEATURE_STIBP  ( 7*32+27) /* Single Thread Indirect 
Branch Predictors */
+#define X86_FEATURE_ZEN( 7*32+28) /* "" CPU is AMD 
family 0x17 (Zen) */
 
 /* Virtualization flags: Linux defined, word 8 */
 #define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
@@ -274,9 +279,10 @@
 #define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */
 #define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired 
Count */
 #define X86_FEATURE_XSAVEERPTR (13*32+ 2) /* Always save/restore FP 
error pointers */
-#define X86_FEATURE_IBPB   (13*32+12) /* Indirect Branch 
Prediction Barrier */
-#define X86_FEATURE_IBRS   (13*32+14) /* Indirect Branch 
Restricted Speculation */
-#define X86_FEATURE_STIBP  (13*32+15) /* Single Thread Indirect 
Branch Predictors */
+#define X86_FEATURE_AMD_IBPB   (13*32+12) /* "" Indirect Branch 
Prediction Barrier */
+#define X86_FEATURE_AMD_IBRS   (13*32+14) /* "" Indirect Branch 
Restricted Speculation */
+#define X86_FEATURE_AMD_STIBP  (13*32+15) /* "" Single Thread Indirect 
Branch Predictors */
+#define X86_F

[PATCH 4/4] perf tools intel-pt-decoder: Update insn.h from the kernel sources

2018-06-02 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

To pick up the changes in:

  ee6a7354a362 ("kprobes/x86: Prohibit probing on exception masking 
instructions")

That doesn't entail changes in tooling, but silences this perf build
warning:

  Warning: Intel PT: x86 instruction decoder header at 
'tools/perf/util/intel-pt-decoder/insn.h' differs from latest version at 
'arch/x86/include/asm/insn.h'

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Masami Hiramatsu 
Cc: Namhyung Kim 
Cc: Thomas Gleixner 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-o3wfwjnyh7r8l0gi9q3y9...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/intel-pt-decoder/insn.h | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/tools/perf/util/intel-pt-decoder/insn.h 
b/tools/perf/util/intel-pt-decoder/insn.h
index e23578c7b1be..2669c9f748e4 100644
--- a/tools/perf/util/intel-pt-decoder/insn.h
+++ b/tools/perf/util/intel-pt-decoder/insn.h
@@ -208,4 +208,22 @@ static inline int insn_offset_immediate(struct insn *insn)
return insn_offset_displacement(insn) + insn->displacement.nbytes;
 }
 
+#define POP_SS_OPCODE 0x1f
+#define MOV_SREG_OPCODE 0x8e
+
+/*
+ * Intel SDM Vol.3A 6.8.3 states;
+ * "Any single-step trap that would be delivered following the MOV to SS
+ * instruction or POP to SS instruction (because EFLAGS.TF is 1) is
+ * suppressed."
+ * This function returns true if @insn is MOV SS or POP SS. On these
+ * instructions, single stepping is suppressed.
+ */
+static inline int insn_masking_exception(struct insn *insn)
+{
+   return insn->opcode.bytes[0] == POP_SS_OPCODE ||
+   (insn->opcode.bytes[0] == MOV_SREG_OPCODE &&
+X86_MODRM_REG(insn->modrm.bytes[0]) == 2);
+}
+
 #endif /* _ASM_X86_INSN_H */
-- 
2.14.3



[PATCH 1/4] perf trace beauty prctl: Default header_dir to cwd to work without parms

2018-06-02 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

Useful when checking the effects of header synchs for the files it uses
as a input to generate string tables, in retrospect this is how it
should've been done from day 1, not requiring the header_dir to be set
on the Makefile, will change everything later, so that the only parm,
common to all generators will be $(srctree) and $(beauty_outdir).

So, to see what it generates, just call it without any parameters:

  $ tools/perf/trace/beauty/prctl_option.sh
  static const char *prctl_options[] = {
  [1] = "SET_PDEATHSIG",
  [2] = "GET_PDEATHSIG",
  [3] = "GET_DUMPABLE",
  [4] = "SET_DUMPABLE",
  [5] = "GET_UNALIGN",
  [6] = "SET_UNALIGN",
  [7] = "GET_KEEPCAPS",
  [8] = "SET_KEEPCAPS",
  [9] = "GET_FPEMU",
  [10] = "SET_FPEMU",
  [11] = "GET_FPEXC",
  [12] = "SET_FPEXC",
  [13] = "GET_TIMING",
  [14] = "SET_TIMING",
  [15] = "SET_NAME",
  [16] = "GET_NAME",
  [19] = "GET_ENDIAN",
  [20] = "SET_ENDIAN",
  [21] = "GET_SECCOMP",
  [22] = "SET_SECCOMP",
  [25] = "GET_TSC",
  [26] = "SET_TSC",
  [27] = "GET_SECUREBITS",
  [28] = "SET_SECUREBITS",
  [29] = "SET_TIMERSLACK",
  [30] = "GET_TIMERSLACK",
  [35] = "SET_MM",
  [36] = "SET_CHILD_SUBREAPER",
  [37] = "GET_CHILD_SUBREAPER",
  [38] = "SET_NO_NEW_PRIVS",
  [39] = "GET_NO_NEW_PRIVS",
  [40] = "GET_TID_ADDRESS",
  [41] = "SET_THP_DISABLE",
  [42] = "GET_THP_DISABLE",
  [45] = "SET_FP_MODE",
  [46] = "GET_FP_MODE",
  };
  static const char *prctl_set_mm_options[] = {
  [1] = "START_CODE",
  [2] = "END_CODE",
  [3] = "START_DATA",
  [4] = "END_DATA",
  [5] = "START_STACK",
  [6] = "START_BRK",
  [7] = "BRK",
  [8] = "ARG_START",
  [9] = "ARG_END",
  [10] = "ENV_START",
  [11] = "ENV_END",
  [12] = "AUXV",
  [13] = "EXE_FILE",
  [14] = "MAP",
  [15] = "MAP_SIZE",
  };
  $

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-qtotspuztydjttxi7k6me...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/trace/beauty/prctl_option.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/trace/beauty/prctl_option.sh 
b/tools/perf/trace/beauty/prctl_option.sh
index 0be4138fbe71..f24722146ebe 100755
--- a/tools/perf/trace/beauty/prctl_option.sh
+++ b/tools/perf/trace/beauty/prctl_option.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-header_dir=$1
+[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/
 
 printf "static const char *prctl_options[] = {\n"
 regex='^#define[[:space:]]+PR_([GS]ET\w+)[[:space:]]*([[:xdigit:]]+).*'
-- 
2.14.3



Re: [PATCH] mm: Change return type to vm_fault_t

2018-06-02 Thread Luc Van Oostenryck
On Sat, Jun 02, 2018 at 08:25:29PM +0530, Souptick Joarder wrote:
>   CHECK   mm/gup.c
> mm/gup.c:394:17: error: undefined identifier '__COUNTER__'
> mm/gup.c:439:9: error: undefined identifier '__COUNTER__'
> mm/gup.c:441:9: error: undefined identifier '__COUNTER__'
> mm/gup.c:443:9: error: undefined identifier '__COUNTER__'
> mm/gup.c:508:17: error: undefined identifier '__COUNTER__'
> mm/gup.c:716:25: error: undefined identifier '__COUNTER__'
> mm/gup.c:826:17: error: undefined identifier '__COUNTER__'
> mm/gup.c:863:17: error: undefined identifier '__COUNTER__'
> mm/gup.c:865:17: error: undefined identifier '__COUNTER__'
> mm/gup.c:882:25: error: undefined identifier '__COUNTER__'
> mm/gup.c:883:25: error: undefined identifier '__COUNTER__'
> mm/gup.c:920:25: error: undefined identifier '__COUNTER__'
> ./include/linux/hugetlb.h:239:9: error: undefined identifier '__COUNTER__'

It seems you're using a rather old version of sparse.
Please use something more recent like v0.5.1 or v0.5.2.

Regards,
-- Luc


[PATCH 2/4] tools headers: Synchronize prctl.h ABI header

2018-06-02 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

To pick up changes from:

  $ git log --oneline -2 -i include/uapi/linux/prctl.h
  356e4bfff2c5 prctl: Add force disable speculation
  b617cfc85816 prctl: Add speculation control prctls

  $ tools/perf/trace/beauty/prctl_option.sh > before.c
  $ cp include/uapi/linux/prctl.h tools/include/uapi/linux/prctl.h
  $ tools/perf/trace/beauty/prctl_option.sh > after.c
  $ diff -u before.c after.c
  --- before.c  2018-06-01 10:39:53.834073962 -0300
  +++ after.c   2018-06-01 10:42:11.307985394 -0300
  @@ -35,6 +35,8 @@
  [42] = "GET_THP_DISABLE",
  [45] = "SET_FP_MODE",
  [46] = "GET_FP_MODE",
  +   [52] = "GET_SPECULATION_CTRL",
  +   [53] = "SET_SPECULATION_CTRL",
   };
   static const char *prctl_set_mm_options[] = {
  [1] = "START_CODE",
  $

This will be used by 'perf trace' to show these strings when beautifying
the prctl syscall args. At some point we'll be able to say something
like:

'perf trace --all-cpus -e prctl(option=*SPEC*)'

To filter by arg by name.

  This silences this warning when building tools/perf:

Warning: Kernel ABI header at 'tools/include/uapi/linux/prctl.h' differs 
from latest version at 'include/uapi/linux/prctl.h'

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Thomas Gleixner 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-zztsptwhc264r8wg44tqh...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/include/uapi/linux/prctl.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/tools/include/uapi/linux/prctl.h b/tools/include/uapi/linux/prctl.h
index af5f8c2df87a..db9f15f5db04 100644
--- a/tools/include/uapi/linux/prctl.h
+++ b/tools/include/uapi/linux/prctl.h
@@ -207,4 +207,16 @@ struct prctl_mm_map {
 # define PR_SVE_VL_LEN_MASK0x
 # define PR_SVE_VL_INHERIT (1 << 17) /* inherit across exec */
 
+/* Per task speculation control */
+#define PR_GET_SPECULATION_CTRL52
+#define PR_SET_SPECULATION_CTRL53
+/* Speculation control variants */
+# define PR_SPEC_STORE_BYPASS  0
+/* Return and control values for PR_SET/GET_SPECULATION_CTRL */
+# define PR_SPEC_NOT_AFFECTED  0
+# define PR_SPEC_PRCTL (1UL << 0)
+# define PR_SPEC_ENABLE(1UL << 1)
+# define PR_SPEC_DISABLE   (1UL << 2)
+# define PR_SPEC_FORCE_DISABLE (1UL << 3)
+
 #endif /* _LINUX_PRCTL_H */
-- 
2.14.3



[GIT PULL 0/4] perf/urgent fixes

2018-06-02 Thread Arnaldo Carvalho de Melo
Hi Ingo,

Please consider pulling,

- Arnaldo

Test results at the end of this message, as usual.

The following changes since commit 6497bbc35ac5efce3bccd31d3719bae020282da6:

  Merge tag 'perf-urgent-for-mingo-4.17-20180531' of 
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent 
(2018-05-31 12:37:07 +0200)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git 
tags/perf-urgent-for-mingo-4.17-20180602

for you to fetch changes up to 0b3a18387f3e5cdcfaaf884860a4688280d09c9d:

  perf tools intel-pt-decoder: Update insn.h from the kernel sources 
(2018-06-01 16:13:18 -0300)


perf/urgent fixes:

- Update prctl and cpufeatures.h tools/ copies with the kernel sources
  originals, which makes 'perf trace' know about the new prctl options
  for speculation control and silences the build warnings (Arnaldo Carvalho de 
Melo)

- Update insn.h in Intel-PT instruction decoder with its original from from the
  kernel sources, to silence build warnings, no effect on the actual tools this
  time around (Arnaldo Carvalho de Melo)

Signed-off-by: Arnaldo Carvalho de Melo 


Arnaldo Carvalho de Melo (4):
  perf trace beauty prctl: Default header_dir to cwd to work without parms
  tools headers: Synchronize prctl.h ABI header
  tools headers: Sync x86 cpufeatures.h with the kernel sources
  perf tools intel-pt-decoder: Update insn.h from the kernel sources

 tools/arch/x86/include/asm/cpufeatures.h | 20 ++--
 tools/include/uapi/linux/prctl.h | 12 
 tools/perf/trace/beauty/prctl_option.sh  |  2 +-
 tools/perf/util/intel-pt-decoder/insn.h  | 18 ++
 4 files changed, 45 insertions(+), 7 deletions(-)

Test results:

The first ones are container (docker) based builds of tools/perf with
and without libelf support.  Where clang is available, it is also used
to build perf with/without libelf, and building with LIBCLANGLLVM=1
(built-in clang) with gcc and clang when clang and its devel libraries
are installed.

The objtool and samples/bpf/ builds are disabled now that I'm switching from
using the sources in a local volume to fetching them from a http server to
build it inside the container, to make it easier to build in a container 
cluster.
Those will come back later.

Several are cross builds, the ones with -x-ARCH and the android one, and those
may not have all the features built, due to lack of multi-arch devel packages,
available and being used so far on just a few, like
debian:experimental-x-{arm64,mipsel}.

The 'perf test' one will perform a variety of tests exercising
tools/perf/util/, tools/lib/{bpf,traceevent,etc}, as well as run perf commands
with a variety of command line event specifications to then intercept the
sys_perf_event syscall to check that the perf_event_attr fields are set up as
expected, among a variety of other unit tests.

Then there is the 'make -C tools/perf build-test' ones, that build tools/perf/
with a variety of feature sets, exercising the build with an incomplete set of
features as well as with a complete one. It is planned to have it run on each
of the containers mentioned above, using some container orchestration
infrastructure. Get in contact if interested in helping having this in place.

# dm
 1 alpine:3.4: Ok   gcc (Alpine 5.3.0) 5.3.0
 2 alpine:3.5: Ok   gcc (Alpine 6.2.1) 6.2.1 20160822
 3 alpine:3.6: Ok   gcc (Alpine 6.3.0) 6.3.0
 4 alpine:3.7: Ok   gcc (Alpine 6.4.0) 6.4.0
 5 alpine:edge   : Ok   gcc (Alpine 6.4.0) 6.4.0
 6 amazonlinux:1 : Ok   gcc (GCC) 4.8.5 20150623 (Red Hat 
4.8.5-28)
 7 amazonlinux:2 : Ok   gcc (GCC) 7.3.1 20180303 (Red Hat 
7.3.1-5)
 8 android-ndk:r12b-arm  : Ok   arm-linux-androideabi-gcc (GCC) 
4.9.x 20150123 (prerelease)
 9 android-ndk:r15c-arm  : Ok   arm-linux-androideabi-gcc (GCC) 
4.9.x 20150123 (prerelease)
10 centos:5  : Ok   gcc (GCC) 4.1.2 20080704 (Red Hat 
4.1.2-55)
11 centos:6  : Ok   gcc (GCC) 4.4.7 20120313 (Red Hat 
4.4.7-18)
12 centos:7  : Ok   gcc (GCC) 4.8.5 20150623 (Red Hat 
4.8.5-16)
13 debian:7  : Ok   gcc (Debian 4.7.2-5) 4.7.2
14 debian:8  : Ok   gcc (Debian 4.9.2-10+deb8u1) 4.9.2
15 debian:9  : Ok   gcc (Debian 6.3.0-18+deb9u1) 6.3.0 
20170516
16 debian:experimental   : Ok   gcc (Debian 7.3.0-19) 7.3.0
17 debian:experimental-x-arm64   : Ok   aarch64-linux-gnu-gcc (Debian 
7.3.0-19) 7.3.0
18 debian:experimental-x-mips: Ok   mips-linux-gnu-gcc (Debian 
7.3.0-19) 7.3.0
1

Re: bisected 4.17-rc - BUG: Bad page state in process qemu-system-x86 pfn:7178f3

2018-06-02 Thread Alex Williamson
On Sat, 2 Jun 2018 11:56:24 +0200
Amadeusz Sławiński  wrote:

> Hey,
> 
> so I've been getting system instability problems after shutting down
> virtual machine with GPU pass-through in 4.17-rc series and I finally
> got around to bisecting it.
> 
> Seems to be caused by 356e88ebe4473a3663cf3d14727ce293a4526d34
> and problem seems to be gone after reverting it.

Thanks for bisecting this, seems that we're hitting some sort of
unbalanced page state, suggesting we're not skipping the pfn mappings
on unmap.  As this was introduced in v4.17-rc, which is about to close,
I think our only option is to revert it for now.  I'll post that
shortly.  Thanks,

Alex

> trce from /varlog/messages:
> 
> Jun  1 22:47:23 milkyway kernel: BUG: Bad page state in process 
> qemu-system-x86  pfn:7178f3
> Jun  1 22:47:23 milkyway kernel: page:fbfddc5e3cc0 count:0 mapcount:1 
> mapping: index:0x1
> Jun  1 22:47:23 milkyway kernel: flags: 0x200()
> Jun  1 22:47:23 milkyway kernel: raw: 0200  
> 0001 
> Jun  1 22:47:23 milkyway kernel: raw: dead0100 dead0200 
>  
> Jun  1 22:47:23 milkyway kernel: page dumped because: nonzero mapcount
> Jun  1 22:47:23 milkyway kernel: Modules linked in: x86_pkg_temp_thermal 
> coretemp crc32_pclmul crc32c_intel ghash_clmulni_intel pcbc aesni_intel 
> eeepc_wmi asus_wmi wmi_bmof aes_x86_64 crypto_simd cryptd wmi glue_helper
> Jun  1 22:47:23 milkyway kernel: CPU: 4 PID: 4303 Comm: qemu-system-x86 Not 
> tainted 4.16.0+ #26
> Jun  1 22:47:23 milkyway kernel: Hardware name: ASUS All Series/SABERTOOTH 
> Z97 MARK 2, BIOS 3503 04/18/2018
> Jun  1 22:47:23 milkyway kernel: Call Trace:
> Jun  1 22:47:23 milkyway kernel:  dump_stack+0x46/0x5b
> Jun  1 22:47:23 milkyway kernel:  bad_page+0xbf/0x120
> Jun  1 22:47:23 milkyway kernel:  free_pcppages_bulk+0x434/0x500
> Jun  1 22:47:23 milkyway kernel:  free_unref_page+0x33/0x40
> Jun  1 22:47:23 milkyway kernel:  dma_free_pagelist+0x27/0x40
> Jun  1 22:47:23 milkyway kernel:  intel_iommu_unmap+0x114/0x150
> Jun  1 22:47:23 milkyway kernel:  __iommu_unmap+0xe4/0x130
> Jun  1 22:47:23 milkyway kernel:  vfio_unmap_unpin+0x13f/0x330
> Jun  1 22:47:23 milkyway kernel:  vfio_remove_dma+0x12/0x40
> Jun  1 22:47:23 milkyway kernel:  vfio_iommu_unmap_unpin_all+0x16/0x30
> Jun  1 22:47:23 milkyway kernel:  vfio_iommu_type1_detach_group+0x2b3/0x2c0
> Jun  1 22:47:23 milkyway kernel:  __vfio_group_unset_container+0x4d/0x180
> Jun  1 22:47:23 milkyway kernel:  vfio_group_put_external_user+0x9/0x20
> Jun  1 22:47:23 milkyway kernel:  kvm_vfio_group_put_external_user+0x1d/0x30
> Jun  1 22:47:23 milkyway kernel:  kvm_vfio_destroy+0x4a/0xc0
> Jun  1 22:47:23 milkyway kernel:  kvm_put_kvm+0x1a1/0x290
> Jun  1 22:47:23 milkyway kernel:  kvm_vm_release+0x18/0x20
> Jun  1 22:47:23 milkyway kernel:  __fput+0xcd/0x1f0
> Jun  1 22:47:23 milkyway kernel:  task_work_run+0x8d/0xb0
> Jun  1 22:47:23 milkyway kernel:  do_exit+0x2d9/0xbe0
> Jun  1 22:47:23 milkyway kernel:  ? hrtimer_init+0x10/0x10
> Jun  1 22:47:23 milkyway kernel:  do_group_exit+0x31/0xb0
> Jun  1 22:47:23 milkyway kernel:  get_signal+0x12d/0x570
> Jun  1 22:47:23 milkyway kernel:  do_signal+0x3e/0x5d0
> Jun  1 22:47:23 milkyway kernel:  exit_to_usermode_loop+0x46/0x80
> Jun  1 22:47:23 milkyway kernel:  do_syscall_64+0xe0/0xf0
> Jun  1 22:47:23 milkyway kernel:  entry_SYSCALL_64_after_hwframe+0x3d/0xa2
> Jun  1 22:47:23 milkyway kernel: RIP: 0033:0x7e7c7512750f
> Jun  1 22:47:23 milkyway kernel: RSP: 002b:7e77df3f29d0 EFLAGS: 0246 
> ORIG_RAX: 00ca
> Jun  1 22:47:23 milkyway kernel: RAX: fdfc RBX: 0189 
> RCX: 7e7c7512750f
> Jun  1 22:47:23 milkyway kernel: RDX:  RSI: 0189 
> RDI: 57066f99c0a8
> Jun  1 22:47:23 milkyway kernel: RBP:  R08:  
> R09: 
> Jun  1 22:47:23 milkyway kernel: R10: 7e77df3f2a80 R11: 0246 
> R12: 7e77df3f2a80
> Jun  1 22:47:23 milkyway kernel: R13: 57066f99c0a8 R14: 7e77df3f2a80 
> R15: 7fff7e253a30
> Jun  1 22:47:23 milkyway kernel: Disabling lock debugging due to kernel taint
> 
> 
> 
> git bisect log
> 
> git bisect start
> # good: [0adb32858b0bddf4ada5f364a84ed60b196dbcda] Linux 4.16
> git bisect good 0adb32858b0bddf4ada5f364a84ed60b196dbcda
> # bad: [60cc43fc888428bb2f18f08997432d426a243338] Linux 4.17-rc1
> git bisect bad 60cc43fc888428bb2f18f08997432d426a243338
> # good: [ac9053d2dcb9e8c3fa35ce458dfca8fddc141680] Merge tag 'usb-4.17-rc1' 
> of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
> git bisect good ac9053d2dcb9e8c3fa35ce458dfca8fddc141680
> # good: [38c23685b273cfb4ccf31a199feccce3bdcb5d83] Merge tag 'armsoc-drivers' 
> of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
> git bisect good 38c23685b273cfb4ccf31a199feccce3bdcb5d83
> # bad: [fbe173e3ffbd897b5a859020d714c0eaf4

Re: [PATCH v2 0/5] staging: mt7621-spi: Fix Coding style issues.

2018-06-02 Thread Joe Perches
On Sat, 2018-06-02 at 19:56 +0530, Sankalp Negi wrote:
> This patch series lists different changes for coding style fixes
> as reported by checkpatch.pl, changes can be broken down as :
> 
> 1. Indent switch and case labels at the same level
> 2. Fix a line over 80 columns
> 3. Place tabs for indentation instead of spaces
> 4. Add a space before open paranthesis in switch 
> 5. Remove unnecessary braces {} from single statement if
> 
> version 2 changes
> - segregated changes in individual commits as per fix category
> 
> Sankalp Negi (5):
>   staging: mt7621-spi: Fix Coding style issues reported by
> checkpatch.pl.
>   staging: mt7621-spi: Fix Coding style issues reported by
> checkpatch.pl.
>   staging: mt7621-spi: Fix Coding style issues reported by
> checkpatch.pl.
>   staging: mt7621-spi: Fix Coding style issues reported by
> checkpatch.pl.
>   staging: mt7621-spi: Fix Coding style issues reported by
> checkpatch.pl.

Plese use unique subjects for each patch in a series.



[PATCH v2] DMA: OMAP: fix OMAP1510 incorrect residue_granularity

2018-06-02 Thread Janusz Krzysztofik
Commit 0198d7bb8a0c ("ASoC: omap-mcbsp: Convert to use the sdma-pcm
instead of omap-pcm") resulted in broken audio playback on OMAP1510
(discovered on Amstrad Delta).

When running on OMAP1510, omap-pcm used to obtain DMA offset from
snd_dmaengine_pcm_pointer_no_residue() based on DMA interrupt triggered
software calculations instead of snd_dmaengine_pcm_pointer() which
depended on residue value calculated from omap_dma_get_src_pos().
Similar code path is still available in now used
sound/soc/soc-generic-dmaengine-pcm.c but it is not triggered.

It was verified already before that omap_get_dma_src_pos() from
arch/arm/plat-omap/dma.c didn't work correctly for OMAP1510 - see
commit 1bdd7419910c ("ASoC: OMAP: fix OMAP1510 broken PCM pointer
callback") for details.  Apparently the same applies to its successor,
omap_dma_get_src_pos() from drivers/dma/ti/omap-dma.c.

On the other hand, snd_dmaengine_pcm_pointer_no_residue() is described
as depreciated and discouraged for use in new drivers because of its
unreliable accuracy.  However, it seems the only working option for
OPAM1510 now, as long as a software calculated residue is not
implemented as OMAP1510 fallback in omap-dma.

Using snd_dmaengine_pcm_pointer_no_residue() code path instead of
snd_dmaengine_pcm_pointer() in sound/soc/soc-generic-dmaengine-pcm.c
can be triggered in two ways:
- by passing pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE from
  sound/soc/omap/sdma-pcm.c,
- by passing dma_caps.residue_granularity =
  DMA_RESIDUE_GRANULARITY_DESCRIPTOR from DMA engine.

Let's do the latter.

Created and tested against next-20180531 tag from linux-next tree.

Signed-off-by: Janusz Krzysztofik 
---
Changelog:
v2: apply the patch against omap-dma.c moved to drivers/dma/ti/

 drivers/dma/ti/omap-dma.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c
index b73fb51fbc81..96b5096c26dd 100644
--- a/drivers/dma/ti/omap-dma.c
+++ b/drivers/dma/ti/omap-dma.c
@@ -1485,7 +1485,11 @@ static int omap_dma_probe(struct platform_device *pdev)
od->ddev.src_addr_widths = OMAP_DMA_BUSWIDTHS;
od->ddev.dst_addr_widths = OMAP_DMA_BUSWIDTHS;
od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
-   od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
+   if (__dma_omap15xx(od->plat->dma_attr))
+   od->ddev.residue_granularity =
+   DMA_RESIDUE_GRANULARITY_DESCRIPTOR;
+   else
+   od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
od->ddev.max_burst = SZ_16M - 1; /* CCEN: 24bit unsigned */
od->ddev.dev = &pdev->dev;
INIT_LIST_HEAD(&od->ddev.channels);
-- 
2.16.1



Re: [PATCH] ARM: dts: exynos: Add missing CPU clocks to secondary CPUs on Exynos542x

2018-06-02 Thread Alim Akhtar
Hi Krzysztof,

On Wed, May 30, 2018 at 10:19 PM, Krzysztof Kozlowski  wrote:
> Secondary CPUs should have the same information in DeviceTree as booting
> CPU from both correctness point of view and for possible hotplug
> scenarios.
>
> Suggested-by: Viresh Kumar 
> Signed-off-by: Krzysztof Kozlowski 
> ---
>  arch/arm/boot/dts/exynos5420-cpus.dtsi | 6 ++
>  arch/arm/boot/dts/exynos5422-cpus.dtsi | 8 +++-
>  2 files changed, 13 insertions(+), 1 deletion(-)

Reviewed-by: Alim Akhtar 

Tested on exynos5800 peach-pi, so feel free to add

Tested-by: Alim Akhtar 

>
> diff --git a/arch/arm/boot/dts/exynos5420-cpus.dtsi 
> b/arch/arm/boot/dts/exynos5420-cpus.dtsi
> index a8e449471304..0ee6e92a3c29 100644
> --- a/arch/arm/boot/dts/exynos5420-cpus.dtsi
> +++ b/arch/arm/boot/dts/exynos5420-cpus.dtsi
> @@ -38,6 +38,7 @@
> device_type = "cpu";
> compatible = "arm,cortex-a15";
> reg = <0x1>;
> +   clocks = <&clock CLK_ARM_CLK>;
> clock-frequency = <18>;
> cci-control-port = <&cci_control1>;
> operating-points-v2 = <&cluster_a15_opp_table>;
> @@ -49,6 +50,7 @@
> device_type = "cpu";
> compatible = "arm,cortex-a15";
> reg = <0x2>;
> +   clocks = <&clock CLK_ARM_CLK>;
> clock-frequency = <18>;
> cci-control-port = <&cci_control1>;
> operating-points-v2 = <&cluster_a15_opp_table>;
> @@ -60,6 +62,7 @@
> device_type = "cpu";
> compatible = "arm,cortex-a15";
> reg = <0x3>;
> +   clocks = <&clock CLK_ARM_CLK>;
> clock-frequency = <18>;
> cci-control-port = <&cci_control1>;
> operating-points-v2 = <&cluster_a15_opp_table>;
> @@ -83,6 +86,7 @@
> device_type = "cpu";
> compatible = "arm,cortex-a7";
> reg = <0x101>;
> +   clocks = <&clock CLK_KFC_CLK>;
> clock-frequency = <10>;
> cci-control-port = <&cci_control0>;
> operating-points-v2 = <&cluster_a7_opp_table>;
> @@ -94,6 +98,7 @@
> device_type = "cpu";
> compatible = "arm,cortex-a7";
> reg = <0x102>;
> +   clocks = <&clock CLK_KFC_CLK>;
> clock-frequency = <10>;
> cci-control-port = <&cci_control0>;
> operating-points-v2 = <&cluster_a7_opp_table>;
> @@ -105,6 +110,7 @@
> device_type = "cpu";
> compatible = "arm,cortex-a7";
> reg = <0x103>;
> +   clocks = <&clock CLK_KFC_CLK>;
> clock-frequency = <10>;
> cci-control-port = <&cci_control0>;
> operating-points-v2 = <&cluster_a7_opp_table>;
> diff --git a/arch/arm/boot/dts/exynos5422-cpus.dtsi 
> b/arch/arm/boot/dts/exynos5422-cpus.dtsi
> index 7c130a00d1a8..e4a5857c135f 100644
> --- a/arch/arm/boot/dts/exynos5422-cpus.dtsi
> +++ b/arch/arm/boot/dts/exynos5422-cpus.dtsi
> @@ -37,6 +37,7 @@
> device_type = "cpu";
> compatible = "arm,cortex-a7";
> reg = <0x101>;
> +   clocks = <&clock CLK_KFC_CLK>;
> clock-frequency = <10>;
> cci-control-port = <&cci_control0>;
> operating-points-v2 = <&cluster_a7_opp_table>;
> @@ -48,6 +49,7 @@
> device_type = "cpu";
> compatible = "arm,cortex-a7";
> reg = <0x102>;
> +   clocks = <&clock CLK_KFC_CLK>;
> clock-frequency = <10>;
> cci-control-port = <&cci_control0>;
> operating-points-v2 = <&cluster_a7_opp_table>;
> @@ -59,6 +61,7 @@
> device_type = "cpu";
> compatible = "arm,cortex-a7";
> reg = <0x103>;
> +   clocks = <&clock CLK_KFC_CLK>;
> clock-frequency = <10>;
> cci-control-port = <&cci_control0>;
> operating-points-v2 = <&cluster_a7_opp_table>;
> @@ -69,8 +72,8 @@
> cpu4: cpu@0 {
> device_type = "cpu";
> compatible = "arm,cortex-a15";
> -   clocks = <&clock CLK_ARM_CLK>;
>  

  1   2   >