Re: Multiple generic PHY instances for DWC3 USB IP

2018-04-03 Thread Masahiro Yamada
2018-04-04 14:36 GMT+09:00 Felipe Balbi :
>
> Hi,
>
> Masahiro Yamada  writes:
>> Currently, DWC3 core IP (drivers/usb/dwc3/core.c)
>> can take only one PHY phandle for each of SS, HS.
>> (phy-names DT property is "usb2-phy" and "usb3-phy" for each)
>
> We never had any other requirements :-)
>
>> The DWC3 core IP is provided by Synopsys,
>> but some SoC-dependent parts (a.k.a glue-layer)
>> are implemented by SoC venders.
>>
>> The number of connected PHY instances are SoC-dependent.
>>
>> If you look at generic drivers such as
>>   drivers/usb/host/ehci-platform.c
>> the driver can handle arbitrary number of PHY instances.
>>
>> However, as mentioned above, DWC3 core allows only one PHY phandle
>> for each SS/HS.
>> This can result in a strange DT structure.
>>
>> For example, Socionext PXs3 SoC is integrated with 2 instances of DWC3.
>>
>> The instance 0 of DWC3 is connected with 2 super-speed PHYs.
>
> why 2 super-speed phys? Is this a two-port host-only implementation?


Socionext SoCs only support the host-mode.


The instance 0 has 2 ports.
In our integration, 1 SS PHY is needed for each port.
That's why it needs 2 SS PHYs.

Each DWC3 instance is connected with
multiple HS PHYs and multiple SS PHYs,
depending on the number of ports.




>> The instance 1 of DWC3 is connected with 1 super-speed PHY.
>
> Are both of these instances incapable of high/full/low-speed
> communication?

Also HS PHYs are connected.


To narrow down the problem,
I picked up the DT snippet only for SS PHY device nodes.




>> @@ -894,8 +894,8 @@ struct dwc3 {
>> struct usb_phy  *usb2_phy;
>> struct usb_phy  *usb3_phy;
>>
>> -   struct phy  *usb2_generic_phy;
>> -   struct phy  *usb3_generic_phy;
>> +   unsigned intnum_phys;
>> +   struct phy  **phys;
>>
>> boolphys_ready;
>>
>>
>>
>> Is this OK?
>
> I don't know, I need a bit more details about your integration :-)


I can send a patch.

My concern is the following commit.
I do not know which parts are using this lookups.




commit 08f871a3aca252b15107fc37dedcdacbac80fdb5
Author: Heikki Krogerus 
Date:   Wed Nov 19 17:28:23 2014 +0200

usb: dwc3: host: convey the PHYs to xhci

On some platforms a PHY may need to be handled also in the
host controller driver. Exynos5420 SoC requires some "PHY
tuning" based on the USB speed. This patch delivers dwc3's
PHYs to the xhci platform device when it's created.

Signed-off-by: Heikki Krogerus 
Tested-by: Vivek Gautam 
Acked-by: Felipe Balbi 
Signed-off-by: Kishon Vijay Abraham I 

-- 
Best Regards
Masahiro Yamada


Re: Multiple generic PHY instances for DWC3 USB IP

2018-04-03 Thread Masahiro Yamada
2018-04-04 14:36 GMT+09:00 Felipe Balbi :
>
> Hi,
>
> Masahiro Yamada  writes:
>> Currently, DWC3 core IP (drivers/usb/dwc3/core.c)
>> can take only one PHY phandle for each of SS, HS.
>> (phy-names DT property is "usb2-phy" and "usb3-phy" for each)
>
> We never had any other requirements :-)
>
>> The DWC3 core IP is provided by Synopsys,
>> but some SoC-dependent parts (a.k.a glue-layer)
>> are implemented by SoC venders.
>>
>> The number of connected PHY instances are SoC-dependent.
>>
>> If you look at generic drivers such as
>>   drivers/usb/host/ehci-platform.c
>> the driver can handle arbitrary number of PHY instances.
>>
>> However, as mentioned above, DWC3 core allows only one PHY phandle
>> for each SS/HS.
>> This can result in a strange DT structure.
>>
>> For example, Socionext PXs3 SoC is integrated with 2 instances of DWC3.
>>
>> The instance 0 of DWC3 is connected with 2 super-speed PHYs.
>
> why 2 super-speed phys? Is this a two-port host-only implementation?


Socionext SoCs only support the host-mode.


The instance 0 has 2 ports.
In our integration, 1 SS PHY is needed for each port.
That's why it needs 2 SS PHYs.

Each DWC3 instance is connected with
multiple HS PHYs and multiple SS PHYs,
depending on the number of ports.




>> The instance 1 of DWC3 is connected with 1 super-speed PHY.
>
> Are both of these instances incapable of high/full/low-speed
> communication?

Also HS PHYs are connected.


To narrow down the problem,
I picked up the DT snippet only for SS PHY device nodes.




>> @@ -894,8 +894,8 @@ struct dwc3 {
>> struct usb_phy  *usb2_phy;
>> struct usb_phy  *usb3_phy;
>>
>> -   struct phy  *usb2_generic_phy;
>> -   struct phy  *usb3_generic_phy;
>> +   unsigned intnum_phys;
>> +   struct phy  **phys;
>>
>> boolphys_ready;
>>
>>
>>
>> Is this OK?
>
> I don't know, I need a bit more details about your integration :-)


I can send a patch.

My concern is the following commit.
I do not know which parts are using this lookups.




commit 08f871a3aca252b15107fc37dedcdacbac80fdb5
Author: Heikki Krogerus 
Date:   Wed Nov 19 17:28:23 2014 +0200

usb: dwc3: host: convey the PHYs to xhci

On some platforms a PHY may need to be handled also in the
host controller driver. Exynos5420 SoC requires some "PHY
tuning" based on the USB speed. This patch delivers dwc3's
PHYs to the xhci platform device when it's created.

Signed-off-by: Heikki Krogerus 
Tested-by: Vivek Gautam 
Acked-by: Felipe Balbi 
Signed-off-by: Kishon Vijay Abraham I 

-- 
Best Regards
Masahiro Yamada


Re: [PATCH 1/1] dmaengine:jz4740:fix memory leak

2018-04-03 Thread Vinod Koul
On Wed, Apr 04, 2018 at 11:21:58AM +0800, Xidong Wang wrote:
> In function jz4740_dma_probe(), the memory allocated by
> clk_get() is not released on the error path that ret, which holds
> the return value of dma_async_device_register(), is not NULL.
> This will result in a memory leak bug.

I dont think we cna cal it mem leak, it seems your ref counting of clock
resource is imbalance as you dont free up which eventually would lead to mem
leak. Also dabove description needs a bit of cleanup please

> 
> Signed-off-by: Xidong Wang 
> ---
>  drivers/dma/dma-jz4740.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/dma/dma-jz4740.c b/drivers/dma/dma-jz4740.c
> index afd5e10..082c158 100644
> --- a/drivers/dma/dma-jz4740.c
> +++ b/drivers/dma/dma-jz4740.c
> @@ -570,6 +570,7 @@ static int jz4740_dma_probe(struct platform_device *pdev)
>   dma_async_device_unregister(dd);
>  err_clk:
>   clk_disable_unprepare(dmadev->clk);
> + clk_put(dmadev->clk);
>   return ret;
>  }
>  
> -- 
> 2.7.4
> 
> 

-- 
~Vinod


Re: [PATCH 1/1] dmaengine:jz4740:fix memory leak

2018-04-03 Thread Vinod Koul
On Wed, Apr 04, 2018 at 11:21:58AM +0800, Xidong Wang wrote:
> In function jz4740_dma_probe(), the memory allocated by
> clk_get() is not released on the error path that ret, which holds
> the return value of dma_async_device_register(), is not NULL.
> This will result in a memory leak bug.

I dont think we cna cal it mem leak, it seems your ref counting of clock
resource is imbalance as you dont free up which eventually would lead to mem
leak. Also dabove description needs a bit of cleanup please

> 
> Signed-off-by: Xidong Wang 
> ---
>  drivers/dma/dma-jz4740.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/dma/dma-jz4740.c b/drivers/dma/dma-jz4740.c
> index afd5e10..082c158 100644
> --- a/drivers/dma/dma-jz4740.c
> +++ b/drivers/dma/dma-jz4740.c
> @@ -570,6 +570,7 @@ static int jz4740_dma_probe(struct platform_device *pdev)
>   dma_async_device_unregister(dd);
>  err_clk:
>   clk_disable_unprepare(dmadev->clk);
> + clk_put(dmadev->clk);
>   return ret;
>  }
>  
> -- 
> 2.7.4
> 
> 

-- 
~Vinod


Re: [PATCH] dmaengine: rcar-dmac: Fix too early/late system suspend/resume callbacks

2018-04-03 Thread Vinod Koul
On Thu, Mar 29, 2018 at 06:53:32PM +0200, Geert Uytterhoeven wrote:
> If serial console wake-up is enabled ("echo enabled >
> /sys/.../ttySC0/power/wakeup"), and any serial input is received while
> the system is suspended, serial port input no longer works after system
> resume.
> 
> Note that:
>   1) The system can still be woken up using the serial console,
>   2) Serial port input keeps working if the system is woken up in some
>  other way (e.g. Wake-on-LAN or gpio-keys), and no serial input was
>  received while suspended.
> 
> To fix this, replace SET_LATE_SYSTEM_SLEEP_PM_OPS() by
> SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(), as the callbacks installed by the
> former happen too early resp. late in the suspend resp. resume process.

Applied, thanks

-- 
~Vinod


Re: [PATCH] dmaengine: rcar-dmac: Fix too early/late system suspend/resume callbacks

2018-04-03 Thread Vinod Koul
On Thu, Mar 29, 2018 at 06:53:32PM +0200, Geert Uytterhoeven wrote:
> If serial console wake-up is enabled ("echo enabled >
> /sys/.../ttySC0/power/wakeup"), and any serial input is received while
> the system is suspended, serial port input no longer works after system
> resume.
> 
> Note that:
>   1) The system can still be woken up using the serial console,
>   2) Serial port input keeps working if the system is woken up in some
>  other way (e.g. Wake-on-LAN or gpio-keys), and no serial input was
>  received while suspended.
> 
> To fix this, replace SET_LATE_SYSTEM_SLEEP_PM_OPS() by
> SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(), as the callbacks installed by the
> former happen too early resp. late in the suspend resp. resume process.

Applied, thanks

-- 
~Vinod


tools include: define READ_ONCE/WRITE_ONCE for C++

2018-04-03 Thread Sandipan Das
From: Li Zhijian 

since 6aa7de0, we failed to build perf with C++(clang)
to fix the following compile errors
--
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf$ make 
LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
...
  CC   util/probe-finder.o
In file included from /home/lizj/linux/tools/perf/util/util.h:13:0,
 from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
 from util/c++/clang-c.h:5,
 from util/c++/clang-test.cpp:2:
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h: In 
function ‘int atomic_read(const atomic_t*)’:
/home/lizj/linux/tools/include/linux/compiler.h:157:45: error: use of deleted 
function ‘atomic_read(const atomic_t*)()’
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
 ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: note: 
‘atomic_read(const atomic_t*)()’ is 
implicitly deleted because the default definition would be ill-formed:
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: error: uninitialized 
const member in ‘union atomic_read(const atomic_t*)::’
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:23: note: ‘const int 
atomic_read(const atomic_t*)__val’ should be initialized
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
  LD   tests/perf-in.o
...
--

Signed-off-by: Li Zhijian 
---
 tools/include/linux/compiler.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 07fd03c..e4c8a0d 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -86,6 +86,10 @@
 
 #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
 
+#ifdef __cplusplus
+#define READ_ONCE(x) ACCESS_ONCE(x)
+#define WRITE_ONCE(x, val) ACCESS_ONCE(x) = val
+#else
 #include 
 
 /*
@@ -160,6 +164,7 @@ static __always_inline void __write_once_size(volatile void 
*p, void *res, int s
 #define WRITE_ONCE(x, val) \
({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; 
__write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
 
+#endif /* __cplusplus */
 
 #ifndef __fallthrough
 # define __fallthrough



tools include: define READ_ONCE/WRITE_ONCE for C++

2018-04-03 Thread Sandipan Das
From: Li Zhijian 

since 6aa7de0, we failed to build perf with C++(clang)
to fix the following compile errors
--
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf$ make 
LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
...
  CC   util/probe-finder.o
In file included from /home/lizj/linux/tools/perf/util/util.h:13:0,
 from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
 from util/c++/clang-c.h:5,
 from util/c++/clang-test.cpp:2:
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h: In 
function ‘int atomic_read(const atomic_t*)’:
/home/lizj/linux/tools/include/linux/compiler.h:157:45: error: use of deleted 
function ‘atomic_read(const atomic_t*)()’
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
 ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: note: 
‘atomic_read(const atomic_t*)()’ is 
implicitly deleted because the default definition would be ill-formed:
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: error: uninitialized 
const member in ‘union atomic_read(const atomic_t*)::’
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:23: note: ‘const int 
atomic_read(const atomic_t*)__val’ should be initialized
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
  LD   tests/perf-in.o
...
--

Signed-off-by: Li Zhijian 
---
 tools/include/linux/compiler.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 07fd03c..e4c8a0d 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -86,6 +86,10 @@
 
 #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
 
+#ifdef __cplusplus
+#define READ_ONCE(x) ACCESS_ONCE(x)
+#define WRITE_ONCE(x, val) ACCESS_ONCE(x) = val
+#else
 #include 
 
 /*
@@ -160,6 +164,7 @@ static __always_inline void __write_once_size(volatile void 
*p, void *res, int s
 #define WRITE_ONCE(x, val) \
({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; 
__write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
 
+#endif /* __cplusplus */
 
 #ifndef __fallthrough
 # define __fallthrough



Re: Multiple generic PHY instances for DWC3 USB IP

2018-04-03 Thread Felipe Balbi

Hi,

Masahiro Yamada  writes:
> Currently, DWC3 core IP (drivers/usb/dwc3/core.c)
> can take only one PHY phandle for each of SS, HS.
> (phy-names DT property is "usb2-phy" and "usb3-phy" for each)

We never had any other requirements :-)

> The DWC3 core IP is provided by Synopsys,
> but some SoC-dependent parts (a.k.a glue-layer)
> are implemented by SoC venders.
>
> The number of connected PHY instances are SoC-dependent.
>
> If you look at generic drivers such as
>   drivers/usb/host/ehci-platform.c
> the driver can handle arbitrary number of PHY instances.
>
> However, as mentioned above, DWC3 core allows only one PHY phandle
> for each SS/HS.
> This can result in a strange DT structure.
>
> For example, Socionext PXs3 SoC is integrated with 2 instances of DWC3.
>
> The instance 0 of DWC3 is connected with 2 super-speed PHYs.

why 2 super-speed phys? Is this a two-port host-only implementation?

> The instance 1 of DWC3 is connected with 1 super-speed PHY.

Are both of these instances incapable of high/full/low-speed
communication?

> According to the feed-back from Felipe Balbe,
> (https://patchwork.kernel.org/patch/10180167/)
> Socionext is trying to split the glue layer into small chunks.
>
>
> The following is the DT under internal review of Socionext.
> The full DT is super long, so
> here is only snippet for the SS PHY parts.
>
>
> [ instance 0  (with 2 SS PHYs) ]
>
> dwc3@65a0 {
> compatible = "snps,dwc3";
> reg = <0x65a0 0xcd00>;
> interrupt-names = "host", "peripheral";
> interrupts = <0 134 4>, <0 135 4>;
> phy-names = "usb2-phy", "usb3-phy";
> phys = <_hsphy>, <_ssphy>;
> dr_mode = "host";
> };
>
> usb0_ssphy: ss-phy {
> compatible = "socionext,uniphier-pxs3-usb3-ssphy";
> #address-cells = <1>;
> #size-cells = <0>;
> #phy-cells = <0>;
> clock-names = "phy-clk0", "phy-clk1";
> clocks = <_clk 17>, <_clk 18>;
> reset-names = "phy-rst0", "phy-rst1";
> resets = <_rst 17>, <_rst 18>;
> port0-supply = <_vbus0>;
> port1-supply = <_vbus1>;
>
> port@0 {
> reg = <0>;
> };
> port@1 {
> reg = <1>;
> };
> };
>
> [ instance 1 (with 1 SS PHY) ]
>
> dwc3@65c0 {
> compatible = "snps,dwc3";
> reg = <0x65c0 0xcd00>;
> interrupt-names = "host", "peripheral";
> interrupts = <0 137 4>, <0 138 4>;
> phy-names = "usb2-phy", "usb3-phy";
> phys = <_hsphy>, <_ssphy>;
> dr_mode = "host";
> };
>
> usb1_ssphy: ss-phy {
> compatible = "socionext,uniphier-pxs3-usb3-ssphy";
> #address-cells = <1>;
> #size-cells = <0>;
> #phy-cells = <0>;
> clock-names = "phy-clk0";
> clocks = <_clk 21>;
> reset-names = "phy-rst0";
> resets = <_rst 21>;
> port0-supply = <_vbus0>;
>
> port@0 {
>  reg = <0>;
> };
> };
>
>
> I think this is strange, but the PHY driver
> counts the number of sub-nodes ("port@0", "port@1" ...)
> and iterate the port settings.
>
>
>
>
>
> In my opinion, the structure like follows
> will be more natural.
> (flattening homogeneous PHY nodes)
>
>
> [ instance 0 (with 2 SS PHYs)]
>
> dwc3@65a0 {
> compatible = "snps,dwc3";
> reg = <0x65a0 0xcd00>;
> interrupt-names = "host", "peripheral";
> interrupts = <0 134 4>, <0 135 4>;
> phys = <_hsphy>, <_ssphy0>, <_ssphy1>;
> dr_mode = "host";
> };
>
> usb0_ssphy0: ss-phy0@65b00300 {
> compatible = "socionext,uniphier-dwc3-ssphy";
> reg = <0x65b00300 0x10>;
> #phy-cells = <0>;
> clocks = <_clk 17>;
> resets = <_rst 17>;
> port-supply = <_vbus0>;
> };
>
> usb0_ssphy1: ss-phy1@65b00310 {
> compatible = "socionext,uniphier-dwc3-ssphy";
> reg = <0x65b00310 0x10>;
> #phy-cells = <0>;
> clocks = <_clk 18>;
> resets = <_rst 18>;
> port-supply = <_vbus1>;
> };
>
>
>
>
> [ instance 1 (with 1 SS PHY) ]
>
> usb0: dwc3@65c0 {
> compatible = "snps,dwc3";
> reg = <0x65c0 0xcd00>;
> interrupt-names = "host", "peripheral";
> interrupts = <0 137 4>, <0 

Re: Multiple generic PHY instances for DWC3 USB IP

2018-04-03 Thread Felipe Balbi

Hi,

Masahiro Yamada  writes:
> Currently, DWC3 core IP (drivers/usb/dwc3/core.c)
> can take only one PHY phandle for each of SS, HS.
> (phy-names DT property is "usb2-phy" and "usb3-phy" for each)

We never had any other requirements :-)

> The DWC3 core IP is provided by Synopsys,
> but some SoC-dependent parts (a.k.a glue-layer)
> are implemented by SoC venders.
>
> The number of connected PHY instances are SoC-dependent.
>
> If you look at generic drivers such as
>   drivers/usb/host/ehci-platform.c
> the driver can handle arbitrary number of PHY instances.
>
> However, as mentioned above, DWC3 core allows only one PHY phandle
> for each SS/HS.
> This can result in a strange DT structure.
>
> For example, Socionext PXs3 SoC is integrated with 2 instances of DWC3.
>
> The instance 0 of DWC3 is connected with 2 super-speed PHYs.

why 2 super-speed phys? Is this a two-port host-only implementation?

> The instance 1 of DWC3 is connected with 1 super-speed PHY.

Are both of these instances incapable of high/full/low-speed
communication?

> According to the feed-back from Felipe Balbe,
> (https://patchwork.kernel.org/patch/10180167/)
> Socionext is trying to split the glue layer into small chunks.
>
>
> The following is the DT under internal review of Socionext.
> The full DT is super long, so
> here is only snippet for the SS PHY parts.
>
>
> [ instance 0  (with 2 SS PHYs) ]
>
> dwc3@65a0 {
> compatible = "snps,dwc3";
> reg = <0x65a0 0xcd00>;
> interrupt-names = "host", "peripheral";
> interrupts = <0 134 4>, <0 135 4>;
> phy-names = "usb2-phy", "usb3-phy";
> phys = <_hsphy>, <_ssphy>;
> dr_mode = "host";
> };
>
> usb0_ssphy: ss-phy {
> compatible = "socionext,uniphier-pxs3-usb3-ssphy";
> #address-cells = <1>;
> #size-cells = <0>;
> #phy-cells = <0>;
> clock-names = "phy-clk0", "phy-clk1";
> clocks = <_clk 17>, <_clk 18>;
> reset-names = "phy-rst0", "phy-rst1";
> resets = <_rst 17>, <_rst 18>;
> port0-supply = <_vbus0>;
> port1-supply = <_vbus1>;
>
> port@0 {
> reg = <0>;
> };
> port@1 {
> reg = <1>;
> };
> };
>
> [ instance 1 (with 1 SS PHY) ]
>
> dwc3@65c0 {
> compatible = "snps,dwc3";
> reg = <0x65c0 0xcd00>;
> interrupt-names = "host", "peripheral";
> interrupts = <0 137 4>, <0 138 4>;
> phy-names = "usb2-phy", "usb3-phy";
> phys = <_hsphy>, <_ssphy>;
> dr_mode = "host";
> };
>
> usb1_ssphy: ss-phy {
> compatible = "socionext,uniphier-pxs3-usb3-ssphy";
> #address-cells = <1>;
> #size-cells = <0>;
> #phy-cells = <0>;
> clock-names = "phy-clk0";
> clocks = <_clk 21>;
> reset-names = "phy-rst0";
> resets = <_rst 21>;
> port0-supply = <_vbus0>;
>
> port@0 {
>  reg = <0>;
> };
> };
>
>
> I think this is strange, but the PHY driver
> counts the number of sub-nodes ("port@0", "port@1" ...)
> and iterate the port settings.
>
>
>
>
>
> In my opinion, the structure like follows
> will be more natural.
> (flattening homogeneous PHY nodes)
>
>
> [ instance 0 (with 2 SS PHYs)]
>
> dwc3@65a0 {
> compatible = "snps,dwc3";
> reg = <0x65a0 0xcd00>;
> interrupt-names = "host", "peripheral";
> interrupts = <0 134 4>, <0 135 4>;
> phys = <_hsphy>, <_ssphy0>, <_ssphy1>;
> dr_mode = "host";
> };
>
> usb0_ssphy0: ss-phy0@65b00300 {
> compatible = "socionext,uniphier-dwc3-ssphy";
> reg = <0x65b00300 0x10>;
> #phy-cells = <0>;
> clocks = <_clk 17>;
> resets = <_rst 17>;
> port-supply = <_vbus0>;
> };
>
> usb0_ssphy1: ss-phy1@65b00310 {
> compatible = "socionext,uniphier-dwc3-ssphy";
> reg = <0x65b00310 0x10>;
> #phy-cells = <0>;
> clocks = <_clk 18>;
> resets = <_rst 18>;
> port-supply = <_vbus1>;
> };
>
>
>
>
> [ instance 1 (with 1 SS PHY) ]
>
> usb0: dwc3@65c0 {
> compatible = "snps,dwc3";
> reg = <0x65c0 0xcd00>;
> interrupt-names = "host", "peripheral";
> interrupts = <0 137 4>, <0 138 4>;
> phys 

[tip:perf/urgent] perf trace: Remove redundant ')'

2018-04-03 Thread tip-bot for Changbin Du
Commit-ID:  51125a29a395048fdb3429b8c4ca0ada57097744
Gitweb: https://git.kernel.org/tip/51125a29a395048fdb3429b8c4ca0ada57097744
Author: Changbin Du 
AuthorDate: Tue, 13 Mar 2018 18:40:01 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 16:16:41 -0300

perf trace: Remove redundant ')'

There is a redundant ')' at the tail of each event. So remove it.

$ sudo perf trace --no-syscalls -e 'kmem:*' -a
   899.342 kmem:kfree:(vfs_writev+0xb9) call_site=9c453979 ptr=(nil))
   899.344 kmem:kfree:(___sys_recvmsg+0x188) call_site=9c9b8b88 
ptr=(nil))

Signed-off-by: Changbin Du 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1520937601-24952-1-git-send-email-changbin...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 4e03f0f68241..3ad17ee89403 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1962,7 +1962,7 @@ static int trace__event_handler(struct trace *trace, 
struct perf_evsel *evsel,
  trace->output);
}
 
-   fprintf(trace->output, ")\n");
+   fprintf(trace->output, "\n");
 
if (callchain_ret > 0)
trace__fprintf_callchain(trace, sample);


[tip:perf/urgent] perf trace: Remove redundant ')'

2018-04-03 Thread tip-bot for Changbin Du
Commit-ID:  51125a29a395048fdb3429b8c4ca0ada57097744
Gitweb: https://git.kernel.org/tip/51125a29a395048fdb3429b8c4ca0ada57097744
Author: Changbin Du 
AuthorDate: Tue, 13 Mar 2018 18:40:01 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 16:16:41 -0300

perf trace: Remove redundant ')'

There is a redundant ')' at the tail of each event. So remove it.

$ sudo perf trace --no-syscalls -e 'kmem:*' -a
   899.342 kmem:kfree:(vfs_writev+0xb9) call_site=9c453979 ptr=(nil))
   899.344 kmem:kfree:(___sys_recvmsg+0x188) call_site=9c9b8b88 
ptr=(nil))

Signed-off-by: Changbin Du 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1520937601-24952-1-git-send-email-changbin...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 4e03f0f68241..3ad17ee89403 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1962,7 +1962,7 @@ static int trace__event_handler(struct trace *trace, 
struct perf_evsel *evsel,
  trace->output);
}
 
-   fprintf(trace->output, ")\n");
+   fprintf(trace->output, "\n");
 
if (callchain_ret > 0)
trace__fprintf_callchain(trace, sample);


[tip:perf/urgent] perf annotate stdio2: Print more descriptive event information header

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  520d3f01ea5322edeedff4bb25a0aff07ad72d43
Gitweb: https://git.kernel.org/tip/520d3f01ea5322edeedff4bb25a0aff07ad72d43
Author: Arnaldo Carvalho de Melo 
AuthorDate: Mon, 2 Apr 2018 16:42:01 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 16:05:13 -0300

perf annotate stdio2: Print more descriptive event information header

To match the recently added event header information to --tui, e.g.:

  # perf annotate --ignore-vmlinux --stdio2 _raw_spin_lock_irqsave
  Samples: 128  of event 'cycles:ppp', 4000 Hz, Event count (approx.): 48617682
  _raw_spin_lock_irqsave() /proc/kcore
0.78nop
7.03push   %rbx
3.12pushfq
6.25pop%rax
nop
mov%rax,%rbx
3.12cli
nop
xor%eax,%eax
mov$0x1,%edx
   79.69lock   cmpxchg %edx,(%rdi)
test   %eax,%eax
  ↓ jne2b
mov%rbx,%rax
pop%rbx
  ← retq
  2b:   mov%eax,%esi
  → callq  *b30eaed0
mov%rbx,%rax
pop%rbx
  ← retq
  #

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Martin Liška 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-ujy46x7cldyhyxelyf2b9...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index b956bb7eabcf..fffe16af9797 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -2325,7 +2325,7 @@ int symbol__tty_annotate2(struct symbol *sym, struct map 
*map,
struct dso *dso = map->dso;
struct rb_root source_line = RB_ROOT;
struct annotation_options opts = annotation__default_options;
-   const char *ev_name = perf_evsel__name(evsel);
+   struct annotation *notes = symbol__annotation(sym);
char buf[1024];
 
if (symbol__annotate2(sym, map, evsel, , NULL) < 0)
@@ -2337,12 +2337,8 @@ int symbol__tty_annotate2(struct symbol *sym, struct map 
*map,
print_summary(_line, dso->long_name);
}
 
-   if (perf_evsel__is_group_event(evsel)) {
-   perf_evsel__group_desc(evsel, buf, sizeof(buf));
-   ev_name = buf;
-   }
-
-   fprintf(stdout, "%s() %s\nEvent: %s\n\n", sym->name, dso->long_name, 
ev_name);
+   annotation__scnprintf_samples_period(notes, buf, sizeof(buf), evsel);
+   fprintf(stdout, "%s\n%s() %s\n", buf, sym->name, dso->long_name);
symbol__annotate_fprintf2(sym, stdout);
 
annotated_source__purge(symbol__annotation(sym)->src);


[tip:perf/urgent] perf annotate stdio2: Print more descriptive event information header

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  520d3f01ea5322edeedff4bb25a0aff07ad72d43
Gitweb: https://git.kernel.org/tip/520d3f01ea5322edeedff4bb25a0aff07ad72d43
Author: Arnaldo Carvalho de Melo 
AuthorDate: Mon, 2 Apr 2018 16:42:01 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 16:05:13 -0300

perf annotate stdio2: Print more descriptive event information header

To match the recently added event header information to --tui, e.g.:

  # perf annotate --ignore-vmlinux --stdio2 _raw_spin_lock_irqsave
  Samples: 128  of event 'cycles:ppp', 4000 Hz, Event count (approx.): 48617682
  _raw_spin_lock_irqsave() /proc/kcore
0.78nop
7.03push   %rbx
3.12pushfq
6.25pop%rax
nop
mov%rax,%rbx
3.12cli
nop
xor%eax,%eax
mov$0x1,%edx
   79.69lock   cmpxchg %edx,(%rdi)
test   %eax,%eax
  ↓ jne2b
mov%rbx,%rax
pop%rbx
  ← retq
  2b:   mov%eax,%esi
  → callq  *b30eaed0
mov%rbx,%rax
pop%rbx
  ← retq
  #

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Martin Liška 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-ujy46x7cldyhyxelyf2b9...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index b956bb7eabcf..fffe16af9797 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -2325,7 +2325,7 @@ int symbol__tty_annotate2(struct symbol *sym, struct map 
*map,
struct dso *dso = map->dso;
struct rb_root source_line = RB_ROOT;
struct annotation_options opts = annotation__default_options;
-   const char *ev_name = perf_evsel__name(evsel);
+   struct annotation *notes = symbol__annotation(sym);
char buf[1024];
 
if (symbol__annotate2(sym, map, evsel, , NULL) < 0)
@@ -2337,12 +2337,8 @@ int symbol__tty_annotate2(struct symbol *sym, struct map 
*map,
print_summary(_line, dso->long_name);
}
 
-   if (perf_evsel__is_group_event(evsel)) {
-   perf_evsel__group_desc(evsel, buf, sizeof(buf));
-   ev_name = buf;
-   }
-
-   fprintf(stdout, "%s() %s\nEvent: %s\n\n", sym->name, dso->long_name, 
ev_name);
+   annotation__scnprintf_samples_period(notes, buf, sizeof(buf), evsel);
+   fprintf(stdout, "%s\n%s() %s\n", buf, sym->name, dso->long_name);
symbol__annotate_fprintf2(sym, stdout);
 
annotated_source__purge(symbol__annotation(sym)->src);


[tip:perf/urgent] perf annotate browser: Show extra title line with event information

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  6920e2854e9a16226ca57199d48fd6b68819f6d5
Gitweb: https://git.kernel.org/tip/6920e2854e9a16226ca57199d48fd6b68819f6d5
Author: Arnaldo Carvalho de Melo 
AuthorDate: Mon, 2 Apr 2018 16:18:45 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 15:23:11 -0300

perf annotate browser: Show extra title line with event information

So at the top we'll have two lines, like this, from 'perf report':

  # perf report --group --ignore-vmlinux
=
Samples: 46  of events 'cycles', 4000 Hz, Event count (approx.): 5154895
_raw_spin_lock_irqsave  /proc/kcore
Percent  │  nop
 │  push   %rbx
  0.00  14.29   0.00 │  pushfq
  9.09   0.00   0.00 │  pop%rax
  9.09   0.00  20.00 │  nop
 │  mov%rax,%rbx
 │  cli
  4.55   7.14   0.00 │  nop
 │  xor%eax,%eax
 │  mov$0x1,%edx
 │  lock   cmpxchg %edx,(%rdi)
 77.27  78.57  70.00 │  test   %eax,%eax
 │↓ jne2b
 │  mov%rbx,%rax
  0.00   0.00  10.00 │  pop%rbx
 │← retq
 │2b:   mov%eax,%esi
 │→ callq  queued_spin_lock_slowpath
 │  mov%rbx,%rax
 │  pop%rbx
Press 'h' for help on│key bindings
=

 9.09 + 9.09 + 4.55 + 77.27 = 100
14.29 + 7.14 + 78.57 = 100
20 + 70 + 10 = 100

We can do the math by using 't' to toggle from 'percent' to nr

=
Samples: 46  of events 'cycles', 4000 Hz, Event count (approx.): 5154895
_raw_spin_lock_irqsave  /proc/kcore
Period  │  nop
│  push   %rbx
  0   79273   0 │  pushfq
 190455   0   0 │  pop%rax
 198038   03045 │  nop
│  mov%rax,%rbx
│  cli
 217233   32562   0 │  nop
│  xor%eax,%eax
│  mov$0x1,%edx
│  lock   cmpxchg %edx,(%rdi)
3421649  979174   28273 │  test   %eax,%eax
│↓ jne2b
│  mov%rbx,%rax
  0   05193 │  pop%rbx
│← retq
│2b:   mov%eax,%esi
│→ callq  queued_spin_lock_slowpath
│  mov%rbx,%rax
│  pop%rbx
Press 'h' for help on│key bindings
=

79273 + 190455 + 198038 + 3045 + 217233 + 32562 + 3421649 + 979174 + 28273 + 
5193 = 5154895

Or number of samples:

=
ooSamples: 46  of events 'cycles', 4000 Hz, Event count (approx.): 5154895
_raw_spin_lock_irqsave  /proc/kcore
Samples  │  nop
 │  push   %rbx
 0  2  0 │  pushfq
 2  0  0 │  pop%rax
 2  0  2 │  nop
 │  mov%rax,%rbx
 │  cli
 1  1  0 │  nop
 │  xor%eax,%eax
 │  mov$0x1,%edx
 │  lock   cmpxchg %edx,(%rdi)
17 11  7 │  test   %eax,%eax
 │↓ jne2b
 │  mov%rbx,%rax
 0  0  1 │  pop%rbx
 │← retq
 │2b:   mov%eax,%esi
 │→ callq  queued_spin_lock_slowpath
 │  mov%rbx,%rax
 │  pop%rbx
Press 'h' for help on key bindings
=

2 + 2 + 2 + 2 + 1 + 1 + 17 + 11 + 7 + 1 = 46

Suggested-by: Martin Liška 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Namhyung Kim 
Cc: Wang Nan 
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
Link: 

[tip:perf/urgent] perf annotate browser: Show extra title line with event information

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  6920e2854e9a16226ca57199d48fd6b68819f6d5
Gitweb: https://git.kernel.org/tip/6920e2854e9a16226ca57199d48fd6b68819f6d5
Author: Arnaldo Carvalho de Melo 
AuthorDate: Mon, 2 Apr 2018 16:18:45 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 15:23:11 -0300

perf annotate browser: Show extra title line with event information

So at the top we'll have two lines, like this, from 'perf report':

  # perf report --group --ignore-vmlinux
=
Samples: 46  of events 'cycles', 4000 Hz, Event count (approx.): 5154895
_raw_spin_lock_irqsave  /proc/kcore
Percent  │  nop
 │  push   %rbx
  0.00  14.29   0.00 │  pushfq
  9.09   0.00   0.00 │  pop%rax
  9.09   0.00  20.00 │  nop
 │  mov%rax,%rbx
 │  cli
  4.55   7.14   0.00 │  nop
 │  xor%eax,%eax
 │  mov$0x1,%edx
 │  lock   cmpxchg %edx,(%rdi)
 77.27  78.57  70.00 │  test   %eax,%eax
 │↓ jne2b
 │  mov%rbx,%rax
  0.00   0.00  10.00 │  pop%rbx
 │← retq
 │2b:   mov%eax,%esi
 │→ callq  queued_spin_lock_slowpath
 │  mov%rbx,%rax
 │  pop%rbx
Press 'h' for help on│key bindings
=

 9.09 + 9.09 + 4.55 + 77.27 = 100
14.29 + 7.14 + 78.57 = 100
20 + 70 + 10 = 100

We can do the math by using 't' to toggle from 'percent' to nr

=
Samples: 46  of events 'cycles', 4000 Hz, Event count (approx.): 5154895
_raw_spin_lock_irqsave  /proc/kcore
Period  │  nop
│  push   %rbx
  0   79273   0 │  pushfq
 190455   0   0 │  pop%rax
 198038   03045 │  nop
│  mov%rax,%rbx
│  cli
 217233   32562   0 │  nop
│  xor%eax,%eax
│  mov$0x1,%edx
│  lock   cmpxchg %edx,(%rdi)
3421649  979174   28273 │  test   %eax,%eax
│↓ jne2b
│  mov%rbx,%rax
  0   05193 │  pop%rbx
│← retq
│2b:   mov%eax,%esi
│→ callq  queued_spin_lock_slowpath
│  mov%rbx,%rax
│  pop%rbx
Press 'h' for help on│key bindings
=

79273 + 190455 + 198038 + 3045 + 217233 + 32562 + 3421649 + 979174 + 28273 + 
5193 = 5154895

Or number of samples:

=
ooSamples: 46  of events 'cycles', 4000 Hz, Event count (approx.): 5154895
_raw_spin_lock_irqsave  /proc/kcore
Samples  │  nop
 │  push   %rbx
 0  2  0 │  pushfq
 2  0  0 │  pop%rax
 2  0  2 │  nop
 │  mov%rax,%rbx
 │  cli
 1  1  0 │  nop
 │  xor%eax,%eax
 │  mov$0x1,%edx
 │  lock   cmpxchg %edx,(%rdi)
17 11  7 │  test   %eax,%eax
 │↓ jne2b
 │  mov%rbx,%rax
 0  0  1 │  pop%rbx
 │← retq
 │2b:   mov%eax,%esi
 │→ callq  queued_spin_lock_slowpath
 │  mov%rbx,%rax
 │  pop%rbx
Press 'h' for help on key bindings
=

2 + 2 + 2 + 2 + 1 + 1 + 17 + 11 + 7 + 1 = 46

Suggested-by: Martin Liška 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Namhyung Kim 
Cc: Wang Nan 
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
Link: https://lkml.kernel.org/n/tip-ezccyxld50wtwyt66np6a...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/annotate.c | 31 +++
 1 file 

Re: [RFC] prctl: Deprecate non PR_SET_MM_MAP operations

2018-04-03 Thread Michal Hocko
On Tue 03-04-18 16:15:20, Yang Shi wrote:
> 
> 
> On 4/3/18 3:37 PM, Cyrill Gorcunov wrote:
> > An ability to manipulate mm_struct fields was introduced in
> > sake of CRIU in first place. Later we provide more suitable
> > and safe operation PR_SET_MM_MAP where all fields to be modifed
> > are passed in one structure which allows us to make more detailed
> > verification.
> > 
> > Still old interface remains present for compatibility reason
> > though CRIU itself already switched to PR_SET_MM_MAP on its
> > own long ago.
> > 
> > Googling didn't reveal some other users of this operation
> > so I think it should be safe to issue deprecation warning
> > first time and get rid of this interface after a couple
> > of releases.
> > 
> > CC: Andrey Vagin 
> > CC: Andrew Morton 
> > CC: Pavel Emelyanov 
> > CC: Michael Kerrisk 
> > CC: Yang Shi 
> > CC: Michal Hocko 
> > Signed-off-by: Cyrill Gorcunov 
> > ---
> > Or we can simply drop it off because PR_SET_MM_MAP covers all needs,
> > and I would rather prefer to do that asap.
> 
> Thanks for making it deprecated. I'd prefer just drop it off if nobody
> objects. The change will get soaked in linux-next for a while , we will know
> if it breaks compatibility (it sounds very unlikely).

Yeah, let's just drop it and have the patch in linux-next (via mmotm)
for 2 release cycles and see whether somebody complains.

You can add
Acked-by: Michal Hocko 
for such a patch.
-- 
Michal Hocko
SUSE Labs


Re: [RFC] prctl: Deprecate non PR_SET_MM_MAP operations

2018-04-03 Thread Michal Hocko
On Tue 03-04-18 16:15:20, Yang Shi wrote:
> 
> 
> On 4/3/18 3:37 PM, Cyrill Gorcunov wrote:
> > An ability to manipulate mm_struct fields was introduced in
> > sake of CRIU in first place. Later we provide more suitable
> > and safe operation PR_SET_MM_MAP where all fields to be modifed
> > are passed in one structure which allows us to make more detailed
> > verification.
> > 
> > Still old interface remains present for compatibility reason
> > though CRIU itself already switched to PR_SET_MM_MAP on its
> > own long ago.
> > 
> > Googling didn't reveal some other users of this operation
> > so I think it should be safe to issue deprecation warning
> > first time and get rid of this interface after a couple
> > of releases.
> > 
> > CC: Andrey Vagin 
> > CC: Andrew Morton 
> > CC: Pavel Emelyanov 
> > CC: Michael Kerrisk 
> > CC: Yang Shi 
> > CC: Michal Hocko 
> > Signed-off-by: Cyrill Gorcunov 
> > ---
> > Or we can simply drop it off because PR_SET_MM_MAP covers all needs,
> > and I would rather prefer to do that asap.
> 
> Thanks for making it deprecated. I'd prefer just drop it off if nobody
> objects. The change will get soaked in linux-next for a while , we will know
> if it breaks compatibility (it sounds very unlikely).

Yeah, let's just drop it and have the patch in linux-next (via mmotm)
for 2 release cycles and see whether somebody complains.

You can add
Acked-by: Michal Hocko 
for such a patch.
-- 
Michal Hocko
SUSE Labs


[tip:perf/urgent] perf annotate: Introduce annotation__scnprintf_samples_period() method

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  b213eac245aa2d29a3b9dd90f3b96ab182337ee8
Gitweb: https://git.kernel.org/tip/b213eac245aa2d29a3b9dd90f3b96ab182337ee8
Author: Arnaldo Carvalho de Melo 
AuthorDate: Tue, 3 Apr 2018 15:19:47 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 15:22:55 -0300

perf annotate: Introduce annotation__scnprintf_samples_period() method

To print a string using the total period (nr_events) and the number of
samples for a given annotation, i.e. for a given symbol, the counterpart
to hists__scnprintf_samples_period(), that is for all the samples in a
session (be it a live session, think 'perf top' or a perf.data file,
think 'perf report').

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Martin Liška 
Cc: Namhyung Kim 
Cc: Wang Nan 
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
Link: https://lkml.kernel.org/n/tip-goj2wu4fxutc8vd46mw3y...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 38 ++
 tools/perf/util/annotate.h | 12 
 2 files changed, 50 insertions(+)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 3a428d7c59b9..b956bb7eabcf 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -17,6 +17,7 @@
 #include "config.h"
 #include "cache.h"
 #include "symbol.h"
+#include "units.h"
 #include "debug.h"
 #include "annotate.h"
 #include "evsel.h"
@@ -2597,6 +2598,43 @@ out_free_offsets:
return -1;
 }
 
+int __annotation__scnprintf_samples_period(struct annotation *notes,
+  char *bf, size_t size,
+  struct perf_evsel *evsel,
+  bool show_freq)
+{
+   const char *ev_name = perf_evsel__name(evsel);
+   char ref[30] = " show reference callgraph, ";
+   char sample_freq_str[64] = "";
+   unsigned long nr_samples = 0;
+   int nr_members = 1;
+   bool enable_ref = false;
+   u64 nr_events = 0;
+   char unit;
+   int i;
+
+   if (perf_evsel__is_group_event(evsel))
+nr_members = evsel->nr_members;
+
+   for (i = 0; i < nr_members; i++) {
+   struct sym_hist *ah = annotation__histogram(notes, evsel->idx + 
i);
+
+   nr_samples += ah->nr_samples;
+   nr_events  += ah->period;
+   }
+
+   if (symbol_conf.show_ref_callgraph && strstr(ev_name, "call-graph=no"))
+   enable_ref = true;
+
+   if (show_freq)
+   scnprintf(sample_freq_str, sizeof(sample_freq_str), " %d Hz,", 
evsel->attr.sample_freq);
+
+   nr_samples = convert_unit(nr_samples, );
+   return scnprintf(bf, size, "Samples: %lu%c of event%s '%s',%s%sEvent 
count (approx.): %" PRIu64,
+nr_samples, unit, evsel->nr_members > 1 ? "s" : "",
+ev_name, sample_freq_str, enable_ref ? ref : " ", 
nr_events);
+}
+
 #define ANNOTATION__CFG(n) \
{ .name = #n, .value = __default_options.n, }
 
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index ff7e3df31efa..db8d09bea07e 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -151,6 +151,18 @@ double annotation_line__max_percent(struct annotation_line 
*al, struct annotatio
 void annotation_line__write(struct annotation_line *al, struct annotation 
*notes,
struct annotation_write_ops *ops);
 
+int __annotation__scnprintf_samples_period(struct annotation *notes,
+  char *bf, size_t size,
+  struct perf_evsel *evsel,
+  bool show_freq);
+
+static inline int annotation__scnprintf_samples_period(struct annotation 
*notes,
+  char *bf, size_t size,
+  struct perf_evsel *evsel)
+{
+   return __annotation__scnprintf_samples_period(notes, bf, size, evsel, 
true);
+}
+
 int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool 
raw);
 size_t disasm__fprintf(struct list_head *head, FILE *fp);
 void symbol__calc_percent(struct symbol *sym, struct perf_evsel *evsel);


[tip:perf/urgent] perf annotate: Introduce annotation__scnprintf_samples_period() method

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  b213eac245aa2d29a3b9dd90f3b96ab182337ee8
Gitweb: https://git.kernel.org/tip/b213eac245aa2d29a3b9dd90f3b96ab182337ee8
Author: Arnaldo Carvalho de Melo 
AuthorDate: Tue, 3 Apr 2018 15:19:47 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 15:22:55 -0300

perf annotate: Introduce annotation__scnprintf_samples_period() method

To print a string using the total period (nr_events) and the number of
samples for a given annotation, i.e. for a given symbol, the counterpart
to hists__scnprintf_samples_period(), that is for all the samples in a
session (be it a live session, think 'perf top' or a perf.data file,
think 'perf report').

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Martin Liška 
Cc: Namhyung Kim 
Cc: Wang Nan 
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
Link: https://lkml.kernel.org/n/tip-goj2wu4fxutc8vd46mw3y...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 38 ++
 tools/perf/util/annotate.h | 12 
 2 files changed, 50 insertions(+)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 3a428d7c59b9..b956bb7eabcf 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -17,6 +17,7 @@
 #include "config.h"
 #include "cache.h"
 #include "symbol.h"
+#include "units.h"
 #include "debug.h"
 #include "annotate.h"
 #include "evsel.h"
@@ -2597,6 +2598,43 @@ out_free_offsets:
return -1;
 }
 
+int __annotation__scnprintf_samples_period(struct annotation *notes,
+  char *bf, size_t size,
+  struct perf_evsel *evsel,
+  bool show_freq)
+{
+   const char *ev_name = perf_evsel__name(evsel);
+   char ref[30] = " show reference callgraph, ";
+   char sample_freq_str[64] = "";
+   unsigned long nr_samples = 0;
+   int nr_members = 1;
+   bool enable_ref = false;
+   u64 nr_events = 0;
+   char unit;
+   int i;
+
+   if (perf_evsel__is_group_event(evsel))
+nr_members = evsel->nr_members;
+
+   for (i = 0; i < nr_members; i++) {
+   struct sym_hist *ah = annotation__histogram(notes, evsel->idx + 
i);
+
+   nr_samples += ah->nr_samples;
+   nr_events  += ah->period;
+   }
+
+   if (symbol_conf.show_ref_callgraph && strstr(ev_name, "call-graph=no"))
+   enable_ref = true;
+
+   if (show_freq)
+   scnprintf(sample_freq_str, sizeof(sample_freq_str), " %d Hz,", 
evsel->attr.sample_freq);
+
+   nr_samples = convert_unit(nr_samples, );
+   return scnprintf(bf, size, "Samples: %lu%c of event%s '%s',%s%sEvent 
count (approx.): %" PRIu64,
+nr_samples, unit, evsel->nr_members > 1 ? "s" : "",
+ev_name, sample_freq_str, enable_ref ? ref : " ", 
nr_events);
+}
+
 #define ANNOTATION__CFG(n) \
{ .name = #n, .value = __default_options.n, }
 
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index ff7e3df31efa..db8d09bea07e 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -151,6 +151,18 @@ double annotation_line__max_percent(struct annotation_line 
*al, struct annotatio
 void annotation_line__write(struct annotation_line *al, struct annotation 
*notes,
struct annotation_write_ops *ops);
 
+int __annotation__scnprintf_samples_period(struct annotation *notes,
+  char *bf, size_t size,
+  struct perf_evsel *evsel,
+  bool show_freq);
+
+static inline int annotation__scnprintf_samples_period(struct annotation 
*notes,
+  char *bf, size_t size,
+  struct perf_evsel *evsel)
+{
+   return __annotation__scnprintf_samples_period(notes, bf, size, evsel, 
true);
+}
+
 int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool 
raw);
 size_t disasm__fprintf(struct list_head *head, FILE *fp);
 void symbol__calc_percent(struct symbol *sym, struct perf_evsel *evsel);


[tip:perf/urgent] perf ui browser: Move the extra title lines from the hists browser

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  ef9ff6017e3c4593f3efa5776784cb417c58ad6c
Gitweb: https://git.kernel.org/tip/ef9ff6017e3c4593f3efa5776784cb417c58ad6c
Author: Arnaldo Carvalho de Melo 
AuthorDate: Mon, 2 Apr 2018 15:48:18 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 10:24:26 -0300

perf ui browser: Move the extra title lines from the hists browser

This will be useful for the annotate browser as well, that wants to have
extra title lines, i.e. the current ui_browser unconditionally reserves
the first line for a browser title and the last one for status messages.

But some browsers, like the buckets one (hists browser) needs extra
lines to show headers, allowing it to be shown or not, press 'H' in
'perf top' or 'perf report' to see this feature.

So move that logic to the core ui_browser used by the hists_browser
('perf top' and 'perf report' main interface) so that it can be used by
the annotate browser too.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Martin Liška 
Cc: Namhyung Kim 
Cc: Wang Nan 
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
Link: https://lkml.kernel.org/n/tip-r38xm3ut37ulbg1o5tn5i...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browser.c|  8 +++-
 tools/perf/ui/browser.h|  2 ++
 tools/perf/ui/browsers/hists.c | 43 +++---
 3 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index 9f6ce29b83b4..d7bb2591838e 100644
--- a/tools/perf/ui/browser.c
+++ b/tools/perf/ui/browser.c
@@ -45,11 +45,16 @@ void ui_browser__set_percent_color(struct ui_browser 
*browser,
 ui_browser__set_color(browser, color);
 }
 
-void ui_browser__gotorc(struct ui_browser *browser, int y, int x)
+void ui_browser__gotorc_title(struct ui_browser *browser, int y, int x)
 {
SLsmg_gotorc(browser->y + y, browser->x + x);
 }
 
+void ui_browser__gotorc(struct ui_browser *browser, int y, int x)
+{
+   SLsmg_gotorc(browser->y + y + browser->extra_title_lines, browser->x + 
x);
+}
+
 void ui_browser__write_nstring(struct ui_browser *browser __maybe_unused, 
const char *msg,
   unsigned int width)
 {
@@ -191,6 +196,7 @@ void ui_browser__refresh_dimensions(struct ui_browser 
*browser)
 {
browser->width = SLtt_Screen_Cols - 1;
browser->height = browser->rows = SLtt_Screen_Rows - 2;
+   browser->rows -= browser->extra_title_lines;
browser->y = 1;
browser->x = 0;
 }
diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h
index 70057178ee34..aa5932e1d62e 100644
--- a/tools/perf/ui/browser.h
+++ b/tools/perf/ui/browser.h
@@ -17,6 +17,7 @@ struct ui_browser {
u64   index, top_idx;
void  *top, *entries;
u16   y, x, width, height, rows, columns, horiz_scroll;
+   u8extra_title_lines;
int   current_color;
void  *priv;
const char*title;
@@ -38,6 +39,7 @@ bool ui_browser__is_current_entry(struct ui_browser *browser, 
unsigned row);
 void ui_browser__refresh_dimensions(struct ui_browser *browser);
 void ui_browser__reset_index(struct ui_browser *browser);
 
+void ui_browser__gotorc_title(struct ui_browser *browser, int y, int x);
 void ui_browser__gotorc(struct ui_browser *browser, int y, int x);
 void ui_browser__write_nstring(struct ui_browser *browser, const char *msg,
   unsigned int width);
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index cde9bab5061d..b06afb8f51fb 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -61,6 +61,15 @@ static int hist_browser__get_folding(struct hist_browser 
*browser)
return unfolded_rows;
 }
 
+static void hist_browser__set_title_space(struct hist_browser *hb)
+{
+   struct ui_browser *browser = >b;
+   struct hists *hists = hb->hists;
+   struct perf_hpp_list *hpp_list = hists->hpp_list;
+
+   browser->extra_title_lines = hb->show_headers ? 
hpp_list->nr_header_lines : 0;
+}
+
 static u32 hist_browser__nr_entries(struct hist_browser *hb)
 {
u32 nr_entries;
@@ -81,10 +90,16 @@ static void hist_browser__update_rows(struct hist_browser 
*hb)
struct ui_browser *browser = >b;
struct hists *hists = hb->hists;
struct perf_hpp_list *hpp_list = hists->hpp_list;
-   u16 header_offset, index_row;
+   u16 index_row;
+
+   if (!hb->show_headers) {
+   browser->rows += browser->extra_title_lines;
+   browser->extra_title_lines = 0;
+   return;
+   }
 
-   header_offset = hb->show_headers ? hpp_list->nr_header_lines : 0;
-   browser->rows = browser->height - 

[tip:perf/urgent] perf ui browser: Move the extra title lines from the hists browser

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  ef9ff6017e3c4593f3efa5776784cb417c58ad6c
Gitweb: https://git.kernel.org/tip/ef9ff6017e3c4593f3efa5776784cb417c58ad6c
Author: Arnaldo Carvalho de Melo 
AuthorDate: Mon, 2 Apr 2018 15:48:18 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 10:24:26 -0300

perf ui browser: Move the extra title lines from the hists browser

This will be useful for the annotate browser as well, that wants to have
extra title lines, i.e. the current ui_browser unconditionally reserves
the first line for a browser title and the last one for status messages.

But some browsers, like the buckets one (hists browser) needs extra
lines to show headers, allowing it to be shown or not, press 'H' in
'perf top' or 'perf report' to see this feature.

So move that logic to the core ui_browser used by the hists_browser
('perf top' and 'perf report' main interface) so that it can be used by
the annotate browser too.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Martin Liška 
Cc: Namhyung Kim 
Cc: Wang Nan 
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
Link: https://lkml.kernel.org/n/tip-r38xm3ut37ulbg1o5tn5i...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browser.c|  8 +++-
 tools/perf/ui/browser.h|  2 ++
 tools/perf/ui/browsers/hists.c | 43 +++---
 3 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index 9f6ce29b83b4..d7bb2591838e 100644
--- a/tools/perf/ui/browser.c
+++ b/tools/perf/ui/browser.c
@@ -45,11 +45,16 @@ void ui_browser__set_percent_color(struct ui_browser 
*browser,
 ui_browser__set_color(browser, color);
 }
 
-void ui_browser__gotorc(struct ui_browser *browser, int y, int x)
+void ui_browser__gotorc_title(struct ui_browser *browser, int y, int x)
 {
SLsmg_gotorc(browser->y + y, browser->x + x);
 }
 
+void ui_browser__gotorc(struct ui_browser *browser, int y, int x)
+{
+   SLsmg_gotorc(browser->y + y + browser->extra_title_lines, browser->x + 
x);
+}
+
 void ui_browser__write_nstring(struct ui_browser *browser __maybe_unused, 
const char *msg,
   unsigned int width)
 {
@@ -191,6 +196,7 @@ void ui_browser__refresh_dimensions(struct ui_browser 
*browser)
 {
browser->width = SLtt_Screen_Cols - 1;
browser->height = browser->rows = SLtt_Screen_Rows - 2;
+   browser->rows -= browser->extra_title_lines;
browser->y = 1;
browser->x = 0;
 }
diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h
index 70057178ee34..aa5932e1d62e 100644
--- a/tools/perf/ui/browser.h
+++ b/tools/perf/ui/browser.h
@@ -17,6 +17,7 @@ struct ui_browser {
u64   index, top_idx;
void  *top, *entries;
u16   y, x, width, height, rows, columns, horiz_scroll;
+   u8extra_title_lines;
int   current_color;
void  *priv;
const char*title;
@@ -38,6 +39,7 @@ bool ui_browser__is_current_entry(struct ui_browser *browser, 
unsigned row);
 void ui_browser__refresh_dimensions(struct ui_browser *browser);
 void ui_browser__reset_index(struct ui_browser *browser);
 
+void ui_browser__gotorc_title(struct ui_browser *browser, int y, int x);
 void ui_browser__gotorc(struct ui_browser *browser, int y, int x);
 void ui_browser__write_nstring(struct ui_browser *browser, const char *msg,
   unsigned int width);
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index cde9bab5061d..b06afb8f51fb 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -61,6 +61,15 @@ static int hist_browser__get_folding(struct hist_browser 
*browser)
return unfolded_rows;
 }
 
+static void hist_browser__set_title_space(struct hist_browser *hb)
+{
+   struct ui_browser *browser = >b;
+   struct hists *hists = hb->hists;
+   struct perf_hpp_list *hpp_list = hists->hpp_list;
+
+   browser->extra_title_lines = hb->show_headers ? 
hpp_list->nr_header_lines : 0;
+}
+
 static u32 hist_browser__nr_entries(struct hist_browser *hb)
 {
u32 nr_entries;
@@ -81,10 +90,16 @@ static void hist_browser__update_rows(struct hist_browser 
*hb)
struct ui_browser *browser = >b;
struct hists *hists = hb->hists;
struct perf_hpp_list *hpp_list = hists->hpp_list;
-   u16 header_offset, index_row;
+   u16 index_row;
+
+   if (!hb->show_headers) {
+   browser->rows += browser->extra_title_lines;
+   browser->extra_title_lines = 0;
+   return;
+   }
 
-   header_offset = hb->show_headers ? hpp_list->nr_header_lines : 0;
-   browser->rows = browser->height - header_offset;
+   browser->extra_title_lines = hpp_list->nr_header_lines;
+   browser->rows -= browser->extra_title_lines;
/*
 * Verify if we were at the 

[tip:perf/urgent] perf hists: Introduce hists__scnprint_title()

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  967a464a7e6d939f0b0dbb4ee41bd3d515fa9a6d
Gitweb: https://git.kernel.org/tip/967a464a7e6d939f0b0dbb4ee41bd3d515fa9a6d
Author: Arnaldo Carvalho de Melo 
AuthorDate: Mon, 2 Apr 2018 14:20:20 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 10:23:18 -0300

perf hists: Introduce hists__scnprint_title()

That is not use any struct hists_browser internals, so that it can be
shared with the other UIs and tools.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Martin Liška 
Cc: Namhyung Kim 
Cc: Wang Nan 
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
Link: https://lkml.kernel.org/n/tip-w8mczjnqnbcj9yzfkv9ja...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/hists.c | 15 +++
 tools/perf/util/hist.h |  6 ++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 2ac66011354f..c20f0ad22f34 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2208,10 +2208,8 @@ static inline bool is_report_browser(void *timer)
return timer == NULL;
 }
 
-static int hists_browser__scnprintf_title(struct hist_browser *browser, char 
*bf, size_t size)
+int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool 
show_freq)
 {
-   struct hist_browser_timer *hbt = browser->hbt;
-   struct hists *hists = browser->hists;
char unit;
int printed;
const struct dso *dso = hists->dso_filter;
@@ -2254,7 +2252,7 @@ static int hists_browser__scnprintf_title(struct 
hist_browser *browser, char *bf
strstr(ev_name, "call-graph=no"))
enable_ref = true;
 
-   if (!is_report_browser(hbt))
+   if (show_freq)
scnprintf(sample_freq_str, sizeof(sample_freq_str), " %d Hz,", 
evsel->attr.sample_freq);
 
nr_samples = convert_unit(nr_samples, );
@@ -2285,6 +2283,15 @@ static int hists_browser__scnprintf_title(struct 
hist_browser *browser, char *bf
if (socket_id > -1)
printed += scnprintf(bf + printed, size - printed,
", Processor Socket: %d", socket_id);
+
+   return printed;
+}
+
+static int hists_browser__scnprintf_title(struct hist_browser *browser, char 
*bf, size_t size)
+{
+   struct hist_browser_timer *hbt = browser->hbt;
+   int printed = __hists__scnprintf_title(browser->hists, bf, size, 
!is_report_browser(hbt));
+
if (!is_report_browser(hbt)) {
struct perf_top *top = hbt->arg;
 
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 32fbf26e0c18..fbabfd8a215d 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -504,5 +504,11 @@ int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const 
char *fmt, ...);
 int __hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp,
   struct perf_hpp_list *hpp_list);
 int hists__fprintf_headers(struct hists *hists, FILE *fp);
+int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool 
show_freq);
+
+static inline int hists__scnprintf_title(struct hists *hists, char *bf, size_t 
size)
+{
+   return __hists__scnprintf_title(hists, bf, size, true);
+}
 
 #endif /* __PERF_HIST_H */


[tip:perf/urgent] perf hists: Introduce hists__scnprint_title()

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  967a464a7e6d939f0b0dbb4ee41bd3d515fa9a6d
Gitweb: https://git.kernel.org/tip/967a464a7e6d939f0b0dbb4ee41bd3d515fa9a6d
Author: Arnaldo Carvalho de Melo 
AuthorDate: Mon, 2 Apr 2018 14:20:20 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 10:23:18 -0300

perf hists: Introduce hists__scnprint_title()

That is not use any struct hists_browser internals, so that it can be
shared with the other UIs and tools.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Martin Liška 
Cc: Namhyung Kim 
Cc: Wang Nan 
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
Link: https://lkml.kernel.org/n/tip-w8mczjnqnbcj9yzfkv9ja...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/hists.c | 15 +++
 tools/perf/util/hist.h |  6 ++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 2ac66011354f..c20f0ad22f34 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2208,10 +2208,8 @@ static inline bool is_report_browser(void *timer)
return timer == NULL;
 }
 
-static int hists_browser__scnprintf_title(struct hist_browser *browser, char 
*bf, size_t size)
+int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool 
show_freq)
 {
-   struct hist_browser_timer *hbt = browser->hbt;
-   struct hists *hists = browser->hists;
char unit;
int printed;
const struct dso *dso = hists->dso_filter;
@@ -2254,7 +2252,7 @@ static int hists_browser__scnprintf_title(struct 
hist_browser *browser, char *bf
strstr(ev_name, "call-graph=no"))
enable_ref = true;
 
-   if (!is_report_browser(hbt))
+   if (show_freq)
scnprintf(sample_freq_str, sizeof(sample_freq_str), " %d Hz,", 
evsel->attr.sample_freq);
 
nr_samples = convert_unit(nr_samples, );
@@ -2285,6 +2283,15 @@ static int hists_browser__scnprintf_title(struct 
hist_browser *browser, char *bf
if (socket_id > -1)
printed += scnprintf(bf + printed, size - printed,
", Processor Socket: %d", socket_id);
+
+   return printed;
+}
+
+static int hists_browser__scnprintf_title(struct hist_browser *browser, char 
*bf, size_t size)
+{
+   struct hist_browser_timer *hbt = browser->hbt;
+   int printed = __hists__scnprintf_title(browser->hists, bf, size, 
!is_report_browser(hbt));
+
if (!is_report_browser(hbt)) {
struct perf_top *top = hbt->arg;
 
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 32fbf26e0c18..fbabfd8a215d 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -504,5 +504,11 @@ int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const 
char *fmt, ...);
 int __hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp,
   struct perf_hpp_list *hpp_list);
 int hists__fprintf_headers(struct hists *hists, FILE *fp);
+int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool 
show_freq);
+
+static inline int hists__scnprintf_title(struct hists *hists, char *bf, size_t 
size)
+{
+   return __hists__scnprintf_title(hists, bf, size, true);
+}
 
 #endif /* __PERF_HIST_H */


[REGRESSION][BISECTED] i.MX6 pinctrl hogs stopped working

2018-04-03 Thread Mika Penttilä
Hi!

Reverting this made the hogs on a i.MX6 board work again. : 


commit b89405b6102fcc3746f43697b826028caa94c823
Author: Richard Fitzgerald 
Date:   Wed Feb 28 15:53:06 2018 +

pinctrl: devicetree: Fix dt_to_map_one_config handling of hogs



--Mika



[REGRESSION][BISECTED] i.MX6 pinctrl hogs stopped working

2018-04-03 Thread Mika Penttilä
Hi!

Reverting this made the hogs on a i.MX6 board work again. : 


commit b89405b6102fcc3746f43697b826028caa94c823
Author: Richard Fitzgerald 
Date:   Wed Feb 28 15:53:06 2018 +

pinctrl: devicetree: Fix dt_to_map_one_config handling of hogs



--Mika



[tip:perf/urgent] perf hists: Move hists__scnprintf_title() away from the TUI code

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  25c312dbf88ca402bf47389c5aa4f1552799a8ca
Gitweb: https://git.kernel.org/tip/25c312dbf88ca402bf47389c5aa4f1552799a8ca
Author: Arnaldo Carvalho de Melo 
AuthorDate: Mon, 2 Apr 2018 14:24:28 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 10:23:32 -0300

perf hists: Move hists__scnprintf_title() away from the TUI code

The previous patch made this function useful to non-TUI parts of the
tools, but left it where the function from what it was carved, so that
the patch showed more clearly the process.

Now just move it outside the TUI parts so that we can finally use it,
even when the TUI code doesn't get built/linked.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Martin Liška 
Cc: Namhyung Kim 
Cc: Wang Nan 
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
Link: https://lkml.kernel.org/n/tip-hqj7hvcr3mu5lvcqp3css...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/hists.c | 79 
 tools/perf/util/hist.c | 81 ++
 2 files changed, 81 insertions(+), 79 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index c20f0ad22f34..cde9bab5061d 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2208,85 +2208,6 @@ static inline bool is_report_browser(void *timer)
return timer == NULL;
 }
 
-int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool 
show_freq)
-{
-   char unit;
-   int printed;
-   const struct dso *dso = hists->dso_filter;
-   const struct thread *thread = hists->thread_filter;
-   int socket_id = hists->socket_filter;
-   unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
-   u64 nr_events = hists->stats.total_period;
-   struct perf_evsel *evsel = hists_to_evsel(hists);
-   const char *ev_name = perf_evsel__name(evsel);
-   char buf[512], sample_freq_str[64] = "";
-   size_t buflen = sizeof(buf);
-   char ref[30] = " show reference callgraph, ";
-   bool enable_ref = false;
-
-   if (symbol_conf.filter_relative) {
-   nr_samples = hists->stats.nr_non_filtered_samples;
-   nr_events = hists->stats.total_non_filtered_period;
-   }
-
-   if (perf_evsel__is_group_event(evsel)) {
-   struct perf_evsel *pos;
-
-   perf_evsel__group_desc(evsel, buf, buflen);
-   ev_name = buf;
-
-   for_each_group_member(pos, evsel) {
-   struct hists *pos_hists = evsel__hists(pos);
-
-   if (symbol_conf.filter_relative) {
-   nr_samples += 
pos_hists->stats.nr_non_filtered_samples;
-   nr_events += 
pos_hists->stats.total_non_filtered_period;
-   } else {
-   nr_samples += 
pos_hists->stats.nr_events[PERF_RECORD_SAMPLE];
-   nr_events += pos_hists->stats.total_period;
-   }
-   }
-   }
-
-   if (symbol_conf.show_ref_callgraph &&
-   strstr(ev_name, "call-graph=no"))
-   enable_ref = true;
-
-   if (show_freq)
-   scnprintf(sample_freq_str, sizeof(sample_freq_str), " %d Hz,", 
evsel->attr.sample_freq);
-
-   nr_samples = convert_unit(nr_samples, );
-   printed = scnprintf(bf, size,
-  "Samples: %lu%c of event%s '%s',%s%sEvent count 
(approx.): %" PRIu64,
-  nr_samples, unit, evsel->nr_members > 1 ? "s" : "",
-  ev_name, sample_freq_str, enable_ref ? ref : " ", 
nr_events);
-
-
-   if (hists->uid_filter_str)
-   printed += snprintf(bf + printed, size - printed,
-   ", UID: %s", hists->uid_filter_str);
-   if (thread) {
-   if (hists__has(hists, thread)) {
-   printed += scnprintf(bf + printed, size - printed,
-   ", Thread: %s(%d)",
-(thread->comm_set ? 
thread__comm_str(thread) : ""),
-   thread->tid);
-   } else {
-   printed += scnprintf(bf + printed, size - printed,
-   ", Thread: %s",
-(thread->comm_set ? 
thread__comm_str(thread) : ""));
-   }
-   }
-   if (dso)
-   printed += scnprintf(bf + printed, size - printed,
-   ", DSO: %s", dso->short_name);
-   if (socket_id > -1)
-   printed += scnprintf(bf + printed, size - printed,
- 

[tip:perf/urgent] perf hists: Move hists__scnprintf_title() away from the TUI code

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  25c312dbf88ca402bf47389c5aa4f1552799a8ca
Gitweb: https://git.kernel.org/tip/25c312dbf88ca402bf47389c5aa4f1552799a8ca
Author: Arnaldo Carvalho de Melo 
AuthorDate: Mon, 2 Apr 2018 14:24:28 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 10:23:32 -0300

perf hists: Move hists__scnprintf_title() away from the TUI code

The previous patch made this function useful to non-TUI parts of the
tools, but left it where the function from what it was carved, so that
the patch showed more clearly the process.

Now just move it outside the TUI parts so that we can finally use it,
even when the TUI code doesn't get built/linked.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Martin Liška 
Cc: Namhyung Kim 
Cc: Wang Nan 
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
Link: https://lkml.kernel.org/n/tip-hqj7hvcr3mu5lvcqp3css...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/hists.c | 79 
 tools/perf/util/hist.c | 81 ++
 2 files changed, 81 insertions(+), 79 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index c20f0ad22f34..cde9bab5061d 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2208,85 +2208,6 @@ static inline bool is_report_browser(void *timer)
return timer == NULL;
 }
 
-int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool 
show_freq)
-{
-   char unit;
-   int printed;
-   const struct dso *dso = hists->dso_filter;
-   const struct thread *thread = hists->thread_filter;
-   int socket_id = hists->socket_filter;
-   unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
-   u64 nr_events = hists->stats.total_period;
-   struct perf_evsel *evsel = hists_to_evsel(hists);
-   const char *ev_name = perf_evsel__name(evsel);
-   char buf[512], sample_freq_str[64] = "";
-   size_t buflen = sizeof(buf);
-   char ref[30] = " show reference callgraph, ";
-   bool enable_ref = false;
-
-   if (symbol_conf.filter_relative) {
-   nr_samples = hists->stats.nr_non_filtered_samples;
-   nr_events = hists->stats.total_non_filtered_period;
-   }
-
-   if (perf_evsel__is_group_event(evsel)) {
-   struct perf_evsel *pos;
-
-   perf_evsel__group_desc(evsel, buf, buflen);
-   ev_name = buf;
-
-   for_each_group_member(pos, evsel) {
-   struct hists *pos_hists = evsel__hists(pos);
-
-   if (symbol_conf.filter_relative) {
-   nr_samples += 
pos_hists->stats.nr_non_filtered_samples;
-   nr_events += 
pos_hists->stats.total_non_filtered_period;
-   } else {
-   nr_samples += 
pos_hists->stats.nr_events[PERF_RECORD_SAMPLE];
-   nr_events += pos_hists->stats.total_period;
-   }
-   }
-   }
-
-   if (symbol_conf.show_ref_callgraph &&
-   strstr(ev_name, "call-graph=no"))
-   enable_ref = true;
-
-   if (show_freq)
-   scnprintf(sample_freq_str, sizeof(sample_freq_str), " %d Hz,", 
evsel->attr.sample_freq);
-
-   nr_samples = convert_unit(nr_samples, );
-   printed = scnprintf(bf, size,
-  "Samples: %lu%c of event%s '%s',%s%sEvent count 
(approx.): %" PRIu64,
-  nr_samples, unit, evsel->nr_members > 1 ? "s" : "",
-  ev_name, sample_freq_str, enable_ref ? ref : " ", 
nr_events);
-
-
-   if (hists->uid_filter_str)
-   printed += snprintf(bf + printed, size - printed,
-   ", UID: %s", hists->uid_filter_str);
-   if (thread) {
-   if (hists__has(hists, thread)) {
-   printed += scnprintf(bf + printed, size - printed,
-   ", Thread: %s(%d)",
-(thread->comm_set ? 
thread__comm_str(thread) : ""),
-   thread->tid);
-   } else {
-   printed += scnprintf(bf + printed, size - printed,
-   ", Thread: %s",
-(thread->comm_set ? 
thread__comm_str(thread) : ""));
-   }
-   }
-   if (dso)
-   printed += scnprintf(bf + printed, size - printed,
-   ", DSO: %s", dso->short_name);
-   if (socket_id > -1)
-   printed += scnprintf(bf + printed, size - printed,
-   ", Processor Socket: %d", socket_id);
-
-   return printed;
-}
-
 static int hists_browser__scnprintf_title(struct hist_browser *browser, char 

[tip:perf/urgent] perf hists browser: Rename perf_evsel_browser_title to a more descriptive name

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  f016d24acd95660ca264e0424c8037391d165553
Gitweb: https://git.kernel.org/tip/f016d24acd95660ca264e0424c8037391d165553
Author: Arnaldo Carvalho de Melo 
AuthorDate: Mon, 2 Apr 2018 14:00:04 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 10:22:42 -0300

perf hists browser: Rename perf_evsel_browser_title to a more descriptive name

Rename it to hists_browser__scnprintf_title() to better reflect that it
provides a scnprintf-like function operating on a hists_browser
instance.

This paves the way to have a non-hists_browser specific function to
scnprintf format a title with per evsel information to use in other
tools or UIs.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Martin Liška 
Cc: Namhyung Kim 
Cc: Wang Nan 
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
Link: https://lkml.kernel.org/n/tip-sntpyzxsnme9jvuz2qntw...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/hists.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 8b4e82548f8e..2ac66011354f 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -32,8 +32,7 @@
 
 extern void hist_browser__init_hpp(void);
 
-static int perf_evsel_browser_title(struct hist_browser *browser,
-   char *bf, size_t size);
+static int hists_browser__scnprintf_title(struct hist_browser *browser, char 
*bf, size_t size);
 static void hist_browser__update_nr_entries(struct hist_browser *hb);
 
 static struct rb_node *hists__filter_entries(struct rb_node *nd,
@@ -2183,7 +2182,7 @@ perf_evsel_browser__new(struct perf_evsel *evsel,
if (browser) {
browser->hbt   = hbt;
browser->env   = env;
-   browser->title = perf_evsel_browser_title;
+   browser->title = hists_browser__scnprintf_title;
}
return browser;
 }
@@ -2209,8 +2208,7 @@ static inline bool is_report_browser(void *timer)
return timer == NULL;
 }
 
-static int perf_evsel_browser_title(struct hist_browser *browser,
-   char *bf, size_t size)
+static int hists_browser__scnprintf_title(struct hist_browser *browser, char 
*bf, size_t size)
 {
struct hist_browser_timer *hbt = browser->hbt;
struct hists *hists = browser->hists;


[tip:perf/urgent] perf version: Add man page

2018-04-03 Thread tip-bot for Jin Yao
Commit-ID:  709846725673a944ee38da1c275a6dfbf0576d0f
Gitweb: https://git.kernel.org/tip/709846725673a944ee38da1c275a6dfbf0576d0f
Author: Jin Yao 
AuthorDate: Fri, 30 Mar 2018 17:27:16 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 13:52:23 -0300

perf version: Add man page

Since a new option '--build-options' is created for 'perf version', so
we need to document it.

Signed-off-by: Jin Yao 
Acked-by: Jiri Olsa 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: Jin Yao 
Cc: Kan Liang 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1522402036-22915-7-git-send-email-yao@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-version.txt | 24 
 1 file changed, 24 insertions(+)

diff --git a/tools/perf/Documentation/perf-version.txt 
b/tools/perf/Documentation/perf-version.txt
new file mode 100644
index ..e207b7cfca26
--- /dev/null
+++ b/tools/perf/Documentation/perf-version.txt
@@ -0,0 +1,24 @@
+perf-version(1)
+===
+
+NAME
+
+perf-version - display the version of perf binary
+
+SYNOPSIS
+
+'perf version' [--build-options]
+
+DESCRIPTION
+---
+With no options given, the 'perf version' prints the perf version
+on the standard output.
+
+If the option '--build-options' is given, then the status of
+compiled-in libraries are printed on the standard output.
+
+OPTIONS
+---
+--build-options::
+Prints the status of compiled-in libraries on the
+standard output.


[tip:perf/urgent] perf hists browser: Rename perf_evsel_browser_title to a more descriptive name

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  f016d24acd95660ca264e0424c8037391d165553
Gitweb: https://git.kernel.org/tip/f016d24acd95660ca264e0424c8037391d165553
Author: Arnaldo Carvalho de Melo 
AuthorDate: Mon, 2 Apr 2018 14:00:04 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 3 Apr 2018 10:22:42 -0300

perf hists browser: Rename perf_evsel_browser_title to a more descriptive name

Rename it to hists_browser__scnprintf_title() to better reflect that it
provides a scnprintf-like function operating on a hists_browser
instance.

This paves the way to have a non-hists_browser specific function to
scnprintf format a title with per evsel information to use in other
tools or UIs.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Martin Liška 
Cc: Namhyung Kim 
Cc: Wang Nan 
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
Link: https://lkml.kernel.org/n/tip-sntpyzxsnme9jvuz2qntw...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/hists.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 8b4e82548f8e..2ac66011354f 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -32,8 +32,7 @@
 
 extern void hist_browser__init_hpp(void);
 
-static int perf_evsel_browser_title(struct hist_browser *browser,
-   char *bf, size_t size);
+static int hists_browser__scnprintf_title(struct hist_browser *browser, char 
*bf, size_t size);
 static void hist_browser__update_nr_entries(struct hist_browser *hb);
 
 static struct rb_node *hists__filter_entries(struct rb_node *nd,
@@ -2183,7 +2182,7 @@ perf_evsel_browser__new(struct perf_evsel *evsel,
if (browser) {
browser->hbt   = hbt;
browser->env   = env;
-   browser->title = perf_evsel_browser_title;
+   browser->title = hists_browser__scnprintf_title;
}
return browser;
 }
@@ -2209,8 +2208,7 @@ static inline bool is_report_browser(void *timer)
return timer == NULL;
 }
 
-static int perf_evsel_browser_title(struct hist_browser *browser,
-   char *bf, size_t size)
+static int hists_browser__scnprintf_title(struct hist_browser *browser, char 
*bf, size_t size)
 {
struct hist_browser_timer *hbt = browser->hbt;
struct hists *hists = browser->hists;


[tip:perf/urgent] perf version: Add man page

2018-04-03 Thread tip-bot for Jin Yao
Commit-ID:  709846725673a944ee38da1c275a6dfbf0576d0f
Gitweb: https://git.kernel.org/tip/709846725673a944ee38da1c275a6dfbf0576d0f
Author: Jin Yao 
AuthorDate: Fri, 30 Mar 2018 17:27:16 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 13:52:23 -0300

perf version: Add man page

Since a new option '--build-options' is created for 'perf version', so
we need to document it.

Signed-off-by: Jin Yao 
Acked-by: Jiri Olsa 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: Jin Yao 
Cc: Kan Liang 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1522402036-22915-7-git-send-email-yao@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-version.txt | 24 
 1 file changed, 24 insertions(+)

diff --git a/tools/perf/Documentation/perf-version.txt 
b/tools/perf/Documentation/perf-version.txt
new file mode 100644
index ..e207b7cfca26
--- /dev/null
+++ b/tools/perf/Documentation/perf-version.txt
@@ -0,0 +1,24 @@
+perf-version(1)
+===
+
+NAME
+
+perf-version - display the version of perf binary
+
+SYNOPSIS
+
+'perf version' [--build-options]
+
+DESCRIPTION
+---
+With no options given, the 'perf version' prints the perf version
+on the standard output.
+
+If the option '--build-options' is given, then the status of
+compiled-in libraries are printed on the standard output.
+
+OPTIONS
+---
+--build-options::
+Prints the status of compiled-in libraries on the
+standard output.


[tip:perf/urgent] perf version: Print the compiled-in status of libraries

2018-04-03 Thread tip-bot for Jin Yao
Commit-ID:  9ff2a64708a642b3dee867d0a083171077663b0a
Gitweb: https://git.kernel.org/tip/9ff2a64708a642b3dee867d0a083171077663b0a
Author: Jin Yao 
AuthorDate: Fri, 30 Mar 2018 17:27:14 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 13:50:30 -0300

perf version: Print the compiled-in status of libraries

This patch checks the values passed by CFLAGS (-DHAVE_XXX) and then
print the status of libraries.

For example, if HAVE_DWARF_SUPPORT is defined, that means the library
"dwarf" is compiled-in. The patch will print the status "on" for this
library otherwise it print the status "OFF".

A new option '--build-options' created for 'perf version' supports the
printing of library status.

For example:

$ ./perf version --build-options
or
  ./perf --version --build-options
or
  ./perf -v --build-options

perf version 4.13.rc5.g6727c5
 dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
 glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
  gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
  libaudit: [ OFF ]  # HAVE_LIBAUDIT_SUPPORT
libbfd: [ on  ]  # HAVE_LIBBFD_SUPPORT
libelf: [ on  ]  # HAVE_LIBELF_SUPPORT
   libnuma: [ on  ]  # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on  ]  # HAVE_LIBNUMA_SUPPORT
   libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
 libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
  libslang: [ on  ]  # HAVE_SLANG_SUPPORT
 libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
 libunwind: [ on  ]  # HAVE_LIBUNWIND_SUPPORT
libdw-dwarf-unwind: [ on  ]  # HAVE_DWARF_SUPPORT
  zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
  lzma: [ on  ]  # HAVE_LZMA_SUPPORT
 get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
   bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT

v4:

1. Also print the macro name. That would make it easier
   to grep around in the source looking for where code
   related a particular features is located.

2. Update since HAVE_DWARF_GETLOCATIONS is renamed to
   HAVE_DWARF_GETLOCATIONS_SUPPORT

v3:

Remove following unnecessary help message.

1. [ on  ]: library is compiled-in
   [ OFF ]: library is disabled in make configuration
OR library is not installed in build environment

2. Create '--build-options' option.

3. Use standard option parsing API 'parse_options'.

v2:

1. Use IS_BUILTIN macro to replace #ifdef/#endif block.

2. Print color for on/OFF.

Signed-off-by: Jin Yao 
Suggested-by: Arnaldo Carvalho de Melo 
Suggested-by: Ingo Molnar 
Suggested-by: Jiri Olsa 
Tested-by: Arnaldo Carvalho de Melo 
Acked-by: Jiri Olsa 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: Jin Yao 
Cc: Kan Liang 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1522402036-22915-5-git-send-email-yao@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-version.c | 82 +++-
 1 file changed, 81 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
index 37019c5d675f..2abe3910d6b6 100644
--- a/tools/perf/builtin-version.c
+++ b/tools/perf/builtin-version.c
@@ -1,11 +1,91 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "builtin.h"
 #include "perf.h"
+#include "color.h"
 #include 
+#include 
 #include 
+#include 
+#include 
 
-int cmd_version(int argc __maybe_unused, const char **argv __maybe_unused)
+int version_verbose;
+
+struct version {
+   boolbuild_options;
+};
+
+static struct version version;
+
+static struct option version_options[] = {
+   OPT_BOOLEAN(0, "build-options", _options,
+   "display the build options"),
+};
+
+static const char * const version_usage[] = {
+   "perf version []",
+   NULL
+};
+
+static void on_off_print(const char *status)
+{
+   printf("[ ");
+
+   if (!strcmp(status, "OFF"))
+   color_fprintf(stdout, PERF_COLOR_RED, "%-3s", status);
+   else
+   color_fprintf(stdout, PERF_COLOR_GREEN, "%-3s", status);
+
+   printf(" ]");
+}
+
+static void status_print(const char *name, const char *macro,
+const char *status)
 {
+   printf("%22s: ", name);
+   on_off_print(status);
+   printf("  # %s\n", macro);
+}
+
+#define STATUS(__d, __m)   \
+do {   \
+   if (IS_BUILTIN(__d))\
+   status_print(#__m, #__d, "on"); \
+   else\
+   

[tip:perf/urgent] perf version: Print the compiled-in status of libraries

2018-04-03 Thread tip-bot for Jin Yao
Commit-ID:  9ff2a64708a642b3dee867d0a083171077663b0a
Gitweb: https://git.kernel.org/tip/9ff2a64708a642b3dee867d0a083171077663b0a
Author: Jin Yao 
AuthorDate: Fri, 30 Mar 2018 17:27:14 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 13:50:30 -0300

perf version: Print the compiled-in status of libraries

This patch checks the values passed by CFLAGS (-DHAVE_XXX) and then
print the status of libraries.

For example, if HAVE_DWARF_SUPPORT is defined, that means the library
"dwarf" is compiled-in. The patch will print the status "on" for this
library otherwise it print the status "OFF".

A new option '--build-options' created for 'perf version' supports the
printing of library status.

For example:

$ ./perf version --build-options
or
  ./perf --version --build-options
or
  ./perf -v --build-options

perf version 4.13.rc5.g6727c5
 dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
 glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
  gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
  libaudit: [ OFF ]  # HAVE_LIBAUDIT_SUPPORT
libbfd: [ on  ]  # HAVE_LIBBFD_SUPPORT
libelf: [ on  ]  # HAVE_LIBELF_SUPPORT
   libnuma: [ on  ]  # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on  ]  # HAVE_LIBNUMA_SUPPORT
   libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
 libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
  libslang: [ on  ]  # HAVE_SLANG_SUPPORT
 libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
 libunwind: [ on  ]  # HAVE_LIBUNWIND_SUPPORT
libdw-dwarf-unwind: [ on  ]  # HAVE_DWARF_SUPPORT
  zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
  lzma: [ on  ]  # HAVE_LZMA_SUPPORT
 get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
   bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT

v4:

1. Also print the macro name. That would make it easier
   to grep around in the source looking for where code
   related a particular features is located.

2. Update since HAVE_DWARF_GETLOCATIONS is renamed to
   HAVE_DWARF_GETLOCATIONS_SUPPORT

v3:

Remove following unnecessary help message.

1. [ on  ]: library is compiled-in
   [ OFF ]: library is disabled in make configuration
OR library is not installed in build environment

2. Create '--build-options' option.

3. Use standard option parsing API 'parse_options'.

v2:

1. Use IS_BUILTIN macro to replace #ifdef/#endif block.

2. Print color for on/OFF.

Signed-off-by: Jin Yao 
Suggested-by: Arnaldo Carvalho de Melo 
Suggested-by: Ingo Molnar 
Suggested-by: Jiri Olsa 
Tested-by: Arnaldo Carvalho de Melo 
Acked-by: Jiri Olsa 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: Jin Yao 
Cc: Kan Liang 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1522402036-22915-5-git-send-email-yao@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-version.c | 82 +++-
 1 file changed, 81 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
index 37019c5d675f..2abe3910d6b6 100644
--- a/tools/perf/builtin-version.c
+++ b/tools/perf/builtin-version.c
@@ -1,11 +1,91 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "builtin.h"
 #include "perf.h"
+#include "color.h"
 #include 
+#include 
 #include 
+#include 
+#include 
 
-int cmd_version(int argc __maybe_unused, const char **argv __maybe_unused)
+int version_verbose;
+
+struct version {
+   boolbuild_options;
+};
+
+static struct version version;
+
+static struct option version_options[] = {
+   OPT_BOOLEAN(0, "build-options", _options,
+   "display the build options"),
+};
+
+static const char * const version_usage[] = {
+   "perf version []",
+   NULL
+};
+
+static void on_off_print(const char *status)
+{
+   printf("[ ");
+
+   if (!strcmp(status, "OFF"))
+   color_fprintf(stdout, PERF_COLOR_RED, "%-3s", status);
+   else
+   color_fprintf(stdout, PERF_COLOR_GREEN, "%-3s", status);
+
+   printf(" ]");
+}
+
+static void status_print(const char *name, const char *macro,
+const char *status)
 {
+   printf("%22s: ", name);
+   on_off_print(status);
+   printf("  # %s\n", macro);
+}
+
+#define STATUS(__d, __m)   \
+do {   \
+   if (IS_BUILTIN(__d))\
+   status_print(#__m, #__d, "on"); \
+   else\
+   status_print(#__m, #__d, "OFF");\
+} while (0)
+
+static void library_status(void)
+{
+   STATUS(HAVE_DWARF_SUPPORT, dwarf);
+   STATUS(HAVE_DWARF_GETLOCATIONS_SUPPORT, dwarf_getlocations);
+   STATUS(HAVE_GLIBC_SUPPORT, glibc);
+   STATUS(HAVE_GTK2_SUPPORT, gtk2);
+ 

[tip:perf/urgent] perf tools: Add 'perf -vv' as an alias to 'perf version --build-options'

2018-04-03 Thread tip-bot for Jin Yao
Commit-ID:  3aa94b10ab0a818ed9fa2dc06c40812c136f9a5a
Gitweb: https://git.kernel.org/tip/3aa94b10ab0a818ed9fa2dc06c40812c136f9a5a
Author: Jin Yao 
AuthorDate: Fri, 30 Mar 2018 17:27:15 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 13:50:35 -0300

perf tools: Add 'perf -vv' as an alias to 'perf version --build-options'

We keep having bug reports that when users build perf on their own, but
they don't install some needed libraries such as libelf,
libbfd/libibery.

The perf can build, but it is missing important functionality.

This patch provides a new option '-vv' for perf which will print the
compiled-in status of libraries.

The 'perf -vv' is mapped to 'perf version --build-options'.

For example:

$ ./perf -vv

perf version 4.13.rc5.g6727c5
 dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
 glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
  gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
  libaudit: [ OFF ]  # HAVE_LIBAUDIT_SUPPORT
libbfd: [ on  ]  # HAVE_LIBBFD_SUPPORT
libelf: [ on  ]  # HAVE_LIBELF_SUPPORT
   libnuma: [ on  ]  # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on  ]  # HAVE_LIBNUMA_SUPPORT
   libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
 libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
  libslang: [ on  ]  # HAVE_SLANG_SUPPORT
 libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
 libunwind: [ on  ]  # HAVE_LIBUNWIND_SUPPORT
libdw-dwarf-unwind: [ on  ]  # HAVE_DWARF_SUPPORT
  zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
  lzma: [ on  ]  # HAVE_LZMA_SUPPORT
 get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
   bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT

v3:

One bug is found in v2. It didn't process the option like '-vabc'
correctly. Fix this bug.

v2:

Use a global variable version_verbose to record the number of 'v'.

Signed-off-by: Jin Yao 
Tested-by: Arnaldo Carvalho de Melo 
Acked-by: Jiri Olsa 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: Jin Yao 
Cc: Kan Liang 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1522402036-22915-6-git-send-email-yao@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/perf.c | 6 ++
 tools/perf/perf.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 1b3fc8ec0fa2..1659029d03fc 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -190,6 +190,12 @@ static int handle_options(const char ***argv, int *argc, 
int *envchanged)
break;
}
 
+   if (!strcmp(cmd, "-vv")) {
+   (*argv)[0] = "version";
+   version_verbose = 1;
+   break;
+   }
+
/*
 * Check remaining flags.
 */
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 8fec1abd0f1f..a1a97956136f 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -84,6 +84,7 @@ struct record_opts {
 struct option;
 extern const char * const *record_usage;
 extern struct option *record_options;
+extern int version_verbose;
 
 int record__parse_freq(const struct option *opt, const char *str, int unset);
 #endif


[tip:perf/urgent] perf tools: Add 'perf -vv' as an alias to 'perf version --build-options'

2018-04-03 Thread tip-bot for Jin Yao
Commit-ID:  3aa94b10ab0a818ed9fa2dc06c40812c136f9a5a
Gitweb: https://git.kernel.org/tip/3aa94b10ab0a818ed9fa2dc06c40812c136f9a5a
Author: Jin Yao 
AuthorDate: Fri, 30 Mar 2018 17:27:15 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 13:50:35 -0300

perf tools: Add 'perf -vv' as an alias to 'perf version --build-options'

We keep having bug reports that when users build perf on their own, but
they don't install some needed libraries such as libelf,
libbfd/libibery.

The perf can build, but it is missing important functionality.

This patch provides a new option '-vv' for perf which will print the
compiled-in status of libraries.

The 'perf -vv' is mapped to 'perf version --build-options'.

For example:

$ ./perf -vv

perf version 4.13.rc5.g6727c5
 dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
 glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
  gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
  libaudit: [ OFF ]  # HAVE_LIBAUDIT_SUPPORT
libbfd: [ on  ]  # HAVE_LIBBFD_SUPPORT
libelf: [ on  ]  # HAVE_LIBELF_SUPPORT
   libnuma: [ on  ]  # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on  ]  # HAVE_LIBNUMA_SUPPORT
   libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
 libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
  libslang: [ on  ]  # HAVE_SLANG_SUPPORT
 libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
 libunwind: [ on  ]  # HAVE_LIBUNWIND_SUPPORT
libdw-dwarf-unwind: [ on  ]  # HAVE_DWARF_SUPPORT
  zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
  lzma: [ on  ]  # HAVE_LZMA_SUPPORT
 get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
   bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT

v3:

One bug is found in v2. It didn't process the option like '-vabc'
correctly. Fix this bug.

v2:

Use a global variable version_verbose to record the number of 'v'.

Signed-off-by: Jin Yao 
Tested-by: Arnaldo Carvalho de Melo 
Acked-by: Jiri Olsa 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: Jin Yao 
Cc: Kan Liang 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1522402036-22915-6-git-send-email-yao@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/perf.c | 6 ++
 tools/perf/perf.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 1b3fc8ec0fa2..1659029d03fc 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -190,6 +190,12 @@ static int handle_options(const char ***argv, int *argc, 
int *envchanged)
break;
}
 
+   if (!strcmp(cmd, "-vv")) {
+   (*argv)[0] = "version";
+   version_verbose = 1;
+   break;
+   }
+
/*
 * Check remaining flags.
 */
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 8fec1abd0f1f..a1a97956136f 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -84,6 +84,7 @@ struct record_opts {
 struct option;
 extern const char * const *record_usage;
 extern struct option *record_options;
+extern int version_verbose;
 
 int record__parse_freq(const struct option *opt, const char *str, int unset);
 #endif


[tip:perf/urgent] perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT

2018-04-03 Thread tip-bot for Jin Yao
Commit-ID:  a36ebe4e242a2f6818f424b03a5e8dae3964e458
Gitweb: https://git.kernel.org/tip/a36ebe4e242a2f6818f424b03a5e8dae3964e458
Author: Jin Yao 
AuthorDate: Fri, 30 Mar 2018 17:27:13 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 13:50:24 -0300

perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT

In Makefile.config, to make all libraries flags have _SUPPORT suffix,
rename HAVE_DWARF_GETLOCATIONS to HAVE_DWARF_GETLOCATIONS_SUPPORT

Signed-off-by: Jin Yao 
Suggested-by: Ingo Molnar 
Acked-by: Jiri Olsa 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: Jin Yao 
Cc: Kan Liang 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1522402036-22915-4-git-send-email-yao@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Makefile.config  | 2 +-
 tools/perf/util/dwarf-aux.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index deb8fba2f4f1..c7abd83a8e19 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -346,7 +346,7 @@ else
   ifneq ($(feature-dwarf_getlocations), 1)
 msg := $(warning Old libdw.h, finding variables at given 'perf probe' 
point will not work, install elfutils-devel/libdw-dev >= 0.157);
   else
-CFLAGS += -DHAVE_DWARF_GETLOCATIONS
+CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT
   endif # dwarf_getlocations
 endif # Dwarf support
   endif # libelf support
diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index f5acda13dcfa..7eb7de5aee44 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -979,7 +979,7 @@ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf)
return ret < 0 ? ret : strbuf_addf(buf, "\t%s", dwarf_diename(vr_die));
 }
 
-#ifdef HAVE_DWARF_GETLOCATIONS
+#ifdef HAVE_DWARF_GETLOCATIONS_SUPPORT
 /**
  * die_get_var_innermost_scope - Get innermost scope range of given variable 
DIE
  * @sp_die: a subprogram DIE


[tip:perf/urgent] perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT

2018-04-03 Thread tip-bot for Jin Yao
Commit-ID:  a36ebe4e242a2f6818f424b03a5e8dae3964e458
Gitweb: https://git.kernel.org/tip/a36ebe4e242a2f6818f424b03a5e8dae3964e458
Author: Jin Yao 
AuthorDate: Fri, 30 Mar 2018 17:27:13 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 13:50:24 -0300

perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT

In Makefile.config, to make all libraries flags have _SUPPORT suffix,
rename HAVE_DWARF_GETLOCATIONS to HAVE_DWARF_GETLOCATIONS_SUPPORT

Signed-off-by: Jin Yao 
Suggested-by: Ingo Molnar 
Acked-by: Jiri Olsa 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: Jin Yao 
Cc: Kan Liang 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1522402036-22915-4-git-send-email-yao@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Makefile.config  | 2 +-
 tools/perf/util/dwarf-aux.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index deb8fba2f4f1..c7abd83a8e19 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -346,7 +346,7 @@ else
   ifneq ($(feature-dwarf_getlocations), 1)
 msg := $(warning Old libdw.h, finding variables at given 'perf probe' 
point will not work, install elfutils-devel/libdw-dev >= 0.157);
   else
-CFLAGS += -DHAVE_DWARF_GETLOCATIONS
+CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT
   endif # dwarf_getlocations
 endif # Dwarf support
   endif # libelf support
diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index f5acda13dcfa..7eb7de5aee44 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -979,7 +979,7 @@ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf)
return ret < 0 ? ret : strbuf_addf(buf, "\t%s", dwarf_diename(vr_die));
 }
 
-#ifdef HAVE_DWARF_GETLOCATIONS
+#ifdef HAVE_DWARF_GETLOCATIONS_SUPPORT
 /**
  * die_get_var_innermost_scope - Get innermost scope range of given variable 
DIE
  * @sp_die: a subprogram DIE


[tip:perf/urgent] tools include: Add config.h header file

2018-04-03 Thread tip-bot for Jiri Olsa
Commit-ID:  6b416ebcc32c5753214d53c18ac5719c93bc340e
Gitweb: https://git.kernel.org/tip/6b416ebcc32c5753214d53c18ac5719c93bc340e
Author: Jiri Olsa 
AuthorDate: Fri, 30 Mar 2018 17:27:11 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 13:31:38 -0300

tools include: Add config.h header file

Adding IS_BUILTIN macro and its dependencies into tools world.

It's taken from kernel's include/linux/kconfig.h, which can't be taken
completely due to its kconfig dependencies.

Signed-off-by: Jiri Olsa 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: Jin Yao 
Cc: Kan Liang 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1522402036-22915-2-git-send-email-yao@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/include/tools/config.h | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/tools/include/tools/config.h b/tools/include/tools/config.h
new file mode 100644
index ..08ade7df8132
--- /dev/null
+++ b/tools/include/tools/config.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _TOOLS_CONFIG_H
+#define _TOOLS_CONFIG_H
+
+/* Subset of include/linux/kconfig.h */
+
+#define __ARG_PLACEHOLDER_1 0,
+#define __take_second_arg(__ignored, val, ...) val
+
+/*
+ * Helper macros to use CONFIG_ options in C/CPP expressions. Note that
+ * these only work with boolean and tristate options.
+ */
+
+/*
+ * Getting something that works in C and CPP for an arg that may or may
+ * not be defined is tricky.  Here, if we have "#define CONFIG_BOOGER 1"
+ * we match on the placeholder define, insert the "0," for arg1 and generate
+ * the triplet (0, 1, 0).  Then the last step cherry picks the 2nd arg (a one).
+ * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when
+ * the last step cherry picks the 2nd arg, we get a zero.
+ */
+#define __is_defined(x)___is_defined(x)
+#define ___is_defined(val) is_defined(__ARG_PLACEHOLDER_##val)
+#define is_defined(arg1_or_junk)   __take_second_arg(arg1_or_junk 1, 0)
+
+/*
+ * IS_BUILTIN(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0
+ * otherwise. For boolean options, this is equivalent to
+ * IS_ENABLED(CONFIG_FOO).
+ */
+#define IS_BUILTIN(option) __is_defined(option)
+
+#endif /* _TOOLS_CONFIG_H */


[tip:perf/urgent] tools include: Add config.h header file

2018-04-03 Thread tip-bot for Jiri Olsa
Commit-ID:  6b416ebcc32c5753214d53c18ac5719c93bc340e
Gitweb: https://git.kernel.org/tip/6b416ebcc32c5753214d53c18ac5719c93bc340e
Author: Jiri Olsa 
AuthorDate: Fri, 30 Mar 2018 17:27:11 +0800
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 13:31:38 -0300

tools include: Add config.h header file

Adding IS_BUILTIN macro and its dependencies into tools world.

It's taken from kernel's include/linux/kconfig.h, which can't be taken
completely due to its kconfig dependencies.

Signed-off-by: Jiri Olsa 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: Jin Yao 
Cc: Kan Liang 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1522402036-22915-2-git-send-email-yao@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/include/tools/config.h | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/tools/include/tools/config.h b/tools/include/tools/config.h
new file mode 100644
index ..08ade7df8132
--- /dev/null
+++ b/tools/include/tools/config.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _TOOLS_CONFIG_H
+#define _TOOLS_CONFIG_H
+
+/* Subset of include/linux/kconfig.h */
+
+#define __ARG_PLACEHOLDER_1 0,
+#define __take_second_arg(__ignored, val, ...) val
+
+/*
+ * Helper macros to use CONFIG_ options in C/CPP expressions. Note that
+ * these only work with boolean and tristate options.
+ */
+
+/*
+ * Getting something that works in C and CPP for an arg that may or may
+ * not be defined is tricky.  Here, if we have "#define CONFIG_BOOGER 1"
+ * we match on the placeholder define, insert the "0," for arg1 and generate
+ * the triplet (0, 1, 0).  Then the last step cherry picks the 2nd arg (a one).
+ * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when
+ * the last step cherry picks the 2nd arg, we get a zero.
+ */
+#define __is_defined(x)___is_defined(x)
+#define ___is_defined(val) is_defined(__ARG_PLACEHOLDER_##val)
+#define is_defined(arg1_or_junk)   __take_second_arg(arg1_or_junk 1, 0)
+
+/*
+ * IS_BUILTIN(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0
+ * otherwise. For boolean options, this is equivalent to
+ * IS_ENABLED(CONFIG_FOO).
+ */
+#define IS_BUILTIN(option) __is_defined(option)
+
+#endif /* _TOOLS_CONFIG_H */


[tip:perf/urgent] perf trace: Show only failing syscalls

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  0a6545bda2756807a089c64352edfc5628c57e6c
Gitweb: https://git.kernel.org/tip/0a6545bda2756807a089c64352edfc5628c57e6c
Author: Arnaldo Carvalho de Melo 
AuthorDate: Thu, 29 Mar 2018 12:22:59 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 07:57:37 -0300

perf trace: Show only failing syscalls

For instance:

  # perf probe "vfs_getname=getname_flags:72 pathname=result->name:string"
  Added new event:
probe:vfs_getname(on getname_flags:72 with pathname=result->name:string)

  You can now use it in all perf tools, such as:

  perf record -e probe:vfs_getname -aR sleep 1

  # perf trace --failure sleep 1
 0.043 ( 0.010 ms): sleep/10978 access(filename: /etc/ld.so.preload, mode: 
R) = -1 ENOENT No such file or directory

For reference, here are all the syscalls in this case:

  # perf trace sleep 1
 ? ( ): sleep/10976  ... [continued]: execve()) = 0
   0.027 ( 0.001 ms): sleep/10976 brk() = 0x55bdc2d04000
   0.044 ( 0.010 ms): sleep/10976 access(filename: /etc/ld.so.preload, 
mode: R) = -1 ENOENT No such file or directory
   0.057 ( 0.006 ms): sleep/10976 openat(dfd: CWD, filename: 
/etc/ld.so.cache, flags: CLOEXEC) = 3
   0.064 ( 0.002 ms): sleep/10976 fstat(fd: 3, statbuf: 0x7fffac22b370) = 0
   0.067 ( 0.003 ms): sleep/10976 mmap(len: 111457, prot: READ, flags: 
PRIVATE, fd: 3) = 0x7feec8615000
   0.071 ( 0.001 ms): sleep/10976 close(fd: 3) = 0
   0.080 ( 0.007 ms): sleep/10976 openat(dfd: CWD, filename: 
/lib64/libc.so.6, flags: CLOEXEC) = 3
   0.088 ( 0.002 ms): sleep/10976 read(fd: 3, buf: 0x7fffac22b538, count: 
832) = 832
   0.092 ( 0.001 ms): sleep/10976 fstat(fd: 3, statbuf: 0x7fffac22b3d0) = 0
   0.094 ( 0.002 ms): sleep/10976 mmap(len: 8192, prot: READ|WRITE, flags: 
PRIVATE|ANONYMOUS) = 0x7feec8613000
   0.099 ( 0.004 ms): sleep/10976 mmap(len: 3889792, prot: EXEC|READ, 
flags: PRIVATE|DENYWRITE, fd: 3) = 0x7feec8057000
   0.104 ( 0.007 ms): sleep/10976 mprotect(start: 0x7feec8203000, len: 
2097152) = 0
   0.112 ( 0.005 ms): sleep/10976 mmap(addr: 0x7feec8403000, len: 24576, 
prot: READ|WRITE, flags: PRIVATE|DENYWRITE|FIXED, fd: 3, off: 1753088) = 
0x7feec8403000
   0.120 ( 0.003 ms): sleep/10976 mmap(addr: 0x7feec8409000, len: 14976, 
prot: READ|WRITE, flags: PRIVATE|ANONYMOUS|FIXED) = 0x7feec8409000
   0.128 ( 0.001 ms): sleep/10976 close(fd: 3) = 0
   0.139 ( 0.001 ms): sleep/10976 arch_prctl(option: 4098, arg2: 
140663540761856) = 0
   0.186 ( 0.004 ms): sleep/10976 mprotect(start: 0x7feec8403000, len: 
16384, prot: READ) = 0
   0.204 ( 0.003 ms): sleep/10976 mprotect(start: 0x55bdc0ec3000, len: 
4096, prot: READ) = 0
   0.209 ( 0.004 ms): sleep/10976 mprotect(start: 0x7feec8631000, len: 
4096, prot: READ) = 0
   0.214 ( 0.010 ms): sleep/10976 munmap(addr: 0x7feec8615000, len: 111457) 
= 0
   0.269 ( 0.001 ms): sleep/10976 brk() = 0x55bdc2d04000
   0.271 ( 0.002 ms): sleep/10976 brk(brk: 0x55bdc2d25000) = 0x55bdc2d25000
   0.274 ( 0.001 ms): sleep/10976 brk() = 0x55bdc2d25000
   0.278 ( 0.007 ms): sleep/10976 open(filename: 
/usr/lib/locale/locale-archive, flags: CLOEXEC) = 3
   0.288 ( 0.001 ms): sleep/10976 fstat(fd: 
3, statbuf: 0x7feec8408aa0) = 0
   0.290 ( 0.003 ms): sleep/10976 mmap(len: 113045344, prot: READ, flags: 
PRIVATE, fd: 3) = 0x7feec1488000
   0.297 ( 0.001 ms): sleep/10976 close(fd: 
3) = 0
   0.325 (1000.193 ms): sleep/10976 nanosleep(rqtp: 0x7fffac22c0b0) = 0
1000.560 ( 0.006 ms): sleep/10976 close(fd: 1) = 0
1000.573 ( 0.005 ms): sleep/10976 close(fd: 2) = 0
1000.596 ( ): sleep/10976 exit_group()
  #

And can be done systemwide, etc, with backtraces:

  # perf trace --max-stack=16 --failure sleep 1
 0.048 ( 0.015 ms): sleep/11092 access(filename: /etc/ld.so.preload, mode: 
R) = -1 ENOENT No such file or directory
   __access (inlined)
   dl_main (/usr/lib64/ld-2.26.so)
  #

Or for some specific syscalls:

  # perf trace --max-stack=16 -e openat --failure cat /tmp/rien
  cat: /tmp/rien: No such file or directory
   0.251 ( 0.012 ms): cat/11106 openat(dfd: CWD, filename: /tmp/rien) = -1 
ENOENT No such file or directory
 __libc_open64 (inlined)
 main (/usr/bin/cat)
 __libc_start_main 
(/usr/lib64/libc-2.26.so)
 _start (/usr/bin/cat)
  #

Look for inotify* syscalls that fail, system wide, for 2 seconds, with 
backtraces:

  # perf trace -a --max-stack=16 --failure -e inotify* sleep 2
   819.165 ( 0.058 ms): gmain/1724 inotify_add_watch(fd: 8, 
pathname: /home/acme/~, mask: 16789454) = -1 ENOENT No such file or directory
   __GI_inotify_add_watch (inlined)
  

[tip:perf/urgent] perf trace: Show only failing syscalls

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  0a6545bda2756807a089c64352edfc5628c57e6c
Gitweb: https://git.kernel.org/tip/0a6545bda2756807a089c64352edfc5628c57e6c
Author: Arnaldo Carvalho de Melo 
AuthorDate: Thu, 29 Mar 2018 12:22:59 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 07:57:37 -0300

perf trace: Show only failing syscalls

For instance:

  # perf probe "vfs_getname=getname_flags:72 pathname=result->name:string"
  Added new event:
probe:vfs_getname(on getname_flags:72 with pathname=result->name:string)

  You can now use it in all perf tools, such as:

  perf record -e probe:vfs_getname -aR sleep 1

  # perf trace --failure sleep 1
 0.043 ( 0.010 ms): sleep/10978 access(filename: /etc/ld.so.preload, mode: 
R) = -1 ENOENT No such file or directory

For reference, here are all the syscalls in this case:

  # perf trace sleep 1
 ? ( ): sleep/10976  ... [continued]: execve()) = 0
   0.027 ( 0.001 ms): sleep/10976 brk() = 0x55bdc2d04000
   0.044 ( 0.010 ms): sleep/10976 access(filename: /etc/ld.so.preload, 
mode: R) = -1 ENOENT No such file or directory
   0.057 ( 0.006 ms): sleep/10976 openat(dfd: CWD, filename: 
/etc/ld.so.cache, flags: CLOEXEC) = 3
   0.064 ( 0.002 ms): sleep/10976 fstat(fd: 3, statbuf: 0x7fffac22b370) = 0
   0.067 ( 0.003 ms): sleep/10976 mmap(len: 111457, prot: READ, flags: 
PRIVATE, fd: 3) = 0x7feec8615000
   0.071 ( 0.001 ms): sleep/10976 close(fd: 3) = 0
   0.080 ( 0.007 ms): sleep/10976 openat(dfd: CWD, filename: 
/lib64/libc.so.6, flags: CLOEXEC) = 3
   0.088 ( 0.002 ms): sleep/10976 read(fd: 3, buf: 0x7fffac22b538, count: 
832) = 832
   0.092 ( 0.001 ms): sleep/10976 fstat(fd: 3, statbuf: 0x7fffac22b3d0) = 0
   0.094 ( 0.002 ms): sleep/10976 mmap(len: 8192, prot: READ|WRITE, flags: 
PRIVATE|ANONYMOUS) = 0x7feec8613000
   0.099 ( 0.004 ms): sleep/10976 mmap(len: 3889792, prot: EXEC|READ, 
flags: PRIVATE|DENYWRITE, fd: 3) = 0x7feec8057000
   0.104 ( 0.007 ms): sleep/10976 mprotect(start: 0x7feec8203000, len: 
2097152) = 0
   0.112 ( 0.005 ms): sleep/10976 mmap(addr: 0x7feec8403000, len: 24576, 
prot: READ|WRITE, flags: PRIVATE|DENYWRITE|FIXED, fd: 3, off: 1753088) = 
0x7feec8403000
   0.120 ( 0.003 ms): sleep/10976 mmap(addr: 0x7feec8409000, len: 14976, 
prot: READ|WRITE, flags: PRIVATE|ANONYMOUS|FIXED) = 0x7feec8409000
   0.128 ( 0.001 ms): sleep/10976 close(fd: 3) = 0
   0.139 ( 0.001 ms): sleep/10976 arch_prctl(option: 4098, arg2: 
140663540761856) = 0
   0.186 ( 0.004 ms): sleep/10976 mprotect(start: 0x7feec8403000, len: 
16384, prot: READ) = 0
   0.204 ( 0.003 ms): sleep/10976 mprotect(start: 0x55bdc0ec3000, len: 
4096, prot: READ) = 0
   0.209 ( 0.004 ms): sleep/10976 mprotect(start: 0x7feec8631000, len: 
4096, prot: READ) = 0
   0.214 ( 0.010 ms): sleep/10976 munmap(addr: 0x7feec8615000, len: 111457) 
= 0
   0.269 ( 0.001 ms): sleep/10976 brk() = 0x55bdc2d04000
   0.271 ( 0.002 ms): sleep/10976 brk(brk: 0x55bdc2d25000) = 0x55bdc2d25000
   0.274 ( 0.001 ms): sleep/10976 brk() = 0x55bdc2d25000
   0.278 ( 0.007 ms): sleep/10976 open(filename: 
/usr/lib/locale/locale-archive, flags: CLOEXEC) = 3
   0.288 ( 0.001 ms): sleep/10976 fstat(fd: 
3, statbuf: 0x7feec8408aa0) = 0
   0.290 ( 0.003 ms): sleep/10976 mmap(len: 113045344, prot: READ, flags: 
PRIVATE, fd: 3) = 0x7feec1488000
   0.297 ( 0.001 ms): sleep/10976 close(fd: 
3) = 0
   0.325 (1000.193 ms): sleep/10976 nanosleep(rqtp: 0x7fffac22c0b0) = 0
1000.560 ( 0.006 ms): sleep/10976 close(fd: 1) = 0
1000.573 ( 0.005 ms): sleep/10976 close(fd: 2) = 0
1000.596 ( ): sleep/10976 exit_group()
  #

And can be done systemwide, etc, with backtraces:

  # perf trace --max-stack=16 --failure sleep 1
 0.048 ( 0.015 ms): sleep/11092 access(filename: /etc/ld.so.preload, mode: 
R) = -1 ENOENT No such file or directory
   __access (inlined)
   dl_main (/usr/lib64/ld-2.26.so)
  #

Or for some specific syscalls:

  # perf trace --max-stack=16 -e openat --failure cat /tmp/rien
  cat: /tmp/rien: No such file or directory
   0.251 ( 0.012 ms): cat/11106 openat(dfd: CWD, filename: /tmp/rien) = -1 
ENOENT No such file or directory
 __libc_open64 (inlined)
 main (/usr/bin/cat)
 __libc_start_main 
(/usr/lib64/libc-2.26.so)
 _start (/usr/bin/cat)
  #

Look for inotify* syscalls that fail, system wide, for 2 seconds, with 
backtraces:

  # perf trace -a --max-stack=16 --failure -e inotify* sleep 2
   819.165 ( 0.058 ms): gmain/1724 inotify_add_watch(fd: 8, 
pathname: /home/acme/~, mask: 16789454) = -1 ENOENT No such file or directory
   __GI_inotify_add_watch (inlined)
   

[tip:perf/urgent] perf tools: Add a "dso_size" sort order

2018-04-03 Thread tip-bot for Kim Phillips
Commit-ID:  b74d12d598143c2dd30b9cb9636a50dded4cc49f
Gitweb: https://git.kernel.org/tip/b74d12d598143c2dd30b9cb9636a50dded4cc49f
Author: Kim Phillips 
AuthorDate: Tue, 27 Mar 2018 06:09:56 -0500
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 07:57:37 -0300

perf tools: Add a "dso_size" sort order

Add DSO size to perf report/top sort output list.

This includes adding a map__size fn to map.h, which is
approximately equal to the DSO data file_size:

  DSO   file size   map (end-start) file / 
(end-start)
  libwebkit2gtk-4.0.so.37.24.9  432600724129587295%
  libglib-2.0.so.0.5400.11125680 111820899%
  libc-2.26.so   1960656 1925120101%
  libdbus-1.so.3.14.13309456  303104102%

Sample output:

  $ ./perf report -s dso_size,dso
  Samples: 2K of event 'cycles:uppp', Event count (approx.): 128373340
  Overhead  DSO size  Shared Object
90.62%   unknown  [unknown]
 2.87%   1118208  libglib-2.0.so.0.5400.1
 1.92%303104  libdbus-1.so.3.14.13
 1.42%   1925120  libc-2.26.so
 0.77%  41295872  libwebkit2gtk-4.0.so.37.24.9
 0.61%335872  libgobject-2.0.so.0.5400.1
 0.41%   1052672  libgdk-3.so.0.2200.25
 0.36%106496  libpthread-2.26.so
 0.29%221184  dbus-daemon
 0.17%159744  ld-2.26.so
 0.13% 49152  libwayland-client.so.0.3.0
 0.12%   1642496  libgio-2.0.so.0.5400.1
 0.09%   7327744  libgtk-3.so.0.2200.25
 0.09%  12324864  libmozjs-52.so.0.0.0
 0.05%   4796416  perf
 0.04%843776  libgjs.so.0.0.0
 0.03%   1409024  libmutter-clutter-1.so

Committer testing:

To sort by DSO size, use:

  # perf report -F dso_size,dso,overhead -s dso_size
  
 3465216  libdns-export.so.174.0.1   0.00%
 3522560  libgc.so.1.0.3 0.00%
 3538944  libbfd-2.29-13.fc27.so 0.59%
 3670016  libunistring.so.2.1.0  0.00%
 3723264  libguile-2.0.so.22.8.1 0.00%
 3776512  libgio-2.0.so.0.5400.3 0.00%
 3891200  libc-2.26.so   0.96%
 398  libmozjs-17.0.so   0.00%
 4218880  libperl.so.5.26.1  0.18%
 4452352  libpython2.7.so.1.00.02%
 4472832  perf   0.02%
 4603904  git0.01%
 4751360  libcrypto.so.1.1.0g0.00%
 5005312  libslang.so.2.3.1  0.00%
 7315456  libgtk-3.so.0.2200.26  0.09%
 8818688  i965_dri.so2.46%
 8818688  i965_dri.so (deleted)  1.26%
12414976  libmozjs-52.so.0.0.0   0.03%
23642112  cc12.02%
27889664  [kernel.kallsyms] 25.41%
80834560  libxul.so (deleted)   15.68%
98078720  chrome32.03%
  1056964608  [kernel.kallsyms]  1.59%
  #

Signed-off-by: Kim Phillips 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: Jin Yao 
Cc: Jiri Olsa 
Cc: Maxim Kuvyrkov 
Cc: Milian Wolff 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20180327060956.1c01ebe67a2a941bb4468...@arm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-report.txt |  1 +
 tools/perf/util/hist.h   |  1 +
 tools/perf/util/map.h|  4 
 tools/perf/util/sort.c   | 41 
 tools/perf/util/sort.h   |  1 +
 5 files changed, 48 insertions(+)

diff --git a/tools/perf/Documentation/perf-report.txt 
b/tools/perf/Documentation/perf-report.txt
index e1a660e60849..917e36fde6d8 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -80,6 +80,7 @@ OPTIONS
- comm: command (name) of the task which can be read via 
/proc//comm
- pid: command and tid of the task
- dso: name of library or module executed at the time of sample
+   - dso_size: size of library or module executed at the time of sample
- symbol: name of function executed at the time of sample
- symbol_size: size of function executed at the time of sample
- parent: name of function matched to the parent regex filter. Unmatched
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index e869cad4d89f..32fbf26e0c18 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -61,6 +61,7 @@ enum hist_column {
HISTC_SRCLINE_TO,
HISTC_TRACE,
HISTC_SYM_SIZE,
+   HISTC_DSO_SIZE,
HISTC_NR_COLS, /* Last entry */
 };
 
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 

[tip:perf/urgent] tools headers: Synchronize x86's cpufeatures.h

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  5e2a146bbdae6095b13bca9ebe26a867030ae010
Gitweb: https://git.kernel.org/tip/5e2a146bbdae6095b13bca9ebe26a867030ae010
Author: Arnaldo Carvalho de Melo 
AuthorDate: Thu, 29 Mar 2018 11:46:53 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 07:57:37 -0300

tools headers: Synchronize x86's cpufeatures.h

Due to these commits:

  1da961d72ab0 ("x86/cpufeatures: Add Intel Total Memory Encryption cpufeature")
  7958b2246fad ("x86/cpufeatures: Add Intel PCONFIG cpufeature")

To silence 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'

Nothing in those csets requires changes in tools/perf/, so just
sync it to silence the build.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Kirill A. Shutemov 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-m2yl8wj0uxs8pncq2ncfc...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/arch/x86/include/asm/cpufeatures.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/arch/x86/include/asm/cpufeatures.h 
b/tools/arch/x86/include/asm/cpufeatures.h
index f41079da38c5..d554c11e01ff 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -316,6 +316,7 @@
 #define X86_FEATURE_VPCLMULQDQ (16*32+10) /* Carry-Less Multiplication 
Double Quadword */
 #define X86_FEATURE_AVX512_VNNI(16*32+11) /* Vector Neural 
Network Instructions */
 #define X86_FEATURE_AVX512_BITALG  (16*32+12) /* Support for VPOPCNT[B,W] 
and VPSHUF-BITQMB instructions */
+#define X86_FEATURE_TME(16*32+13) /* Intel Total 
Memory Encryption */
 #define X86_FEATURE_AVX512_VPOPCNTDQ   (16*32+14) /* POPCNT for vectors of 
DW/QW */
 #define X86_FEATURE_LA57   (16*32+16) /* 5-level page tables */
 #define X86_FEATURE_RDPID  (16*32+22) /* RDPID instruction */
@@ -328,6 +329,7 @@
 /* Intel-defined CPU features, CPUID level 0x0007:0 (EDX), word 18 */
 #define X86_FEATURE_AVX512_4VNNIW  (18*32+ 2) /* AVX-512 Neural Network 
Instructions */
 #define X86_FEATURE_AVX512_4FMAPS  (18*32+ 3) /* AVX-512 Multiply 
Accumulation Single precision */
+#define X86_FEATURE_PCONFIG(18*32+18) /* Intel PCONFIG */
 #define X86_FEATURE_SPEC_CTRL  (18*32+26) /* "" Speculation Control 
(IBRS + IBPB) */
 #define X86_FEATURE_INTEL_STIBP(18*32+27) /* "" Single Thread 
Indirect Branch Predictors */
 #define X86_FEATURE_ARCH_CAPABILITIES  (18*32+29) /* IA32_ARCH_CAPABILITIES 
MSR (Intel) */


[tip:perf/urgent] perf tools: Add a "dso_size" sort order

2018-04-03 Thread tip-bot for Kim Phillips
Commit-ID:  b74d12d598143c2dd30b9cb9636a50dded4cc49f
Gitweb: https://git.kernel.org/tip/b74d12d598143c2dd30b9cb9636a50dded4cc49f
Author: Kim Phillips 
AuthorDate: Tue, 27 Mar 2018 06:09:56 -0500
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 07:57:37 -0300

perf tools: Add a "dso_size" sort order

Add DSO size to perf report/top sort output list.

This includes adding a map__size fn to map.h, which is
approximately equal to the DSO data file_size:

  DSO   file size   map (end-start) file / 
(end-start)
  libwebkit2gtk-4.0.so.37.24.9  432600724129587295%
  libglib-2.0.so.0.5400.11125680 111820899%
  libc-2.26.so   1960656 1925120101%
  libdbus-1.so.3.14.13309456  303104102%

Sample output:

  $ ./perf report -s dso_size,dso
  Samples: 2K of event 'cycles:uppp', Event count (approx.): 128373340
  Overhead  DSO size  Shared Object
90.62%   unknown  [unknown]
 2.87%   1118208  libglib-2.0.so.0.5400.1
 1.92%303104  libdbus-1.so.3.14.13
 1.42%   1925120  libc-2.26.so
 0.77%  41295872  libwebkit2gtk-4.0.so.37.24.9
 0.61%335872  libgobject-2.0.so.0.5400.1
 0.41%   1052672  libgdk-3.so.0.2200.25
 0.36%106496  libpthread-2.26.so
 0.29%221184  dbus-daemon
 0.17%159744  ld-2.26.so
 0.13% 49152  libwayland-client.so.0.3.0
 0.12%   1642496  libgio-2.0.so.0.5400.1
 0.09%   7327744  libgtk-3.so.0.2200.25
 0.09%  12324864  libmozjs-52.so.0.0.0
 0.05%   4796416  perf
 0.04%843776  libgjs.so.0.0.0
 0.03%   1409024  libmutter-clutter-1.so

Committer testing:

To sort by DSO size, use:

  # perf report -F dso_size,dso,overhead -s dso_size
  
 3465216  libdns-export.so.174.0.1   0.00%
 3522560  libgc.so.1.0.3 0.00%
 3538944  libbfd-2.29-13.fc27.so 0.59%
 3670016  libunistring.so.2.1.0  0.00%
 3723264  libguile-2.0.so.22.8.1 0.00%
 3776512  libgio-2.0.so.0.5400.3 0.00%
 3891200  libc-2.26.so   0.96%
 398  libmozjs-17.0.so   0.00%
 4218880  libperl.so.5.26.1  0.18%
 4452352  libpython2.7.so.1.00.02%
 4472832  perf   0.02%
 4603904  git0.01%
 4751360  libcrypto.so.1.1.0g0.00%
 5005312  libslang.so.2.3.1  0.00%
 7315456  libgtk-3.so.0.2200.26  0.09%
 8818688  i965_dri.so2.46%
 8818688  i965_dri.so (deleted)  1.26%
12414976  libmozjs-52.so.0.0.0   0.03%
23642112  cc12.02%
27889664  [kernel.kallsyms] 25.41%
80834560  libxul.so (deleted)   15.68%
98078720  chrome32.03%
  1056964608  [kernel.kallsyms]  1.59%
  #

Signed-off-by: Kim Phillips 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: Jin Yao 
Cc: Jiri Olsa 
Cc: Maxim Kuvyrkov 
Cc: Milian Wolff 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20180327060956.1c01ebe67a2a941bb4468...@arm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Documentation/perf-report.txt |  1 +
 tools/perf/util/hist.h   |  1 +
 tools/perf/util/map.h|  4 
 tools/perf/util/sort.c   | 41 
 tools/perf/util/sort.h   |  1 +
 5 files changed, 48 insertions(+)

diff --git a/tools/perf/Documentation/perf-report.txt 
b/tools/perf/Documentation/perf-report.txt
index e1a660e60849..917e36fde6d8 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -80,6 +80,7 @@ OPTIONS
- comm: command (name) of the task which can be read via 
/proc//comm
- pid: command and tid of the task
- dso: name of library or module executed at the time of sample
+   - dso_size: size of library or module executed at the time of sample
- symbol: name of function executed at the time of sample
- symbol_size: size of function executed at the time of sample
- parent: name of function matched to the parent regex filter. Unmatched
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index e869cad4d89f..32fbf26e0c18 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -61,6 +61,7 @@ enum hist_column {
HISTC_SRCLINE_TO,
HISTC_TRACE,
HISTC_SYM_SIZE,
+   HISTC_DSO_SIZE,
HISTC_NR_COLS, /* Last entry */
 };
 
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index edeb7291c8e1..0e9bbe01b0ab 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -103,6 +103,10 @@ static inline u64 identity__map_ip(struct map *map 
__maybe_unused, u64 ip)
return ip;
 }
 
+static inline size_t map__size(const struct map *map)
+{
+   return map->end - map->start;

[tip:perf/urgent] tools headers: Synchronize x86's cpufeatures.h

2018-04-03 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  5e2a146bbdae6095b13bca9ebe26a867030ae010
Gitweb: https://git.kernel.org/tip/5e2a146bbdae6095b13bca9ebe26a867030ae010
Author: Arnaldo Carvalho de Melo 
AuthorDate: Thu, 29 Mar 2018 11:46:53 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 2 Apr 2018 07:57:37 -0300

tools headers: Synchronize x86's cpufeatures.h

Due to these commits:

  1da961d72ab0 ("x86/cpufeatures: Add Intel Total Memory Encryption cpufeature")
  7958b2246fad ("x86/cpufeatures: Add Intel PCONFIG cpufeature")

To silence 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'

Nothing in those csets requires changes in tools/perf/, so just
sync it to silence the build.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Kirill A. Shutemov 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-m2yl8wj0uxs8pncq2ncfc...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/arch/x86/include/asm/cpufeatures.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/arch/x86/include/asm/cpufeatures.h 
b/tools/arch/x86/include/asm/cpufeatures.h
index f41079da38c5..d554c11e01ff 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -316,6 +316,7 @@
 #define X86_FEATURE_VPCLMULQDQ (16*32+10) /* Carry-Less Multiplication 
Double Quadword */
 #define X86_FEATURE_AVX512_VNNI(16*32+11) /* Vector Neural 
Network Instructions */
 #define X86_FEATURE_AVX512_BITALG  (16*32+12) /* Support for VPOPCNT[B,W] 
and VPSHUF-BITQMB instructions */
+#define X86_FEATURE_TME(16*32+13) /* Intel Total 
Memory Encryption */
 #define X86_FEATURE_AVX512_VPOPCNTDQ   (16*32+14) /* POPCNT for vectors of 
DW/QW */
 #define X86_FEATURE_LA57   (16*32+16) /* 5-level page tables */
 #define X86_FEATURE_RDPID  (16*32+22) /* RDPID instruction */
@@ -328,6 +329,7 @@
 /* Intel-defined CPU features, CPUID level 0x0007:0 (EDX), word 18 */
 #define X86_FEATURE_AVX512_4VNNIW  (18*32+ 2) /* AVX-512 Neural Network 
Instructions */
 #define X86_FEATURE_AVX512_4FMAPS  (18*32+ 3) /* AVX-512 Multiply 
Accumulation Single precision */
+#define X86_FEATURE_PCONFIG(18*32+18) /* Intel PCONFIG */
 #define X86_FEATURE_SPEC_CTRL  (18*32+26) /* "" Speculation Control 
(IBRS + IBPB) */
 #define X86_FEATURE_INTEL_STIBP(18*32+27) /* "" Single Thread 
Indirect Branch Predictors */
 #define X86_FEATURE_ARCH_CAPABILITIES  (18*32+29) /* IA32_ARCH_CAPABILITIES 
MSR (Intel) */


Re: [GIT PULL 00/17] perf/core improvements and fixes

2018-04-03 Thread Ingo Molnar

* Arnaldo Carvalho de Melo <a...@kernel.org> wrote:

> Hi Ingo,
> 
>   Please consider pulling,
> 
> - Arnaldo
> 
> Test results at the end of this message, as usual.
> 
> The following changes since commit 1159e09476536250c2a0173d4298d15114df7a89:
> 
>   perf/x86/intel: Enable C-state residency events for Cannon Lake (2018-03-31 
> 11:28:36 +0200)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git 
> tags/perf-core-for-mingo-4.17-20180403
> 
> for you to fetch changes up to 51125a29a395048fdb3429b8c4ca0ada57097744:
> 
>   perf trace: Remove redundant ')' (2018-04-03 16:16:41 -0300)
> 
> 
> perf/core improvements and fixes:
> 
> - Show only failing syscalls with 'perf trace --failure' (Arnaldo Carvalho de 
> Melo)
> 
>   e.g: See what 'openat' syscalls are failing:
> 
>   # perf trace --failure -e openat
>762.323 ( 0.007 ms): VideoCapture/4566 openat(dfd: CWD, filename: 
> /dev/video2) = -1 ENOENT No such file or directory
> lid?!? 8-) >
>790.228 ( 0.008 ms): VideoCapture/4566 openat(dfd: CWD, filename: 
> /dev/video63) = -1 ENOENT No such file or directory
>   ^C#
> 
> - Show information about the event (freq, nr_samples, total period/nr_events) 
> in
>   the annotate --tui and --stdio2 'perf annotate' output, similar to the
>   first line in the 'perf report --tui', but just for the samples for
>   the annotated symbol (Arnaldo Carvalho de Melo)
> 
> - Introduce 'perf version --build-options' to show what features were
>   linked, aliased as well as a shorter 'perf -vv' (Jin Yao)
> 
> - Add a "dso_size" sort order (Kim Phillips)
> 
> - Remove redundant ')' in the tracepoint output in 'perf trace' (Changbin Du)
> 
> - Synchronize x86's cpufeatures.h, no effect on tools (Arnaldo Carvalho de 
> Melo)
> 
> Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
> 
> 
> Arnaldo Carvalho de Melo (9):
>   tools headers: Synchronize x86's cpufeatures.h
>   perf trace: Show only failing syscalls
>   perf hists browser: Rename perf_evsel_browser_title to a more 
> descriptive name
>   perf hists: Introduce hists__scnprint_title()
>   perf hists: Move hists__scnprintf_title() away from the TUI code
>   perf ui browser: Move the extra title lines from the hists browser
>   perf annotate: Introduce annotation__scnprintf_samples_period() method
>   perf annotate browser: Show extra title line with event information
>   perf annotate stdio2: Print more descriptive event information header
> 
> Changbin Du (1):
>   perf trace: Remove redundant ')'
> 
> Jin Yao (5):
>   perf config: Add some new -DHAVE_XXX to CFLAGS
>   perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT
>   perf version: Print the compiled-in status of libraries
>   perf tools: Add 'perf -vv' as an alias to 'perf version --build-options'
>   perf version: Add man page
> 
> Jiri Olsa (1):
>   tools include: Add config.h header file
> 
> Kim Phillips (1):
>   perf tools: Add a "dso_size" sort order
> 
>  tools/arch/x86/include/asm/cpufeatures.h  |   2 +
>  tools/include/tools/config.h  |  34 
>  tools/perf/Documentation/perf-report.txt  |   1 +
>  tools/perf/Documentation/perf-trace.txt   |   3 +
>  tools/perf/Documentation/perf-version.txt |  24 ++
>  tools/perf/Makefile.config|   8 +-
>  tools/perf/builtin-trace.c|  11 ++-
>  tools/perf/builtin-version.c  |  82 +++-
>  tools/perf/perf.c |   6 ++
>  tools/perf/perf.h |   1 +
>  tools/perf/ui/browser.c   |   8 +-
>  tools/perf/ui/browser.h   |   2 +
>  tools/perf/ui/browsers/annotate.c |  31 +++-
>  tools/perf/ui/browsers/hists.c| 125 
> +++---
>  tools/perf/util/annotate.c|  48 ++--
>  tools/perf/util/annotate.h|  12 +++
>  tools/perf/util/dwarf-aux.c   |   2 +-
>  tools/perf/util/hist.c|  81 +++
>  tools/perf/util/hist.h|   7 ++
>  tools/perf/util/map.h |   4 +
>  tools/perf/util/sort.c|  41 ++
>  tools/perf/util/sort.h|   1 +
>  22 files changed, 418 insertions(+), 116 deletions(-)
>  create mode 100644 tools/include/tools/config.h
>  create mode 100644 tools/perf/Documentation/perf-version.txt

Pulled, thanks a lot Arnaldo!

Ingo


Re: [GIT PULL 00/17] perf/core improvements and fixes

2018-04-03 Thread Ingo Molnar

* Arnaldo Carvalho de Melo  wrote:

> Hi Ingo,
> 
>   Please consider pulling,
> 
> - Arnaldo
> 
> Test results at the end of this message, as usual.
> 
> The following changes since commit 1159e09476536250c2a0173d4298d15114df7a89:
> 
>   perf/x86/intel: Enable C-state residency events for Cannon Lake (2018-03-31 
> 11:28:36 +0200)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git 
> tags/perf-core-for-mingo-4.17-20180403
> 
> for you to fetch changes up to 51125a29a395048fdb3429b8c4ca0ada57097744:
> 
>   perf trace: Remove redundant ')' (2018-04-03 16:16:41 -0300)
> 
> 
> perf/core improvements and fixes:
> 
> - Show only failing syscalls with 'perf trace --failure' (Arnaldo Carvalho de 
> Melo)
> 
>   e.g: See what 'openat' syscalls are failing:
> 
>   # perf trace --failure -e openat
>762.323 ( 0.007 ms): VideoCapture/4566 openat(dfd: CWD, filename: 
> /dev/video2) = -1 ENOENT No such file or directory
> lid?!? 8-) >
>790.228 ( 0.008 ms): VideoCapture/4566 openat(dfd: CWD, filename: 
> /dev/video63) = -1 ENOENT No such file or directory
>   ^C#
> 
> - Show information about the event (freq, nr_samples, total period/nr_events) 
> in
>   the annotate --tui and --stdio2 'perf annotate' output, similar to the
>   first line in the 'perf report --tui', but just for the samples for
>   the annotated symbol (Arnaldo Carvalho de Melo)
> 
> - Introduce 'perf version --build-options' to show what features were
>   linked, aliased as well as a shorter 'perf -vv' (Jin Yao)
> 
> - Add a "dso_size" sort order (Kim Phillips)
> 
> - Remove redundant ')' in the tracepoint output in 'perf trace' (Changbin Du)
> 
> - Synchronize x86's cpufeatures.h, no effect on tools (Arnaldo Carvalho de 
> Melo)
> 
> Signed-off-by: Arnaldo Carvalho de Melo 
> 
> 
> Arnaldo Carvalho de Melo (9):
>   tools headers: Synchronize x86's cpufeatures.h
>   perf trace: Show only failing syscalls
>   perf hists browser: Rename perf_evsel_browser_title to a more 
> descriptive name
>   perf hists: Introduce hists__scnprint_title()
>   perf hists: Move hists__scnprintf_title() away from the TUI code
>   perf ui browser: Move the extra title lines from the hists browser
>   perf annotate: Introduce annotation__scnprintf_samples_period() method
>   perf annotate browser: Show extra title line with event information
>   perf annotate stdio2: Print more descriptive event information header
> 
> Changbin Du (1):
>   perf trace: Remove redundant ')'
> 
> Jin Yao (5):
>   perf config: Add some new -DHAVE_XXX to CFLAGS
>   perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT
>   perf version: Print the compiled-in status of libraries
>   perf tools: Add 'perf -vv' as an alias to 'perf version --build-options'
>   perf version: Add man page
> 
> Jiri Olsa (1):
>   tools include: Add config.h header file
> 
> Kim Phillips (1):
>   perf tools: Add a "dso_size" sort order
> 
>  tools/arch/x86/include/asm/cpufeatures.h  |   2 +
>  tools/include/tools/config.h  |  34 
>  tools/perf/Documentation/perf-report.txt  |   1 +
>  tools/perf/Documentation/perf-trace.txt   |   3 +
>  tools/perf/Documentation/perf-version.txt |  24 ++
>  tools/perf/Makefile.config|   8 +-
>  tools/perf/builtin-trace.c|  11 ++-
>  tools/perf/builtin-version.c  |  82 +++-
>  tools/perf/perf.c |   6 ++
>  tools/perf/perf.h |   1 +
>  tools/perf/ui/browser.c   |   8 +-
>  tools/perf/ui/browser.h   |   2 +
>  tools/perf/ui/browsers/annotate.c |  31 +++-
>  tools/perf/ui/browsers/hists.c| 125 
> +++---
>  tools/perf/util/annotate.c|  48 ++--
>  tools/perf/util/annotate.h|  12 +++
>  tools/perf/util/dwarf-aux.c   |   2 +-
>  tools/perf/util/hist.c|  81 +++
>  tools/perf/util/hist.h|   7 ++
>  tools/perf/util/map.h |   4 +
>  tools/perf/util/sort.c|  41 ++
>  tools/perf/util/sort.h|   1 +
>  22 files changed, 418 insertions(+), 116 deletions(-)
>  create mode 100644 tools/include/tools/config.h
>  create mode 100644 tools/perf/Documentation/perf-version.txt

Pulled, thanks a lot Arnaldo!

Ingo


Re: possible deadlock in skb_queue_tail

2018-04-03 Thread Cong Wang
On Tue, Apr 3, 2018 at 4:42 AM, Kirill Tkhai  wrote:
> On 03.04.2018 14:25, Dmitry Vyukov wrote:
>> On Tue, Apr 3, 2018 at 11:50 AM, Kirill Tkhai  wrote:
>>> sk_diag_dump_icons() dumps only sockets in TCP_LISTEN state.
>>> TCP_LISTEN state may be assigned in only place in net/unix/af_unix.c:
>>> it's unix_listen(). The function is applied to stream and seqpacket
>>> socket types.
>>>
>>> It can't be stream because of the second stack, and seqpacket also can't,
>>> as I don't think it's possible for gcc to inline unix_seqpacket_sendmsg()
>>> in the way, we don't see it in the stack.
>>>
>>> So, this is looks like false positive result for me.
>>>
>>> Kirill
>>
>> Do you mean that these &(>lock)->rlock/1 referenced in 2 stacks are
>> always different?
>
> In these 2 particular stacks they have to be different.

So actually my patch could fix this false positive? I thought it couldn't.
https://patchwork.ozlabs.org/patch/894342/


Re: possible deadlock in skb_queue_tail

2018-04-03 Thread Cong Wang
On Tue, Apr 3, 2018 at 4:42 AM, Kirill Tkhai  wrote:
> On 03.04.2018 14:25, Dmitry Vyukov wrote:
>> On Tue, Apr 3, 2018 at 11:50 AM, Kirill Tkhai  wrote:
>>> sk_diag_dump_icons() dumps only sockets in TCP_LISTEN state.
>>> TCP_LISTEN state may be assigned in only place in net/unix/af_unix.c:
>>> it's unix_listen(). The function is applied to stream and seqpacket
>>> socket types.
>>>
>>> It can't be stream because of the second stack, and seqpacket also can't,
>>> as I don't think it's possible for gcc to inline unix_seqpacket_sendmsg()
>>> in the way, we don't see it in the stack.
>>>
>>> So, this is looks like false positive result for me.
>>>
>>> Kirill
>>
>> Do you mean that these &(>lock)->rlock/1 referenced in 2 stacks are
>> always different?
>
> In these 2 particular stacks they have to be different.

So actually my patch could fix this false positive? I thought it couldn't.
https://patchwork.ozlabs.org/patch/894342/


Re: [RFC PATCH 0/3] Documentation/features: Provide and apply "features-refresh.sh"

2018-04-03 Thread Ingo Molnar

* Andrea Parri  wrote:

> In Ingo's words [1]:
> 
>   "[...]  what should be done instead is to write a script that refreshes
>all the arch-support.txt files in-place. [...]
> 
>It's OK for the script to have various quirks for weirdly implemented
>features and exceptions: i.e. basically whenever it gets a feature wrong,
>we can just tweak the script with quirks to make it all work out of box.
> 
>[...]  But in the end there should only be a single new script:
> 
>  Documentation/features/scripts/features-refresh.sh
> 
>... which operates on the arch-support.txt files and refreshes them in
>place, and which, after all the refreshes have been committed, should
>produce an empty 'git diff' result."
> 
>   "[...]  New features can then be added by basically just creating a
>header-only arch-support.txt file, such as:
> 
>  triton:~/tip/Documentation/features> cat foo/bar/arch-support.txt
>  #
>  # Feature name:  shiny new fubar kernel feature
>  # Kconfig:   ARCH_USE_FUBAR
>  # description:   arch supports the fubar feature
>  #
> 
>And running Documentation/features/scripts/features-refresh.sh would
>auto-generate the arch support matrix. [...]
>  
>This way we soft- decouple the refreshing of the entries from the
>introduction of the features, while still making it all easy to keep
>sync and to extend."
> 
> This RFC presents a first attempt to implement such a feature/script, and
> applies it script on top of Arnd's:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git 
> arch-removal
> 
> Patch 1/3 provides the "features-refresh.sh" script.  Patch 2/3 removes the
> "BPF-JIT" feature file and it creates header-only files for "cBPF-JIT" and
> "eBPF-JIT".  Patch 3/3 presents the results of running the script; this run
> also printed to standard output the following warnings:
> 
>   WARNING: '__HAVE_ARCH_STRNCASECMP' is not a valid Kconfig
>   WARNING: 'Optimized asm/rwsem.h' is not a valid Kconfig
>   WARNING: '!ARCH_USES_GETTIMEOFFSET' is not a valid Kconfig
>   WARNING: '__HAVE_ARCH_PTE_SPECIAL' is not a valid Kconfig
> 
> (I'm sending these patches with empty commit messagges, for early feedback:
>  I'll fill in these messages in subsequent versions if this makes sense...)
> 
> Cheers,
>   Andrea
> 
> Andrea Parri (3):
>   Documentation/features: Add script that refreshes the arch support status 
> files in place
>   Documentation/features/core: Add arch support status files for 'cBPF-JIT' 
> and 'eBPF-JIT'
>   Documentation/features: Refresh and auto-generate the arch support status 
> files in place

Ok, this series is really impressive at its RFC stage already!

Beyond fixing those warnings, I'd also suggest another change: please make the 
new BPF features patch the last one, so that the 'refresh' patch shows how much 
original bit-rot we gathered recently.

The 'new features' patch should then also include the result of also running 
the 
script, i.e. a single patch adding the base fields and the generated parts as 
well. That will be the usual development flow anyway - people won't do two-part 
patches just to show which bits are by hand and which are auto-generated.

Thanks,

Ingo


Re: [RFC PATCH 0/3] Documentation/features: Provide and apply "features-refresh.sh"

2018-04-03 Thread Ingo Molnar

* Andrea Parri  wrote:

> In Ingo's words [1]:
> 
>   "[...]  what should be done instead is to write a script that refreshes
>all the arch-support.txt files in-place. [...]
> 
>It's OK for the script to have various quirks for weirdly implemented
>features and exceptions: i.e. basically whenever it gets a feature wrong,
>we can just tweak the script with quirks to make it all work out of box.
> 
>[...]  But in the end there should only be a single new script:
> 
>  Documentation/features/scripts/features-refresh.sh
> 
>... which operates on the arch-support.txt files and refreshes them in
>place, and which, after all the refreshes have been committed, should
>produce an empty 'git diff' result."
> 
>   "[...]  New features can then be added by basically just creating a
>header-only arch-support.txt file, such as:
> 
>  triton:~/tip/Documentation/features> cat foo/bar/arch-support.txt
>  #
>  # Feature name:  shiny new fubar kernel feature
>  # Kconfig:   ARCH_USE_FUBAR
>  # description:   arch supports the fubar feature
>  #
> 
>And running Documentation/features/scripts/features-refresh.sh would
>auto-generate the arch support matrix. [...]
>  
>This way we soft- decouple the refreshing of the entries from the
>introduction of the features, while still making it all easy to keep
>sync and to extend."
> 
> This RFC presents a first attempt to implement such a feature/script, and
> applies it script on top of Arnd's:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git 
> arch-removal
> 
> Patch 1/3 provides the "features-refresh.sh" script.  Patch 2/3 removes the
> "BPF-JIT" feature file and it creates header-only files for "cBPF-JIT" and
> "eBPF-JIT".  Patch 3/3 presents the results of running the script; this run
> also printed to standard output the following warnings:
> 
>   WARNING: '__HAVE_ARCH_STRNCASECMP' is not a valid Kconfig
>   WARNING: 'Optimized asm/rwsem.h' is not a valid Kconfig
>   WARNING: '!ARCH_USES_GETTIMEOFFSET' is not a valid Kconfig
>   WARNING: '__HAVE_ARCH_PTE_SPECIAL' is not a valid Kconfig
> 
> (I'm sending these patches with empty commit messagges, for early feedback:
>  I'll fill in these messages in subsequent versions if this makes sense...)
> 
> Cheers,
>   Andrea
> 
> Andrea Parri (3):
>   Documentation/features: Add script that refreshes the arch support status 
> files in place
>   Documentation/features/core: Add arch support status files for 'cBPF-JIT' 
> and 'eBPF-JIT'
>   Documentation/features: Refresh and auto-generate the arch support status 
> files in place

Ok, this series is really impressive at its RFC stage already!

Beyond fixing those warnings, I'd also suggest another change: please make the 
new BPF features patch the last one, so that the 'refresh' patch shows how much 
original bit-rot we gathered recently.

The 'new features' patch should then also include the result of also running 
the 
script, i.e. a single patch adding the base fields and the generated parts as 
well. That will be the usual development flow anyway - people won't do two-part 
patches just to show which bits are by hand and which are auto-generated.

Thanks,

Ingo


[git pull] vfs pile 1 (dcache)

2018-04-03 Thread Al Viro
fs/dcache.c work, mostly - part of that is what trylock elimination
series has turned into, part - making d_move() preserve the parent (and thus
the path) of victim, plus some general cleanups.

The following changes since commit 8cc07c808c9d595e81cbe5aad419b7769eb2e5c9:

  fs: dcache: Use READ_ONCE when accessing i_dir_seq (2018-02-25 12:51:10 -0500)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git work.dcache

for you to fetch changes up to 04bbc9795d2e89c79edf48fb1303ace2e8c90a60:

  Merge branch 'old.dcache' into work.dcache (2018-04-04 00:40:19 -0400)


Al Viro (19):
  take write_seqcount_invalidate() into __d_drop()
  d_delete(): get rid of trylock loop
  get rid of trylock loop in locking dentries on shrink list
  now lock_parent() can't run into killed dentry
  split the slow part of lock_parent() off
  dput(): consolidate the "do we need to retain it?" into an inlined helper
  handle move to LRU in retain_dentry()
  get rid of trylock loop around dentry_kill()
  dcache.c: trim includes
  split d_path() and friends into a separate file
  take out orphan externs (empty_string/slash_string)
  fold lookup_real() into __lookup_hash()
  debugfs_lookup(): switch to lookup_one_len_unlocked()
  lustre: get rid of pointless casts to struct dentry *
  oprofilefs: don't oops on allocation failure
  make non-exchanging __d_move() copy ->d_parent rather than swap them
  fold dentry_lock_for_move() into its sole caller and clean it up
  d_genocide: move export to definition
  Merge branch 'old.dcache' into work.dcache

John Ogness (3):
  fs/dcache: Remove stale comment from dentry_kill()
  fs/dcache: Move dentry_kill() below lock_parent()
  fs/dcache: Avoid a try_lock loop in shrink_dentry_list()

NeilBrown (1):
  constify more dcache.h inlined helpers.

 drivers/oprofile/oprofilefs.c|   3 +
 drivers/staging/lustre/lustre/llite/dcache.c |   6 +-
 fs/Makefile  |   2 +-
 fs/d_path.c  | 470 +
 fs/dcache.c  | 966 +++
 fs/debugfs/inode.c   |   5 +-
 fs/namei.c   |  41 +-
 include/linux/dcache.h   |   6 +-
 8 files changed, 735 insertions(+), 764 deletions(-)
 create mode 100644 fs/d_path.c


[git pull] vfs pile 1 (dcache)

2018-04-03 Thread Al Viro
fs/dcache.c work, mostly - part of that is what trylock elimination
series has turned into, part - making d_move() preserve the parent (and thus
the path) of victim, plus some general cleanups.

The following changes since commit 8cc07c808c9d595e81cbe5aad419b7769eb2e5c9:

  fs: dcache: Use READ_ONCE when accessing i_dir_seq (2018-02-25 12:51:10 -0500)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git work.dcache

for you to fetch changes up to 04bbc9795d2e89c79edf48fb1303ace2e8c90a60:

  Merge branch 'old.dcache' into work.dcache (2018-04-04 00:40:19 -0400)


Al Viro (19):
  take write_seqcount_invalidate() into __d_drop()
  d_delete(): get rid of trylock loop
  get rid of trylock loop in locking dentries on shrink list
  now lock_parent() can't run into killed dentry
  split the slow part of lock_parent() off
  dput(): consolidate the "do we need to retain it?" into an inlined helper
  handle move to LRU in retain_dentry()
  get rid of trylock loop around dentry_kill()
  dcache.c: trim includes
  split d_path() and friends into a separate file
  take out orphan externs (empty_string/slash_string)
  fold lookup_real() into __lookup_hash()
  debugfs_lookup(): switch to lookup_one_len_unlocked()
  lustre: get rid of pointless casts to struct dentry *
  oprofilefs: don't oops on allocation failure
  make non-exchanging __d_move() copy ->d_parent rather than swap them
  fold dentry_lock_for_move() into its sole caller and clean it up
  d_genocide: move export to definition
  Merge branch 'old.dcache' into work.dcache

John Ogness (3):
  fs/dcache: Remove stale comment from dentry_kill()
  fs/dcache: Move dentry_kill() below lock_parent()
  fs/dcache: Avoid a try_lock loop in shrink_dentry_list()

NeilBrown (1):
  constify more dcache.h inlined helpers.

 drivers/oprofile/oprofilefs.c|   3 +
 drivers/staging/lustre/lustre/llite/dcache.c |   6 +-
 fs/Makefile  |   2 +-
 fs/d_path.c  | 470 +
 fs/dcache.c  | 966 +++
 fs/debugfs/inode.c   |   5 +-
 fs/namei.c   |  41 +-
 include/linux/dcache.h   |   6 +-
 8 files changed, 735 insertions(+), 764 deletions(-)
 create mode 100644 fs/d_path.c


Re: [PATCH 09/11] x86/pti: enable global pages for shared areas

2018-04-03 Thread Nadav Amit
Dave Hansen  wrote:

> 
> From: Dave Hansen 
> 
> The entry/exit text and cpu_entry_area are mapped into userspace and
> the kernel.  But, they are not _PAGE_GLOBAL.  This creates unnecessary
> TLB misses.
> 
> Add the _PAGE_GLOBAL flag for these areas.
> 
> Signed-off-by: Dave Hansen 
> Cc: Andrea Arcangeli 
> Cc: Andy Lutomirski 
> Cc: Linus Torvalds 
> Cc: Kees Cook 
> Cc: Hugh Dickins 
> Cc: Juergen Gross 
> Cc: x...@kernel.org
> Cc: Nadav Amit 
> ---
> 
> b/arch/x86/mm/cpu_entry_area.c |   10 +-
> b/arch/x86/mm/pti.c|   14 +-
> 2 files changed, 22 insertions(+), 2 deletions(-)
> 
> diff -puN arch/x86/mm/cpu_entry_area.c~kpti-why-no-global 
> arch/x86/mm/cpu_entry_area.c
> --- a/arch/x86/mm/cpu_entry_area.c~kpti-why-no-global 2018-04-02 
> 16:41:17.157605167 -0700
> +++ b/arch/x86/mm/cpu_entry_area.c2018-04-02 16:41:17.162605167 -0700
> @@ -27,8 +27,16 @@ EXPORT_SYMBOL(get_cpu_entry_area);
> void cea_set_pte(void *cea_vaddr, phys_addr_t pa, pgprot_t flags)
> {
>   unsigned long va = (unsigned long) cea_vaddr;
> + pte_t pte = pfn_pte(pa >> PAGE_SHIFT, flags);
> 
> - set_pte_vaddr(va, pfn_pte(pa >> PAGE_SHIFT, flags));
> + /*
> +  * The cpu_entry_area is shared between the user and kernel
> +  * page tables.  All of its ptes can safely be global.
> +  */
> + if (boot_cpu_has(X86_FEATURE_PGE))
> + pte = pte_set_flags(pte, _PAGE_GLOBAL);

I think it would be safer to check that the PTE is indeed present before
setting _PAGE_GLOBAL. For example, percpu_setup_debug_store() sets PAGE_NONE
for non-present entries. In this case, since PAGE_NONE and PAGE_GLOBAL use
the same bit, everything would be fine, but it might cause bugs one day.

> +
> + set_pte_vaddr(va, pte);
> }
> 
> static void __init
> diff -puN arch/x86/mm/pti.c~kpti-why-no-global arch/x86/mm/pti.c
> --- a/arch/x86/mm/pti.c~kpti-why-no-global2018-04-02 16:41:17.159605167 
> -0700
> +++ b/arch/x86/mm/pti.c   2018-04-02 16:41:17.163605167 -0700
> @@ -300,6 +300,18 @@ pti_clone_pmds(unsigned long start, unsi
>   return;
> 
>   /*
> +  * Setting 'target_pmd' below creates a mapping in both
> +  * the user and kernel page tables.  It is effectively
> +  * global, so set it as global in both copies.  Note:
> +  * the X86_FEATURE_PGE check is not _required_ because
> +  * the CPU ignores _PAGE_GLOBAL when PGE is not
> +  * supported.  The check keeps consistentency with
> +  * code that only set this bit when supported.
> +  */
> + if (boot_cpu_has(X86_FEATURE_PGE))
> + *pmd = pmd_set_flags(*pmd, _PAGE_GLOBAL);

Same here.



Re: [PATCH 09/11] x86/pti: enable global pages for shared areas

2018-04-03 Thread Nadav Amit
Dave Hansen  wrote:

> 
> From: Dave Hansen 
> 
> The entry/exit text and cpu_entry_area are mapped into userspace and
> the kernel.  But, they are not _PAGE_GLOBAL.  This creates unnecessary
> TLB misses.
> 
> Add the _PAGE_GLOBAL flag for these areas.
> 
> Signed-off-by: Dave Hansen 
> Cc: Andrea Arcangeli 
> Cc: Andy Lutomirski 
> Cc: Linus Torvalds 
> Cc: Kees Cook 
> Cc: Hugh Dickins 
> Cc: Juergen Gross 
> Cc: x...@kernel.org
> Cc: Nadav Amit 
> ---
> 
> b/arch/x86/mm/cpu_entry_area.c |   10 +-
> b/arch/x86/mm/pti.c|   14 +-
> 2 files changed, 22 insertions(+), 2 deletions(-)
> 
> diff -puN arch/x86/mm/cpu_entry_area.c~kpti-why-no-global 
> arch/x86/mm/cpu_entry_area.c
> --- a/arch/x86/mm/cpu_entry_area.c~kpti-why-no-global 2018-04-02 
> 16:41:17.157605167 -0700
> +++ b/arch/x86/mm/cpu_entry_area.c2018-04-02 16:41:17.162605167 -0700
> @@ -27,8 +27,16 @@ EXPORT_SYMBOL(get_cpu_entry_area);
> void cea_set_pte(void *cea_vaddr, phys_addr_t pa, pgprot_t flags)
> {
>   unsigned long va = (unsigned long) cea_vaddr;
> + pte_t pte = pfn_pte(pa >> PAGE_SHIFT, flags);
> 
> - set_pte_vaddr(va, pfn_pte(pa >> PAGE_SHIFT, flags));
> + /*
> +  * The cpu_entry_area is shared between the user and kernel
> +  * page tables.  All of its ptes can safely be global.
> +  */
> + if (boot_cpu_has(X86_FEATURE_PGE))
> + pte = pte_set_flags(pte, _PAGE_GLOBAL);

I think it would be safer to check that the PTE is indeed present before
setting _PAGE_GLOBAL. For example, percpu_setup_debug_store() sets PAGE_NONE
for non-present entries. In this case, since PAGE_NONE and PAGE_GLOBAL use
the same bit, everything would be fine, but it might cause bugs one day.

> +
> + set_pte_vaddr(va, pte);
> }
> 
> static void __init
> diff -puN arch/x86/mm/pti.c~kpti-why-no-global arch/x86/mm/pti.c
> --- a/arch/x86/mm/pti.c~kpti-why-no-global2018-04-02 16:41:17.159605167 
> -0700
> +++ b/arch/x86/mm/pti.c   2018-04-02 16:41:17.163605167 -0700
> @@ -300,6 +300,18 @@ pti_clone_pmds(unsigned long start, unsi
>   return;
> 
>   /*
> +  * Setting 'target_pmd' below creates a mapping in both
> +  * the user and kernel page tables.  It is effectively
> +  * global, so set it as global in both copies.  Note:
> +  * the X86_FEATURE_PGE check is not _required_ because
> +  * the CPU ignores _PAGE_GLOBAL when PGE is not
> +  * supported.  The check keeps consistentency with
> +  * code that only set this bit when supported.
> +  */
> + if (boot_cpu_has(X86_FEATURE_PGE))
> + *pmd = pmd_set_flags(*pmd, _PAGE_GLOBAL);

Same here.



Re: [PATCH v10 2/2] fpga: lattice machxo2: Add Lattice MachXO2 support

2018-04-03 Thread kbuild test robot
Hi Paolo,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.16 next-20180403]
[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/Paolo-Pisati/dt-bindings-fpga-add-lattice-machxo2-slave-spi-binding-description/20180404-055540
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
   drivers/fpga/machxo2-spi.c:369:12: sparse: no member 'parent' in struct 
fpga_manager
>> drivers/fpga/machxo2-spi.c:375:33: sparse: not enough arguments for function 
>> fpga_mgr_register
>> drivers/fpga/machxo2-spi.c:382:29: sparse: incorrect type in argument 1 
>> (different base types) @@expected struct device *dev @@got 
>> structstruct device *dev @@
>> drivers/fpga/machxo2-spi.c:369:12: sparse: generating address of non-lvalue 
>> (8)
   drivers/fpga/machxo2-spi.c: In function 'machxo2_spi_probe':
   drivers/fpga/machxo2-spi.c:369:5: error: 'struct fpga_manager' has no member 
named 'parent'
 mgr->parent = dev;
^~
   drivers/fpga/machxo2-spi.c:375:27: error: passing argument 1 of 
'fpga_mgr_register' from incompatible pointer type 
[-Werror=incompatible-pointer-types]
 return fpga_mgr_register(mgr);
  ^~~
   In file included from drivers/fpga/machxo2-spi.c:12:0:
   include/linux/fpga/fpga-mgr.h:173:5: note: expected 'struct device *' but 
argument is of type 'struct fpga_manager *'
int fpga_mgr_register(struct device *dev, const char *name,
^
   drivers/fpga/machxo2-spi.c:375:9: error: too few arguments to function 
'fpga_mgr_register'
 return fpga_mgr_register(mgr);
^
   In file included from drivers/fpga/machxo2-spi.c:12:0:
   include/linux/fpga/fpga-mgr.h:173:5: note: declared here
int fpga_mgr_register(struct device *dev, const char *name,
^
   drivers/fpga/machxo2-spi.c: In function 'machxo2_spi_remove':
   drivers/fpga/machxo2-spi.c:382:22: error: passing argument 1 of 
'fpga_mgr_unregister' from incompatible pointer type 
[-Werror=incompatible-pointer-types]
 fpga_mgr_unregister(mgr);
 ^~~
   In file included from drivers/fpga/machxo2-spi.c:12:0:
   include/linux/fpga/fpga-mgr.h:176:6: note: expected 'struct device *' but 
argument is of type 'struct fpga_manager *'
void fpga_mgr_unregister(struct device *dev);
 ^~~
   drivers/fpga/machxo2-spi.c: In function 'machxo2_spi_probe':
   drivers/fpga/machxo2-spi.c:376:1: warning: control reaches end of non-void 
function [-Wreturn-type]
}
^
   cc1: some warnings being treated as errors

vim +86 drivers/fpga/machxo2-spi.c

65  
66  static int get_status(struct spi_device *spi, unsigned long *status)
67  {
68  struct spi_message msg;
69  struct spi_transfer rx, tx;
70  static const u8 cmd[] = LSC_READ_STATUS;
71  int ret;
72  
73  memset(, 0, sizeof(rx));
74  memset(, 0, sizeof(tx));
75  tx.tx_buf = cmd;
76  tx.len = sizeof(cmd);
77  rx.rx_buf = status;
78  rx.len = 4;
79  spi_message_init();
80  spi_message_add_tail(, );
81  spi_message_add_tail(, );
82  ret = spi_sync(spi, );
83  if (ret)
84  return ret;
85  
  > 86  *status = be32_to_cpu(*status);
87  
88  return 0;
89  }
90  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


Re: [PATCH v10 2/2] fpga: lattice machxo2: Add Lattice MachXO2 support

2018-04-03 Thread kbuild test robot
Hi Paolo,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.16 next-20180403]
[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/Paolo-Pisati/dt-bindings-fpga-add-lattice-machxo2-slave-spi-binding-description/20180404-055540
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
   drivers/fpga/machxo2-spi.c:369:12: sparse: no member 'parent' in struct 
fpga_manager
>> drivers/fpga/machxo2-spi.c:375:33: sparse: not enough arguments for function 
>> fpga_mgr_register
>> drivers/fpga/machxo2-spi.c:382:29: sparse: incorrect type in argument 1 
>> (different base types) @@expected struct device *dev @@got 
>> structstruct device *dev @@
>> drivers/fpga/machxo2-spi.c:369:12: sparse: generating address of non-lvalue 
>> (8)
   drivers/fpga/machxo2-spi.c: In function 'machxo2_spi_probe':
   drivers/fpga/machxo2-spi.c:369:5: error: 'struct fpga_manager' has no member 
named 'parent'
 mgr->parent = dev;
^~
   drivers/fpga/machxo2-spi.c:375:27: error: passing argument 1 of 
'fpga_mgr_register' from incompatible pointer type 
[-Werror=incompatible-pointer-types]
 return fpga_mgr_register(mgr);
  ^~~
   In file included from drivers/fpga/machxo2-spi.c:12:0:
   include/linux/fpga/fpga-mgr.h:173:5: note: expected 'struct device *' but 
argument is of type 'struct fpga_manager *'
int fpga_mgr_register(struct device *dev, const char *name,
^
   drivers/fpga/machxo2-spi.c:375:9: error: too few arguments to function 
'fpga_mgr_register'
 return fpga_mgr_register(mgr);
^
   In file included from drivers/fpga/machxo2-spi.c:12:0:
   include/linux/fpga/fpga-mgr.h:173:5: note: declared here
int fpga_mgr_register(struct device *dev, const char *name,
^
   drivers/fpga/machxo2-spi.c: In function 'machxo2_spi_remove':
   drivers/fpga/machxo2-spi.c:382:22: error: passing argument 1 of 
'fpga_mgr_unregister' from incompatible pointer type 
[-Werror=incompatible-pointer-types]
 fpga_mgr_unregister(mgr);
 ^~~
   In file included from drivers/fpga/machxo2-spi.c:12:0:
   include/linux/fpga/fpga-mgr.h:176:6: note: expected 'struct device *' but 
argument is of type 'struct fpga_manager *'
void fpga_mgr_unregister(struct device *dev);
 ^~~
   drivers/fpga/machxo2-spi.c: In function 'machxo2_spi_probe':
   drivers/fpga/machxo2-spi.c:376:1: warning: control reaches end of non-void 
function [-Wreturn-type]
}
^
   cc1: some warnings being treated as errors

vim +86 drivers/fpga/machxo2-spi.c

65  
66  static int get_status(struct spi_device *spi, unsigned long *status)
67  {
68  struct spi_message msg;
69  struct spi_transfer rx, tx;
70  static const u8 cmd[] = LSC_READ_STATUS;
71  int ret;
72  
73  memset(, 0, sizeof(rx));
74  memset(, 0, sizeof(tx));
75  tx.tx_buf = cmd;
76  tx.len = sizeof(cmd);
77  rx.rx_buf = status;
78  rx.len = 4;
79  spi_message_init();
80  spi_message_add_tail(, );
81  spi_message_add_tail(, );
82  ret = spi_sync(spi, );
83  if (ret)
84  return ret;
85  
  > 86  *status = be32_to_cpu(*status);
87  
88  return 0;
89  }
90  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


[PATCH 1/3] arm64: Set CONFIG_MULTI_IRQ_HANDLER

2018-04-03 Thread Palmer Dabbelt
arm has an optional MULTI_IRQ_HANDLER, which arm64 copied but didn't
make optional.  I'm converting this to generic code, but in order to aid
the porting effort I want to define this on arm64 for a bit.  This will
go away at the end of this patch set.

Signed-off-by: Palmer Dabbelt 
---
 arch/arm64/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 7381eeb7ef8e..302d0b681676 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -132,6 +132,7 @@ config ARM64
select IRQ_DOMAIN
select IRQ_FORCED_THREADING
select MODULES_USE_ELF_RELA
+   select MULTI_IRQ_HANDLER
select NO_BOOTMEM
select OF
select OF_EARLY_FLATTREE
@@ -275,6 +276,9 @@ config ARCH_SUPPORTS_UPROBES
 config ARCH_PROC_KCORE_TEXT
def_bool y
 
+config MULTI_IRQ_HANDLER
+   def_bool y
+
 source "init/Kconfig"
 
 source "kernel/Kconfig.freezer"
-- 
2.16.1



Re: [GIT pull] irq updates for 4.17

2018-04-03 Thread Palmer Dabbelt
On Tue, 03 Apr 2018 19:03:28 PDT (-0700), Linus Torvalds wrote:
> On Tue, Apr 3, 2018 at 6:51 PM, Palmer Dabbelt  wrote:
>>
>> Thanks!  The linked patch set should be fully bisectable, while this one
>> will fail on some ARM randconfigs.
>
> If it's only some (not very realistic) randconfigs, I suspect an
> incremental fix is probably the easier solution, rather than redoing
> that whole branch.

They're randconfigs that can't be selected via menuconfig so maybe that's not a
big deal (and it's why I missed it in the first place).  I'm a big fan of the
sorts of automated build tools that find all my bugs, which is why I was 
willing to jump through some hoops to make the patch set bisectable.

> So mind at least sending that incremental fix on top of the branch to
> Thomas and making his life easier if he decides to go that way?

I'm treating this as the cover letter to that patch set.  I've build
tested this with the same set of configs as my full patch set (arm
defconfig, arm64 defconfig, openrisc defconfig, and a failing arm config
from the 0-day robot) but only after the final patch was applied -- it's
not bisectable anyway.

I've dropped the various acknowledgements, as this is a bit messy and I
don't want to sign any else up as agreeing with it :).

I have follow-on patches to convert arm, arm64, and openrisc to
GENERIC_IRQ_MULTI_HANDLER and then remove the MULTI_IRQ_HANDLER, but
since they're not strictly part of this cleanup I'll submit those via a
more normal process if you end up taking these patches.

This is available as a more pull request smelling method via

git://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux.git
palmer-for-linus-4.17-ugly_irq

It's on top of the full IRQ pull request.  After doing everything I feel
like it might have been a bit better to base this only on top of the
broken patch (so git bisect could have a bit more info to avoid entering
the broken region), but I feel like that's splitting hairs at this
point.

> And if Thomas is busy doing something else (*), and I come back to
> this tomorrow as-is, I'd want to pull his tree and just apply the
> incremental fix anyway, so it makes sense to send it to me as well.
>
> Linus
>
> (*) I have long since accepted that some people have a life outside of
> kernel development too, and don't always reply immediately. I may not
> _understand_ it, but I am resigned to the fact.

Ah, well, I guess in this case it's all really my fault: While I
generally try to avoid having a life, I recently went outside to attend
ELC and managed to catch the flu, which resulted in me missing Thomas'
complaints of me breaking things.

I can't promise that won't happen again :).


[PATCH 2/3] openrisc: Set CONFIG_MULTI_IRQ_HANDLER

2018-04-03 Thread Palmer Dabbelt
arm has an optional MULTI_IRQ_HANDLER, which arm64 copied but didn't
make optional.  I'm converting this to generic code, but in order to aid
the porting effort I want to define this on arm64 for a bit.  This will
go away at the end of this patch set.

Signed-off-by: Palmer Dabbelt 
---
 arch/openrisc/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 339df7324e9c..9ecad05bfc73 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -27,6 +27,7 @@ config OPENRISC
select GENERIC_STRNLEN_USER
select GENERIC_SMP_IDLE_THREAD
select MODULES_USE_ELF_RELA
+   select MULTI_IRQ_HANDLER
select HAVE_DEBUG_STACKOVERFLOW
select OR1K_PIC
select CPU_NO_EFFICIENT_FFS if !OPENRISC_HAVE_INST_FF1
@@ -68,6 +69,9 @@ config STACKTRACE_SUPPORT
 config LOCKDEP_SUPPORT
def_bool  y
 
+config MULTI_IRQ_HANDLER
+   def_bool y
+
 source "init/Kconfig"
 
 source "kernel/Kconfig.freezer"
-- 
2.16.1



[PATCH 3/3] irq: GENERIC_IRQ_MULTI_HANDLER conflicts with MULTI_IRQ_HANDLER

2018-04-03 Thread Palmer Dabbelt
These define the same symbol so they're mutually exclusive.  By the end
of this patch set I'll have removed MULTI_IRQ_HANDLER, but for now it's
slightly easier to make these as conflicting so architectures that now
define MULTI_IRQ_HANDLER won't get the generic version selected by
randconfig.

This will go away when every port is converted over to
GENERIC_IRQ_MULTI_HANDLER.

Signed-off-by: Palmer Dabbelt 
---
 kernel/irq/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index 5f3e2baefca9..c6766f326072 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -134,6 +134,7 @@ config GENERIC_IRQ_DEBUGFS
 endmenu
 
 config GENERIC_IRQ_MULTI_HANDLER
+   depends on !MULTI_IRQ_HANDLER
bool
help
  Allow to specify the low level IRQ handler at run time.
-- 
2.16.1



[PATCH 1/3] arm64: Set CONFIG_MULTI_IRQ_HANDLER

2018-04-03 Thread Palmer Dabbelt
arm has an optional MULTI_IRQ_HANDLER, which arm64 copied but didn't
make optional.  I'm converting this to generic code, but in order to aid
the porting effort I want to define this on arm64 for a bit.  This will
go away at the end of this patch set.

Signed-off-by: Palmer Dabbelt 
---
 arch/arm64/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 7381eeb7ef8e..302d0b681676 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -132,6 +132,7 @@ config ARM64
select IRQ_DOMAIN
select IRQ_FORCED_THREADING
select MODULES_USE_ELF_RELA
+   select MULTI_IRQ_HANDLER
select NO_BOOTMEM
select OF
select OF_EARLY_FLATTREE
@@ -275,6 +276,9 @@ config ARCH_SUPPORTS_UPROBES
 config ARCH_PROC_KCORE_TEXT
def_bool y
 
+config MULTI_IRQ_HANDLER
+   def_bool y
+
 source "init/Kconfig"
 
 source "kernel/Kconfig.freezer"
-- 
2.16.1



Re: [GIT pull] irq updates for 4.17

2018-04-03 Thread Palmer Dabbelt
On Tue, 03 Apr 2018 19:03:28 PDT (-0700), Linus Torvalds wrote:
> On Tue, Apr 3, 2018 at 6:51 PM, Palmer Dabbelt  wrote:
>>
>> Thanks!  The linked patch set should be fully bisectable, while this one
>> will fail on some ARM randconfigs.
>
> If it's only some (not very realistic) randconfigs, I suspect an
> incremental fix is probably the easier solution, rather than redoing
> that whole branch.

They're randconfigs that can't be selected via menuconfig so maybe that's not a
big deal (and it's why I missed it in the first place).  I'm a big fan of the
sorts of automated build tools that find all my bugs, which is why I was 
willing to jump through some hoops to make the patch set bisectable.

> So mind at least sending that incremental fix on top of the branch to
> Thomas and making his life easier if he decides to go that way?

I'm treating this as the cover letter to that patch set.  I've build
tested this with the same set of configs as my full patch set (arm
defconfig, arm64 defconfig, openrisc defconfig, and a failing arm config
from the 0-day robot) but only after the final patch was applied -- it's
not bisectable anyway.

I've dropped the various acknowledgements, as this is a bit messy and I
don't want to sign any else up as agreeing with it :).

I have follow-on patches to convert arm, arm64, and openrisc to
GENERIC_IRQ_MULTI_HANDLER and then remove the MULTI_IRQ_HANDLER, but
since they're not strictly part of this cleanup I'll submit those via a
more normal process if you end up taking these patches.

This is available as a more pull request smelling method via

git://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux.git
palmer-for-linus-4.17-ugly_irq

It's on top of the full IRQ pull request.  After doing everything I feel
like it might have been a bit better to base this only on top of the
broken patch (so git bisect could have a bit more info to avoid entering
the broken region), but I feel like that's splitting hairs at this
point.

> And if Thomas is busy doing something else (*), and I come back to
> this tomorrow as-is, I'd want to pull his tree and just apply the
> incremental fix anyway, so it makes sense to send it to me as well.
>
> Linus
>
> (*) I have long since accepted that some people have a life outside of
> kernel development too, and don't always reply immediately. I may not
> _understand_ it, but I am resigned to the fact.

Ah, well, I guess in this case it's all really my fault: While I
generally try to avoid having a life, I recently went outside to attend
ELC and managed to catch the flu, which resulted in me missing Thomas'
complaints of me breaking things.

I can't promise that won't happen again :).


[PATCH 2/3] openrisc: Set CONFIG_MULTI_IRQ_HANDLER

2018-04-03 Thread Palmer Dabbelt
arm has an optional MULTI_IRQ_HANDLER, which arm64 copied but didn't
make optional.  I'm converting this to generic code, but in order to aid
the porting effort I want to define this on arm64 for a bit.  This will
go away at the end of this patch set.

Signed-off-by: Palmer Dabbelt 
---
 arch/openrisc/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 339df7324e9c..9ecad05bfc73 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -27,6 +27,7 @@ config OPENRISC
select GENERIC_STRNLEN_USER
select GENERIC_SMP_IDLE_THREAD
select MODULES_USE_ELF_RELA
+   select MULTI_IRQ_HANDLER
select HAVE_DEBUG_STACKOVERFLOW
select OR1K_PIC
select CPU_NO_EFFICIENT_FFS if !OPENRISC_HAVE_INST_FF1
@@ -68,6 +69,9 @@ config STACKTRACE_SUPPORT
 config LOCKDEP_SUPPORT
def_bool  y
 
+config MULTI_IRQ_HANDLER
+   def_bool y
+
 source "init/Kconfig"
 
 source "kernel/Kconfig.freezer"
-- 
2.16.1



[PATCH 3/3] irq: GENERIC_IRQ_MULTI_HANDLER conflicts with MULTI_IRQ_HANDLER

2018-04-03 Thread Palmer Dabbelt
These define the same symbol so they're mutually exclusive.  By the end
of this patch set I'll have removed MULTI_IRQ_HANDLER, but for now it's
slightly easier to make these as conflicting so architectures that now
define MULTI_IRQ_HANDLER won't get the generic version selected by
randconfig.

This will go away when every port is converted over to
GENERIC_IRQ_MULTI_HANDLER.

Signed-off-by: Palmer Dabbelt 
---
 kernel/irq/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index 5f3e2baefca9..c6766f326072 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -134,6 +134,7 @@ config GENERIC_IRQ_DEBUGFS
 endmenu
 
 config GENERIC_IRQ_MULTI_HANDLER
+   depends on !MULTI_IRQ_HANDLER
bool
help
  Allow to specify the low level IRQ handler at run time.
-- 
2.16.1



Re: [GIT PULL] Kernel lockdown for secure boot

2018-04-03 Thread Matthew Garrett
On Tue, Apr 3, 2018 at 7:34 PM Alexei Starovoitov <
alexei.starovoi...@gmail.com> wrote:
> If the only thing that folks are paranoid about is reading
> arbitrary kernel memory with bpf_probe_read() helper
> then preferred patch would be to disable it during verification
> when in lockdown mode.
> No run-time overhead and android folks will be happy
> that lockdown doesn't break their work.
> They converted out-of-tree networking accounting
> module and corresponding user daemon to use bpf:

https://www.linuxplumbersconf.org/2017/ocw/system/presentations/4791/original/eBPF%20cgroup%20filters%20for%20data%20usage%20accounting%20on%20Android.pdf

An alternative would be to only disable kernel reads if the kernel contains
secrets that aren't supposed to be readable by root. If the keyring is
configured such that root can read everything, it seems like less of a
concern?


Re: [GIT PULL] Kernel lockdown for secure boot

2018-04-03 Thread Matthew Garrett
On Tue, Apr 3, 2018 at 7:34 PM Alexei Starovoitov <
alexei.starovoi...@gmail.com> wrote:
> If the only thing that folks are paranoid about is reading
> arbitrary kernel memory with bpf_probe_read() helper
> then preferred patch would be to disable it during verification
> when in lockdown mode.
> No run-time overhead and android folks will be happy
> that lockdown doesn't break their work.
> They converted out-of-tree networking accounting
> module and corresponding user daemon to use bpf:

https://www.linuxplumbersconf.org/2017/ocw/system/presentations/4791/original/eBPF%20cgroup%20filters%20for%20data%20usage%20accounting%20on%20Android.pdf

An alternative would be to only disable kernel reads if the kernel contains
secrets that aren't supposed to be readable by root. If the keyring is
configured such that root can read everything, it seems like less of a
concern?


Re: [GIT PULL] Kernel lockdown for secure boot

2018-04-03 Thread Matthew Garrett
On Tue, Apr 3, 2018 at 6:43 PM Linus Torvalds

wrote:

> On Tue, Apr 3, 2018 at 6:13 PM, Matthew Garrett  wrote:
> >
> > There are four cases:

> No.

> Matthew., stop with the agenda already.

> This shit is what I'm talking about:

> > Verified Boot off, lockdown on: Perception of security improvement
that's
> > trivially circumvented (and so bad)

> You're doing some serious value judgement that is simply bogus.

> If lockdown actually helps avoid CPL0 execution attacks, then it helps
> even if secure more is off.

Bear in mind that I'm talking about defaults here - in more constrained
configurations the answers may change. But the kernel has no way of knowing
whether it's in one of those configurations, and as a result there's an
argument for not overpromising on the security that you're providing users.
If a user has a configuration where you're able to verify that userspace
has some degree of protection (eg, disk encryption keys are in the TPM and
won't unseal if someone's switched out the kernel) then it's reasonable for
userland (or a kernel command line option) to enable the functionality.

What I'm afraid of is this turning into a "security" feature that ends up
being circumvented in most scenarios where it's currently deployed - eg,
module signatures are mostly worthless in the non-lockdown case because you
can just grab the sig_enforce symbol address and then kexec a preamble that
flips it back to N regardless of the kernel config. This is the sort of
thing that's not obvious to most users, and it potentially causes them to
make worse security decisions as a result. The goal for this part of the
patchset isn't to cover every single conceivable case, it's to provide
reasonable defaults in a way that makes life easier for distributions.

> Or think of virtual machines - which people often use on purpose for
> security things. Again, they very much are _not_ going to have secure
> boot, but it's not necessarily even possible to "replace the kernel
> and reboot" at all, because the kernel came from outside the virtual
> machine entirely, and rebooting might just kill the VM rather than
> restart anything.

And where you have a trustworthy external thing providing your kernel,
yeah, that's also an argument - and having a kernel command line argument
that enables it in this case also seems entirely reasonable.

> This is what I mean by having an agenda.  We all know you are a big
> proponent of secure boot. But it seems to cloud your arguments, by
> turning your assumptions and your agenda into an "argument" that is
> simply not even TRUE.

I'm making this argument from the perspective of "What should the kernel do
when it has no additional information". Having the kernel automatically
enable lockdown without the user being aware of which guarantees their
environment is providing risks giving users the impression of security that
they may not have - in that case it makes more sense to have the user make
an explicit decision to enable it.

> See what I'm unhappy about?

> > Verified Boot on, lockdown off: Perception of security improvement
that's
> > trivially circumvented (and so bad), status quo in mainline kernels

> I think this is entirely false too. Again, the "trivial circumvention"
> shows a bias and agenda that isn't really all that true.

> > Of these four options, only two make sense.

> No.

> You say that, because you have that bias and that agenda.

Ok. Only two make sense *in the absence of additional information about
local configuration*. Distributions have to make reasonable choices here,
and where a configuration choice decreases functionality and provides what
may only be a marginal increase in security it's not a good configuration
choice to make by default.

> That said, wouldn't it be equally good to just make the whole thing be
> a protected EFI variable instead? Once you have physical access to the
> EFI shell (to turn off secure boot) you have access to that too.

That's pretty much exactly what mokutil does, without you needing to find a
copy of the UEFI shell to install first. If you think there's a strong
enough need for it, we could definitely add an additional variable that
allowed you to disable lockdown without disabling signature validation.


Re: [GIT PULL] Kernel lockdown for secure boot

2018-04-03 Thread Matthew Garrett
On Tue, Apr 3, 2018 at 6:43 PM Linus Torvalds

wrote:

> On Tue, Apr 3, 2018 at 6:13 PM, Matthew Garrett  wrote:
> >
> > There are four cases:

> No.

> Matthew., stop with the agenda already.

> This shit is what I'm talking about:

> > Verified Boot off, lockdown on: Perception of security improvement
that's
> > trivially circumvented (and so bad)

> You're doing some serious value judgement that is simply bogus.

> If lockdown actually helps avoid CPL0 execution attacks, then it helps
> even if secure more is off.

Bear in mind that I'm talking about defaults here - in more constrained
configurations the answers may change. But the kernel has no way of knowing
whether it's in one of those configurations, and as a result there's an
argument for not overpromising on the security that you're providing users.
If a user has a configuration where you're able to verify that userspace
has some degree of protection (eg, disk encryption keys are in the TPM and
won't unseal if someone's switched out the kernel) then it's reasonable for
userland (or a kernel command line option) to enable the functionality.

What I'm afraid of is this turning into a "security" feature that ends up
being circumvented in most scenarios where it's currently deployed - eg,
module signatures are mostly worthless in the non-lockdown case because you
can just grab the sig_enforce symbol address and then kexec a preamble that
flips it back to N regardless of the kernel config. This is the sort of
thing that's not obvious to most users, and it potentially causes them to
make worse security decisions as a result. The goal for this part of the
patchset isn't to cover every single conceivable case, it's to provide
reasonable defaults in a way that makes life easier for distributions.

> Or think of virtual machines - which people often use on purpose for
> security things. Again, they very much are _not_ going to have secure
> boot, but it's not necessarily even possible to "replace the kernel
> and reboot" at all, because the kernel came from outside the virtual
> machine entirely, and rebooting might just kill the VM rather than
> restart anything.

And where you have a trustworthy external thing providing your kernel,
yeah, that's also an argument - and having a kernel command line argument
that enables it in this case also seems entirely reasonable.

> This is what I mean by having an agenda.  We all know you are a big
> proponent of secure boot. But it seems to cloud your arguments, by
> turning your assumptions and your agenda into an "argument" that is
> simply not even TRUE.

I'm making this argument from the perspective of "What should the kernel do
when it has no additional information". Having the kernel automatically
enable lockdown without the user being aware of which guarantees their
environment is providing risks giving users the impression of security that
they may not have - in that case it makes more sense to have the user make
an explicit decision to enable it.

> See what I'm unhappy about?

> > Verified Boot on, lockdown off: Perception of security improvement
that's
> > trivially circumvented (and so bad), status quo in mainline kernels

> I think this is entirely false too. Again, the "trivial circumvention"
> shows a bias and agenda that isn't really all that true.

> > Of these four options, only two make sense.

> No.

> You say that, because you have that bias and that agenda.

Ok. Only two make sense *in the absence of additional information about
local configuration*. Distributions have to make reasonable choices here,
and where a configuration choice decreases functionality and provides what
may only be a marginal increase in security it's not a good configuration
choice to make by default.

> That said, wouldn't it be equally good to just make the whole thing be
> a protected EFI variable instead? Once you have physical access to the
> EFI shell (to turn off secure boot) you have access to that too.

That's pretty much exactly what mokutil does, without you needing to find a
copy of the UEFI shell to install first. If you think there's a strong
enough need for it, we could definitely add an additional variable that
allowed you to disable lockdown without disabling signature validation.


[PATCH v4 0/3] ASoC: topology: Improve hw_configs

2018-04-03 Thread Kirill Marinushkin
Hello Mark,

This patch series waits since 20th of February, because it modifies UAPI headers
and should be done in sync with ALSA. I see that previously there was no clear
understanding, how to do this in sync.

Two days ago I discussed with Takashi, and he suggested the following steps:

Step 1. A person from Intel, who knows the topic (Pierre), adds his
"Reviewed-by" or "Acked-by" tags
Step 2. I clarify with you to apply the Linux part (this patch series)
Step 3. After that, I clarify with Takashi to apply the ALSA part (it is ready,
but not sent untill we apply the Linux part)

The step 1 is done. Old patches are reviewed by Pierre, so they have his
"Reviewed-by" tag. New patches are suggested by him, and we agreed on the
implementation, so they have his "Acked-by" tag.

Now we are on the step 2. If you don't have anything against this patch series,
please apply it to Linux.

Best Regards,
Kirill

Kirill Marinushkin (3):
  ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  ASoC: topology: Add missing clock gating parameter when parsing
hw_configs
  ASoC: topology: Add definitions for mclk_direction values

 include/uapi/sound/asoc.h | 29 +
 sound/soc/soc-topology.c  | 19 ++-
 2 files changed, 39 insertions(+), 9 deletions(-)

-- 
2.13.6



[PATCH v4 2/3] ASoC: topology: Add missing clock gating parameter when parsing hw_configs

2018-04-03 Thread Kirill Marinushkin
Clock gating parameter is a part of `dai_fmt`. It is supported by
`alsa-lib` when creating a topology binary file, but ignored by kernel
when loading this topology file.

After applying this commit, the clock gating parameter is not ignored any
more. This solution is backwards compatible. The existing behaviour is
not broken, because by default the parameter value is 0 and is ignored.

snd_soc_tplg_hw_config.clock_gated = 0 => no effect
snd_soc_tplg_hw_config.clock_gated = 1 => SND_SOC_DAIFMT_GATED
snd_soc_tplg_hw_config.clock_gated = 2 => SND_SOC_DAIFMT_CONT

For example, the following config, based on
alsa-lib/src/conf/topology/broadwell/broadwell.conf, is now supported:


SectionHWConfig."CodecHWConfig" {
id "1"
format "I2S"# physical audio format.
pm_gate_clocks "true"   # clock can be gated
}

SectionLink."Codec" {

# used for binding to the physical link
id "0"

hw_configs [
"CodecHWConfig"
]

default_hw_conf_id "1"
}


Signed-off-by: Kirill Marinushkin 
Reviewed-by: Pierre-Louis Bossart 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: Mark Brown 
Cc: Pan Xiuli 
Cc: Liam Girdwood 
Cc: linux-kernel@vger.kernel.org
Cc: alsa-de...@alsa-project.org
---
 include/uapi/sound/asoc.h | 7 ++-
 sound/soc/soc-topology.c  | 7 +++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h
index f0e5e21efa54..f3c4b46e39d8 100644
--- a/include/uapi/sound/asoc.h
+++ b/include/uapi/sound/asoc.h
@@ -139,6 +139,11 @@
 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS  (1 << 1)
 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS(1 << 2)
 
+/* DAI clock gating */
+#define SND_SOC_TPLG_DAI_CLK_GATE_UNDEFINED0
+#define SND_SOC_TPLG_DAI_CLK_GATE_GATED1
+#define SND_SOC_TPLG_DAI_CLK_GATE_CONT 2
+
 /* DAI physical PCM data formats.
  * Add new formats to the end of the list.
  */
@@ -324,7 +329,7 @@ struct snd_soc_tplg_hw_config {
__le32 size;/* in bytes of this structure */
__le32 id;  /* unique ID - - used to match */
__le32 fmt; /* SND_SOC_DAI_FORMAT_ format value */
-   __u8 clock_gated;   /* 1 if clock can be gated to save power */
+   __u8 clock_gated;   /* SND_SOC_TPLG_DAI_CLK_GATE_ value */
__u8 invert_bclk;   /* 1 for inverted BCLK, 0 for normal */
__u8 invert_fsync;  /* 1 for inverted frame clock, 0 for normal */
__u8 bclk_master;   /* SND_SOC_TPLG_BCLK_ value */
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index c5bdc673b195..04f834e6a6b5 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1981,6 +1981,13 @@ static void set_link_hw_format(struct snd_soc_dai_link 
*link,
 
link->dai_fmt = hw_config->fmt & SND_SOC_DAIFMT_FORMAT_MASK;
 
+   /* clock gating */
+   if (hw_config->clock_gated == SND_SOC_TPLG_DAI_CLK_GATE_GATED)
+   link->dai_fmt |= SND_SOC_DAIFMT_GATED;
+   else if (hw_config->clock_gated ==
+SND_SOC_TPLG_DAI_CLK_GATE_CONT)
+   link->dai_fmt |= SND_SOC_DAIFMT_CONT;
+
/* clock signal polarity */
invert_bclk = hw_config->invert_bclk;
invert_fsync = hw_config->invert_fsync;
-- 
2.13.6



[PATCH v4 1/3] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()

2018-04-03 Thread Kirill Marinushkin
The values of bclk and fsync are inverted WRT the codec. But the existing
solution already works for Broadwell, see the alsa-lib config:

`alsa-lib/src/conf/topology/broadwell/broadwell.conf`

This commit provides the backwards-compatible solution to fix this misuse.

Signed-off-by: Kirill Marinushkin 
Reviewed-by: Pierre-Louis Bossart 
Tested-by: Pan Xiuli 
Tested-by: Pierre-Louis Bossart 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: Mark Brown 
Cc: Liam Girdwood 
Cc: linux-kernel@vger.kernel.org
Cc: alsa-de...@alsa-project.org
---
 include/uapi/sound/asoc.h | 16 ++--
 sound/soc/soc-topology.c  | 12 +++-
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h
index 69c37ecbff7e..f0e5e21efa54 100644
--- a/include/uapi/sound/asoc.h
+++ b/include/uapi/sound/asoc.h
@@ -160,6 +160,18 @@
 #define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS(1 << 2)
 #define SND_SOC_TPLG_LNK_FLGBIT_VOICE_WAKEUP(1 << 3)
 
+/* DAI topology BCLK parameter
+ * For the backwards capability, by default codec is bclk master
+ */
+#define SND_SOC_TPLG_BCLK_CM 0 /* codec is bclk master */
+#define SND_SOC_TPLG_BCLK_CS 1 /* codec is bclk slave */
+
+/* DAI topology FSYNC parameter
+ * For the backwards capability, by default codec is fsync master
+ */
+#define SND_SOC_TPLG_FSYNC_CM 0 /* codec is fsync master */
+#define SND_SOC_TPLG_FSYNC_CS 1 /* codec is fsync slave */
+
 /*
  * Block Header.
  * This header precedes all object and object arrays below.
@@ -315,8 +327,8 @@ struct snd_soc_tplg_hw_config {
__u8 clock_gated;   /* 1 if clock can be gated to save power */
__u8 invert_bclk;   /* 1 for inverted BCLK, 0 for normal */
__u8 invert_fsync;  /* 1 for inverted frame clock, 0 for normal */
-   __u8 bclk_master;   /* 1 for master of BCLK, 0 for slave */
-   __u8 fsync_master;  /* 1 for master of FSYNC, 0 for slave */
+   __u8 bclk_master;   /* SND_SOC_TPLG_BCLK_ value */
+   __u8 fsync_master;  /* SND_SOC_TPLG_FSYNC_ value */
__u8 mclk_direction;/* 0 for input, 1 for output */
__le16 reserved;/* for 32bit alignment */
__le32 mclk_rate;   /* MCLK or SYSCLK freqency in Hz */
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 01a50413c66f..c5bdc673b195 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1994,13 +1994,15 @@ static void set_link_hw_format(struct snd_soc_dai_link 
*link,
link->dai_fmt |= SND_SOC_DAIFMT_IB_IF;
 
/* clock masters */
-   bclk_master = hw_config->bclk_master;
-   fsync_master = hw_config->fsync_master;
-   if (!bclk_master && !fsync_master)
+   bclk_master = (hw_config->bclk_master ==
+  SND_SOC_TPLG_BCLK_CM);
+   fsync_master = (hw_config->fsync_master ==
+   SND_SOC_TPLG_FSYNC_CM);
+   if (bclk_master && fsync_master)
link->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
-   else if (bclk_master && !fsync_master)
-   link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
else if (!bclk_master && fsync_master)
+   link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
+   else if (bclk_master && !fsync_master)
link->dai_fmt |= SND_SOC_DAIFMT_CBM_CFS;
else
link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
-- 
2.13.6



[PATCH v4 0/3] ASoC: topology: Improve hw_configs

2018-04-03 Thread Kirill Marinushkin
Hello Mark,

This patch series waits since 20th of February, because it modifies UAPI headers
and should be done in sync with ALSA. I see that previously there was no clear
understanding, how to do this in sync.

Two days ago I discussed with Takashi, and he suggested the following steps:

Step 1. A person from Intel, who knows the topic (Pierre), adds his
"Reviewed-by" or "Acked-by" tags
Step 2. I clarify with you to apply the Linux part (this patch series)
Step 3. After that, I clarify with Takashi to apply the ALSA part (it is ready,
but not sent untill we apply the Linux part)

The step 1 is done. Old patches are reviewed by Pierre, so they have his
"Reviewed-by" tag. New patches are suggested by him, and we agreed on the
implementation, so they have his "Acked-by" tag.

Now we are on the step 2. If you don't have anything against this patch series,
please apply it to Linux.

Best Regards,
Kirill

Kirill Marinushkin (3):
  ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  ASoC: topology: Add missing clock gating parameter when parsing
hw_configs
  ASoC: topology: Add definitions for mclk_direction values

 include/uapi/sound/asoc.h | 29 +
 sound/soc/soc-topology.c  | 19 ++-
 2 files changed, 39 insertions(+), 9 deletions(-)

-- 
2.13.6



[PATCH v4 2/3] ASoC: topology: Add missing clock gating parameter when parsing hw_configs

2018-04-03 Thread Kirill Marinushkin
Clock gating parameter is a part of `dai_fmt`. It is supported by
`alsa-lib` when creating a topology binary file, but ignored by kernel
when loading this topology file.

After applying this commit, the clock gating parameter is not ignored any
more. This solution is backwards compatible. The existing behaviour is
not broken, because by default the parameter value is 0 and is ignored.

snd_soc_tplg_hw_config.clock_gated = 0 => no effect
snd_soc_tplg_hw_config.clock_gated = 1 => SND_SOC_DAIFMT_GATED
snd_soc_tplg_hw_config.clock_gated = 2 => SND_SOC_DAIFMT_CONT

For example, the following config, based on
alsa-lib/src/conf/topology/broadwell/broadwell.conf, is now supported:


SectionHWConfig."CodecHWConfig" {
id "1"
format "I2S"# physical audio format.
pm_gate_clocks "true"   # clock can be gated
}

SectionLink."Codec" {

# used for binding to the physical link
id "0"

hw_configs [
"CodecHWConfig"
]

default_hw_conf_id "1"
}


Signed-off-by: Kirill Marinushkin 
Reviewed-by: Pierre-Louis Bossart 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: Mark Brown 
Cc: Pan Xiuli 
Cc: Liam Girdwood 
Cc: linux-kernel@vger.kernel.org
Cc: alsa-de...@alsa-project.org
---
 include/uapi/sound/asoc.h | 7 ++-
 sound/soc/soc-topology.c  | 7 +++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h
index f0e5e21efa54..f3c4b46e39d8 100644
--- a/include/uapi/sound/asoc.h
+++ b/include/uapi/sound/asoc.h
@@ -139,6 +139,11 @@
 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS  (1 << 1)
 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS(1 << 2)
 
+/* DAI clock gating */
+#define SND_SOC_TPLG_DAI_CLK_GATE_UNDEFINED0
+#define SND_SOC_TPLG_DAI_CLK_GATE_GATED1
+#define SND_SOC_TPLG_DAI_CLK_GATE_CONT 2
+
 /* DAI physical PCM data formats.
  * Add new formats to the end of the list.
  */
@@ -324,7 +329,7 @@ struct snd_soc_tplg_hw_config {
__le32 size;/* in bytes of this structure */
__le32 id;  /* unique ID - - used to match */
__le32 fmt; /* SND_SOC_DAI_FORMAT_ format value */
-   __u8 clock_gated;   /* 1 if clock can be gated to save power */
+   __u8 clock_gated;   /* SND_SOC_TPLG_DAI_CLK_GATE_ value */
__u8 invert_bclk;   /* 1 for inverted BCLK, 0 for normal */
__u8 invert_fsync;  /* 1 for inverted frame clock, 0 for normal */
__u8 bclk_master;   /* SND_SOC_TPLG_BCLK_ value */
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index c5bdc673b195..04f834e6a6b5 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1981,6 +1981,13 @@ static void set_link_hw_format(struct snd_soc_dai_link 
*link,
 
link->dai_fmt = hw_config->fmt & SND_SOC_DAIFMT_FORMAT_MASK;
 
+   /* clock gating */
+   if (hw_config->clock_gated == SND_SOC_TPLG_DAI_CLK_GATE_GATED)
+   link->dai_fmt |= SND_SOC_DAIFMT_GATED;
+   else if (hw_config->clock_gated ==
+SND_SOC_TPLG_DAI_CLK_GATE_CONT)
+   link->dai_fmt |= SND_SOC_DAIFMT_CONT;
+
/* clock signal polarity */
invert_bclk = hw_config->invert_bclk;
invert_fsync = hw_config->invert_fsync;
-- 
2.13.6



[PATCH v4 1/3] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()

2018-04-03 Thread Kirill Marinushkin
The values of bclk and fsync are inverted WRT the codec. But the existing
solution already works for Broadwell, see the alsa-lib config:

`alsa-lib/src/conf/topology/broadwell/broadwell.conf`

This commit provides the backwards-compatible solution to fix this misuse.

Signed-off-by: Kirill Marinushkin 
Reviewed-by: Pierre-Louis Bossart 
Tested-by: Pan Xiuli 
Tested-by: Pierre-Louis Bossart 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: Mark Brown 
Cc: Liam Girdwood 
Cc: linux-kernel@vger.kernel.org
Cc: alsa-de...@alsa-project.org
---
 include/uapi/sound/asoc.h | 16 ++--
 sound/soc/soc-topology.c  | 12 +++-
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h
index 69c37ecbff7e..f0e5e21efa54 100644
--- a/include/uapi/sound/asoc.h
+++ b/include/uapi/sound/asoc.h
@@ -160,6 +160,18 @@
 #define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS(1 << 2)
 #define SND_SOC_TPLG_LNK_FLGBIT_VOICE_WAKEUP(1 << 3)
 
+/* DAI topology BCLK parameter
+ * For the backwards capability, by default codec is bclk master
+ */
+#define SND_SOC_TPLG_BCLK_CM 0 /* codec is bclk master */
+#define SND_SOC_TPLG_BCLK_CS 1 /* codec is bclk slave */
+
+/* DAI topology FSYNC parameter
+ * For the backwards capability, by default codec is fsync master
+ */
+#define SND_SOC_TPLG_FSYNC_CM 0 /* codec is fsync master */
+#define SND_SOC_TPLG_FSYNC_CS 1 /* codec is fsync slave */
+
 /*
  * Block Header.
  * This header precedes all object and object arrays below.
@@ -315,8 +327,8 @@ struct snd_soc_tplg_hw_config {
__u8 clock_gated;   /* 1 if clock can be gated to save power */
__u8 invert_bclk;   /* 1 for inverted BCLK, 0 for normal */
__u8 invert_fsync;  /* 1 for inverted frame clock, 0 for normal */
-   __u8 bclk_master;   /* 1 for master of BCLK, 0 for slave */
-   __u8 fsync_master;  /* 1 for master of FSYNC, 0 for slave */
+   __u8 bclk_master;   /* SND_SOC_TPLG_BCLK_ value */
+   __u8 fsync_master;  /* SND_SOC_TPLG_FSYNC_ value */
__u8 mclk_direction;/* 0 for input, 1 for output */
__le16 reserved;/* for 32bit alignment */
__le32 mclk_rate;   /* MCLK or SYSCLK freqency in Hz */
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 01a50413c66f..c5bdc673b195 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1994,13 +1994,15 @@ static void set_link_hw_format(struct snd_soc_dai_link 
*link,
link->dai_fmt |= SND_SOC_DAIFMT_IB_IF;
 
/* clock masters */
-   bclk_master = hw_config->bclk_master;
-   fsync_master = hw_config->fsync_master;
-   if (!bclk_master && !fsync_master)
+   bclk_master = (hw_config->bclk_master ==
+  SND_SOC_TPLG_BCLK_CM);
+   fsync_master = (hw_config->fsync_master ==
+   SND_SOC_TPLG_FSYNC_CM);
+   if (bclk_master && fsync_master)
link->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
-   else if (bclk_master && !fsync_master)
-   link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
else if (!bclk_master && fsync_master)
+   link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
+   else if (bclk_master && !fsync_master)
link->dai_fmt |= SND_SOC_DAIFMT_CBM_CFS;
else
link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
-- 
2.13.6



[PATCH v4 3/3] ASoC: topology: Add definitions for mclk_direction values

2018-04-03 Thread Kirill Marinushkin
Current comment makes not clear the direction of mclk. Previously, similar
description caused a misunderstanding for bclk_master and fsync_master.

This commit solves the potential confusion the same way it is solved for
bclk_master and fsync_master.

Signed-off-by: Kirill Marinushkin 
Acked-by: Pierre-Louis Bossart 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: Mark Brown 
Cc: Pan Xiuli 
Cc: Liam Girdwood 
Cc: linux-kernel@vger.kernel.org
Cc: alsa-de...@alsa-project.org
---
 include/uapi/sound/asoc.h | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h
index f3c4b46e39d8..b901cdbe532a 100644
--- a/include/uapi/sound/asoc.h
+++ b/include/uapi/sound/asoc.h
@@ -144,6 +144,10 @@
 #define SND_SOC_TPLG_DAI_CLK_GATE_GATED1
 #define SND_SOC_TPLG_DAI_CLK_GATE_CONT 2
 
+/* DAI mclk_direction */
+#define SND_SOC_TPLG_MCLK_CO0 /* for codec, mclk is output */
+#define SND_SOC_TPLG_MCLK_CI1 /* for codec, mclk is input */
+
 /* DAI physical PCM data formats.
  * Add new formats to the end of the list.
  */
@@ -334,7 +338,7 @@ struct snd_soc_tplg_hw_config {
__u8 invert_fsync;  /* 1 for inverted frame clock, 0 for normal */
__u8 bclk_master;   /* SND_SOC_TPLG_BCLK_ value */
__u8 fsync_master;  /* SND_SOC_TPLG_FSYNC_ value */
-   __u8 mclk_direction;/* 0 for input, 1 for output */
+   __u8 mclk_direction;/* SND_SOC_TPLG_MCLK_ value */
__le16 reserved;/* for 32bit alignment */
__le32 mclk_rate;   /* MCLK or SYSCLK freqency in Hz */
__le32 bclk_rate;   /* BCLK freqency in Hz */
-- 
2.13.6



[PATCH v4 3/3] ASoC: topology: Add definitions for mclk_direction values

2018-04-03 Thread Kirill Marinushkin
Current comment makes not clear the direction of mclk. Previously, similar
description caused a misunderstanding for bclk_master and fsync_master.

This commit solves the potential confusion the same way it is solved for
bclk_master and fsync_master.

Signed-off-by: Kirill Marinushkin 
Acked-by: Pierre-Louis Bossart 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: Mark Brown 
Cc: Pan Xiuli 
Cc: Liam Girdwood 
Cc: linux-kernel@vger.kernel.org
Cc: alsa-de...@alsa-project.org
---
 include/uapi/sound/asoc.h | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h
index f3c4b46e39d8..b901cdbe532a 100644
--- a/include/uapi/sound/asoc.h
+++ b/include/uapi/sound/asoc.h
@@ -144,6 +144,10 @@
 #define SND_SOC_TPLG_DAI_CLK_GATE_GATED1
 #define SND_SOC_TPLG_DAI_CLK_GATE_CONT 2
 
+/* DAI mclk_direction */
+#define SND_SOC_TPLG_MCLK_CO0 /* for codec, mclk is output */
+#define SND_SOC_TPLG_MCLK_CI1 /* for codec, mclk is input */
+
 /* DAI physical PCM data formats.
  * Add new formats to the end of the list.
  */
@@ -334,7 +338,7 @@ struct snd_soc_tplg_hw_config {
__u8 invert_fsync;  /* 1 for inverted frame clock, 0 for normal */
__u8 bclk_master;   /* SND_SOC_TPLG_BCLK_ value */
__u8 fsync_master;  /* SND_SOC_TPLG_FSYNC_ value */
-   __u8 mclk_direction;/* 0 for input, 1 for output */
+   __u8 mclk_direction;/* SND_SOC_TPLG_MCLK_ value */
__le16 reserved;/* for 32bit alignment */
__le32 mclk_rate;   /* MCLK or SYSCLK freqency in Hz */
__le32 bclk_rate;   /* BCLK freqency in Hz */
-- 
2.13.6



Re: [PATCH 2/2] smp: introduce kick_active_cpus_sync()

2018-04-03 Thread Yury Norov
Hi Mark,

Thank you for review.

On Tue, Apr 03, 2018 at 02:48:32PM +0100, Mark Rutland wrote:
> Hi Yury,
> 
> On Sun, Apr 01, 2018 at 02:11:08PM +0300, Yury Norov wrote:
> > +/*
> > + * Flush I-cache if CPU is in extended quiescent state
> > + */
> 
> This comment is misleading. An ISB doesn't touch the I-cache; it forces
> a context synchronization event.
> 
> > +   .macro  isb_if_eqs
> > +#ifndef CONFIG_TINY_RCU
> > +   bl  rcu_is_watching
> > +   tst w0, #0xff
> > +   b.ne1f
> 
> The TST+B.NE can be a CBNZ:
> 
>   bl  rcu_is_watching
>   cbnzx0, 1f
>   isb
> 1:
> 
> > +   /* Pairs with aarch64_insn_patch_text for EQS CPUs. */
> > +   isb
> > +1:
> > +#endif
> > +   .endm
> > +
> >  el0_sync_invalid:
> > inv_entry 0, BAD_SYNC
> >  ENDPROC(el0_sync_invalid)
> > @@ -840,8 +861,10 @@ el0_svc:
> > mov wsc_nr, #__NR_syscalls
> >  el0_svc_naked: // compat entry point
> > stp x0, xscno, [sp, #S_ORIG_X0] // save the original x0 and 
> > syscall number
> > +   isb_if_eqs
> > enable_dbg_and_irq
> > -   ct_user_exit 1
> > +   ct_user_exit
> 
> I don't think this is safe. here we issue the ISB *before* exiting a
> quiesecent state, so I think we can race with another CPU that calls
> kick_all_active_cpus_sync, e.g.
> 
>   CPU0CPU1
> 
>   ISB
>   patch_some_text()
>   kick_all_active_cpus_sync()
>   ct_user_exit
> 
>   // not synchronized!
>   use_of_patched_text()
> 
> ... and therefore the ISB has no effect, which could be disasterous.
> 
> I believe we need the ISB *after* we transition into a non-quiescent
> state, so that we can't possibly miss a context synchronization event.
 
I decided to put isb() in entry because there's a chance that there will
be patched code prior to exiting a quiescent state. But after some
headscratching, I think it's safe. I'll do like you suggested here.

Thanks,
Yury


Re: [PATCH 2/2] smp: introduce kick_active_cpus_sync()

2018-04-03 Thread Yury Norov
Hi Mark,

Thank you for review.

On Tue, Apr 03, 2018 at 02:48:32PM +0100, Mark Rutland wrote:
> Hi Yury,
> 
> On Sun, Apr 01, 2018 at 02:11:08PM +0300, Yury Norov wrote:
> > +/*
> > + * Flush I-cache if CPU is in extended quiescent state
> > + */
> 
> This comment is misleading. An ISB doesn't touch the I-cache; it forces
> a context synchronization event.
> 
> > +   .macro  isb_if_eqs
> > +#ifndef CONFIG_TINY_RCU
> > +   bl  rcu_is_watching
> > +   tst w0, #0xff
> > +   b.ne1f
> 
> The TST+B.NE can be a CBNZ:
> 
>   bl  rcu_is_watching
>   cbnzx0, 1f
>   isb
> 1:
> 
> > +   /* Pairs with aarch64_insn_patch_text for EQS CPUs. */
> > +   isb
> > +1:
> > +#endif
> > +   .endm
> > +
> >  el0_sync_invalid:
> > inv_entry 0, BAD_SYNC
> >  ENDPROC(el0_sync_invalid)
> > @@ -840,8 +861,10 @@ el0_svc:
> > mov wsc_nr, #__NR_syscalls
> >  el0_svc_naked: // compat entry point
> > stp x0, xscno, [sp, #S_ORIG_X0] // save the original x0 and 
> > syscall number
> > +   isb_if_eqs
> > enable_dbg_and_irq
> > -   ct_user_exit 1
> > +   ct_user_exit
> 
> I don't think this is safe. here we issue the ISB *before* exiting a
> quiesecent state, so I think we can race with another CPU that calls
> kick_all_active_cpus_sync, e.g.
> 
>   CPU0CPU1
> 
>   ISB
>   patch_some_text()
>   kick_all_active_cpus_sync()
>   ct_user_exit
> 
>   // not synchronized!
>   use_of_patched_text()
> 
> ... and therefore the ISB has no effect, which could be disasterous.
> 
> I believe we need the ISB *after* we transition into a non-quiescent
> state, so that we can't possibly miss a context synchronization event.
 
I decided to put isb() in entry because there's a chance that there will
be patched code prior to exiting a quiescent state. But after some
headscratching, I think it's safe. I'll do like you suggested here.

Thanks,
Yury


Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

2018-04-03 Thread Stuart Yoder
On Tue, Apr 3, 2018 at 8:05 PM, Andrew Lunn  wrote:
>> Suppose you want to create and assign a network interface to a KVM
>> virtual machine, you would do something like the following using
>> a user space tool like restool:
>>-create a new (empty) dprc object
>>-create a new dpni and assign it to the dprc
>>-create a new dpio and assign it to the dprc
>>-create a new dpbp and assign it to the dprc
>>-create a new dpmcp and assign it to the dprc
>>-create a new dpmac and assign it to the dprc
>>-connect the dpni to the dpmac
>
> Hi Stuart
>
> It this connecting to a physical port at the bottom?

Yes.

> If so, i would expect that when you probe the device you just create
> all these for each physical port.

The problem is that there is not just one set of objects to implement a network
interface.  For the highest throughput packet processing you need one dpio
per core.  So, it will depend on what the requirements are.  You might want
multiple dpbp (buffer pools) and set up pools of different size
buffers for different
packet classifications.

You might want to have other objects like a crypto accelerator (dpseci) in the
container as well.

The dprc is a container holding any combination of those objects.  So you have
complete flexibility.

> You then just need to map one of
> them into the KVM, in the same way you map one PCI device into a KVM.
>
> If these are virtual devices, VF devices you would normally do
>
> echo 4 > /sys/class/net//device/sriov_numvfs
>
> on the physical device to create virtual devices.
>
>> The fsl-mc bus and DPAA2 is very NXP-specific, so there doesn't
>> seem to be anything that can be made generic here to provide
>> more common benefit.
>
> Which is why you should try to avoid all of this.  The user knows how
> to use standard linux commands and concepts. They don't want to have
> to learn the inside plumbing of your hardware.

I hear you.  It is more complicated this way...having all these individual
objects vs just a single "bundle" of them that represents a NIC.  But, that's
the way the DPAA2 hardware is, and we're implementing kernel support for
the hardware as it is.

Thanks,
Stuart


Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

2018-04-03 Thread Stuart Yoder
On Tue, Apr 3, 2018 at 8:05 PM, Andrew Lunn  wrote:
>> Suppose you want to create and assign a network interface to a KVM
>> virtual machine, you would do something like the following using
>> a user space tool like restool:
>>-create a new (empty) dprc object
>>-create a new dpni and assign it to the dprc
>>-create a new dpio and assign it to the dprc
>>-create a new dpbp and assign it to the dprc
>>-create a new dpmcp and assign it to the dprc
>>-create a new dpmac and assign it to the dprc
>>-connect the dpni to the dpmac
>
> Hi Stuart
>
> It this connecting to a physical port at the bottom?

Yes.

> If so, i would expect that when you probe the device you just create
> all these for each physical port.

The problem is that there is not just one set of objects to implement a network
interface.  For the highest throughput packet processing you need one dpio
per core.  So, it will depend on what the requirements are.  You might want
multiple dpbp (buffer pools) and set up pools of different size
buffers for different
packet classifications.

You might want to have other objects like a crypto accelerator (dpseci) in the
container as well.

The dprc is a container holding any combination of those objects.  So you have
complete flexibility.

> You then just need to map one of
> them into the KVM, in the same way you map one PCI device into a KVM.
>
> If these are virtual devices, VF devices you would normally do
>
> echo 4 > /sys/class/net//device/sriov_numvfs
>
> on the physical device to create virtual devices.
>
>> The fsl-mc bus and DPAA2 is very NXP-specific, so there doesn't
>> seem to be anything that can be made generic here to provide
>> more common benefit.
>
> Which is why you should try to avoid all of this.  The user knows how
> to use standard linux commands and concepts. They don't want to have
> to learn the inside plumbing of your hardware.

I hear you.  It is more complicated this way...having all these individual
objects vs just a single "bundle" of them that represents a NIC.  But, that's
the way the DPAA2 hardware is, and we're implementing kernel support for
the hardware as it is.

Thanks,
Stuart


[PATCH -mm] mm, gup: prevent pmd checking race in follow_pmd_mask()

2018-04-03 Thread Huang, Ying
From: Huang Ying 

mmap_sem will be read locked when calling follow_pmd_mask().  But this
cannot prevent PMD from being changed for all cases when PTL is
unlocked, for example, from pmd_trans_huge() to pmd_none() via
MADV_DONTNEED.  So it is possible for the pmd_present() check in
follow_pmd_mask() encounter a none PMD.  This may cause incorrect
VM_BUG_ON() or infinite loop.  Fixed this via reading PMD entry again
but only once and checking the local variable and pmd_none() in the
retry loop.

As Kirill pointed out, with PTL unlocked, the *pmd may be changed
under us, so read it directly again and again may incur weird bugs.
So although using *pmd directly other than pmd_present() checking may
be safe, it is still better to replace them to read *pmd once and
check the local variable for multiple times.

Signed-off-by: "Huang, Ying" 
 # When PTL unlocked, replace all *pmd with local variable
Suggested-by: "Kirill A. Shutemov" 
Cc: Al Viro 
Cc: "Aneesh Kumar K.V" 
Cc: Dan Williams 
Cc: Zi Yan 
---
 mm/gup.c | 30 +++---
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index 2e2df7f3e92d..51734292839b 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -213,53 +213,61 @@ static struct page *follow_pmd_mask(struct vm_area_struct 
*vma,
unsigned long address, pud_t *pudp,
unsigned int flags, unsigned int *page_mask)
 {
-   pmd_t *pmd;
+   pmd_t *pmd, pmdval;
spinlock_t *ptl;
struct page *page;
struct mm_struct *mm = vma->vm_mm;
 
pmd = pmd_offset(pudp, address);
-   if (pmd_none(*pmd))
+   pmdval = READ_ONCE(*pmd);
+   if (pmd_none(pmdval))
return no_page_table(vma, flags);
-   if (pmd_huge(*pmd) && vma->vm_flags & VM_HUGETLB) {
+   if (pmd_huge(pmdval) && vma->vm_flags & VM_HUGETLB) {
page = follow_huge_pmd(mm, address, pmd, flags);
if (page)
return page;
return no_page_table(vma, flags);
}
-   if (is_hugepd(__hugepd(pmd_val(*pmd {
+   if (is_hugepd(__hugepd(pmd_val(pmdval {
page = follow_huge_pd(vma, address,
- __hugepd(pmd_val(*pmd)), flags,
+ __hugepd(pmd_val(pmdval)), flags,
  PMD_SHIFT);
if (page)
return page;
return no_page_table(vma, flags);
}
 retry:
-   if (!pmd_present(*pmd)) {
+   if (!pmd_present(pmdval)) {
if (likely(!(flags & FOLL_MIGRATION)))
return no_page_table(vma, flags);
VM_BUG_ON(thp_migration_supported() &&
- !is_pmd_migration_entry(*pmd));
-   if (is_pmd_migration_entry(*pmd))
+ !is_pmd_migration_entry(pmdval));
+   if (is_pmd_migration_entry(pmdval))
pmd_migration_entry_wait(mm, pmd);
+   pmdval = READ_ONCE(*pmd);
+   if (pmd_none(pmdval))
+   return no_page_table(vma, flags);
goto retry;
}
-   if (pmd_devmap(*pmd)) {
+   if (pmd_devmap(pmdval)) {
ptl = pmd_lock(mm, pmd);
page = follow_devmap_pmd(vma, address, pmd, flags);
spin_unlock(ptl);
if (page)
return page;
}
-   if (likely(!pmd_trans_huge(*pmd)))
+   if (likely(!pmd_trans_huge(pmdval)))
return follow_page_pte(vma, address, pmd, flags);
 
-   if ((flags & FOLL_NUMA) && pmd_protnone(*pmd))
+   if ((flags & FOLL_NUMA) && pmd_protnone(pmdval))
return no_page_table(vma, flags);
 
 retry_locked:
ptl = pmd_lock(mm, pmd);
+   if (unlikely(pmd_none(*pmd))) {
+   spin_unlock(ptl);
+   return no_page_table(vma, flags);
+   }
if (unlikely(!pmd_present(*pmd))) {
spin_unlock(ptl);
if (likely(!(flags & FOLL_MIGRATION)))
-- 
2.15.1



[PATCH -mm] mm, gup: prevent pmd checking race in follow_pmd_mask()

2018-04-03 Thread Huang, Ying
From: Huang Ying 

mmap_sem will be read locked when calling follow_pmd_mask().  But this
cannot prevent PMD from being changed for all cases when PTL is
unlocked, for example, from pmd_trans_huge() to pmd_none() via
MADV_DONTNEED.  So it is possible for the pmd_present() check in
follow_pmd_mask() encounter a none PMD.  This may cause incorrect
VM_BUG_ON() or infinite loop.  Fixed this via reading PMD entry again
but only once and checking the local variable and pmd_none() in the
retry loop.

As Kirill pointed out, with PTL unlocked, the *pmd may be changed
under us, so read it directly again and again may incur weird bugs.
So although using *pmd directly other than pmd_present() checking may
be safe, it is still better to replace them to read *pmd once and
check the local variable for multiple times.

Signed-off-by: "Huang, Ying" 
 # When PTL unlocked, replace all *pmd with local variable
Suggested-by: "Kirill A. Shutemov" 
Cc: Al Viro 
Cc: "Aneesh Kumar K.V" 
Cc: Dan Williams 
Cc: Zi Yan 
---
 mm/gup.c | 30 +++---
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index 2e2df7f3e92d..51734292839b 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -213,53 +213,61 @@ static struct page *follow_pmd_mask(struct vm_area_struct 
*vma,
unsigned long address, pud_t *pudp,
unsigned int flags, unsigned int *page_mask)
 {
-   pmd_t *pmd;
+   pmd_t *pmd, pmdval;
spinlock_t *ptl;
struct page *page;
struct mm_struct *mm = vma->vm_mm;
 
pmd = pmd_offset(pudp, address);
-   if (pmd_none(*pmd))
+   pmdval = READ_ONCE(*pmd);
+   if (pmd_none(pmdval))
return no_page_table(vma, flags);
-   if (pmd_huge(*pmd) && vma->vm_flags & VM_HUGETLB) {
+   if (pmd_huge(pmdval) && vma->vm_flags & VM_HUGETLB) {
page = follow_huge_pmd(mm, address, pmd, flags);
if (page)
return page;
return no_page_table(vma, flags);
}
-   if (is_hugepd(__hugepd(pmd_val(*pmd {
+   if (is_hugepd(__hugepd(pmd_val(pmdval {
page = follow_huge_pd(vma, address,
- __hugepd(pmd_val(*pmd)), flags,
+ __hugepd(pmd_val(pmdval)), flags,
  PMD_SHIFT);
if (page)
return page;
return no_page_table(vma, flags);
}
 retry:
-   if (!pmd_present(*pmd)) {
+   if (!pmd_present(pmdval)) {
if (likely(!(flags & FOLL_MIGRATION)))
return no_page_table(vma, flags);
VM_BUG_ON(thp_migration_supported() &&
- !is_pmd_migration_entry(*pmd));
-   if (is_pmd_migration_entry(*pmd))
+ !is_pmd_migration_entry(pmdval));
+   if (is_pmd_migration_entry(pmdval))
pmd_migration_entry_wait(mm, pmd);
+   pmdval = READ_ONCE(*pmd);
+   if (pmd_none(pmdval))
+   return no_page_table(vma, flags);
goto retry;
}
-   if (pmd_devmap(*pmd)) {
+   if (pmd_devmap(pmdval)) {
ptl = pmd_lock(mm, pmd);
page = follow_devmap_pmd(vma, address, pmd, flags);
spin_unlock(ptl);
if (page)
return page;
}
-   if (likely(!pmd_trans_huge(*pmd)))
+   if (likely(!pmd_trans_huge(pmdval)))
return follow_page_pte(vma, address, pmd, flags);
 
-   if ((flags & FOLL_NUMA) && pmd_protnone(*pmd))
+   if ((flags & FOLL_NUMA) && pmd_protnone(pmdval))
return no_page_table(vma, flags);
 
 retry_locked:
ptl = pmd_lock(mm, pmd);
+   if (unlikely(pmd_none(*pmd))) {
+   spin_unlock(ptl);
+   return no_page_table(vma, flags);
+   }
if (unlikely(!pmd_present(*pmd))) {
spin_unlock(ptl);
if (likely(!(flags & FOLL_MIGRATION)))
-- 
2.15.1



[PATCH 1/1] dmaengine:jz4740:fix memory leak

2018-04-03 Thread Xidong Wang
In function jz4740_dma_probe(), the memory allocated by
clk_get() is not released on the error path that ret, which holds
the return value of dma_async_device_register(), is not NULL.
This will result in a memory leak bug.

Signed-off-by: Xidong Wang 
---
 drivers/dma/dma-jz4740.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/dma/dma-jz4740.c b/drivers/dma/dma-jz4740.c
index afd5e10..082c158 100644
--- a/drivers/dma/dma-jz4740.c
+++ b/drivers/dma/dma-jz4740.c
@@ -570,6 +570,7 @@ static int jz4740_dma_probe(struct platform_device *pdev)
dma_async_device_unregister(dd);
 err_clk:
clk_disable_unprepare(dmadev->clk);
+   clk_put(dmadev->clk);
return ret;
 }
 
-- 
2.7.4




[PATCH 1/1] dmaengine:jz4740:fix memory leak

2018-04-03 Thread Xidong Wang
In function jz4740_dma_probe(), the memory allocated by
clk_get() is not released on the error path that ret, which holds
the return value of dma_async_device_register(), is not NULL.
This will result in a memory leak bug.

Signed-off-by: Xidong Wang 
---
 drivers/dma/dma-jz4740.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/dma/dma-jz4740.c b/drivers/dma/dma-jz4740.c
index afd5e10..082c158 100644
--- a/drivers/dma/dma-jz4740.c
+++ b/drivers/dma/dma-jz4740.c
@@ -570,6 +570,7 @@ static int jz4740_dma_probe(struct platform_device *pdev)
dma_async_device_unregister(dd);
 err_clk:
clk_disable_unprepare(dmadev->clk);
+   clk_put(dmadev->clk);
return ret;
 }
 
-- 
2.7.4




[PATCH 3/5] dts: arm64: hi3660: Add CPU frequency scaling support

2018-04-03 Thread Leo Yan
Add two CPU OPP tables, one table is corresponding to one cluster,
which allow CPU frequency scaling on hi3660 platforms.

Signed-off-by: Leo Yan 
---
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 86 +++
 1 file changed, 86 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi 
b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index 3a3bcff..a39da09 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -62,6 +62,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_0>;
capacity-dmips-mhz = <592>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER0>;
+   operating-points-v2 = <_opp>;
};
 
cpu1: cpu@1 {
@@ -72,6 +74,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_0>;
capacity-dmips-mhz = <592>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER0>;
+   operating-points-v2 = <_opp>;
};
 
cpu2: cpu@2 {
@@ -82,6 +86,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_0>;
capacity-dmips-mhz = <592>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER0>;
+   operating-points-v2 = <_opp>;
};
 
cpu3: cpu@3 {
@@ -92,6 +98,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_0>;
capacity-dmips-mhz = <592>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER0>;
+   operating-points-v2 = <_opp>;
};
 
cpu4: cpu@100 {
@@ -102,6 +110,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_1>;
capacity-dmips-mhz = <1024>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER1>;
+   operating-points-v2 = <_opp>;
};
 
cpu5: cpu@101 {
@@ -112,6 +122,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_1>;
capacity-dmips-mhz = <1024>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER1>;
+   operating-points-v2 = <_opp>;
};
 
cpu6: cpu@102 {
@@ -122,6 +134,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_1>;
capacity-dmips-mhz = <1024>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER1>;
+   operating-points-v2 = <_opp>;
};
 
cpu7: cpu@103 {
@@ -132,6 +146,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_1>;
capacity-dmips-mhz = <1024>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER1>;
+   operating-points-v2 = <_opp>;
};
 
idle-states {
@@ -174,6 +190,76 @@
};
};
 
+   cluster0_opp: opp_table0 {
+   compatible = "operating-points-v2";
+   opp-shared;
+
+   opp00 {
+   opp-hz = /bits/ 64 <53300>;
+   opp-microvolt = <70>;
+   clock-latency-ns = <30>;
+   };
+
+   opp01 {
+   opp-hz = /bits/ 64 <99900>;
+   opp-microvolt = <80>;
+   clock-latency-ns = <30>;
+   };
+
+   opp02 {
+   opp-hz = /bits/ 64 <140200>;
+   opp-microvolt = <90>;
+   clock-latency-ns = <30>;
+   };
+
+   opp03 {
+   opp-hz = /bits/ 64 <170900>;
+   opp-microvolt = <100>;
+   clock-latency-ns = <30>;
+   };
+
+   opp04 {
+   opp-hz = /bits/ 64 <184400>;
+   opp-microvolt = <110>;
+   clock-latency-ns = <30>;
+   };
+   };
+
+   cluster1_opp: opp_table1 {
+   compatible = "operating-points-v2";
+   opp-shared;
+
+   opp10 {
+   opp-hz = /bits/ 64 <90300>;
+   opp-microvolt = <70>;
+   clock-latency-ns = <30>;
+   };
+
+   opp11 {
+   opp-hz = /bits/ 64 <142100>;
+   

[PATCH 3/5] dts: arm64: hi3660: Add CPU frequency scaling support

2018-04-03 Thread Leo Yan
Add two CPU OPP tables, one table is corresponding to one cluster,
which allow CPU frequency scaling on hi3660 platforms.

Signed-off-by: Leo Yan 
---
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 86 +++
 1 file changed, 86 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi 
b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index 3a3bcff..a39da09 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -62,6 +62,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_0>;
capacity-dmips-mhz = <592>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER0>;
+   operating-points-v2 = <_opp>;
};
 
cpu1: cpu@1 {
@@ -72,6 +74,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_0>;
capacity-dmips-mhz = <592>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER0>;
+   operating-points-v2 = <_opp>;
};
 
cpu2: cpu@2 {
@@ -82,6 +86,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_0>;
capacity-dmips-mhz = <592>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER0>;
+   operating-points-v2 = <_opp>;
};
 
cpu3: cpu@3 {
@@ -92,6 +98,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_0>;
capacity-dmips-mhz = <592>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER0>;
+   operating-points-v2 = <_opp>;
};
 
cpu4: cpu@100 {
@@ -102,6 +110,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_1>;
capacity-dmips-mhz = <1024>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER1>;
+   operating-points-v2 = <_opp>;
};
 
cpu5: cpu@101 {
@@ -112,6 +122,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_1>;
capacity-dmips-mhz = <1024>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER1>;
+   operating-points-v2 = <_opp>;
};
 
cpu6: cpu@102 {
@@ -122,6 +134,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_1>;
capacity-dmips-mhz = <1024>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER1>;
+   operating-points-v2 = <_opp>;
};
 
cpu7: cpu@103 {
@@ -132,6 +146,8 @@
next-level-cache = <_L2>;
cpu-idle-states = <_SLEEP _SLEEP_1>;
capacity-dmips-mhz = <1024>;
+   clocks = <_clock HI3660_CLK_STUB_CLUSTER1>;
+   operating-points-v2 = <_opp>;
};
 
idle-states {
@@ -174,6 +190,76 @@
};
};
 
+   cluster0_opp: opp_table0 {
+   compatible = "operating-points-v2";
+   opp-shared;
+
+   opp00 {
+   opp-hz = /bits/ 64 <53300>;
+   opp-microvolt = <70>;
+   clock-latency-ns = <30>;
+   };
+
+   opp01 {
+   opp-hz = /bits/ 64 <99900>;
+   opp-microvolt = <80>;
+   clock-latency-ns = <30>;
+   };
+
+   opp02 {
+   opp-hz = /bits/ 64 <140200>;
+   opp-microvolt = <90>;
+   clock-latency-ns = <30>;
+   };
+
+   opp03 {
+   opp-hz = /bits/ 64 <170900>;
+   opp-microvolt = <100>;
+   clock-latency-ns = <30>;
+   };
+
+   opp04 {
+   opp-hz = /bits/ 64 <184400>;
+   opp-microvolt = <110>;
+   clock-latency-ns = <30>;
+   };
+   };
+
+   cluster1_opp: opp_table1 {
+   compatible = "operating-points-v2";
+   opp-shared;
+
+   opp10 {
+   opp-hz = /bits/ 64 <90300>;
+   opp-microvolt = <70>;
+   clock-latency-ns = <30>;
+   };
+
+   opp11 {
+   opp-hz = /bits/ 64 <142100>;
+   opp-microvolt = 

[PATCH 2/5] dts: arm64: hi3660: Add stub clock node

2018-04-03 Thread Leo Yan
From: Kaihua Zhong 

Add stub clock node for hi3660 platform.

Reviewed-by: Leo Yan 
Signed-off-by: Kaihua Zhong 
---
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi 
b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index b9e7c91..3a3bcff 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -282,6 +282,13 @@
#mbox-cells = <3>;
};
 
+   stub_clock: stub_clock@e896b500 {
+   compatible = "hisilicon,hi3660-stub-clk";
+   reg = <0x0 0xe896b500 0x0 0x0100>;
+   #clock-cells = <1>;
+   mboxes = < 13 3 0>;
+   };
+
dual_timer0: timer@fff14000 {
compatible = "arm,sp804", "arm,primecell";
reg = <0x0 0xfff14000 0x0 0x1000>;
-- 
1.9.1



[PATCH 2/5] dts: arm64: hi3660: Add stub clock node

2018-04-03 Thread Leo Yan
From: Kaihua Zhong 

Add stub clock node for hi3660 platform.

Reviewed-by: Leo Yan 
Signed-off-by: Kaihua Zhong 
---
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi 
b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index b9e7c91..3a3bcff 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -282,6 +282,13 @@
#mbox-cells = <3>;
};
 
+   stub_clock: stub_clock@e896b500 {
+   compatible = "hisilicon,hi3660-stub-clk";
+   reg = <0x0 0xe896b500 0x0 0x0100>;
+   #clock-cells = <1>;
+   mboxes = < 13 3 0>;
+   };
+
dual_timer0: timer@fff14000 {
compatible = "arm,sp804", "arm,primecell";
reg = <0x0 0xfff14000 0x0 0x1000>;
-- 
1.9.1



[PATCH 4/5] dts: arm64: hi3660: Add thermal cooling management

2018-04-03 Thread Leo Yan
From: Tao Wang 

Add nodes and properties for thermal cooling management support.

Signed-off-by: Tao Wang 
Signed-off-by: Leo Yan 
---
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 44 +++
 1 file changed, 44 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi 
b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index a39da09..e20edd9 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 
 / {
compatible = "hisilicon,hi3660";
@@ -64,6 +65,8 @@
capacity-dmips-mhz = <592>;
clocks = <_clock HI3660_CLK_STUB_CLUSTER0>;
operating-points-v2 = <_opp>;
+   #cooling-cells = <2>;
+   dynamic-power-coefficient = <110>;
};
 
cpu1: cpu@1 {
@@ -112,6 +115,8 @@
capacity-dmips-mhz = <1024>;
clocks = <_clock HI3660_CLK_STUB_CLUSTER1>;
operating-points-v2 = <_opp>;
+   #cooling-cells = <2>;
+   dynamic-power-coefficient = <550>;
};
 
cpu5: cpu@101 {
@@ -1073,5 +1078,44 @@
interrupts = ;
#thermal-sensor-cells = <1>;
};
+
+   thermal-zones {
+
+   cls0: cls0 {
+   polling-delay = <1000>;
+   polling-delay-passive = <100>;
+   sustainable-power = <4500>;
+
+   /* sensor ID */
+   thermal-sensors = < 1>;
+
+   trips {
+   threshold: trip-point@0 {
+   temperature = <65000>;
+   hysteresis = <1000>;
+   type = "passive";
+   };
+
+   target: trip-point@1 {
+   temperature = <75000>;
+   hysteresis = <1000>;
+   type = "passive";
+   };
+   };
+
+   cooling-maps {
+   map0 {
+   trip = <>;
+   contribution = <1024>;
+   cooling-device = < 
THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+   };
+   map1 {
+   trip = <>;
+   contribution = <512>;
+   cooling-device = < 
THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+   };
+   };
+   };
+   };
};
 };
-- 
1.9.1



[PATCH 5/5] hisi: Consolidate the Kconfigs for the CLOCK_STUB and the MAILBOX

2018-04-03 Thread Leo Yan
From: Daniel Lezcano 

The current defconfig is inconsistent as it selects the mailbox and
the clock for the hi6220 and the hi3660 without having their Kconfigs
making sure the dependencies are correct. It ends up when selecting
different versions for the kernel (for example when git bisecting)
those options disappear and they don't get back, leading to unexpected
behaviors. In our case, the cpufreq driver does no longer work because
the clock fails to initialize due to the clock stub and the mailbox
missing.

In order to have the dependencies correctly set when defaulting, let's
do the same as commit 3a49afb84ca074e ("clk: enable hi655x common clk
automatically") where we select automatically the driver when the
parent driver is selected. With sensible defaults in place, we can leave
other choices for EXPERT.

Signed-off-by: Daniel Lezcano 
---
 arch/arm64/configs/defconfig  |  1 -
 drivers/clk/hisilicon/Kconfig | 13 -
 drivers/mailbox/Kconfig   | 12 
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index ecf6137..1d9d8b9 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -549,7 +549,6 @@ CONFIG_HWSPINLOCK_QCOM=y
 CONFIG_ARM_MHU=y
 CONFIG_PLATFORM_MHU=y
 CONFIG_BCM2835_MBOX=y
-CONFIG_HI6220_MBOX=y
 CONFIG_QCOM_APCS_IPC=y
 CONFIG_ROCKCHIP_IOMMU=y
 CONFIG_TEGRA_IOMMU_SMMU=y
diff --git a/drivers/clk/hisilicon/Kconfig b/drivers/clk/hisilicon/Kconfig
index 1bd4355..becdb1d 100644
--- a/drivers/clk/hisilicon/Kconfig
+++ b/drivers/clk/hisilicon/Kconfig
@@ -44,14 +44,17 @@ config RESET_HISI
  Build reset controller driver for HiSilicon device chipsets.
 
 config STUB_CLK_HI6220
-   bool "Hi6220 Stub Clock Driver"
-   depends on COMMON_CLK_HI6220 && MAILBOX
-   default ARCH_HISI
+   bool "Hi6220 Stub Clock Driver" if EXPERT
+   depends on (COMMON_CLK_HI6220 || COMPILE_TEST)
+   depends on MAILBOX
+   default COMMON_CLK_HI6220
help
  Build the Hisilicon Hi6220 stub clock driver.
 
 config STUB_CLK_HI3660
-   bool "Hi3660 Stub Clock Driver"
-   depends on COMMON_CLK_HI3660 && MAILBOX
+   bool "Hi3660 Stub Clock Driver" if EXPERT
+   depends on (COMMON_CLK_HI3660 || COMPILE_TEST)
+   depends on MAILBOX
+   default COMMON_CLK_HI3660
help
  Build the Hisilicon Hi3660 stub clock driver.
diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index a2bb274..567cd02 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -109,16 +109,20 @@ config TI_MESSAGE_MANAGER
  platform has support for the hardware block.
 
 config HI3660_MBOX
-   tristate "Hi3660 Mailbox"
-   depends on ARCH_HISI && OF
+   tristate "Hi3660 Mailbox" if EXPERT
+   depends on (ARCH_HISI || COMPILE_TEST)
+   depends on OF
+   default ARCH_HISI
help
  An implementation of the hi3660 mailbox. It is used to send message
  between application processors and other processors/MCU/DSP. Select
  Y here if you want to use Hi3660 mailbox controller.
 
 config HI6220_MBOX
-   tristate "Hi6220 Mailbox"
-   depends on ARCH_HISI
+   tristate "Hi6220 Mailbox" if EXPERT
+   depends on (ARCH_HISI || COMPILE_TEST)
+   depends on OF
+   default ARCH_HISI
help
  An implementation of the hi6220 mailbox. It is used to send message
  between application processors and MCU. Say Y here if you want to
-- 
1.9.1



[PATCH 0/5] Hi3660: enable power management features

2018-04-03 Thread Leo Yan
Since hi3660 drivers have been merged into Linux kernel (mailbox driver is in
Linux-next branch and other drivers are existed in Linux mainline kernel), so
this patch series is to enable power management features on hi3660.

This patch series includes device tree binding for mailbox, stub clock and CPU
OPPs, and has one patch to consolidate the Kconfigs for driver modules.

This patch set have been tested on Hikey960 and also verified the patch 'hisi:
Consolidate the Kconfigs for the CLOCK_STUB and the MAILBOX' for Hikey620.


Daniel Lezcano (1):
  hisi: Consolidate the Kconfigs for the CLOCK_STUB and the MAILBOX

Kaihua Zhong (2):
  dts: arm64: hi3660: Add mailbox node
  dts: arm64: hi3660: Add stub clock node

Leo Yan (1):
  dts: arm64: hi3660: Add CPU frequency scaling support

Tao Wang (1):
  dts: arm64: hi3660: Add thermal cooling management

 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 145 ++
 arch/arm64/configs/defconfig  |   1 -
 drivers/clk/hisilicon/Kconfig |  13 +--
 drivers/mailbox/Kconfig   |  12 ++-
 4 files changed, 161 insertions(+), 10 deletions(-)

-- 
1.9.1



[PATCH 1/5] dts: arm64: hi3660: Add mailbox node

2018-04-03 Thread Leo Yan
From: Kaihua Zhong 

Add the mailbox controller node for hi3660 platform.

Signed-off-by: Kaihua Zhong 
Signed-off-by: Ruyi Wang 
---
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi 
b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index ec3eb8e..b9e7c91 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -274,6 +274,14 @@
#reset-cells = <2>;
};
 
+   mailbox: mailbox@e896b000 {
+   compatible = "hisilicon,hi3660-mbox";
+   reg = <0x0 0xe896b000 0x0 0x1000>;
+   interrupts = ,
+;
+   #mbox-cells = <3>;
+   };
+
dual_timer0: timer@fff14000 {
compatible = "arm,sp804", "arm,primecell";
reg = <0x0 0xfff14000 0x0 0x1000>;
-- 
1.9.1



[PATCH 4/5] dts: arm64: hi3660: Add thermal cooling management

2018-04-03 Thread Leo Yan
From: Tao Wang 

Add nodes and properties for thermal cooling management support.

Signed-off-by: Tao Wang 
Signed-off-by: Leo Yan 
---
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 44 +++
 1 file changed, 44 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi 
b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index a39da09..e20edd9 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 
 / {
compatible = "hisilicon,hi3660";
@@ -64,6 +65,8 @@
capacity-dmips-mhz = <592>;
clocks = <_clock HI3660_CLK_STUB_CLUSTER0>;
operating-points-v2 = <_opp>;
+   #cooling-cells = <2>;
+   dynamic-power-coefficient = <110>;
};
 
cpu1: cpu@1 {
@@ -112,6 +115,8 @@
capacity-dmips-mhz = <1024>;
clocks = <_clock HI3660_CLK_STUB_CLUSTER1>;
operating-points-v2 = <_opp>;
+   #cooling-cells = <2>;
+   dynamic-power-coefficient = <550>;
};
 
cpu5: cpu@101 {
@@ -1073,5 +1078,44 @@
interrupts = ;
#thermal-sensor-cells = <1>;
};
+
+   thermal-zones {
+
+   cls0: cls0 {
+   polling-delay = <1000>;
+   polling-delay-passive = <100>;
+   sustainable-power = <4500>;
+
+   /* sensor ID */
+   thermal-sensors = < 1>;
+
+   trips {
+   threshold: trip-point@0 {
+   temperature = <65000>;
+   hysteresis = <1000>;
+   type = "passive";
+   };
+
+   target: trip-point@1 {
+   temperature = <75000>;
+   hysteresis = <1000>;
+   type = "passive";
+   };
+   };
+
+   cooling-maps {
+   map0 {
+   trip = <>;
+   contribution = <1024>;
+   cooling-device = < 
THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+   };
+   map1 {
+   trip = <>;
+   contribution = <512>;
+   cooling-device = < 
THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+   };
+   };
+   };
+   };
};
 };
-- 
1.9.1



[PATCH 5/5] hisi: Consolidate the Kconfigs for the CLOCK_STUB and the MAILBOX

2018-04-03 Thread Leo Yan
From: Daniel Lezcano 

The current defconfig is inconsistent as it selects the mailbox and
the clock for the hi6220 and the hi3660 without having their Kconfigs
making sure the dependencies are correct. It ends up when selecting
different versions for the kernel (for example when git bisecting)
those options disappear and they don't get back, leading to unexpected
behaviors. In our case, the cpufreq driver does no longer work because
the clock fails to initialize due to the clock stub and the mailbox
missing.

In order to have the dependencies correctly set when defaulting, let's
do the same as commit 3a49afb84ca074e ("clk: enable hi655x common clk
automatically") where we select automatically the driver when the
parent driver is selected. With sensible defaults in place, we can leave
other choices for EXPERT.

Signed-off-by: Daniel Lezcano 
---
 arch/arm64/configs/defconfig  |  1 -
 drivers/clk/hisilicon/Kconfig | 13 -
 drivers/mailbox/Kconfig   | 12 
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index ecf6137..1d9d8b9 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -549,7 +549,6 @@ CONFIG_HWSPINLOCK_QCOM=y
 CONFIG_ARM_MHU=y
 CONFIG_PLATFORM_MHU=y
 CONFIG_BCM2835_MBOX=y
-CONFIG_HI6220_MBOX=y
 CONFIG_QCOM_APCS_IPC=y
 CONFIG_ROCKCHIP_IOMMU=y
 CONFIG_TEGRA_IOMMU_SMMU=y
diff --git a/drivers/clk/hisilicon/Kconfig b/drivers/clk/hisilicon/Kconfig
index 1bd4355..becdb1d 100644
--- a/drivers/clk/hisilicon/Kconfig
+++ b/drivers/clk/hisilicon/Kconfig
@@ -44,14 +44,17 @@ config RESET_HISI
  Build reset controller driver for HiSilicon device chipsets.
 
 config STUB_CLK_HI6220
-   bool "Hi6220 Stub Clock Driver"
-   depends on COMMON_CLK_HI6220 && MAILBOX
-   default ARCH_HISI
+   bool "Hi6220 Stub Clock Driver" if EXPERT
+   depends on (COMMON_CLK_HI6220 || COMPILE_TEST)
+   depends on MAILBOX
+   default COMMON_CLK_HI6220
help
  Build the Hisilicon Hi6220 stub clock driver.
 
 config STUB_CLK_HI3660
-   bool "Hi3660 Stub Clock Driver"
-   depends on COMMON_CLK_HI3660 && MAILBOX
+   bool "Hi3660 Stub Clock Driver" if EXPERT
+   depends on (COMMON_CLK_HI3660 || COMPILE_TEST)
+   depends on MAILBOX
+   default COMMON_CLK_HI3660
help
  Build the Hisilicon Hi3660 stub clock driver.
diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index a2bb274..567cd02 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -109,16 +109,20 @@ config TI_MESSAGE_MANAGER
  platform has support for the hardware block.
 
 config HI3660_MBOX
-   tristate "Hi3660 Mailbox"
-   depends on ARCH_HISI && OF
+   tristate "Hi3660 Mailbox" if EXPERT
+   depends on (ARCH_HISI || COMPILE_TEST)
+   depends on OF
+   default ARCH_HISI
help
  An implementation of the hi3660 mailbox. It is used to send message
  between application processors and other processors/MCU/DSP. Select
  Y here if you want to use Hi3660 mailbox controller.
 
 config HI6220_MBOX
-   tristate "Hi6220 Mailbox"
-   depends on ARCH_HISI
+   tristate "Hi6220 Mailbox" if EXPERT
+   depends on (ARCH_HISI || COMPILE_TEST)
+   depends on OF
+   default ARCH_HISI
help
  An implementation of the hi6220 mailbox. It is used to send message
  between application processors and MCU. Say Y here if you want to
-- 
1.9.1



[PATCH 0/5] Hi3660: enable power management features

2018-04-03 Thread Leo Yan
Since hi3660 drivers have been merged into Linux kernel (mailbox driver is in
Linux-next branch and other drivers are existed in Linux mainline kernel), so
this patch series is to enable power management features on hi3660.

This patch series includes device tree binding for mailbox, stub clock and CPU
OPPs, and has one patch to consolidate the Kconfigs for driver modules.

This patch set have been tested on Hikey960 and also verified the patch 'hisi:
Consolidate the Kconfigs for the CLOCK_STUB and the MAILBOX' for Hikey620.


Daniel Lezcano (1):
  hisi: Consolidate the Kconfigs for the CLOCK_STUB and the MAILBOX

Kaihua Zhong (2):
  dts: arm64: hi3660: Add mailbox node
  dts: arm64: hi3660: Add stub clock node

Leo Yan (1):
  dts: arm64: hi3660: Add CPU frequency scaling support

Tao Wang (1):
  dts: arm64: hi3660: Add thermal cooling management

 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 145 ++
 arch/arm64/configs/defconfig  |   1 -
 drivers/clk/hisilicon/Kconfig |  13 +--
 drivers/mailbox/Kconfig   |  12 ++-
 4 files changed, 161 insertions(+), 10 deletions(-)

-- 
1.9.1



[PATCH 1/5] dts: arm64: hi3660: Add mailbox node

2018-04-03 Thread Leo Yan
From: Kaihua Zhong 

Add the mailbox controller node for hi3660 platform.

Signed-off-by: Kaihua Zhong 
Signed-off-by: Ruyi Wang 
---
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi 
b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index ec3eb8e..b9e7c91 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -274,6 +274,14 @@
#reset-cells = <2>;
};
 
+   mailbox: mailbox@e896b000 {
+   compatible = "hisilicon,hi3660-mbox";
+   reg = <0x0 0xe896b000 0x0 0x1000>;
+   interrupts = ,
+;
+   #mbox-cells = <3>;
+   };
+
dual_timer0: timer@fff14000 {
compatible = "arm,sp804", "arm,primecell";
reg = <0x0 0xfff14000 0x0 0x1000>;
-- 
1.9.1



[PATCH 1/1] mtd:nand:fix memory leak

2018-04-03 Thread Xidong Wang
In function tango_nand_probe(), the memory allocated by
clk_get() is not released on the normal path and
the error path that IS_ERR(nfc->chan) returns true.
This will result in a memory leak bug.

Signed-off-by: Xidong Wang 
---
 drivers/mtd/nand/tango_nand.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/tango_nand.c b/drivers/mtd/nand/tango_nand.c
index c5bee00b..8083459 100644
--- a/drivers/mtd/nand/tango_nand.c
+++ b/drivers/mtd/nand/tango_nand.c
@@ -648,12 +648,15 @@ static int tango_nand_probe(struct platform_device *pdev)
return PTR_ERR(clk);
 
nfc->chan = dma_request_chan(>dev, "rxtx");
-   if (IS_ERR(nfc->chan))
+   if (IS_ERR(nfc->chan)) {
+   clk_put(clk);
return PTR_ERR(nfc->chan);
+   }
 
platform_set_drvdata(pdev, nfc);
nand_hw_control_init(>hw);
nfc->freq_kHz = clk_get_rate(clk) / 1000;
+   clk_put(clk);
 
for_each_child_of_node(pdev->dev.of_node, np) {
err = chip_init(>dev, np);
-- 
2.7.4




[PATCH 1/1] mtd:nand:fix memory leak

2018-04-03 Thread Xidong Wang
In function tango_nand_probe(), the memory allocated by
clk_get() is not released on the normal path and
the error path that IS_ERR(nfc->chan) returns true.
This will result in a memory leak bug.

Signed-off-by: Xidong Wang 
---
 drivers/mtd/nand/tango_nand.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/tango_nand.c b/drivers/mtd/nand/tango_nand.c
index c5bee00b..8083459 100644
--- a/drivers/mtd/nand/tango_nand.c
+++ b/drivers/mtd/nand/tango_nand.c
@@ -648,12 +648,15 @@ static int tango_nand_probe(struct platform_device *pdev)
return PTR_ERR(clk);
 
nfc->chan = dma_request_chan(>dev, "rxtx");
-   if (IS_ERR(nfc->chan))
+   if (IS_ERR(nfc->chan)) {
+   clk_put(clk);
return PTR_ERR(nfc->chan);
+   }
 
platform_set_drvdata(pdev, nfc);
nand_hw_control_init(>hw);
nfc->freq_kHz = clk_get_rate(clk) / 1000;
+   clk_put(clk);
 
for_each_child_of_node(pdev->dev.of_node, np) {
err = chip_init(>dev, np);
-- 
2.7.4




  1   2   3   4   5   6   7   8   9   10   >