Re: [PATCH 0/2] Add devicetree for Axentia Nattis

2017-12-01 Thread Peter Rosin
On 2017-12-02 02:05, Javier Martinez Canillas wrote:
> Hello Peter,
> 
> On Fri, Dec 1, 2017 at 11:44 PM, Peter Rosin  wrote:
>> Hi!
>>
>> I'd like to add a devicetree for our Nattis to the kernel. The
>> Nattis is a device for showing departures for public transportation
>> (optionally including a text-to-speech module for the visually
>> impaired).
>>
>> I'm a bit unsure if the tfa9879 sound codec binding is needed,
>> but I suppose it belongs in trivial-devices?
>>
> 
> There's a DT binding for this device now:
> 
> https://patchwork.ozlabs.org/patch/816157/

What do you know, thanks for the hint. I even reviewed a followup
patch for that one, so I guess I should have known...

Anyway, I should probably add a #sound-dai-cells entry. v2 coming up.

Cheers,
peda


Re: [PATCH 0/2] Add devicetree for Axentia Nattis

2017-12-01 Thread Peter Rosin
On 2017-12-02 02:05, Javier Martinez Canillas wrote:
> Hello Peter,
> 
> On Fri, Dec 1, 2017 at 11:44 PM, Peter Rosin  wrote:
>> Hi!
>>
>> I'd like to add a devicetree for our Nattis to the kernel. The
>> Nattis is a device for showing departures for public transportation
>> (optionally including a text-to-speech module for the visually
>> impaired).
>>
>> I'm a bit unsure if the tfa9879 sound codec binding is needed,
>> but I suppose it belongs in trivial-devices?
>>
> 
> There's a DT binding for this device now:
> 
> https://patchwork.ozlabs.org/patch/816157/

What do you know, thanks for the hint. I even reviewed a followup
patch for that one, so I guess I should have known...

Anyway, I should probably add a #sound-dai-cells entry. v2 coming up.

Cheers,
peda


RE: [PATCH 01/43] x86/decoder: Add new TEST instruction pattern

2017-12-01 Thread Robert Elliott (Persistent Memory)
> -Original Message-
> From: linux-kernel-ow...@vger.kernel.org [mailto:linux-kernel-
> ow...@vger.kernel.org] On Behalf Of Ingo Molnar
> Sent: Friday, November 24, 2017 3:14 AM
> To: linux-kernel@vger.kernel.org
> Subject: [PATCH 01/43] x86/decoder: Add new TEST instruction pattern
> 
> From: Masami Hiramatsu 
> 
...
> diff --git a/arch/x86/lib/x86-opcode-map.txt b/arch/x86/lib/x86-opcode-map.txt
> index 12e377184ee4..c4d55919fac1 100644

I think this patch (commit 12a78d43de76, also posted for 3.18, 4.4, and 4.9) 
also needs to update these:
tools/objtool/arch/x86/lib/x86-opcode-map.txt
tools/perf/util/intel-pt-decoder/x86-opcode-map.txt

to avoid warnings like:

Warning: synced file at 'tools/objtool/arch/x86/lib/x86-opcode-map.txt' differs 
from latest kernel version at 'arch/x86/lib/x86-opcode-map.txt'
  LINK /home/user/linux/tools/objtool/objtool


---
Robert Elliott, HPE Persistent Memory




RE: [PATCH 01/43] x86/decoder: Add new TEST instruction pattern

2017-12-01 Thread Robert Elliott (Persistent Memory)
> -Original Message-
> From: linux-kernel-ow...@vger.kernel.org [mailto:linux-kernel-
> ow...@vger.kernel.org] On Behalf Of Ingo Molnar
> Sent: Friday, November 24, 2017 3:14 AM
> To: linux-kernel@vger.kernel.org
> Subject: [PATCH 01/43] x86/decoder: Add new TEST instruction pattern
> 
> From: Masami Hiramatsu 
> 
...
> diff --git a/arch/x86/lib/x86-opcode-map.txt b/arch/x86/lib/x86-opcode-map.txt
> index 12e377184ee4..c4d55919fac1 100644

I think this patch (commit 12a78d43de76, also posted for 3.18, 4.4, and 4.9) 
also needs to update these:
tools/objtool/arch/x86/lib/x86-opcode-map.txt
tools/perf/util/intel-pt-decoder/x86-opcode-map.txt

to avoid warnings like:

Warning: synced file at 'tools/objtool/arch/x86/lib/x86-opcode-map.txt' differs 
from latest kernel version at 'arch/x86/lib/x86-opcode-map.txt'
  LINK /home/user/linux/tools/objtool/objtool


---
Robert Elliott, HPE Persistent Memory




[PATCH v2] net: macb: change GFP_KERNEL to GFP_ATOMIC

2017-12-01 Thread Julia Lawall
Function gem_add_flow_filter called on line 2958 inside lock on line 2949
but uses GFP_KERNEL

Generated by: scripts/coccinelle/locks/call_kern.cocci

Fixes: ae8223de3df5 ("net: macb: Added support for RX filtering")
CC: Rafal Ozieblo 
Signed-off-by: Julia Lawall 
Signed-off-by: Fengguang Wu 
---

v2: Fix some broken email addresses.  No change to the patch.

tree:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
master
head:   fb20eb9d798d2f4c1a75b7fe981d72dfa8d7270d
commit: ae8223de3df5a0ce651d14a50dad31b9cae029f2 [2033/2251] net: macb:
Added support for RX filtering

 macb_main.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -2799,7 +2799,7 @@ static int gem_add_flow_filter(struct ne
int ret = -EINVAL;
bool added = false;

-   newfs = kmalloc(sizeof(*newfs), GFP_KERNEL);
+   newfs = kmalloc(sizeof(*newfs), GFP_ATOMIC);
if (newfs == NULL)
return -ENOMEM;
memcpy(>fs, fs, sizeof(newfs->fs));


[PATCH v2] net: macb: change GFP_KERNEL to GFP_ATOMIC

2017-12-01 Thread Julia Lawall
Function gem_add_flow_filter called on line 2958 inside lock on line 2949
but uses GFP_KERNEL

Generated by: scripts/coccinelle/locks/call_kern.cocci

Fixes: ae8223de3df5 ("net: macb: Added support for RX filtering")
CC: Rafal Ozieblo 
Signed-off-by: Julia Lawall 
Signed-off-by: Fengguang Wu 
---

v2: Fix some broken email addresses.  No change to the patch.

tree:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
master
head:   fb20eb9d798d2f4c1a75b7fe981d72dfa8d7270d
commit: ae8223de3df5a0ce651d14a50dad31b9cae029f2 [2033/2251] net: macb:
Added support for RX filtering

 macb_main.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -2799,7 +2799,7 @@ static int gem_add_flow_filter(struct ne
int ret = -EINVAL;
bool added = false;

-   newfs = kmalloc(sizeof(*newfs), GFP_KERNEL);
+   newfs = kmalloc(sizeof(*newfs), GFP_ATOMIC);
if (newfs == NULL)
return -ENOMEM;
memcpy(>fs, fs, sizeof(newfs->fs));


Re: [PATCH 16/21] x86/entry/64: Use a per-CPU trampoline stack for IDT entries

2017-12-01 Thread Kevin Easton
> From: Dave Hansen 
> 
> The "SYSENTER" stack is used for a lot more than SYSENTER now.
> Give it a better string to display in stack dumps.
> 
> We should probably cleanse the 64-bit code of the remaining
> "SYSENTER" nomenclature too at some point.
> 
> Signed-off-by: Dave Hansen 
> ---
> 
>  b/arch//x86/kernel/dumpstack_64.c |   10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff -puN arch//x86/kernel/dumpstack_64.c~SYSENTER-rename 
> arch//x86/kernel/dumpstack_64.c
> --- a/arch//x86/kernel/dumpstack_64.c~SYSENTER-rename 2017-12-01 
> 12:43:16.768707737 -0800
> +++ b/arch//x86/kernel/dumpstack_64.c 2017-12-01 13:19:21.741702337 -0800
> @@ -37,8 +37,14 @@ const char *stack_type_name(enum stack_t
>   if (type == STACK_TYPE_IRQ)
>   return "IRQ";
>  
> - if (type == STACK_TYPE_SYSENTER)
> - return "SYSENTER";
> + if (type == STACK_TYPE_SYSENTER) {
> + /*
> +  * On 64-bit, we have a generic entry stack that we
> +  * use for all the kernel try points, including
> +  * SYSENTER.

ITYM "kernel entry points".

- Kevin



Re: [PATCH 16/21] x86/entry/64: Use a per-CPU trampoline stack for IDT entries

2017-12-01 Thread Kevin Easton
> From: Dave Hansen 
> 
> The "SYSENTER" stack is used for a lot more than SYSENTER now.
> Give it a better string to display in stack dumps.
> 
> We should probably cleanse the 64-bit code of the remaining
> "SYSENTER" nomenclature too at some point.
> 
> Signed-off-by: Dave Hansen 
> ---
> 
>  b/arch//x86/kernel/dumpstack_64.c |   10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff -puN arch//x86/kernel/dumpstack_64.c~SYSENTER-rename 
> arch//x86/kernel/dumpstack_64.c
> --- a/arch//x86/kernel/dumpstack_64.c~SYSENTER-rename 2017-12-01 
> 12:43:16.768707737 -0800
> +++ b/arch//x86/kernel/dumpstack_64.c 2017-12-01 13:19:21.741702337 -0800
> @@ -37,8 +37,14 @@ const char *stack_type_name(enum stack_t
>   if (type == STACK_TYPE_IRQ)
>   return "IRQ";
>  
> - if (type == STACK_TYPE_SYSENTER)
> - return "SYSENTER";
> + if (type == STACK_TYPE_SYSENTER) {
> + /*
> +  * On 64-bit, we have a generic entry stack that we
> +  * use for all the kernel try points, including
> +  * SYSENTER.

ITYM "kernel entry points".

- Kevin



4.14.0: built-in drivers now require built-in firmware?

2017-12-01 Thread Bob Tracy
The subject question is due to trouble encountered on a DEC Alpha
getting the 4.14.0 kernel to see the machine's SCSI disks at boot time.

I'm using the standard kernel source tree, and have long made it a
practice to build-in the drivers for devices required at boot time (such
as for the video card and local disks).  For as far back as I can
remember, I've had to build-in the firmware for the video card to get
the console working properly.  Up through kernel version 4.13, I had not
had to build-in the firmware for my machine's Qlogic ISP1020 host
adapter.

Beginning with 4.14, the host adapter was no longer being detected and
initialized.  Adding the appropriate firmware file to the list of
built-in firmware fixed the issue.

Is there a way to adjust the kernel configuration process to account for
this evidently new dependency?  The immediate problem I see is the
mapping between drivers and associated firmware files is not necessarily
one-to-one.  In the case of the "qla1280" driver, there are three
associated firmware images: the image corresponding to the host adapter
present at boot time is required to be built-in if the "qla1280" driver
is built-in.  The "radeon" video driver has a *much* longer list of
firmware files to select from.

Since the presence of appropriate firmware files on the kernel build
system isn't guaranteed, perhaps the best thing to do is have the
configuration script/program issue a warning message about firmware for
devices whose drivers are built-in rather than built as modules.

This is presumably a non-issue for people who run distro-provided
kernels where everything is modularized.

--Bob


4.14.0: built-in drivers now require built-in firmware?

2017-12-01 Thread Bob Tracy
The subject question is due to trouble encountered on a DEC Alpha
getting the 4.14.0 kernel to see the machine's SCSI disks at boot time.

I'm using the standard kernel source tree, and have long made it a
practice to build-in the drivers for devices required at boot time (such
as for the video card and local disks).  For as far back as I can
remember, I've had to build-in the firmware for the video card to get
the console working properly.  Up through kernel version 4.13, I had not
had to build-in the firmware for my machine's Qlogic ISP1020 host
adapter.

Beginning with 4.14, the host adapter was no longer being detected and
initialized.  Adding the appropriate firmware file to the list of
built-in firmware fixed the issue.

Is there a way to adjust the kernel configuration process to account for
this evidently new dependency?  The immediate problem I see is the
mapping between drivers and associated firmware files is not necessarily
one-to-one.  In the case of the "qla1280" driver, there are three
associated firmware images: the image corresponding to the host adapter
present at boot time is required to be built-in if the "qla1280" driver
is built-in.  The "radeon" video driver has a *much* longer list of
firmware files to select from.

Since the presence of appropriate firmware files on the kernel build
system isn't guaranteed, perhaps the best thing to do is have the
configuration script/program issue a warning message about firmware for
devices whose drivers are built-in rather than built as modules.

This is presumably a non-issue for people who run distro-provided
kernels where everything is modularized.

--Bob


Re: [PATCH 9/9] ASoC: eukrea-tlv320: Remove include line of fsl_ssi.h

2017-12-01 Thread Nicolin Chen
On Fri, Dec 01, 2017 at 10:23:25PM -0800, Nicolin Chen wrote:
> The eukrea-tlv320 driver is still compiled successfully without
> any erorr using imx_v6_v6_defconfig, after removing it.

A typo here, should be imx_v6_v7_defconfig. Sending a v2 anyway.

Please ignore this version. Thanks.


Re: [PATCH 9/9] ASoC: eukrea-tlv320: Remove include line of fsl_ssi.h

2017-12-01 Thread Nicolin Chen
On Fri, Dec 01, 2017 at 10:23:25PM -0800, Nicolin Chen wrote:
> The eukrea-tlv320 driver is still compiled successfully without
> any erorr using imx_v6_v6_defconfig, after removing it.

A typo here, should be imx_v6_v7_defconfig. Sending a v2 anyway.

Please ignore this version. Thanks.


[PATCH v2] ASoC: eukrea-tlv320: Remove include line of fsl_ssi.h

2017-12-01 Thread Nicolin Chen
The machine driver links both imx-ssi (legacy non-DT driver) and
fsl_ssi (up-to-date DT based driver). So It also includes both
imx-ssi.h and fsl_ssi.h header files. This creates a limitation
for two header files -- they can't define anything with identical
names.

Since the eukrea-tlv320 machine driver now does not really need
anything being defined in the fsl_ssi header file, and it's also
going to take some time to clean up two SSI drivers, this patch
takes a quick way to remove the #include fsl_ssi.h line for now.
It can be added back once the header files are done refactoring.

The eukrea-tlv320 driver is still compiled successfully without
any erorr using imx_v6_v7_defconfig, after removing it.

Signed-off-by: Nicolin Chen 
---

Changelog
v2:
 * Fixed a typo in the commit log at imx_v6_v7_defconfig

 sound/soc/fsl/eukrea-tlv320.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/soc/fsl/eukrea-tlv320.c b/sound/soc/fsl/eukrea-tlv320.c
index 84ef638..191426a 100644
--- a/sound/soc/fsl/eukrea-tlv320.c
+++ b/sound/soc/fsl/eukrea-tlv320.c
@@ -29,7 +29,6 @@
 
 #include "../codecs/tlv320aic23.h"
 #include "imx-ssi.h"
-#include "fsl_ssi.h"
 #include "imx-audmux.h"
 
 #define CODEC_CLOCK 1200
-- 
2.7.4



[PATCH v2] ASoC: eukrea-tlv320: Remove include line of fsl_ssi.h

2017-12-01 Thread Nicolin Chen
The machine driver links both imx-ssi (legacy non-DT driver) and
fsl_ssi (up-to-date DT based driver). So It also includes both
imx-ssi.h and fsl_ssi.h header files. This creates a limitation
for two header files -- they can't define anything with identical
names.

Since the eukrea-tlv320 machine driver now does not really need
anything being defined in the fsl_ssi header file, and it's also
going to take some time to clean up two SSI drivers, this patch
takes a quick way to remove the #include fsl_ssi.h line for now.
It can be added back once the header files are done refactoring.

The eukrea-tlv320 driver is still compiled successfully without
any erorr using imx_v6_v7_defconfig, after removing it.

Signed-off-by: Nicolin Chen 
---

Changelog
v2:
 * Fixed a typo in the commit log at imx_v6_v7_defconfig

 sound/soc/fsl/eukrea-tlv320.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/soc/fsl/eukrea-tlv320.c b/sound/soc/fsl/eukrea-tlv320.c
index 84ef638..191426a 100644
--- a/sound/soc/fsl/eukrea-tlv320.c
+++ b/sound/soc/fsl/eukrea-tlv320.c
@@ -29,7 +29,6 @@
 
 #include "../codecs/tlv320aic23.h"
 #include "imx-ssi.h"
-#include "fsl_ssi.h"
 #include "imx-audmux.h"
 
 #define CODEC_CLOCK 1200
-- 
2.7.4



Re: [PATCH 9/9] ASoC: eukrea-tlv320: Remove include line of fsl_ssi.h

2017-12-01 Thread Nicolin Chen
[PATCH 9/9] ASoC: eukrea-tlv320: Remove include line of fsl_ssi.h

Please ignore the "9/9" in the tag...I forgot to clean it.
It would be removed after getting applied though...


Re: [PATCH 9/9] ASoC: eukrea-tlv320: Remove include line of fsl_ssi.h

2017-12-01 Thread Nicolin Chen
[PATCH 9/9] ASoC: eukrea-tlv320: Remove include line of fsl_ssi.h

Please ignore the "9/9" in the tag...I forgot to clean it.
It would be removed after getting applied though...


[PATCH 9/9] ASoC: eukrea-tlv320: Remove include line of fsl_ssi.h

2017-12-01 Thread Nicolin Chen
The machine driver links both imx-ssi (legacy non-DT driver) and
fsl_ssi (up-to-date DT based driver). So It also includes both
imx-ssi.h and fsl_ssi.h header files. This creates a limitation
for two header files -- they can't define anything with identical
names.

Since the eukrea-tlv320 machine driver now does not really need
anything being defined in the fsl_ssi header file, and it's also
going to take some time to clean up two SSI drivers, this patch
takes a quick way to remove the #include fsl_ssi.h line for now.
It can be added back once the header files are done refactoring.

The eukrea-tlv320 driver is still compiled successfully without
any erorr using imx_v6_v6_defconfig, after removing it.

Signed-off-by: Nicolin Chen 
---
 sound/soc/fsl/eukrea-tlv320.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/soc/fsl/eukrea-tlv320.c b/sound/soc/fsl/eukrea-tlv320.c
index 84ef638..191426a 100644
--- a/sound/soc/fsl/eukrea-tlv320.c
+++ b/sound/soc/fsl/eukrea-tlv320.c
@@ -29,7 +29,6 @@
 
 #include "../codecs/tlv320aic23.h"
 #include "imx-ssi.h"
-#include "fsl_ssi.h"
 #include "imx-audmux.h"
 
 #define CODEC_CLOCK 1200
-- 
2.7.4



[PATCH 9/9] ASoC: eukrea-tlv320: Remove include line of fsl_ssi.h

2017-12-01 Thread Nicolin Chen
The machine driver links both imx-ssi (legacy non-DT driver) and
fsl_ssi (up-to-date DT based driver). So It also includes both
imx-ssi.h and fsl_ssi.h header files. This creates a limitation
for two header files -- they can't define anything with identical
names.

Since the eukrea-tlv320 machine driver now does not really need
anything being defined in the fsl_ssi header file, and it's also
going to take some time to clean up two SSI drivers, this patch
takes a quick way to remove the #include fsl_ssi.h line for now.
It can be added back once the header files are done refactoring.

The eukrea-tlv320 driver is still compiled successfully without
any erorr using imx_v6_v6_defconfig, after removing it.

Signed-off-by: Nicolin Chen 
---
 sound/soc/fsl/eukrea-tlv320.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/soc/fsl/eukrea-tlv320.c b/sound/soc/fsl/eukrea-tlv320.c
index 84ef638..191426a 100644
--- a/sound/soc/fsl/eukrea-tlv320.c
+++ b/sound/soc/fsl/eukrea-tlv320.c
@@ -29,7 +29,6 @@
 
 #include "../codecs/tlv320aic23.h"
 #include "imx-ssi.h"
-#include "fsl_ssi.h"
 #include "imx-audmux.h"
 
 #define CODEC_CLOCK 1200
-- 
2.7.4



[PATCH 0/2] KPTI: get rid of cpu_entry_area mapping duplication

2017-12-01 Thread Andy Lutomirski
I like this variant much better.  It might also fix the nasty bug tglx
and peterz were chasing.

Andy Lutomirski (2):
  Undo the split of setup_cpu_entry_area
  x86/kpti: Reference all cpu_entry_area pagetables in the usermode
tables

 arch/x86/include/asm/fixmap.h | 14 +---
 arch/x86/include/asm/kpti.h   |  8 +++--
 arch/x86/kernel/cpu/common.c  |  3 --
 arch/x86/kernel/smpboot.c |  2 ++
 arch/x86/kernel/traps.c   |  6 +++-
 arch/x86/mm/kpti.c| 82 ++-
 6 files changed, 71 insertions(+), 44 deletions(-)

-- 
2.13.6



[PATCH 1/2] Undo the split of setup_cpu_entry_area

2017-12-01 Thread Andy Lutomirski
This is obviously a hack.  Either the patch should be adjusted back to
the version I sent or trap_init should forcibly initialize all PMDs
by something like __set_fixmap(..., __mkpte(0)); or however it's spelled.
---
 arch/x86/kernel/smpboot.c | 2 ++
 arch/x86/kernel/traps.c   | 6 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 26317716559d..1325844b930a 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1232,8 +1232,10 @@ void __init native_smp_prepare_cpus(unsigned int 
max_cpus)
 * The boot CPU area has been set up in trap_init()
 * already.
 */
+   /*
if (i)
setup_cpu_entry_area(i);
+   */
}
 
/*
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index ff4e6b595ae4..0ad92f35a75b 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -945,8 +945,12 @@ dotraplinkage void do_iret_error(struct pt_regs *regs, 
long error_code)
 
 void __init trap_init(void)
 {
+   int cpu;
/* Init cpu_entry_area before IST entries are set up */
-   setup_cpu_entry_area(smp_processor_id());
+   for_each_possible_cpu(cpu) {
+   pr_err("setup_cpu_entry_area(%d)\n", cpu);
+   setup_cpu_entry_area(cpu);
+   }
 
idt_setup_traps();
 
-- 
2.13.6



[PATCH 0/2] KPTI: get rid of cpu_entry_area mapping duplication

2017-12-01 Thread Andy Lutomirski
I like this variant much better.  It might also fix the nasty bug tglx
and peterz were chasing.

Andy Lutomirski (2):
  Undo the split of setup_cpu_entry_area
  x86/kpti: Reference all cpu_entry_area pagetables in the usermode
tables

 arch/x86/include/asm/fixmap.h | 14 +---
 arch/x86/include/asm/kpti.h   |  8 +++--
 arch/x86/kernel/cpu/common.c  |  3 --
 arch/x86/kernel/smpboot.c |  2 ++
 arch/x86/kernel/traps.c   |  6 +++-
 arch/x86/mm/kpti.c| 82 ++-
 6 files changed, 71 insertions(+), 44 deletions(-)

-- 
2.13.6



[PATCH 1/2] Undo the split of setup_cpu_entry_area

2017-12-01 Thread Andy Lutomirski
This is obviously a hack.  Either the patch should be adjusted back to
the version I sent or trap_init should forcibly initialize all PMDs
by something like __set_fixmap(..., __mkpte(0)); or however it's spelled.
---
 arch/x86/kernel/smpboot.c | 2 ++
 arch/x86/kernel/traps.c   | 6 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 26317716559d..1325844b930a 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1232,8 +1232,10 @@ void __init native_smp_prepare_cpus(unsigned int 
max_cpus)
 * The boot CPU area has been set up in trap_init()
 * already.
 */
+   /*
if (i)
setup_cpu_entry_area(i);
+   */
}
 
/*
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index ff4e6b595ae4..0ad92f35a75b 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -945,8 +945,12 @@ dotraplinkage void do_iret_error(struct pt_regs *regs, 
long error_code)
 
 void __init trap_init(void)
 {
+   int cpu;
/* Init cpu_entry_area before IST entries are set up */
-   setup_cpu_entry_area(smp_processor_id());
+   for_each_possible_cpu(cpu) {
+   pr_err("setup_cpu_entry_area(%d)\n", cpu);
+   setup_cpu_entry_area(cpu);
+   }
 
idt_setup_traps();
 
-- 
2.13.6



[PATCH 2/2] x86/kpti: Reference all cpu_entry_area pagetables in the usermode tables

2017-12-01 Thread Andy Lutomirski
We were manually configuring cpu_entry_area in the usermode tables.
This was error-prone and wasted memory.  (Not much memory, but
still.)  Instead, just reference the same pagetables.

This avoids needing to keep the KPTI code and the normal
cpu_entry_area code in sync, since the KPTI code no longer cares
what's in cpu_entry_area.

[This does *not* work on the current KPTI series.  It requires that
 all the kernelmode cpu_entry_tables are pre-allocated.  That
 happens in the series as I submitted it, but tglx changed it for
 reasons that I haven't figured out.]

Signed-off-by: Andy Lutomirski 
---
 arch/x86/include/asm/fixmap.h | 14 +---
 arch/x86/include/asm/kpti.h   |  8 +++--
 arch/x86/kernel/cpu/common.c  |  3 --
 arch/x86/mm/kpti.c| 82 ++-
 4 files changed, 64 insertions(+), 43 deletions(-)

diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
index 839addd1eaec..a630cd2861f7 100644
--- a/arch/x86/include/asm/fixmap.h
+++ b/arch/x86/include/asm/fixmap.h
@@ -142,16 +142,20 @@ enum fixed_addresses {
 #ifdef CONFIG_PARAVIRT
FIX_PARAVIRT_BOOTMAP,
 #endif
-   FIX_TEXT_POKE1, /* reserve 2 pages for text_poke() */
-   FIX_TEXT_POKE0, /* first page is last, because allocation is backward */
 #ifdef CONFIG_X86_INTEL_MID
FIX_LNW_VRTC,
 #endif
-   /* Fixmap entries to remap the GDTs, one per processor. */
-   FIX_CPU_ENTRY_AREA_TOP,
+   FIX_TEXT_POKE1, /* reserve 2 pages for text_poke() */
+   FIX_TEXT_POKE0, /* first page is last, because allocation is backward */
+
+   /*
+* Fixmap entries to remap the GDTs, one per processor.  Align
+* to a PMD boundary.
+*/
+   FIX_CPU_ENTRY_AREA_TOP = round_up(FIX_TEXT_POKE0 + 1, PTRS_PER_PMD),
FIX_CPU_ENTRY_AREA_BOTTOM = FIX_CPU_ENTRY_AREA_TOP + 
(CPU_ENTRY_AREA_PAGES * NR_CPUS) - 1,
 
-   __end_of_permanent_fixed_addresses,
+   __end_of_permanent_fixed_addresses = round_up(FIX_CPU_ENTRY_AREA_BOTTOM 
+ 1, PTRS_PER_PMD),
 
/*
 * 512 temporary boot-time mappings, used by early_ioremap(),
diff --git a/arch/x86/include/asm/kpti.h b/arch/x86/include/asm/kpti.h
index 0c10e86ae3f8..df52cec2a53b 100644
--- a/arch/x86/include/asm/kpti.h
+++ b/arch/x86/include/asm/kpti.h
@@ -1,5 +1,8 @@
 #ifndef _ASM_X86_KPTI_H
 #define _ASM_X86_KPTI_H
+
+#include 
+
 /*
  * Copyright(c) 2017 Intel Corporation. All rights reserved.
  *
@@ -34,10 +37,9 @@ extern int kpti_add_mapping(unsigned long addr, unsigned 
long size,
  unsigned long flags);
 
 /**
- *  kpti_add_mapping_cpu_entry - map the cpu entry area
- *  @cpu: the CPU for which the entry area is being mapped
+ *  kpti_clone_cpu_entry_areas - clone cpu_entry_areas to the usermode tables
  */
-extern void kpti_add_mapping_cpu_entry(int cpu);
+extern void __init kpti_clone_cpu_entry_areas(void);
 
 /**
  *  kpti_remove_mapping - remove a kernel mapping from the userpage tables
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 00697119f983..3dc814519c92 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -606,9 +606,6 @@ void __init setup_cpu_entry_area(int cpu)
sizeof(struct debug_store) / PAGE_SIZE,
PAGE_KERNEL);
 #endif
-   /* CPU 0's mapping is done in kpti_init() */
-   if (cpu)
-   kpti_add_mapping_cpu_entry(cpu);
 }
 
 /* Load the original GDT from the per-cpu structure */
diff --git a/arch/x86/mm/kpti.c b/arch/x86/mm/kpti.c
index 52fd833845ba..cd81a7432f49 100644
--- a/arch/x86/mm/kpti.c
+++ b/arch/x86/mm/kpti.c
@@ -240,7 +240,7 @@ static pmd_t *kpti_shadow_pagetable_walk_pmd(unsigned long 
address,
  * Returns a pointer to a PTE on success, or NULL on failure.
  */
 static pte_t *kpti_shadow_pagetable_walk(unsigned long address,
-  unsigned long flags)
+unsigned long flags)
 {
pmd_t *pmd = kpti_shadow_pagetable_walk_pmd(address, flags);
pte_t *pte;
@@ -401,28 +401,55 @@ static void __init kpti_init_all_pgds(void)
WARN_ON(__ret); \
 } while (0)
 
-void kpti_add_mapping_cpu_entry(int cpu)
+void __init kpti_clone_cpu_entry_areas(void)
 {
-   kpti_add_user_map_early(get_cpu_gdt_ro(cpu), PAGE_SIZE,
-   __PAGE_KERNEL_RO);
-
-   kpti_add_user_map_early(_cpu_entry_area(cpu)->tss,
-   sizeof(get_cpu_entry_area(cpu)->tss),
-   __PAGE_KERNEL | _PAGE_GLOBAL);
-
-   /* entry stack */
-   kpti_add_user_map_early(_cpu_entry_area(cpu)->SYSENTER_stack_page,
-   
sizeof(get_cpu_entry_area(cpu)->SYSENTER_stack_page),
-   __PAGE_KERNEL | _PAGE_GLOBAL);
-
-   /* Entry code, so needs to 

[PATCH 2/2] x86/kpti: Reference all cpu_entry_area pagetables in the usermode tables

2017-12-01 Thread Andy Lutomirski
We were manually configuring cpu_entry_area in the usermode tables.
This was error-prone and wasted memory.  (Not much memory, but
still.)  Instead, just reference the same pagetables.

This avoids needing to keep the KPTI code and the normal
cpu_entry_area code in sync, since the KPTI code no longer cares
what's in cpu_entry_area.

[This does *not* work on the current KPTI series.  It requires that
 all the kernelmode cpu_entry_tables are pre-allocated.  That
 happens in the series as I submitted it, but tglx changed it for
 reasons that I haven't figured out.]

Signed-off-by: Andy Lutomirski 
---
 arch/x86/include/asm/fixmap.h | 14 +---
 arch/x86/include/asm/kpti.h   |  8 +++--
 arch/x86/kernel/cpu/common.c  |  3 --
 arch/x86/mm/kpti.c| 82 ++-
 4 files changed, 64 insertions(+), 43 deletions(-)

diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
index 839addd1eaec..a630cd2861f7 100644
--- a/arch/x86/include/asm/fixmap.h
+++ b/arch/x86/include/asm/fixmap.h
@@ -142,16 +142,20 @@ enum fixed_addresses {
 #ifdef CONFIG_PARAVIRT
FIX_PARAVIRT_BOOTMAP,
 #endif
-   FIX_TEXT_POKE1, /* reserve 2 pages for text_poke() */
-   FIX_TEXT_POKE0, /* first page is last, because allocation is backward */
 #ifdef CONFIG_X86_INTEL_MID
FIX_LNW_VRTC,
 #endif
-   /* Fixmap entries to remap the GDTs, one per processor. */
-   FIX_CPU_ENTRY_AREA_TOP,
+   FIX_TEXT_POKE1, /* reserve 2 pages for text_poke() */
+   FIX_TEXT_POKE0, /* first page is last, because allocation is backward */
+
+   /*
+* Fixmap entries to remap the GDTs, one per processor.  Align
+* to a PMD boundary.
+*/
+   FIX_CPU_ENTRY_AREA_TOP = round_up(FIX_TEXT_POKE0 + 1, PTRS_PER_PMD),
FIX_CPU_ENTRY_AREA_BOTTOM = FIX_CPU_ENTRY_AREA_TOP + 
(CPU_ENTRY_AREA_PAGES * NR_CPUS) - 1,
 
-   __end_of_permanent_fixed_addresses,
+   __end_of_permanent_fixed_addresses = round_up(FIX_CPU_ENTRY_AREA_BOTTOM 
+ 1, PTRS_PER_PMD),
 
/*
 * 512 temporary boot-time mappings, used by early_ioremap(),
diff --git a/arch/x86/include/asm/kpti.h b/arch/x86/include/asm/kpti.h
index 0c10e86ae3f8..df52cec2a53b 100644
--- a/arch/x86/include/asm/kpti.h
+++ b/arch/x86/include/asm/kpti.h
@@ -1,5 +1,8 @@
 #ifndef _ASM_X86_KPTI_H
 #define _ASM_X86_KPTI_H
+
+#include 
+
 /*
  * Copyright(c) 2017 Intel Corporation. All rights reserved.
  *
@@ -34,10 +37,9 @@ extern int kpti_add_mapping(unsigned long addr, unsigned 
long size,
  unsigned long flags);
 
 /**
- *  kpti_add_mapping_cpu_entry - map the cpu entry area
- *  @cpu: the CPU for which the entry area is being mapped
+ *  kpti_clone_cpu_entry_areas - clone cpu_entry_areas to the usermode tables
  */
-extern void kpti_add_mapping_cpu_entry(int cpu);
+extern void __init kpti_clone_cpu_entry_areas(void);
 
 /**
  *  kpti_remove_mapping - remove a kernel mapping from the userpage tables
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 00697119f983..3dc814519c92 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -606,9 +606,6 @@ void __init setup_cpu_entry_area(int cpu)
sizeof(struct debug_store) / PAGE_SIZE,
PAGE_KERNEL);
 #endif
-   /* CPU 0's mapping is done in kpti_init() */
-   if (cpu)
-   kpti_add_mapping_cpu_entry(cpu);
 }
 
 /* Load the original GDT from the per-cpu structure */
diff --git a/arch/x86/mm/kpti.c b/arch/x86/mm/kpti.c
index 52fd833845ba..cd81a7432f49 100644
--- a/arch/x86/mm/kpti.c
+++ b/arch/x86/mm/kpti.c
@@ -240,7 +240,7 @@ static pmd_t *kpti_shadow_pagetable_walk_pmd(unsigned long 
address,
  * Returns a pointer to a PTE on success, or NULL on failure.
  */
 static pte_t *kpti_shadow_pagetable_walk(unsigned long address,
-  unsigned long flags)
+unsigned long flags)
 {
pmd_t *pmd = kpti_shadow_pagetable_walk_pmd(address, flags);
pte_t *pte;
@@ -401,28 +401,55 @@ static void __init kpti_init_all_pgds(void)
WARN_ON(__ret); \
 } while (0)
 
-void kpti_add_mapping_cpu_entry(int cpu)
+void __init kpti_clone_cpu_entry_areas(void)
 {
-   kpti_add_user_map_early(get_cpu_gdt_ro(cpu), PAGE_SIZE,
-   __PAGE_KERNEL_RO);
-
-   kpti_add_user_map_early(_cpu_entry_area(cpu)->tss,
-   sizeof(get_cpu_entry_area(cpu)->tss),
-   __PAGE_KERNEL | _PAGE_GLOBAL);
-
-   /* entry stack */
-   kpti_add_user_map_early(_cpu_entry_area(cpu)->SYSENTER_stack_page,
-   
sizeof(get_cpu_entry_area(cpu)->SYSENTER_stack_page),
-   __PAGE_KERNEL | _PAGE_GLOBAL);
-
-   /* Entry code, so needs to be EXEC */
-   

Re: [PATCH 2/2] ipc: Fix ipc data structures inconsistency

2017-12-01 Thread Manfred Spraul

Hi,

On 12/01/2017 06:20 PM, Davidlohr Bueso wrote:

On Thu, 30 Nov 2017, Philippe Mikoyan wrote:


As described in the title, this patch fixes id_ds inconsistency
when ctl_stat runs concurrently with some ds-changing function,
e.g. shmat, msgsnd or whatever.

For instance, if shmctl(IPC_STAT) is running concurrently with shmat,
following data structure can be returned:
{... shm_lpid = 0, shm_nattch = 1, ...}


The patch appears to be good. I'll try to perform some tests, but I'm 
not sure when I will be able to.
Especially: I don't know the shm code good enough to immediately check 
the change you make to nattach.


And, perhaps as a side information:
There appears to be a use-after-free in shm, I now got a 2nd mail from 
syzbot:

http://lkml.iu.edu/hypermail/linux/kernel/1702.3/02480.html



Hmm yeah that's pretty fishy, also shm_atime = 0, no?

So I think this patch is fine as we can obviously race at a user level.
This is another justification for converting the ipc lock to rwlock;
performance wise they are the pretty much the same (being queued)...
but that's irrelevant to this patch. I like that you manage to do
security and such checks still only under rcu, like all ipc calls
work; *_stat() is no longer special.

I don't like rwlock, they add complexity without reducing the cache line 
pressure.


What I would like to try is to create a mutex_lock_rcu() function, and 
then convert everything to a mutex.


As pseudocode::
    rcu_lock();
    idr_lookup();
    mutex_trylock();
    if (failed) {
        getref();
        rcu_unlock();
        mutex_lock();
        putref();
    } else {
        rcu_unlock();
    }

Obviously, the getref then within the mutex framework, i.e. only if 
mutex_lock() really sleeps.
If the code in ipc gets significantly simpler, then perhaps convert it 
to an rw mutex.


Re: [PATCH 2/2] ipc: Fix ipc data structures inconsistency

2017-12-01 Thread Manfred Spraul

Hi,

On 12/01/2017 06:20 PM, Davidlohr Bueso wrote:

On Thu, 30 Nov 2017, Philippe Mikoyan wrote:


As described in the title, this patch fixes id_ds inconsistency
when ctl_stat runs concurrently with some ds-changing function,
e.g. shmat, msgsnd or whatever.

For instance, if shmctl(IPC_STAT) is running concurrently with shmat,
following data structure can be returned:
{... shm_lpid = 0, shm_nattch = 1, ...}


The patch appears to be good. I'll try to perform some tests, but I'm 
not sure when I will be able to.
Especially: I don't know the shm code good enough to immediately check 
the change you make to nattach.


And, perhaps as a side information:
There appears to be a use-after-free in shm, I now got a 2nd mail from 
syzbot:

http://lkml.iu.edu/hypermail/linux/kernel/1702.3/02480.html



Hmm yeah that's pretty fishy, also shm_atime = 0, no?

So I think this patch is fine as we can obviously race at a user level.
This is another justification for converting the ipc lock to rwlock;
performance wise they are the pretty much the same (being queued)...
but that's irrelevant to this patch. I like that you manage to do
security and such checks still only under rcu, like all ipc calls
work; *_stat() is no longer special.

I don't like rwlock, they add complexity without reducing the cache line 
pressure.


What I would like to try is to create a mutex_lock_rcu() function, and 
then convert everything to a mutex.


As pseudocode::
    rcu_lock();
    idr_lookup();
    mutex_trylock();
    if (failed) {
        getref();
        rcu_unlock();
        mutex_lock();
        putref();
    } else {
        rcu_unlock();
    }

Obviously, the getref then within the mutex framework, i.e. only if 
mutex_lock() really sleeps.
If the code in ipc gets significantly simpler, then perhaps convert it 
to an rw mutex.


[PATCH v2] ubsan: don't handle misaligned address when support unaligned access

2017-12-01 Thread Ding Tianhong
The ubsan always report Warning just like:

UBSAN: Undefined behaviour in ../include/linux/etherdevice.h:386:9
load of misaligned address ffc069ba0482 for type 'long unsigned int'
which requires 8 byte alignment
CPU: 0 PID: 901 Comm: sshd Not tainted 4.xx+ #1
Hardware name: linux,dummy-virt (DT)
Call trace:
[] dump_backtrace+0x0/0x348
[] show_stack+0x20/0x30
[] dump_stack+0x144/0x1b4
[] ubsan_epilogue+0x18/0x74
[] __ubsan_handle_type_mismatch+0x1a0/0x25c
[] dev_gro_receive+0x17d8/0x1830
[] napi_gro_receive+0x30/0x158
[] virtnet_receive+0xad4/0x1fa8

The reason is that when enable the CONFIG_UBSAN_ALIGNMENT, the ubsan
will report the unaligned access even if the system support it
(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y), it will produce a lot
of noise in the log and cause confusion.

This patch will close the detection of unaligned access when
the system support unaligned access.

Signed-off-by: Ding Tianhong 
---
 lib/ubsan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/ubsan.c b/lib/ubsan.c
index fb0409d..9207e65 100644
--- a/lib/ubsan.c
+++ b/lib/ubsan.c
@@ -322,7 +322,8 @@ void __ubsan_handle_type_mismatch(struct type_mismatch_data 
*data,
if (!ptr)
handle_null_ptr_deref(data);
else if (data->alignment && !IS_ALIGNED(ptr, data->alignment))
-   handle_missaligned_access(data, ptr);
+   if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS))
+   handle_missaligned_access(data, ptr);
else
handle_object_size_mismatch(data, ptr);
 }
-- 
1.8.3.1



[PATCH v2] ubsan: don't handle misaligned address when support unaligned access

2017-12-01 Thread Ding Tianhong
The ubsan always report Warning just like:

UBSAN: Undefined behaviour in ../include/linux/etherdevice.h:386:9
load of misaligned address ffc069ba0482 for type 'long unsigned int'
which requires 8 byte alignment
CPU: 0 PID: 901 Comm: sshd Not tainted 4.xx+ #1
Hardware name: linux,dummy-virt (DT)
Call trace:
[] dump_backtrace+0x0/0x348
[] show_stack+0x20/0x30
[] dump_stack+0x144/0x1b4
[] ubsan_epilogue+0x18/0x74
[] __ubsan_handle_type_mismatch+0x1a0/0x25c
[] dev_gro_receive+0x17d8/0x1830
[] napi_gro_receive+0x30/0x158
[] virtnet_receive+0xad4/0x1fa8

The reason is that when enable the CONFIG_UBSAN_ALIGNMENT, the ubsan
will report the unaligned access even if the system support it
(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y), it will produce a lot
of noise in the log and cause confusion.

This patch will close the detection of unaligned access when
the system support unaligned access.

Signed-off-by: Ding Tianhong 
---
 lib/ubsan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/ubsan.c b/lib/ubsan.c
index fb0409d..9207e65 100644
--- a/lib/ubsan.c
+++ b/lib/ubsan.c
@@ -322,7 +322,8 @@ void __ubsan_handle_type_mismatch(struct type_mismatch_data 
*data,
if (!ptr)
handle_null_ptr_deref(data);
else if (data->alignment && !IS_ALIGNED(ptr, data->alignment))
-   handle_missaligned_access(data, ptr);
+   if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS))
+   handle_missaligned_access(data, ptr);
else
handle_object_size_mismatch(data, ptr);
 }
-- 
1.8.3.1



Re: [PATCH v5 10/12] perf util: Reuse thread_map__new_by_uid to enumerate threads from /proc

2017-12-01 Thread Jin, Yao



On 12/1/2017 11:02 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Dec 01, 2017 at 11:44:25AM -0300, Arnaldo Carvalho de Melo escreveu:

Em Fri, Dec 01, 2017 at 06:57:34PM +0800, Jin Yao escreveu:

Perf already has a function thread_map__new_by_uid() which can
enumerate all threads from /proc by uid.

This patch creates a static function enumerate_threads() which
reuses the common code in thread_map__new_by_uid() to enumerate
threads from /proc.

The enumerate_threads() is shared by thread_map__new_by_uid()
and a new function thread_map__new_threads().

The new function thread_map__new_threads() is called to enumerate
all threads from /proc.

Signed-off-by: Jin Yao 
---
  tools/perf/tests/thread-map.c |  2 +-
  tools/perf/util/evlist.c  |  3 ++-
  tools/perf/util/thread_map.c  | 19 ---
  tools/perf/util/thread_map.h  |  3 ++-
  4 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c
index dbcb6a1..4de1939 100644
--- a/tools/perf/tests/thread-map.c
+++ b/tools/perf/tests/thread-map.c
@@ -105,7 +105,7 @@ int test__thread_map_remove(struct test *test 
__maybe_unused, int subtest __mayb
TEST_ASSERT_VAL("failed to allocate map string",
asprintf(, "%d,%d", getpid(), getppid()) >= 0);
  
-	threads = thread_map__new_str(str, NULL, 0);

+   threads = thread_map__new_str(str, NULL, 0, false);
  
  	TEST_ASSERT_VAL("failed to allocate thread_map",

threads);
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 199bb82..05b8f2b 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1102,7 +1102,8 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, 
struct target *target)
struct cpu_map *cpus;
struct thread_map *threads;
  
-	threads = thread_map__new_str(target->pid, target->tid, target->uid);

+   threads = thread_map__new_str(target->pid, target->tid, target->uid,
+ target->per_thread);
  
  	if (!threads)

return -1;
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index be0d5a7..5672268 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -92,7 +92,7 @@ struct thread_map *thread_map__new_by_tid(pid_t tid)
return threads;
  }
  
-struct thread_map *thread_map__new_by_uid(uid_t uid)

+static struct thread_map *enumerate_threads(uid_t uid)
  {
DIR *proc;
int max_threads = 32, items, i;
@@ -124,7 +124,7 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
if (stat(path, ) != 0)
continue;


Look, for the case where you want all threads enumerated you will incur
the above stat() cost for all of them and will not use it at all...

And new_threads() seems vague, I'm using the ter used by 'perf record'
for system wide sampling, see the patch below:



The one below even compiles, I'll push what I merged already and we can
continue from there:

[acme@jouet linux]$ git log --oneline -3
5cc4fc8994eb (HEAD -> perf/core) perf thread_map: Add method to map all threads 
in the system
9e49c22bd4d8 perf stat: Add rbtree node_delete op
1c92e3226546 perf rblist: Create rblist__exit() function
[acme@jouet linux]$




Yes we can continue from these commits.

I just pull the branch perf/core from 
https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git, but it 
looks the new commits have not been synced.


Maybe I will wait to next week to see if the new commits are synced and 
then continue the work.


Thanks
Jin Yao


commit 5cc4fc8994eb3f3af1950f3b726b6008900c7b06
Author: Arnaldo Carvalho de Melo 
Date:   Fri Dec 1 11:44:30 2017 -0300

 perf thread_map: Add method to map all threads in the system
 
 Reusing the thread_map__new_by_uid() proc scanning already in place to

 return a map with all threads in the system.
 
 Based-on-a-patch-by: Jin Yao 

 Acked-by: Jiri Olsa 
 Cc: Alexander Shishkin 
 Cc: Andi Kleen 
 Cc: Kan Liang 
 Cc: Peter Zijlstra 
 Link: https://lkml.kernel.org/n/tip-khh28q0wwqbqtrk32bfe0...@git.kernel.org
 Signed-off-by: Arnaldo Carvalho de Melo 

diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index be0d5a736dea..2b653853eec2 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -92,7 +92,7 @@ struct thread_map *thread_map__new_by_tid(pid_t tid)
return threads;
  }
  
-struct thread_map *thread_map__new_by_uid(uid_t uid)

+static struct thread_map *__thread_map__new_all_cpus(uid_t uid)
  {
DIR *proc;
int max_threads = 32, items, i;
@@ -113,7 +113,6 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)

Re: [PATCH v5 10/12] perf util: Reuse thread_map__new_by_uid to enumerate threads from /proc

2017-12-01 Thread Jin, Yao



On 12/1/2017 11:02 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Dec 01, 2017 at 11:44:25AM -0300, Arnaldo Carvalho de Melo escreveu:

Em Fri, Dec 01, 2017 at 06:57:34PM +0800, Jin Yao escreveu:

Perf already has a function thread_map__new_by_uid() which can
enumerate all threads from /proc by uid.

This patch creates a static function enumerate_threads() which
reuses the common code in thread_map__new_by_uid() to enumerate
threads from /proc.

The enumerate_threads() is shared by thread_map__new_by_uid()
and a new function thread_map__new_threads().

The new function thread_map__new_threads() is called to enumerate
all threads from /proc.

Signed-off-by: Jin Yao 
---
  tools/perf/tests/thread-map.c |  2 +-
  tools/perf/util/evlist.c  |  3 ++-
  tools/perf/util/thread_map.c  | 19 ---
  tools/perf/util/thread_map.h  |  3 ++-
  4 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c
index dbcb6a1..4de1939 100644
--- a/tools/perf/tests/thread-map.c
+++ b/tools/perf/tests/thread-map.c
@@ -105,7 +105,7 @@ int test__thread_map_remove(struct test *test 
__maybe_unused, int subtest __mayb
TEST_ASSERT_VAL("failed to allocate map string",
asprintf(, "%d,%d", getpid(), getppid()) >= 0);
  
-	threads = thread_map__new_str(str, NULL, 0);

+   threads = thread_map__new_str(str, NULL, 0, false);
  
  	TEST_ASSERT_VAL("failed to allocate thread_map",

threads);
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 199bb82..05b8f2b 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1102,7 +1102,8 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, 
struct target *target)
struct cpu_map *cpus;
struct thread_map *threads;
  
-	threads = thread_map__new_str(target->pid, target->tid, target->uid);

+   threads = thread_map__new_str(target->pid, target->tid, target->uid,
+ target->per_thread);
  
  	if (!threads)

return -1;
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index be0d5a7..5672268 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -92,7 +92,7 @@ struct thread_map *thread_map__new_by_tid(pid_t tid)
return threads;
  }
  
-struct thread_map *thread_map__new_by_uid(uid_t uid)

+static struct thread_map *enumerate_threads(uid_t uid)
  {
DIR *proc;
int max_threads = 32, items, i;
@@ -124,7 +124,7 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
if (stat(path, ) != 0)
continue;


Look, for the case where you want all threads enumerated you will incur
the above stat() cost for all of them and will not use it at all...

And new_threads() seems vague, I'm using the ter used by 'perf record'
for system wide sampling, see the patch below:



The one below even compiles, I'll push what I merged already and we can
continue from there:

[acme@jouet linux]$ git log --oneline -3
5cc4fc8994eb (HEAD -> perf/core) perf thread_map: Add method to map all threads 
in the system
9e49c22bd4d8 perf stat: Add rbtree node_delete op
1c92e3226546 perf rblist: Create rblist__exit() function
[acme@jouet linux]$




Yes we can continue from these commits.

I just pull the branch perf/core from 
https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git, but it 
looks the new commits have not been synced.


Maybe I will wait to next week to see if the new commits are synced and 
then continue the work.


Thanks
Jin Yao


commit 5cc4fc8994eb3f3af1950f3b726b6008900c7b06
Author: Arnaldo Carvalho de Melo 
Date:   Fri Dec 1 11:44:30 2017 -0300

 perf thread_map: Add method to map all threads in the system
 
 Reusing the thread_map__new_by_uid() proc scanning already in place to

 return a map with all threads in the system.
 
 Based-on-a-patch-by: Jin Yao 

 Acked-by: Jiri Olsa 
 Cc: Alexander Shishkin 
 Cc: Andi Kleen 
 Cc: Kan Liang 
 Cc: Peter Zijlstra 
 Link: https://lkml.kernel.org/n/tip-khh28q0wwqbqtrk32bfe0...@git.kernel.org
 Signed-off-by: Arnaldo Carvalho de Melo 

diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index be0d5a736dea..2b653853eec2 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -92,7 +92,7 @@ struct thread_map *thread_map__new_by_tid(pid_t tid)
return threads;
  }
  
-struct thread_map *thread_map__new_by_uid(uid_t uid)

+static struct thread_map *__thread_map__new_all_cpus(uid_t uid)
  {
DIR *proc;
int max_threads = 32, items, i;
@@ -113,7 +113,6 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
while ((dirent = readdir(proc)) != NULL) {
char *end;
bool grow = false;
-   struct stat st;
pid_t pid = strtol(dirent->d_name, , 10);
  
 

Re: [PATCH v5 10/12] perf util: Reuse thread_map__new_by_uid to enumerate threads from /proc

2017-12-01 Thread Jin, Yao



On 12/1/2017 10:44 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Dec 01, 2017 at 06:57:34PM +0800, Jin Yao escreveu:

Perf already has a function thread_map__new_by_uid() which can
enumerate all threads from /proc by uid.

This patch creates a static function enumerate_threads() which
reuses the common code in thread_map__new_by_uid() to enumerate
threads from /proc.

The enumerate_threads() is shared by thread_map__new_by_uid()
and a new function thread_map__new_threads().

The new function thread_map__new_threads() is called to enumerate
all threads from /proc.

Signed-off-by: Jin Yao 
---
  tools/perf/tests/thread-map.c |  2 +-
  tools/perf/util/evlist.c  |  3 ++-
  tools/perf/util/thread_map.c  | 19 ---
  tools/perf/util/thread_map.h  |  3 ++-
  4 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c
index dbcb6a1..4de1939 100644
--- a/tools/perf/tests/thread-map.c
+++ b/tools/perf/tests/thread-map.c
@@ -105,7 +105,7 @@ int test__thread_map_remove(struct test *test 
__maybe_unused, int subtest __mayb
TEST_ASSERT_VAL("failed to allocate map string",
asprintf(, "%d,%d", getpid(), getppid()) >= 0);
  
-	threads = thread_map__new_str(str, NULL, 0);

+   threads = thread_map__new_str(str, NULL, 0, false);
  
  	TEST_ASSERT_VAL("failed to allocate thread_map",

threads);
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 199bb82..05b8f2b 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1102,7 +1102,8 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, 
struct target *target)
struct cpu_map *cpus;
struct thread_map *threads;
  
-	threads = thread_map__new_str(target->pid, target->tid, target->uid);

+   threads = thread_map__new_str(target->pid, target->tid, target->uid,
+ target->per_thread);
  
  	if (!threads)

return -1;
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index be0d5a7..5672268 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -92,7 +92,7 @@ struct thread_map *thread_map__new_by_tid(pid_t tid)
return threads;
  }
  
-struct thread_map *thread_map__new_by_uid(uid_t uid)

+static struct thread_map *enumerate_threads(uid_t uid)
  {
DIR *proc;
int max_threads = 32, items, i;
@@ -124,7 +124,7 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
if (stat(path, ) != 0)
continue;


Look, for the case where you want all threads enumerated you will incur
the above stat() cost for all of them and will not use it at all...

And new_threads() seems vague, I'm using the ter used by 'perf record'
for system wide sampling, see the patch below:

diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index be0d5a736dea..79d11bd4543a 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -92,7 +92,7 @@ struct thread_map *thread_map__new_by_tid(pid_t tid)
return threads;
  }
  
-struct thread_map *thread_map__new_by_uid(uid_t uid)

+static struct thread_map *__thread_map__new_all_cpus(uid_t uid)
  {
DIR *proc;
int max_threads = 32, items, i;
@@ -113,7 +113,6 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
while ((dirent = readdir(proc)) != NULL) {
char *end;
bool grow = false;
-   struct stat st;
pid_t pid = strtol(dirent->d_name, , 10);
  
  		if (*end) /* only interested in proper numerical dirents */

@@ -121,11 +120,12 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
  
  		snprintf(path, sizeof(path), "/proc/%s", dirent->d_name);
  
-		if (stat(path, ) != 0)

-   continue;
+   if (uid != UID_MAX) {
+   struct stat st;
  
-		if (st.st_uid != uid)

-   continue;
+   if (stat(path, ) != 0 || st.st_uid != uid)
+   continue;
+   }
  
  		snprintf(path, sizeof(path), "/proc/%d/task", pid);

items = scandir(path, , filter, NULL);
@@ -178,6 +178,16 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
goto out_closedir;
  }
  
+struct thread_map *thread_map__new_all_cpus(void)

+{
+   return __thread__new_all_cpus(UID_MAX);
+}
+
+struct thread_map *thread_map__new_by_uid(uid_t uid)
+{
+   return __thread__new_all_cpus(uid);
+}
+
  struct thread_map *thread_map__new(pid_t pid, pid_t tid, uid_t uid)
  {
if (pid != -1)
diff --git a/tools/perf/util/thread_map.h b/tools/perf/util/thread_map.h
index f15803985435..07a765fb22bb 100644
--- a/tools/perf/util/thread_map.h
+++ b/tools/perf/util/thread_map.h
@@ -23,6 +23,7 @@ struct thread_map *thread_map__new_dummy(void);
  struct thread_map 

Re: [PATCH v5 10/12] perf util: Reuse thread_map__new_by_uid to enumerate threads from /proc

2017-12-01 Thread Jin, Yao



On 12/1/2017 10:44 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Dec 01, 2017 at 06:57:34PM +0800, Jin Yao escreveu:

Perf already has a function thread_map__new_by_uid() which can
enumerate all threads from /proc by uid.

This patch creates a static function enumerate_threads() which
reuses the common code in thread_map__new_by_uid() to enumerate
threads from /proc.

The enumerate_threads() is shared by thread_map__new_by_uid()
and a new function thread_map__new_threads().

The new function thread_map__new_threads() is called to enumerate
all threads from /proc.

Signed-off-by: Jin Yao 
---
  tools/perf/tests/thread-map.c |  2 +-
  tools/perf/util/evlist.c  |  3 ++-
  tools/perf/util/thread_map.c  | 19 ---
  tools/perf/util/thread_map.h  |  3 ++-
  4 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c
index dbcb6a1..4de1939 100644
--- a/tools/perf/tests/thread-map.c
+++ b/tools/perf/tests/thread-map.c
@@ -105,7 +105,7 @@ int test__thread_map_remove(struct test *test 
__maybe_unused, int subtest __mayb
TEST_ASSERT_VAL("failed to allocate map string",
asprintf(, "%d,%d", getpid(), getppid()) >= 0);
  
-	threads = thread_map__new_str(str, NULL, 0);

+   threads = thread_map__new_str(str, NULL, 0, false);
  
  	TEST_ASSERT_VAL("failed to allocate thread_map",

threads);
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 199bb82..05b8f2b 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1102,7 +1102,8 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, 
struct target *target)
struct cpu_map *cpus;
struct thread_map *threads;
  
-	threads = thread_map__new_str(target->pid, target->tid, target->uid);

+   threads = thread_map__new_str(target->pid, target->tid, target->uid,
+ target->per_thread);
  
  	if (!threads)

return -1;
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index be0d5a7..5672268 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -92,7 +92,7 @@ struct thread_map *thread_map__new_by_tid(pid_t tid)
return threads;
  }
  
-struct thread_map *thread_map__new_by_uid(uid_t uid)

+static struct thread_map *enumerate_threads(uid_t uid)
  {
DIR *proc;
int max_threads = 32, items, i;
@@ -124,7 +124,7 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
if (stat(path, ) != 0)
continue;


Look, for the case where you want all threads enumerated you will incur
the above stat() cost for all of them and will not use it at all...

And new_threads() seems vague, I'm using the ter used by 'perf record'
for system wide sampling, see the patch below:

diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index be0d5a736dea..79d11bd4543a 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -92,7 +92,7 @@ struct thread_map *thread_map__new_by_tid(pid_t tid)
return threads;
  }
  
-struct thread_map *thread_map__new_by_uid(uid_t uid)

+static struct thread_map *__thread_map__new_all_cpus(uid_t uid)
  {
DIR *proc;
int max_threads = 32, items, i;
@@ -113,7 +113,6 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
while ((dirent = readdir(proc)) != NULL) {
char *end;
bool grow = false;
-   struct stat st;
pid_t pid = strtol(dirent->d_name, , 10);
  
  		if (*end) /* only interested in proper numerical dirents */

@@ -121,11 +120,12 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
  
  		snprintf(path, sizeof(path), "/proc/%s", dirent->d_name);
  
-		if (stat(path, ) != 0)

-   continue;
+   if (uid != UID_MAX) {
+   struct stat st;
  
-		if (st.st_uid != uid)

-   continue;
+   if (stat(path, ) != 0 || st.st_uid != uid)
+   continue;
+   }
  
  		snprintf(path, sizeof(path), "/proc/%d/task", pid);

items = scandir(path, , filter, NULL);
@@ -178,6 +178,16 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
goto out_closedir;
  }
  
+struct thread_map *thread_map__new_all_cpus(void)

+{
+   return __thread__new_all_cpus(UID_MAX);
+}
+
+struct thread_map *thread_map__new_by_uid(uid_t uid)
+{
+   return __thread__new_all_cpus(uid);
+}
+
  struct thread_map *thread_map__new(pid_t pid, pid_t tid, uid_t uid)
  {
if (pid != -1)
diff --git a/tools/perf/util/thread_map.h b/tools/perf/util/thread_map.h
index f15803985435..07a765fb22bb 100644
--- a/tools/perf/util/thread_map.h
+++ b/tools/perf/util/thread_map.h
@@ -23,6 +23,7 @@ struct thread_map *thread_map__new_dummy(void);
  struct thread_map 

Re: [PATCH v5 06/12] perf util: Update and print per-thread shadow stats

2017-12-01 Thread Jin, Yao



On 12/1/2017 10:21 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Dec 01, 2017 at 06:57:30PM +0800, Jin Yao escreveu:

The functions perf_stat__update_shadow_stats() and
perf_stat__print_shadow_statss() are called to update
and print the shadow stats on a set of static variables.

But the static variables are the limitations to support
per-thread shadow stats.

This patch lets the perf_stat__update_shadow_stats() support
to update the shadow stats on a input parameter 'stat' and
uses update_runtime_stat() to update the stats. It will not
directly update the static variables as before.

And this patch also lets the perf_stat__print_shadow_stats()


When 'also' appears on a patch usually it means it should be split in
two, one for the things up to the 'also' and another for the remaining
parts.

A patch that has these stats:

5 files changed, 219 insertions(+), 120 deletions(-)

raises eyebrows :-\

I'm trying now to break it into at least two, one for printing and the
other for the rest.

- Arnaldo



Yes, too much in this patch.

Actually I also want to split it into more patches. While I just feel a 
little bit difficulty because some dependencies are there.


If you need me to do anything on this patch (e.g. 
refine/split/reorg/...), I'd like to, please let me know.


Thanks
Jin Yao


support to print the shadow stats from a input parameter 'stat'.

It will not directly get value from static variable. Instead, it now
uses runtime_stat_avg() and runtime_stat_n() to get and compute the
values.

Signed-off-by: Jin Yao 
---
  tools/perf/builtin-script.c   |   6 +-
  tools/perf/builtin-stat.c |  27 ++--
  tools/perf/util/stat-shadow.c | 293 +++---
  tools/perf/util/stat.c|   8 +-
  tools/perf/util/stat.h|   5 +-
  5 files changed, 219 insertions(+), 120 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 39d8b55..fac6f05 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1548,7 +1548,8 @@ static void perf_sample__fprint_metric(struct perf_script 
*script,
val = sample->period * evsel->scale;
perf_stat__update_shadow_stats(evsel,
   val,
-  sample->cpu);
+  sample->cpu,
+  _stat);
evsel_script(evsel)->val = val;
if (evsel_script(evsel->leader)->gnum == evsel->leader->nr_members) {
for_each_group_member (ev2, evsel->leader) {
@@ -1556,7 +1557,8 @@ static void perf_sample__fprint_metric(struct perf_script 
*script,
  evsel_script(ev2)->val,
  sample->cpu,
  ,
- NULL);
+ NULL,
+ _stat);
}
evsel_script(evsel->leader)->gnum = 0;
}
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index a027b47..1edc082 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1097,7 +1097,8 @@ static void abs_printout(int id, int nr, struct 
perf_evsel *evsel, double avg)
  }
  
  static void printout(int id, int nr, struct perf_evsel *counter, double uval,

-char *prefix, u64 run, u64 ena, double noise)
+char *prefix, u64 run, u64 ena, double noise,
+struct runtime_stat *stat)
  {
struct perf_stat_output_ctx out;
struct outstate os = {
@@ -1190,7 +1191,8 @@ static void printout(int id, int nr, struct perf_evsel 
*counter, double uval,
  
  	perf_stat__print_shadow_stats(counter, uval,

first_shadow_cpu(counter, id),
-   , _events);
+   , _events,
+   stat);
if (!csv_output && !metric_only) {
print_noise(counter, noise);
print_running(run, ena);
@@ -1214,7 +1216,8 @@ static void aggr_update_shadow(void)
val += perf_counts(counter->counts, cpu, 
0)->val;
}
perf_stat__update_shadow_stats(counter, val,
-  
first_shadow_cpu(counter, id));
+   first_shadow_cpu(counter, id),
+   _stat);
}
}
  }
@@ -1334,7 +1337,8 @@ static void print_aggr(char *prefix)
fprintf(output, "%s", prefix);
  
  			uval = val * counter->scale;

-   printout(id, nr, counter, uval, prefix, run, ena, 1.0);
+   printout(id, nr, 

Re: [PATCH v5 06/12] perf util: Update and print per-thread shadow stats

2017-12-01 Thread Jin, Yao



On 12/1/2017 10:21 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Dec 01, 2017 at 06:57:30PM +0800, Jin Yao escreveu:

The functions perf_stat__update_shadow_stats() and
perf_stat__print_shadow_statss() are called to update
and print the shadow stats on a set of static variables.

But the static variables are the limitations to support
per-thread shadow stats.

This patch lets the perf_stat__update_shadow_stats() support
to update the shadow stats on a input parameter 'stat' and
uses update_runtime_stat() to update the stats. It will not
directly update the static variables as before.

And this patch also lets the perf_stat__print_shadow_stats()


When 'also' appears on a patch usually it means it should be split in
two, one for the things up to the 'also' and another for the remaining
parts.

A patch that has these stats:

5 files changed, 219 insertions(+), 120 deletions(-)

raises eyebrows :-\

I'm trying now to break it into at least two, one for printing and the
other for the rest.

- Arnaldo



Yes, too much in this patch.

Actually I also want to split it into more patches. While I just feel a 
little bit difficulty because some dependencies are there.


If you need me to do anything on this patch (e.g. 
refine/split/reorg/...), I'd like to, please let me know.


Thanks
Jin Yao


support to print the shadow stats from a input parameter 'stat'.

It will not directly get value from static variable. Instead, it now
uses runtime_stat_avg() and runtime_stat_n() to get and compute the
values.

Signed-off-by: Jin Yao 
---
  tools/perf/builtin-script.c   |   6 +-
  tools/perf/builtin-stat.c |  27 ++--
  tools/perf/util/stat-shadow.c | 293 +++---
  tools/perf/util/stat.c|   8 +-
  tools/perf/util/stat.h|   5 +-
  5 files changed, 219 insertions(+), 120 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 39d8b55..fac6f05 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1548,7 +1548,8 @@ static void perf_sample__fprint_metric(struct perf_script 
*script,
val = sample->period * evsel->scale;
perf_stat__update_shadow_stats(evsel,
   val,
-  sample->cpu);
+  sample->cpu,
+  _stat);
evsel_script(evsel)->val = val;
if (evsel_script(evsel->leader)->gnum == evsel->leader->nr_members) {
for_each_group_member (ev2, evsel->leader) {
@@ -1556,7 +1557,8 @@ static void perf_sample__fprint_metric(struct perf_script 
*script,
  evsel_script(ev2)->val,
  sample->cpu,
  ,
- NULL);
+ NULL,
+ _stat);
}
evsel_script(evsel->leader)->gnum = 0;
}
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index a027b47..1edc082 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1097,7 +1097,8 @@ static void abs_printout(int id, int nr, struct 
perf_evsel *evsel, double avg)
  }
  
  static void printout(int id, int nr, struct perf_evsel *counter, double uval,

-char *prefix, u64 run, u64 ena, double noise)
+char *prefix, u64 run, u64 ena, double noise,
+struct runtime_stat *stat)
  {
struct perf_stat_output_ctx out;
struct outstate os = {
@@ -1190,7 +1191,8 @@ static void printout(int id, int nr, struct perf_evsel 
*counter, double uval,
  
  	perf_stat__print_shadow_stats(counter, uval,

first_shadow_cpu(counter, id),
-   , _events);
+   , _events,
+   stat);
if (!csv_output && !metric_only) {
print_noise(counter, noise);
print_running(run, ena);
@@ -1214,7 +1216,8 @@ static void aggr_update_shadow(void)
val += perf_counts(counter->counts, cpu, 
0)->val;
}
perf_stat__update_shadow_stats(counter, val,
-  
first_shadow_cpu(counter, id));
+   first_shadow_cpu(counter, id),
+   _stat);
}
}
  }
@@ -1334,7 +1337,8 @@ static void print_aggr(char *prefix)
fprintf(output, "%s", prefix);
  
  			uval = val * counter->scale;

-   printout(id, nr, counter, uval, prefix, run, ena, 1.0);
+   printout(id, nr, counter, uval, prefix, run, 

Re: [PATCH tip/core/rcu 20/21] checkpatch: Add warnings for {smp_,}read_barrier_depends()

2017-12-01 Thread Joe Perches
On Fri, 2017-12-01 at 13:44 -0800, Paul E. McKenney wrote:
> On Fri, Dec 01, 2017 at 12:14:17PM -0800, Joe Perches wrote:
> > On Fri, 2017-12-01 at 11:51 -0800, Paul E. McKenney wrote:
> > > Now that both smp_read_barrier_depends() and read_barrier_depends()
> > > are being de-emphasized, warn if any are added.
> > 
> > This would also warn on existing files when run
> > with ./scripts/checkpatch.pl -f 
> > 
> > Do you want it to check new patches only?
> > 
> > If so the test could become "if (!$file && etc...)
> > 
> > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> > > @@ -5586,6 +5586,12 @@ sub process {
> > >   }
> > >   }
> > >  
> > > +# check for smp_read_barrier_depends and read_barrier_depends
> > > + if ($line =~ /\b(smp_|)read_barrier_depends\(/) {
> > 
> > Must become
> > 
> > +   if ($line =~ /\b(smp_|)read_barrier_depends\s*\(/) {
> > 
> > similar to the lines above this as there are sometimes
> > spaces between function name and argument parentheses.
> 
> Good points!  Like this?
[]
> commit ff155ce179aab891dbe2ca80f82a453383fd165a
> Author: Paul E. McKenney 
> Date:   Mon Nov 27 09:37:35 2017 -0800
> 
> checkpatch: Add warnings for {smp_,}read_barrier_depends()
> 
> Now that both smp_read_barrier_depends() and read_barrier_depends()
> are being de-emphasized, warn if any are added.
> 
> Signed-off-by: Paul E. McKenney 
> Cc: Andy Whitcroft 
> Cc: Joe Perches 
> [ paulmck: Skipped checking files and handled whitespace per Joe Perches. 
> ]
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -5586,6 +5586,12 @@ sub process {
>   }
>   }
>  
> +# check for smp_read_barrier_depends and read_barrier_depends
> + if (!$file && $line =~ /\b(smp_|)read_barrier_depends\s*\(/) {
> + WARN("READ_BARRIER_DEPENDS",
> +  "Dependency barriers should only be used in 
> READ_ONCE or DEC Alpha code" . $herecurr);

Almost right.  Missing a '\n' after "DEC Alpha code".
Without the '\n', running checkpatch with --terse outputs badly.

If you really wanted to optimize, you could make the first (smp_|)
become (?:smp_|) to avoid the unused capture group.
Or perhaps this could emit the actual type in the message like:

if (!$file && $line =~ /\b((?:smp_|)read_barrier_depends)\s*\(/ 
{
WARN("READ_BARRIER_DEPENDS",
 "$1 should only be used in READ_ONCE or DEC Alpha 
code\n" . $herecurr);




Re: [PATCH tip/core/rcu 20/21] checkpatch: Add warnings for {smp_,}read_barrier_depends()

2017-12-01 Thread Joe Perches
On Fri, 2017-12-01 at 13:44 -0800, Paul E. McKenney wrote:
> On Fri, Dec 01, 2017 at 12:14:17PM -0800, Joe Perches wrote:
> > On Fri, 2017-12-01 at 11:51 -0800, Paul E. McKenney wrote:
> > > Now that both smp_read_barrier_depends() and read_barrier_depends()
> > > are being de-emphasized, warn if any are added.
> > 
> > This would also warn on existing files when run
> > with ./scripts/checkpatch.pl -f 
> > 
> > Do you want it to check new patches only?
> > 
> > If so the test could become "if (!$file && etc...)
> > 
> > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> > > @@ -5586,6 +5586,12 @@ sub process {
> > >   }
> > >   }
> > >  
> > > +# check for smp_read_barrier_depends and read_barrier_depends
> > > + if ($line =~ /\b(smp_|)read_barrier_depends\(/) {
> > 
> > Must become
> > 
> > +   if ($line =~ /\b(smp_|)read_barrier_depends\s*\(/) {
> > 
> > similar to the lines above this as there are sometimes
> > spaces between function name and argument parentheses.
> 
> Good points!  Like this?
[]
> commit ff155ce179aab891dbe2ca80f82a453383fd165a
> Author: Paul E. McKenney 
> Date:   Mon Nov 27 09:37:35 2017 -0800
> 
> checkpatch: Add warnings for {smp_,}read_barrier_depends()
> 
> Now that both smp_read_barrier_depends() and read_barrier_depends()
> are being de-emphasized, warn if any are added.
> 
> Signed-off-by: Paul E. McKenney 
> Cc: Andy Whitcroft 
> Cc: Joe Perches 
> [ paulmck: Skipped checking files and handled whitespace per Joe Perches. 
> ]
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -5586,6 +5586,12 @@ sub process {
>   }
>   }
>  
> +# check for smp_read_barrier_depends and read_barrier_depends
> + if (!$file && $line =~ /\b(smp_|)read_barrier_depends\s*\(/) {
> + WARN("READ_BARRIER_DEPENDS",
> +  "Dependency barriers should only be used in 
> READ_ONCE or DEC Alpha code" . $herecurr);

Almost right.  Missing a '\n' after "DEC Alpha code".
Without the '\n', running checkpatch with --terse outputs badly.

If you really wanted to optimize, you could make the first (smp_|)
become (?:smp_|) to avoid the unused capture group.
Or perhaps this could emit the actual type in the message like:

if (!$file && $line =~ /\b((?:smp_|)read_barrier_depends)\s*\(/ 
{
WARN("READ_BARRIER_DEPENDS",
 "$1 should only be used in READ_ONCE or DEC Alpha 
code\n" . $herecurr);




Re: [PATCH v5 03/12] perf util: Extend rbtree to support shadow stats

2017-12-01 Thread Jin, Yao



On 12/1/2017 10:10 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Dec 01, 2017 at 06:57:27PM +0800, Jin Yao escreveu:

Previously the rbtree was used to link generic metrics.


Try to make the one line subject more descriptive, I'm changing it to:

perf stat: Extend rbtree to support per-thread shadow stats

- Arnaldo
  


Yes, this new subject is better.

Thanks
Jin Yao


This patches adds new ctx/type/stat into rbtree keys because we
will use this rbtree to maintain shadow metrics to replace original
a couple of static arrays for supporting per-thread shadow stats.

Signed-off-by: Jin Yao 
---
  tools/perf/util/stat-shadow.c | 27 +++
  1 file changed, 27 insertions(+)

diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 5853901..c53b80d 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -45,7 +45,10 @@ struct stats walltime_nsecs_stats;
  struct saved_value {
struct rb_node rb_node;
struct perf_evsel *evsel;
+   enum stat_type type;
+   int ctx;
int cpu;
+   struct runtime_stat *stat;
struct stats stats;
  };
  
@@ -58,6 +61,30 @@ static int saved_value_cmp(struct rb_node *rb_node, const void *entry)
  
  	if (a->cpu != b->cpu)

return a->cpu - b->cpu;
+
+   /*
+* Previously the rbtree was used to link generic metrics.
+* The keys were evsel/cpu. Now the rbtree is extended to support
+* per-thread shadow stats. For shadow stats case, the keys
+* are cpu/type/ctx/stat (evsel is NULL). For generic metrics
+* case, the keys are still evsel/cpu (type/ctx/stat are 0 or NULL).
+*/
+   if (a->type != b->type)
+   return a->type - b->type;
+
+   if (a->ctx != b->ctx)
+   return a->ctx - b->ctx;
+
+   if (a->evsel == NULL && b->evsel == NULL) {
+   if (a->stat == b->stat)
+   return 0;
+
+   if ((char *)a->stat < (char *)b->stat)
+   return -1;
+
+   return 1;
+   }
+
if (a->evsel == b->evsel)
return 0;
if ((char *)a->evsel < (char *)b->evsel)
--
2.7.4


Re: [PATCH v5 03/12] perf util: Extend rbtree to support shadow stats

2017-12-01 Thread Jin, Yao



On 12/1/2017 10:10 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Dec 01, 2017 at 06:57:27PM +0800, Jin Yao escreveu:

Previously the rbtree was used to link generic metrics.


Try to make the one line subject more descriptive, I'm changing it to:

perf stat: Extend rbtree to support per-thread shadow stats

- Arnaldo
  


Yes, this new subject is better.

Thanks
Jin Yao


This patches adds new ctx/type/stat into rbtree keys because we
will use this rbtree to maintain shadow metrics to replace original
a couple of static arrays for supporting per-thread shadow stats.

Signed-off-by: Jin Yao 
---
  tools/perf/util/stat-shadow.c | 27 +++
  1 file changed, 27 insertions(+)

diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 5853901..c53b80d 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -45,7 +45,10 @@ struct stats walltime_nsecs_stats;
  struct saved_value {
struct rb_node rb_node;
struct perf_evsel *evsel;
+   enum stat_type type;
+   int ctx;
int cpu;
+   struct runtime_stat *stat;
struct stats stats;
  };
  
@@ -58,6 +61,30 @@ static int saved_value_cmp(struct rb_node *rb_node, const void *entry)
  
  	if (a->cpu != b->cpu)

return a->cpu - b->cpu;
+
+   /*
+* Previously the rbtree was used to link generic metrics.
+* The keys were evsel/cpu. Now the rbtree is extended to support
+* per-thread shadow stats. For shadow stats case, the keys
+* are cpu/type/ctx/stat (evsel is NULL). For generic metrics
+* case, the keys are still evsel/cpu (type/ctx/stat are 0 or NULL).
+*/
+   if (a->type != b->type)
+   return a->type - b->type;
+
+   if (a->ctx != b->ctx)
+   return a->ctx - b->ctx;
+
+   if (a->evsel == NULL && b->evsel == NULL) {
+   if (a->stat == b->stat)
+   return 0;
+
+   if ((char *)a->stat < (char *)b->stat)
+   return -1;
+
+   return 1;
+   }
+
if (a->evsel == b->evsel)
return 0;
if ((char *)a->evsel < (char *)b->evsel)
--
2.7.4


Re: [PATCH v5 02/12] perf util: Define a structure for runtime shadow stats

2017-12-01 Thread Jin, Yao



On 12/1/2017 10:02 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Dec 01, 2017 at 06:57:26PM +0800, Jin Yao escreveu:

Perf has a set of static variables to record the runtime shadow
metrics stats.

While if we want to record the runtime shadow stats for per-thread,
it will be the limitation. This patch creates a structure and the
next patches will use this structure to update the runtime shadow
stats for per-thread.

Signed-off-by: Jin Yao 
---
  tools/perf/util/stat-shadow.c | 11 ---
  tools/perf/util/stat.h| 44 ++-
  2 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 855e35c..5853901 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -9,17 +9,6 @@
  #include "expr.h"
  #include "metricgroup.h"
  
-enum {

-   CTX_BIT_USER= 1 << 0,
-   CTX_BIT_KERNEL  = 1 << 1,
-   CTX_BIT_HV  = 1 << 2,
-   CTX_BIT_HOST= 1 << 3,
-   CTX_BIT_IDLE= 1 << 4,
-   CTX_BIT_MAX = 1 << 5,
-};
-
-#define NUM_CTX CTX_BIT_MAX
-
  /*
   * AGGR_GLOBAL: Use CPU 0
   * AGGR_SOCKET: Use first CPU of socket
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index eefca5c..290c51e 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -5,6 +5,8 @@
  #include 
  #include 
  #include "xyarray.h"
+#include "evsel.h"


What is this for? You don't add anything in this patch that uses things
from evsel.h.

I'm removing it, will fixup if later this becomes needed.

- Arnaldo




That's fine, thanks Arnaldo!

Thanks
Jin Yao


+#include "rblist.h"
  
  struct stats

  {
@@ -43,6 +45,47 @@ enum aggr_mode {
AGGR_UNSET,
  };
  
+enum {

+   CTX_BIT_USER= 1 << 0,
+   CTX_BIT_KERNEL  = 1 << 1,
+   CTX_BIT_HV  = 1 << 2,
+   CTX_BIT_HOST= 1 << 3,
+   CTX_BIT_IDLE= 1 << 4,
+   CTX_BIT_MAX = 1 << 5,
+};
+
+#define NUM_CTX CTX_BIT_MAX
+
+enum stat_type {
+   STAT_NONE = 0,
+   STAT_NSECS,
+   STAT_CYCLES,
+   STAT_STALLED_CYCLES_FRONT,
+   STAT_STALLED_CYCLES_BACK,
+   STAT_BRANCHES,
+   STAT_CACHEREFS,
+   STAT_L1_DCACHE,
+   STAT_L1_ICACHE,
+   STAT_LL_CACHE,
+   STAT_ITLB_CACHE,
+   STAT_DTLB_CACHE,
+   STAT_CYCLES_IN_TX,
+   STAT_TRANSACTION,
+   STAT_ELISION,
+   STAT_TOPDOWN_TOTAL_SLOTS,
+   STAT_TOPDOWN_SLOTS_ISSUED,
+   STAT_TOPDOWN_SLOTS_RETIRED,
+   STAT_TOPDOWN_FETCH_BUBBLES,
+   STAT_TOPDOWN_RECOVERY_BUBBLES,
+   STAT_SMI_NUM,
+   STAT_APERF,
+   STAT_MAX
+};
+
+struct runtime_stat {
+   struct rblist value_list;
+};
+
  struct perf_stat_config {
enum aggr_mode  aggr_mode;
boolscale;
@@ -92,7 +135,6 @@ struct perf_stat_output_ctx {
bool force_header;
  };
  
-struct rblist;

  void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
   double avg, int cpu,
   struct perf_stat_output_ctx *out,
--
2.7.4


Re: [PATCH v5 02/12] perf util: Define a structure for runtime shadow stats

2017-12-01 Thread Jin, Yao



On 12/1/2017 10:02 PM, Arnaldo Carvalho de Melo wrote:

Em Fri, Dec 01, 2017 at 06:57:26PM +0800, Jin Yao escreveu:

Perf has a set of static variables to record the runtime shadow
metrics stats.

While if we want to record the runtime shadow stats for per-thread,
it will be the limitation. This patch creates a structure and the
next patches will use this structure to update the runtime shadow
stats for per-thread.

Signed-off-by: Jin Yao 
---
  tools/perf/util/stat-shadow.c | 11 ---
  tools/perf/util/stat.h| 44 ++-
  2 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 855e35c..5853901 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -9,17 +9,6 @@
  #include "expr.h"
  #include "metricgroup.h"
  
-enum {

-   CTX_BIT_USER= 1 << 0,
-   CTX_BIT_KERNEL  = 1 << 1,
-   CTX_BIT_HV  = 1 << 2,
-   CTX_BIT_HOST= 1 << 3,
-   CTX_BIT_IDLE= 1 << 4,
-   CTX_BIT_MAX = 1 << 5,
-};
-
-#define NUM_CTX CTX_BIT_MAX
-
  /*
   * AGGR_GLOBAL: Use CPU 0
   * AGGR_SOCKET: Use first CPU of socket
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index eefca5c..290c51e 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -5,6 +5,8 @@
  #include 
  #include 
  #include "xyarray.h"
+#include "evsel.h"


What is this for? You don't add anything in this patch that uses things
from evsel.h.

I'm removing it, will fixup if later this becomes needed.

- Arnaldo




That's fine, thanks Arnaldo!

Thanks
Jin Yao


+#include "rblist.h"
  
  struct stats

  {
@@ -43,6 +45,47 @@ enum aggr_mode {
AGGR_UNSET,
  };
  
+enum {

+   CTX_BIT_USER= 1 << 0,
+   CTX_BIT_KERNEL  = 1 << 1,
+   CTX_BIT_HV  = 1 << 2,
+   CTX_BIT_HOST= 1 << 3,
+   CTX_BIT_IDLE= 1 << 4,
+   CTX_BIT_MAX = 1 << 5,
+};
+
+#define NUM_CTX CTX_BIT_MAX
+
+enum stat_type {
+   STAT_NONE = 0,
+   STAT_NSECS,
+   STAT_CYCLES,
+   STAT_STALLED_CYCLES_FRONT,
+   STAT_STALLED_CYCLES_BACK,
+   STAT_BRANCHES,
+   STAT_CACHEREFS,
+   STAT_L1_DCACHE,
+   STAT_L1_ICACHE,
+   STAT_LL_CACHE,
+   STAT_ITLB_CACHE,
+   STAT_DTLB_CACHE,
+   STAT_CYCLES_IN_TX,
+   STAT_TRANSACTION,
+   STAT_ELISION,
+   STAT_TOPDOWN_TOTAL_SLOTS,
+   STAT_TOPDOWN_SLOTS_ISSUED,
+   STAT_TOPDOWN_SLOTS_RETIRED,
+   STAT_TOPDOWN_FETCH_BUBBLES,
+   STAT_TOPDOWN_RECOVERY_BUBBLES,
+   STAT_SMI_NUM,
+   STAT_APERF,
+   STAT_MAX
+};
+
+struct runtime_stat {
+   struct rblist value_list;
+};
+
  struct perf_stat_config {
enum aggr_mode  aggr_mode;
boolscale;
@@ -92,7 +135,6 @@ struct perf_stat_output_ctx {
bool force_header;
  };
  
-struct rblist;

  void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
   double avg, int cpu,
   struct perf_stat_output_ctx *out,
--
2.7.4


[PATCH V5 1/7] Documentation: DT: qcom_hidma: Bump HW revision for the bugfixed HW

2017-12-01 Thread Sinan Kaya
A new version of the HIDMA IP has been released with bug fixes. Bumping the
hardware version to differentiate from others.

Signed-off-by: Sinan Kaya 
---
 Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt 
b/Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
index 55492c2..5d93d6d 100644
--- a/Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
+++ b/Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
@@ -47,8 +47,8 @@ When the OS is not in control of the management interface 
(i.e. it's a guest),
 the channel nodes appear on their own, not under a management node.
 
 Required properties:
-- compatible: must contain "qcom,hidma-1.0" for initial HW or "qcom,hidma-1.1"
-for MSI capable HW.
+- compatible: must contain "qcom,hidma-1.0" for initial HW or
+  "qcom,hidma-1.1"/"qcom,hidma-1.2" for MSI capable HW.
 - reg: Addresses for the transfer and event channel
 - interrupts: Should contain the event interrupt
 - desc-count: Number of asynchronous requests this channel can handle
-- 
1.9.1



[PATCH V5 1/7] Documentation: DT: qcom_hidma: Bump HW revision for the bugfixed HW

2017-12-01 Thread Sinan Kaya
A new version of the HIDMA IP has been released with bug fixes. Bumping the
hardware version to differentiate from others.

Signed-off-by: Sinan Kaya 
---
 Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt 
b/Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
index 55492c2..5d93d6d 100644
--- a/Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
+++ b/Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
@@ -47,8 +47,8 @@ When the OS is not in control of the management interface 
(i.e. it's a guest),
 the channel nodes appear on their own, not under a management node.
 
 Required properties:
-- compatible: must contain "qcom,hidma-1.0" for initial HW or "qcom,hidma-1.1"
-for MSI capable HW.
+- compatible: must contain "qcom,hidma-1.0" for initial HW or
+  "qcom,hidma-1.1"/"qcom,hidma-1.2" for MSI capable HW.
 - reg: Addresses for the transfer and event channel
 - interrupts: Should contain the event interrupt
 - desc-count: Number of asynchronous requests this channel can handle
-- 
1.9.1



[PATCH V5 3/7] device property: Introduce a common API to fetch device match data

2017-12-01 Thread Sinan Kaya
There is an OF/ACPI function to obtain the driver data. We want to hide
OF/ACPI details from the device drivers and abstract following the device
family of functions.

Signed-off-by: Sinan Kaya 
---
 drivers/base/property.c  | 7 +++
 include/linux/fwnode.h   | 4 
 include/linux/property.h | 2 ++
 3 files changed, 13 insertions(+)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 7ed99c1..dfc53af 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -1335,3 +1335,10 @@ int fwnode_graph_parse_endpoint(const struct 
fwnode_handle *fwnode,
return fwnode_call_int_op(fwnode, graph_parse_endpoint, endpoint);
 }
 EXPORT_SYMBOL(fwnode_graph_parse_endpoint);
+
+void *device_get_match_data(struct device *dev)
+{
+   return fwnode_call_ptr_op(dev_fwnode(dev), get_match_data,
+ dev->driver);
+}
+EXPORT_SYMBOL_GPL(device_get_match_data);
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 0c35b6c..6e5e1dd 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -15,6 +15,7 @@
 #include 
 
 struct fwnode_operations;
+struct device_driver;
 
 struct fwnode_handle {
struct fwnode_handle *secondary;
@@ -66,6 +67,7 @@ struct fwnode_reference_args {
  *endpoint node.
  * @graph_get_port_parent: Return the parent node of a port node.
  * @graph_parse_endpoint: Parse endpoint for port and endpoint id.
+ * @get_match_data: Return the driver match data.
  */
 struct fwnode_operations {
void (*get)(struct fwnode_handle *fwnode);
@@ -101,6 +103,8 @@ struct fwnode_operations {
(*graph_get_port_parent)(struct fwnode_handle *fwnode);
int (*graph_parse_endpoint)(const struct fwnode_handle *fwnode,
struct fwnode_endpoint *endpoint);
+   void *(*get_match_data)(const struct fwnode_handle *fwnode,
+   const struct device_driver *drv);
 };
 
 #define fwnode_has_op(fwnode, op)  \
diff --git a/include/linux/property.h b/include/linux/property.h
index 6bebee1..01fa55b 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -275,6 +275,8 @@ int device_add_properties(struct device *dev,
 
 enum dev_dma_attr device_get_dma_attr(struct device *dev);
 
+void *device_get_match_data(struct device *dev);
+
 int device_get_phy_mode(struct device *dev);
 
 void *device_get_mac_address(struct device *dev, char *addr, int alen);
-- 
1.9.1



[PATCH V5 5/7] ACPI: properties: Implement get_match_data() callback

2017-12-01 Thread Sinan Kaya
Now that we have a get_match_data() callback as part of the firmware node,
implement the ACPI specific piece for it.

Signed-off-by: Sinan Kaya 
---
 drivers/acpi/property.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index e26ea20..49dd50b 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -1271,6 +1271,17 @@ static int acpi_fwnode_graph_parse_endpoint(const struct 
fwnode_handle *fwnode,
return 0;
 }
 
+static void *acpi_fwnode_get_match_data(const struct fwnode_handle *fwnode,
+   const struct device_driver *drv)
+{
+   struct acpi_device *adev = to_acpi_device_node(fwnode);
+
+   if (!adev)
+   return NULL;
+
+   return acpi_get_match_data(adev, drv->acpi_match_table);
+}
+
 #define DECLARE_ACPI_FWNODE_OPS(ops) \
const struct fwnode_operations ops = {  \
.device_is_available = acpi_fwnode_device_is_available, \
@@ -1289,6 +1300,7 @@ static int acpi_fwnode_graph_parse_endpoint(const struct 
fwnode_handle *fwnode,
acpi_fwnode_graph_get_remote_endpoint,  \
.graph_get_port_parent = acpi_fwnode_get_parent,\
.graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint, \
+   .get_match_data = acpi_fwnode_get_match_data,   \
};  \
EXPORT_SYMBOL_GPL(ops)
 
-- 
1.9.1



[PATCH V5 3/7] device property: Introduce a common API to fetch device match data

2017-12-01 Thread Sinan Kaya
There is an OF/ACPI function to obtain the driver data. We want to hide
OF/ACPI details from the device drivers and abstract following the device
family of functions.

Signed-off-by: Sinan Kaya 
---
 drivers/base/property.c  | 7 +++
 include/linux/fwnode.h   | 4 
 include/linux/property.h | 2 ++
 3 files changed, 13 insertions(+)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 7ed99c1..dfc53af 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -1335,3 +1335,10 @@ int fwnode_graph_parse_endpoint(const struct 
fwnode_handle *fwnode,
return fwnode_call_int_op(fwnode, graph_parse_endpoint, endpoint);
 }
 EXPORT_SYMBOL(fwnode_graph_parse_endpoint);
+
+void *device_get_match_data(struct device *dev)
+{
+   return fwnode_call_ptr_op(dev_fwnode(dev), get_match_data,
+ dev->driver);
+}
+EXPORT_SYMBOL_GPL(device_get_match_data);
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 0c35b6c..6e5e1dd 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -15,6 +15,7 @@
 #include 
 
 struct fwnode_operations;
+struct device_driver;
 
 struct fwnode_handle {
struct fwnode_handle *secondary;
@@ -66,6 +67,7 @@ struct fwnode_reference_args {
  *endpoint node.
  * @graph_get_port_parent: Return the parent node of a port node.
  * @graph_parse_endpoint: Parse endpoint for port and endpoint id.
+ * @get_match_data: Return the driver match data.
  */
 struct fwnode_operations {
void (*get)(struct fwnode_handle *fwnode);
@@ -101,6 +103,8 @@ struct fwnode_operations {
(*graph_get_port_parent)(struct fwnode_handle *fwnode);
int (*graph_parse_endpoint)(const struct fwnode_handle *fwnode,
struct fwnode_endpoint *endpoint);
+   void *(*get_match_data)(const struct fwnode_handle *fwnode,
+   const struct device_driver *drv);
 };
 
 #define fwnode_has_op(fwnode, op)  \
diff --git a/include/linux/property.h b/include/linux/property.h
index 6bebee1..01fa55b 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -275,6 +275,8 @@ int device_add_properties(struct device *dev,
 
 enum dev_dma_attr device_get_dma_attr(struct device *dev);
 
+void *device_get_match_data(struct device *dev);
+
 int device_get_phy_mode(struct device *dev);
 
 void *device_get_mac_address(struct device *dev, char *addr, int alen);
-- 
1.9.1



[PATCH V5 5/7] ACPI: properties: Implement get_match_data() callback

2017-12-01 Thread Sinan Kaya
Now that we have a get_match_data() callback as part of the firmware node,
implement the ACPI specific piece for it.

Signed-off-by: Sinan Kaya 
---
 drivers/acpi/property.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index e26ea20..49dd50b 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -1271,6 +1271,17 @@ static int acpi_fwnode_graph_parse_endpoint(const struct 
fwnode_handle *fwnode,
return 0;
 }
 
+static void *acpi_fwnode_get_match_data(const struct fwnode_handle *fwnode,
+   const struct device_driver *drv)
+{
+   struct acpi_device *adev = to_acpi_device_node(fwnode);
+
+   if (!adev)
+   return NULL;
+
+   return acpi_get_match_data(adev, drv->acpi_match_table);
+}
+
 #define DECLARE_ACPI_FWNODE_OPS(ops) \
const struct fwnode_operations ops = {  \
.device_is_available = acpi_fwnode_device_is_available, \
@@ -1289,6 +1300,7 @@ static int acpi_fwnode_graph_parse_endpoint(const struct 
fwnode_handle *fwnode,
acpi_fwnode_graph_get_remote_endpoint,  \
.graph_get_port_parent = acpi_fwnode_get_parent,\
.graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint, \
+   .get_match_data = acpi_fwnode_get_match_data,   \
};  \
EXPORT_SYMBOL_GPL(ops)
 
-- 
1.9.1



[PATCH V5 2/7] ACPI / bus: Introduce acpi_get_match_data() function

2017-12-01 Thread Sinan Kaya
OF has of_device_get_match_data() function to extract driver specific data
structure. Add a similar function for ACPI.

Signed-off-by: Sinan Kaya 
---
 drivers/acpi/bus.c   | 13 +
 include/linux/acpi.h |  8 
 2 files changed, 21 insertions(+)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 4d0979e..05d8d9a 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -785,6 +785,19 @@ const struct acpi_device_id *acpi_match_device(const 
struct acpi_device_id *ids,
 }
 EXPORT_SYMBOL_GPL(acpi_match_device);
 
+void *acpi_get_match_data(struct acpi_device *device,
+ const struct acpi_device_id *ids)
+{
+   const struct acpi_device_id *match;
+
+   match =  __acpi_match_device(device, ids, NULL);
+   if (!match)
+   return NULL;
+
+   return (void *)match->driver_data;
+}
+EXPORT_SYMBOL_GPL(acpi_get_match_data);
+
 int acpi_match_device_ids(struct acpi_device *device,
  const struct acpi_device_id *ids)
 {
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 502af53..196bc7a 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -584,6 +584,8 @@ extern int acpi_nvs_for_each_region(int (*func)(__u64, 
__u64, void *),
 const struct acpi_device_id *acpi_match_device(const struct acpi_device_id 
*ids,
   const struct device *dev);
 
+void *acpi_get_match_data(struct acpi_device *device,
+ const struct acpi_device_id *ids);
 extern bool acpi_driver_match_device(struct device *dev,
 const struct device_driver *drv);
 int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *);
@@ -755,6 +757,12 @@ static inline const struct acpi_device_id 
*acpi_match_device(
return NULL;
 }
 
+static inline void *acpi_get_match_data(struct acpi_device *device,
+   const struct acpi_device_id *ids)
+{
+   return NULL;
+}
+
 static inline bool acpi_driver_match_device(struct device *dev,
const struct device_driver *drv)
 {
-- 
1.9.1



[PATCH V5 2/7] ACPI / bus: Introduce acpi_get_match_data() function

2017-12-01 Thread Sinan Kaya
OF has of_device_get_match_data() function to extract driver specific data
structure. Add a similar function for ACPI.

Signed-off-by: Sinan Kaya 
---
 drivers/acpi/bus.c   | 13 +
 include/linux/acpi.h |  8 
 2 files changed, 21 insertions(+)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 4d0979e..05d8d9a 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -785,6 +785,19 @@ const struct acpi_device_id *acpi_match_device(const 
struct acpi_device_id *ids,
 }
 EXPORT_SYMBOL_GPL(acpi_match_device);
 
+void *acpi_get_match_data(struct acpi_device *device,
+ const struct acpi_device_id *ids)
+{
+   const struct acpi_device_id *match;
+
+   match =  __acpi_match_device(device, ids, NULL);
+   if (!match)
+   return NULL;
+
+   return (void *)match->driver_data;
+}
+EXPORT_SYMBOL_GPL(acpi_get_match_data);
+
 int acpi_match_device_ids(struct acpi_device *device,
  const struct acpi_device_id *ids)
 {
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 502af53..196bc7a 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -584,6 +584,8 @@ extern int acpi_nvs_for_each_region(int (*func)(__u64, 
__u64, void *),
 const struct acpi_device_id *acpi_match_device(const struct acpi_device_id 
*ids,
   const struct device *dev);
 
+void *acpi_get_match_data(struct acpi_device *device,
+ const struct acpi_device_id *ids);
 extern bool acpi_driver_match_device(struct device *dev,
 const struct device_driver *drv);
 int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *);
@@ -755,6 +757,12 @@ static inline const struct acpi_device_id 
*acpi_match_device(
return NULL;
 }
 
+static inline void *acpi_get_match_data(struct acpi_device *device,
+   const struct acpi_device_id *ids)
+{
+   return NULL;
+}
+
 static inline bool acpi_driver_match_device(struct device *dev,
const struct device_driver *drv)
 {
-- 
1.9.1



[PATCH V5 4/7] OF: properties: Implement get_match_data() callback

2017-12-01 Thread Sinan Kaya
Now that we have a get_match_data() callback as part of the firmware node,
implement the OF specific piece for it.

Signed-off-by: Sinan Kaya 
---
 drivers/of/property.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 264c355..adcde1a 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -981,6 +981,22 @@ static int of_fwnode_graph_parse_endpoint(const struct 
fwnode_handle *fwnode,
return 0;
 }
 
+void *of_fwnode_get_match_data(const struct fwnode_handle *fwnode,
+  const struct device_driver *drv)
+{
+   const struct device_node *node = to_of_node(fwnode);
+   const struct of_device_id *match;
+
+   if (!node)
+   return NULL;
+
+   match = of_match_node(drv->of_match_table, node);
+   if (!match)
+   return NULL;
+
+   return (void *)match->data;
+}
+
 const struct fwnode_operations of_fwnode_ops = {
.get = of_fwnode_get,
.put = of_fwnode_put,
@@ -996,5 +1012,6 @@ static int of_fwnode_graph_parse_endpoint(const struct 
fwnode_handle *fwnode,
.graph_get_remote_endpoint = of_fwnode_graph_get_remote_endpoint,
.graph_get_port_parent = of_fwnode_graph_get_port_parent,
.graph_parse_endpoint = of_fwnode_graph_parse_endpoint,
+   .get_match_data = of_fwnode_get_match_data,
 };
 EXPORT_SYMBOL_GPL(of_fwnode_ops);
-- 
1.9.1



[PATCH V5 4/7] OF: properties: Implement get_match_data() callback

2017-12-01 Thread Sinan Kaya
Now that we have a get_match_data() callback as part of the firmware node,
implement the OF specific piece for it.

Signed-off-by: Sinan Kaya 
---
 drivers/of/property.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 264c355..adcde1a 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -981,6 +981,22 @@ static int of_fwnode_graph_parse_endpoint(const struct 
fwnode_handle *fwnode,
return 0;
 }
 
+void *of_fwnode_get_match_data(const struct fwnode_handle *fwnode,
+  const struct device_driver *drv)
+{
+   const struct device_node *node = to_of_node(fwnode);
+   const struct of_device_id *match;
+
+   if (!node)
+   return NULL;
+
+   match = of_match_node(drv->of_match_table, node);
+   if (!match)
+   return NULL;
+
+   return (void *)match->data;
+}
+
 const struct fwnode_operations of_fwnode_ops = {
.get = of_fwnode_get,
.put = of_fwnode_put,
@@ -996,5 +1012,6 @@ static int of_fwnode_graph_parse_endpoint(const struct 
fwnode_handle *fwnode,
.graph_get_remote_endpoint = of_fwnode_graph_get_remote_endpoint,
.graph_get_port_parent = of_fwnode_graph_get_port_parent,
.graph_parse_endpoint = of_fwnode_graph_parse_endpoint,
+   .get_match_data = of_fwnode_get_match_data,
 };
 EXPORT_SYMBOL_GPL(of_fwnode_ops);
-- 
1.9.1



[PATCH V5 7/7] dmaengine: qcom_hidma: Add identity register support

2017-12-01 Thread Sinan Kaya
The location for destination event channel register has been relocated from
offset 0x28 to 0x40. Update the code accordingly.

Signed-off-by: Sinan Kaya 
---
 drivers/dma/qcom/hidma.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/qcom/hidma.c b/drivers/dma/qcom/hidma.c
index c146c6d..963cc52 100644
--- a/drivers/dma/qcom/hidma.c
+++ b/drivers/dma/qcom/hidma.c
@@ -107,6 +107,7 @@ static void hidma_free(struct hidma_dev *dmadev)
 
 enum hidma_cap {
HIDMA_MSI_CAP = 1,
+   HIDMA_IDENTITY_CAP,
 };
 
 /* process completed descriptors */
@@ -838,7 +839,10 @@ static int hidma_probe(struct platform_device *pdev)
if (!dmadev->nr_descriptors)
dmadev->nr_descriptors = HIDMA_NR_DEFAULT_DESC;
 
-   dmadev->chidx = readl(dmadev->dev_trca + 0x28);
+   if (hidma_test_capability(>dev, HIDMA_IDENTITY_CAP))
+   dmadev->chidx = readl(dmadev->dev_trca + 0x40);
+   else
+   dmadev->chidx = readl(dmadev->dev_trca + 0x28);
 
/* Set DMA mask to 64 bits. */
rc = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(64));
@@ -944,7 +948,7 @@ static int hidma_remove(struct platform_device *pdev)
 static const struct acpi_device_id hidma_acpi_ids[] = {
{"QCOM8061"},
{"QCOM8062", HIDMA_MSI_CAP},
-   {"QCOM8063", HIDMA_MSI_CAP},
+   {"QCOM8063", (HIDMA_MSI_CAP | HIDMA_IDENTITY_CAP)},
{},
 };
 MODULE_DEVICE_TABLE(acpi, hidma_acpi_ids);
@@ -953,7 +957,8 @@ static int hidma_remove(struct platform_device *pdev)
 static const struct of_device_id hidma_match[] = {
{.compatible = "qcom,hidma-1.0",},
{.compatible = "qcom,hidma-1.1", .data = (void *)(HIDMA_MSI_CAP),},
-   {.compatible = "qcom,hidma-1.2", .data = (void *)(HIDMA_MSI_CAP),},
+   {.compatible = "qcom,hidma-1.2",
+.data = (void *)(HIDMA_MSI_CAP | HIDMA_IDENTITY_CAP),},
{},
 };
 MODULE_DEVICE_TABLE(of, hidma_match);
-- 
1.9.1



[PATCH V5 6/7] dmaengine: qcom_hidma: Add support for the new revision

2017-12-01 Thread Sinan Kaya
Add support for probing the newer HW and also organize MSI capable hardware
into an array for maintenance reasons.

Signed-off-by: Sinan Kaya 
---
 drivers/dma/qcom/hidma.c | 34 +-
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/dma/qcom/hidma.c b/drivers/dma/qcom/hidma.c
index e366985..c146c6d 100644
--- a/drivers/dma/qcom/hidma.c
+++ b/drivers/dma/qcom/hidma.c
@@ -50,6 +50,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -104,6 +105,9 @@ static void hidma_free(struct hidma_dev *dmadev)
 module_param(nr_desc_prm, uint, 0644);
 MODULE_PARM_DESC(nr_desc_prm, "number of descriptors (default: 0)");
 
+enum hidma_cap {
+   HIDMA_MSI_CAP = 1,
+};
 
 /* process completed descriptors */
 static void hidma_process_completed(struct hidma_chan *mchan)
@@ -736,25 +740,12 @@ static int hidma_request_msi(struct hidma_dev *dmadev,
 #endif
 }
 
-static bool hidma_msi_capable(struct device *dev)
+static bool hidma_test_capability(struct device *dev, enum hidma_cap test_cap)
 {
-   struct acpi_device *adev = ACPI_COMPANION(dev);
-   const char *of_compat;
-   int ret = -EINVAL;
-
-   if (!adev || acpi_disabled) {
-   ret = device_property_read_string(dev, "compatible",
- _compat);
-   if (ret)
-   return false;
+   enum hidma_cap cap;
 
-   ret = strcmp(of_compat, "qcom,hidma-1.1");
-   } else {
-#ifdef CONFIG_ACPI
-   ret = strcmp(acpi_device_hid(adev), "QCOM8062");
-#endif
-   }
-   return ret == 0;
+   cap = (enum hidma_cap) device_get_match_data(dev);
+   return cap ? ((cap & test_cap) > 0) : 0;
 }
 
 static int hidma_probe(struct platform_device *pdev)
@@ -834,8 +825,7 @@ static int hidma_probe(struct platform_device *pdev)
 * Determine the MSI capability of the platform. Old HW doesn't
 * support MSI.
 */
-   msi = hidma_msi_capable(>dev);
-
+   msi = hidma_test_capability(>dev, HIDMA_MSI_CAP);
device_property_read_u32(>dev, "desc-count",
 >nr_descriptors);
 
@@ -953,7 +943,8 @@ static int hidma_remove(struct platform_device *pdev)
 #if IS_ENABLED(CONFIG_ACPI)
 static const struct acpi_device_id hidma_acpi_ids[] = {
{"QCOM8061"},
-   {"QCOM8062"},
+   {"QCOM8062", HIDMA_MSI_CAP},
+   {"QCOM8063", HIDMA_MSI_CAP},
{},
 };
 MODULE_DEVICE_TABLE(acpi, hidma_acpi_ids);
@@ -961,7 +952,8 @@ static int hidma_remove(struct platform_device *pdev)
 
 static const struct of_device_id hidma_match[] = {
{.compatible = "qcom,hidma-1.0",},
-   {.compatible = "qcom,hidma-1.1",},
+   {.compatible = "qcom,hidma-1.1", .data = (void *)(HIDMA_MSI_CAP),},
+   {.compatible = "qcom,hidma-1.2", .data = (void *)(HIDMA_MSI_CAP),},
{},
 };
 MODULE_DEVICE_TABLE(of, hidma_match);
-- 
1.9.1



[PATCH 1/1] timecounter: Make cyclecounter struct part of timecounter struct

2017-12-01 Thread Sagar Arun Kamble
There is no real need for the users of timecounters to define cyclecounter
and timecounter variables separately. Since timecounter will always be
based on cyclecounter, have cyclecounter struct as member of timecounter
struct.

Suggested-by: Chris Wilson 
Signed-off-by: Sagar Arun Kamble 
Cc: Chris Wilson 
Cc: Richard Cochran 
Cc: John Stultz 
Cc: Thomas Gleixner 
Cc: Stephen Boyd 
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: net...@vger.kernel.org
Cc: intel-wired-...@lists.osuosl.org
Cc: linux-r...@vger.kernel.org
Cc: alsa-de...@alsa-project.org
Cc: kvm...@lists.cs.columbia.edu
---
 arch/microblaze/kernel/timer.c | 20 ++--
 drivers/clocksource/arm_arch_timer.c   | 19 ++--
 drivers/net/ethernet/amd/xgbe/xgbe-dev.c   |  3 +-
 drivers/net/ethernet/amd/xgbe/xgbe-ptp.c   |  9 +++---
 drivers/net/ethernet/amd/xgbe/xgbe.h   |  1 -
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h|  1 -
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   | 20 ++--
 drivers/net/ethernet/freescale/fec.h   |  1 -
 drivers/net/ethernet/freescale/fec_ptp.c   | 30 +-
 drivers/net/ethernet/intel/e1000e/e1000.h  |  1 -
 drivers/net/ethernet/intel/e1000e/netdev.c | 27 
 drivers/net/ethernet/intel/e1000e/ptp.c|  2 +-
 drivers/net/ethernet/intel/igb/igb.h   |  1 -
 drivers/net/ethernet/intel/igb/igb_ptp.c   | 25 ---
 drivers/net/ethernet/intel/ixgbe/ixgbe.h   |  1 -
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c   | 17 +-
 drivers/net/ethernet/mellanox/mlx4/en_clock.c  | 28 -
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h   |  1 -
 .../net/ethernet/mellanox/mlx5/core/lib/clock.c| 34 ++--
 drivers/net/ethernet/qlogic/qede/qede_ptp.c| 20 ++--
 drivers/net/ethernet/ti/cpts.c | 36 --
 drivers/net/ethernet/ti/cpts.h |  1 -
 include/linux/mlx5/driver.h|  1 -
 include/linux/timecounter.h|  4 +--
 include/sound/hdaudio.h|  1 -
 kernel/time/timecounter.c  | 28 -
 sound/hda/hdac_stream.c|  7 +++--
 virt/kvm/arm/arch_timer.c  |  6 ++--
 28 files changed, 163 insertions(+), 182 deletions(-)

diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c
index 7de941c..b7f89e9 100644
--- a/arch/microblaze/kernel/timer.c
+++ b/arch/microblaze/kernel/timer.c
@@ -199,27 +199,25 @@ static u64 xilinx_read(struct clocksource *cs)
return (u64)xilinx_clock_read();
 }
 
-static struct timecounter xilinx_tc = {
-   .cc = NULL,
-};
-
 static u64 xilinx_cc_read(const struct cyclecounter *cc)
 {
return xilinx_read(NULL);
 }
 
-static struct cyclecounter xilinx_cc = {
-   .read = xilinx_cc_read,
-   .mask = CLOCKSOURCE_MASK(32),
-   .shift = 8,
+static struct timecounter xilinx_tc = {
+   .cc.read = xilinx_cc_read,
+   .cc.mask = CLOCKSOURCE_MASK(32),
+   .cc.mult = 0,
+   .cc.shift = 8,
 };
 
 static int __init init_xilinx_timecounter(void)
 {
-   xilinx_cc.mult = div_sc(timer_clock_freq, NSEC_PER_SEC,
-   xilinx_cc.shift);
+   struct cyclecounter *cc = _tc.cc;
+
+   cc->mult = div_sc(timer_clock_freq, NSEC_PER_SEC, cc->shift);
 
-   timecounter_init(_tc, _cc, sched_clock());
+   timecounter_init(_tc, sched_clock());
 
return 0;
 }
diff --git a/drivers/clocksource/arm_arch_timer.c 
b/drivers/clocksource/arm_arch_timer.c
index 57cb2f0..31543e5 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -179,11 +179,6 @@ static u64 arch_counter_read_cc(const struct cyclecounter 
*cc)
.flags  = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
-static struct cyclecounter cyclecounter __ro_after_init = {
-   .read   = arch_counter_read_cc,
-   .mask   = CLOCKSOURCE_MASK(56),
-};
-
 struct ate_acpi_oem_info {
char oem_id[ACPI_OEM_ID_SIZE + 1];
char oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1];
@@ -915,7 +910,10 @@ static u64 arch_counter_get_cntvct_mem(void)
return ((u64) vct_hi << 32) | vct_lo;
 }
 
-static struct arch_timer_kvm_info arch_timer_kvm_info;
+static struct arch_timer_kvm_info arch_timer_kvm_info = {
+   .timecounter.cc.read = arch_counter_read_cc,
+   .timecounter.cc.mask = CLOCKSOURCE_MASK(56),
+};
 
 struct arch_timer_kvm_info *arch_timer_get_kvm_info(void)
 {
@@ -925,6 +923,7 @@ struct arch_timer_kvm_info *arch_timer_get_kvm_info(void)
 static void __init 

[PATCH V5 7/7] dmaengine: qcom_hidma: Add identity register support

2017-12-01 Thread Sinan Kaya
The location for destination event channel register has been relocated from
offset 0x28 to 0x40. Update the code accordingly.

Signed-off-by: Sinan Kaya 
---
 drivers/dma/qcom/hidma.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/qcom/hidma.c b/drivers/dma/qcom/hidma.c
index c146c6d..963cc52 100644
--- a/drivers/dma/qcom/hidma.c
+++ b/drivers/dma/qcom/hidma.c
@@ -107,6 +107,7 @@ static void hidma_free(struct hidma_dev *dmadev)
 
 enum hidma_cap {
HIDMA_MSI_CAP = 1,
+   HIDMA_IDENTITY_CAP,
 };
 
 /* process completed descriptors */
@@ -838,7 +839,10 @@ static int hidma_probe(struct platform_device *pdev)
if (!dmadev->nr_descriptors)
dmadev->nr_descriptors = HIDMA_NR_DEFAULT_DESC;
 
-   dmadev->chidx = readl(dmadev->dev_trca + 0x28);
+   if (hidma_test_capability(>dev, HIDMA_IDENTITY_CAP))
+   dmadev->chidx = readl(dmadev->dev_trca + 0x40);
+   else
+   dmadev->chidx = readl(dmadev->dev_trca + 0x28);
 
/* Set DMA mask to 64 bits. */
rc = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(64));
@@ -944,7 +948,7 @@ static int hidma_remove(struct platform_device *pdev)
 static const struct acpi_device_id hidma_acpi_ids[] = {
{"QCOM8061"},
{"QCOM8062", HIDMA_MSI_CAP},
-   {"QCOM8063", HIDMA_MSI_CAP},
+   {"QCOM8063", (HIDMA_MSI_CAP | HIDMA_IDENTITY_CAP)},
{},
 };
 MODULE_DEVICE_TABLE(acpi, hidma_acpi_ids);
@@ -953,7 +957,8 @@ static int hidma_remove(struct platform_device *pdev)
 static const struct of_device_id hidma_match[] = {
{.compatible = "qcom,hidma-1.0",},
{.compatible = "qcom,hidma-1.1", .data = (void *)(HIDMA_MSI_CAP),},
-   {.compatible = "qcom,hidma-1.2", .data = (void *)(HIDMA_MSI_CAP),},
+   {.compatible = "qcom,hidma-1.2",
+.data = (void *)(HIDMA_MSI_CAP | HIDMA_IDENTITY_CAP),},
{},
 };
 MODULE_DEVICE_TABLE(of, hidma_match);
-- 
1.9.1



[PATCH V5 6/7] dmaengine: qcom_hidma: Add support for the new revision

2017-12-01 Thread Sinan Kaya
Add support for probing the newer HW and also organize MSI capable hardware
into an array for maintenance reasons.

Signed-off-by: Sinan Kaya 
---
 drivers/dma/qcom/hidma.c | 34 +-
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/dma/qcom/hidma.c b/drivers/dma/qcom/hidma.c
index e366985..c146c6d 100644
--- a/drivers/dma/qcom/hidma.c
+++ b/drivers/dma/qcom/hidma.c
@@ -50,6 +50,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -104,6 +105,9 @@ static void hidma_free(struct hidma_dev *dmadev)
 module_param(nr_desc_prm, uint, 0644);
 MODULE_PARM_DESC(nr_desc_prm, "number of descriptors (default: 0)");
 
+enum hidma_cap {
+   HIDMA_MSI_CAP = 1,
+};
 
 /* process completed descriptors */
 static void hidma_process_completed(struct hidma_chan *mchan)
@@ -736,25 +740,12 @@ static int hidma_request_msi(struct hidma_dev *dmadev,
 #endif
 }
 
-static bool hidma_msi_capable(struct device *dev)
+static bool hidma_test_capability(struct device *dev, enum hidma_cap test_cap)
 {
-   struct acpi_device *adev = ACPI_COMPANION(dev);
-   const char *of_compat;
-   int ret = -EINVAL;
-
-   if (!adev || acpi_disabled) {
-   ret = device_property_read_string(dev, "compatible",
- _compat);
-   if (ret)
-   return false;
+   enum hidma_cap cap;
 
-   ret = strcmp(of_compat, "qcom,hidma-1.1");
-   } else {
-#ifdef CONFIG_ACPI
-   ret = strcmp(acpi_device_hid(adev), "QCOM8062");
-#endif
-   }
-   return ret == 0;
+   cap = (enum hidma_cap) device_get_match_data(dev);
+   return cap ? ((cap & test_cap) > 0) : 0;
 }
 
 static int hidma_probe(struct platform_device *pdev)
@@ -834,8 +825,7 @@ static int hidma_probe(struct platform_device *pdev)
 * Determine the MSI capability of the platform. Old HW doesn't
 * support MSI.
 */
-   msi = hidma_msi_capable(>dev);
-
+   msi = hidma_test_capability(>dev, HIDMA_MSI_CAP);
device_property_read_u32(>dev, "desc-count",
 >nr_descriptors);
 
@@ -953,7 +943,8 @@ static int hidma_remove(struct platform_device *pdev)
 #if IS_ENABLED(CONFIG_ACPI)
 static const struct acpi_device_id hidma_acpi_ids[] = {
{"QCOM8061"},
-   {"QCOM8062"},
+   {"QCOM8062", HIDMA_MSI_CAP},
+   {"QCOM8063", HIDMA_MSI_CAP},
{},
 };
 MODULE_DEVICE_TABLE(acpi, hidma_acpi_ids);
@@ -961,7 +952,8 @@ static int hidma_remove(struct platform_device *pdev)
 
 static const struct of_device_id hidma_match[] = {
{.compatible = "qcom,hidma-1.0",},
-   {.compatible = "qcom,hidma-1.1",},
+   {.compatible = "qcom,hidma-1.1", .data = (void *)(HIDMA_MSI_CAP),},
+   {.compatible = "qcom,hidma-1.2", .data = (void *)(HIDMA_MSI_CAP),},
{},
 };
 MODULE_DEVICE_TABLE(of, hidma_match);
-- 
1.9.1



[PATCH 1/1] timecounter: Make cyclecounter struct part of timecounter struct

2017-12-01 Thread Sagar Arun Kamble
There is no real need for the users of timecounters to define cyclecounter
and timecounter variables separately. Since timecounter will always be
based on cyclecounter, have cyclecounter struct as member of timecounter
struct.

Suggested-by: Chris Wilson 
Signed-off-by: Sagar Arun Kamble 
Cc: Chris Wilson 
Cc: Richard Cochran 
Cc: John Stultz 
Cc: Thomas Gleixner 
Cc: Stephen Boyd 
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: net...@vger.kernel.org
Cc: intel-wired-...@lists.osuosl.org
Cc: linux-r...@vger.kernel.org
Cc: alsa-de...@alsa-project.org
Cc: kvm...@lists.cs.columbia.edu
---
 arch/microblaze/kernel/timer.c | 20 ++--
 drivers/clocksource/arm_arch_timer.c   | 19 ++--
 drivers/net/ethernet/amd/xgbe/xgbe-dev.c   |  3 +-
 drivers/net/ethernet/amd/xgbe/xgbe-ptp.c   |  9 +++---
 drivers/net/ethernet/amd/xgbe/xgbe.h   |  1 -
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h|  1 -
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   | 20 ++--
 drivers/net/ethernet/freescale/fec.h   |  1 -
 drivers/net/ethernet/freescale/fec_ptp.c   | 30 +-
 drivers/net/ethernet/intel/e1000e/e1000.h  |  1 -
 drivers/net/ethernet/intel/e1000e/netdev.c | 27 
 drivers/net/ethernet/intel/e1000e/ptp.c|  2 +-
 drivers/net/ethernet/intel/igb/igb.h   |  1 -
 drivers/net/ethernet/intel/igb/igb_ptp.c   | 25 ---
 drivers/net/ethernet/intel/ixgbe/ixgbe.h   |  1 -
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c   | 17 +-
 drivers/net/ethernet/mellanox/mlx4/en_clock.c  | 28 -
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h   |  1 -
 .../net/ethernet/mellanox/mlx5/core/lib/clock.c| 34 ++--
 drivers/net/ethernet/qlogic/qede/qede_ptp.c| 20 ++--
 drivers/net/ethernet/ti/cpts.c | 36 --
 drivers/net/ethernet/ti/cpts.h |  1 -
 include/linux/mlx5/driver.h|  1 -
 include/linux/timecounter.h|  4 +--
 include/sound/hdaudio.h|  1 -
 kernel/time/timecounter.c  | 28 -
 sound/hda/hdac_stream.c|  7 +++--
 virt/kvm/arm/arch_timer.c  |  6 ++--
 28 files changed, 163 insertions(+), 182 deletions(-)

diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c
index 7de941c..b7f89e9 100644
--- a/arch/microblaze/kernel/timer.c
+++ b/arch/microblaze/kernel/timer.c
@@ -199,27 +199,25 @@ static u64 xilinx_read(struct clocksource *cs)
return (u64)xilinx_clock_read();
 }
 
-static struct timecounter xilinx_tc = {
-   .cc = NULL,
-};
-
 static u64 xilinx_cc_read(const struct cyclecounter *cc)
 {
return xilinx_read(NULL);
 }
 
-static struct cyclecounter xilinx_cc = {
-   .read = xilinx_cc_read,
-   .mask = CLOCKSOURCE_MASK(32),
-   .shift = 8,
+static struct timecounter xilinx_tc = {
+   .cc.read = xilinx_cc_read,
+   .cc.mask = CLOCKSOURCE_MASK(32),
+   .cc.mult = 0,
+   .cc.shift = 8,
 };
 
 static int __init init_xilinx_timecounter(void)
 {
-   xilinx_cc.mult = div_sc(timer_clock_freq, NSEC_PER_SEC,
-   xilinx_cc.shift);
+   struct cyclecounter *cc = _tc.cc;
+
+   cc->mult = div_sc(timer_clock_freq, NSEC_PER_SEC, cc->shift);
 
-   timecounter_init(_tc, _cc, sched_clock());
+   timecounter_init(_tc, sched_clock());
 
return 0;
 }
diff --git a/drivers/clocksource/arm_arch_timer.c 
b/drivers/clocksource/arm_arch_timer.c
index 57cb2f0..31543e5 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -179,11 +179,6 @@ static u64 arch_counter_read_cc(const struct cyclecounter 
*cc)
.flags  = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
-static struct cyclecounter cyclecounter __ro_after_init = {
-   .read   = arch_counter_read_cc,
-   .mask   = CLOCKSOURCE_MASK(56),
-};
-
 struct ate_acpi_oem_info {
char oem_id[ACPI_OEM_ID_SIZE + 1];
char oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1];
@@ -915,7 +910,10 @@ static u64 arch_counter_get_cntvct_mem(void)
return ((u64) vct_hi << 32) | vct_lo;
 }
 
-static struct arch_timer_kvm_info arch_timer_kvm_info;
+static struct arch_timer_kvm_info arch_timer_kvm_info = {
+   .timecounter.cc.read = arch_counter_read_cc,
+   .timecounter.cc.mask = CLOCKSOURCE_MASK(56),
+};
 
 struct arch_timer_kvm_info *arch_timer_get_kvm_info(void)
 {
@@ -925,6 +923,7 @@ struct arch_timer_kvm_info *arch_timer_get_kvm_info(void)
 static void __init arch_counter_register(unsigned type)
 {
u64 start_count;
+   struct cyclecounter *cc = _timer_kvm_info.timecounter.cc;
 
/* Register the CP15 based counter if we have one */
  

[PATCH] perf c2c: Add a tip about cacheline events

2017-12-01 Thread Sangwon Hong
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Signed-off-by: Sangwon Hong 
---
 tools/perf/Documentation/tips.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/Documentation/tips.txt 
b/tools/perf/Documentation/tips.txt
index 3dd1dbe..849599f 100644
--- a/tools/perf/Documentation/tips.txt
+++ b/tools/perf/Documentation/tips.txt
@@ -33,3 +33,4 @@ System-wide collection from all CPUs: perf record -a
 Show current config key-value pairs: perf config --list
 Show user configuration overrides: perf config --user --list
 To add Node.js USDT(User-Level Statically Defined Tracing): perf buildid-cache 
--add `which node`
+To report cacheline events from previous recording: perf c2c report
-- 
2.7.4



[PATCH] perf c2c: Add a tip about cacheline events

2017-12-01 Thread Sangwon Hong
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Signed-off-by: Sangwon Hong 
---
 tools/perf/Documentation/tips.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/Documentation/tips.txt 
b/tools/perf/Documentation/tips.txt
index 3dd1dbe..849599f 100644
--- a/tools/perf/Documentation/tips.txt
+++ b/tools/perf/Documentation/tips.txt
@@ -33,3 +33,4 @@ System-wide collection from all CPUs: perf record -a
 Show current config key-value pairs: perf config --list
 Show user configuration overrides: perf config --user --list
 To add Node.js USDT(User-Level Statically Defined Tracing): perf buildid-cache 
--add `which node`
+To report cacheline events from previous recording: perf c2c report
-- 
2.7.4



[PATCH] fix system_state checking in early_ioremap

2017-12-01 Thread Dave Young
Since below commit earlyprintk=efi,keep does not work any more with a warning
in mm/early_ioremap.c: WARN_ON(system_state >= SYSTEM_RUNNING):
commit 69a78ff226fe ("init: Introduce SYSTEM_SCHEDULING state")

Reason is the the original assumption is SYSTEM_BOOTING equal to
system_state < SYSTEM_RUNNING. But with commit 69a78ff226fe it is not true
any more. Change the WARN_ON to check system_state >= SYSTEM_RUNNING instead.

Signed-off-by: Dave Young 
---
 mm/early_ioremap.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-x86.orig/mm/early_ioremap.c
+++ linux-x86/mm/early_ioremap.c
@@ -111,7 +111,7 @@ __early_ioremap(resource_size_t phys_add
enum fixed_addresses idx;
int i, slot;
 
-   WARN_ON(system_state != SYSTEM_BOOTING);
+   WARN_ON(system_state >= SYSTEM_RUNNING);
 
slot = -1;
for (i = 0; i < FIX_BTMAPS_SLOTS; i++) {


[PATCH] fix system_state checking in early_ioremap

2017-12-01 Thread Dave Young
Since below commit earlyprintk=efi,keep does not work any more with a warning
in mm/early_ioremap.c: WARN_ON(system_state >= SYSTEM_RUNNING):
commit 69a78ff226fe ("init: Introduce SYSTEM_SCHEDULING state")

Reason is the the original assumption is SYSTEM_BOOTING equal to
system_state < SYSTEM_RUNNING. But with commit 69a78ff226fe it is not true
any more. Change the WARN_ON to check system_state >= SYSTEM_RUNNING instead.

Signed-off-by: Dave Young 
---
 mm/early_ioremap.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-x86.orig/mm/early_ioremap.c
+++ linux-x86/mm/early_ioremap.c
@@ -111,7 +111,7 @@ __early_ioremap(resource_size_t phys_add
enum fixed_addresses idx;
int i, slot;
 
-   WARN_ON(system_state != SYSTEM_BOOTING);
+   WARN_ON(system_state >= SYSTEM_RUNNING);
 
slot = -1;
for (i = 0; i < FIX_BTMAPS_SLOTS; i++) {


[PATCH net-next v2] net: dsa: Allow compiling out legacy support

2017-12-01 Thread Florian Fainelli
Introduce a configuration option: CONFIG_NET_DSA_LEGACY allowing to compile out
support for the old platform device and Device Tree binding registration.
Support for these configurations is scheduled to be removed in 4.17.

Signed-off-by: Florian Fainelli 
---
Changes in v2:
- make the option enabled by default
- make the .probe function part of NET_DSA_LEGACY
- make mv88e6060 depend on NET_DSA_LEGACY
- move dsa_legacy_fdb_{add,del} out of net/dsa/legacy.c

 drivers/net/dsa/Kconfig  |  2 +-
 drivers/net/dsa/mv88e6xxx/chip.c |  4 
 include/net/dsa.h| 11 +++
 net/dsa/Kconfig  |  9 +
 net/dsa/Makefile |  3 ++-
 net/dsa/dsa_priv.h   |  9 +
 net/dsa/legacy.c | 20 
 net/dsa/slave.c  | 20 
 8 files changed, 56 insertions(+), 22 deletions(-)

diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig
index 83a9bc892a3b..2b81b97e994f 100644
--- a/drivers/net/dsa/Kconfig
+++ b/drivers/net/dsa/Kconfig
@@ -33,7 +33,7 @@ config NET_DSA_MT7530
 
 config NET_DSA_MV88E6060
tristate "Marvell 88E6060 ethernet switch chip support"
-   depends on NET_DSA
+   depends on NET_DSA && NET_DSA_LEGACY
select NET_DSA_TAG_TRAILER
---help---
  This enables support for the Marvell 88E6060 ethernet switch
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 8171055fde7a..b2afbd730051 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -3739,6 +3739,7 @@ static enum dsa_tag_protocol 
mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
return chip->info->tag_protocol;
 }
 
+#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
 static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
   struct device *host_dev, int sw_addr,
   void **priv)
@@ -3786,6 +3787,7 @@ static const char *mv88e6xxx_drv_probe(struct device 
*dsa_dev,
 
return NULL;
 }
+#endif
 
 static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
  const struct switchdev_obj_port_mdb *mdb,
@@ -3827,7 +3829,9 @@ static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, 
int port,
 }
 
 static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
+#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
.probe  = mv88e6xxx_drv_probe,
+#endif
.get_tag_protocol   = mv88e6xxx_get_tag_protocol,
.setup  = mv88e6xxx_setup,
.adjust_link= mv88e6xxx_adjust_link,
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 2a05738570d8..e4326695653e 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -315,12 +315,14 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
 typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
  bool is_static, void *data);
 struct dsa_switch_ops {
+#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
/*
 * Legacy probing.
 */
const char  *(*probe)(struct device *dsa_dev,
  struct device *host_dev, int sw_addr,
  void **priv);
+#endif
 
enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds,
  int port);
@@ -472,11 +474,20 @@ struct dsa_switch_driver {
const struct dsa_switch_ops *ops;
 };
 
+#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
 /* Legacy driver registration */
 void register_switch_driver(struct dsa_switch_driver *type);
 void unregister_switch_driver(struct dsa_switch_driver *type);
 struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev);
 
+#else
+static inline void register_switch_driver(struct dsa_switch_driver *type) { }
+static inline void unregister_switch_driver(struct dsa_switch_driver *type) { }
+static inline struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev)
+{
+   return NULL;
+}
+#endif
 struct net_device *dsa_dev_to_net_device(struct device *dev);
 
 /* Keep inline for faster access in hot path */
diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index 03c3bdf25468..bbf2c82cf7b2 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -16,6 +16,15 @@ config NET_DSA
 
 if NET_DSA
 
+config NET_DSA_LEGACY
+   bool "Support for older platform device and Device Tree registration"
+   default y
+   ---help---
+ Say Y if you want to enable support for the older platform device and
+ deprecated Device Tree binding registration.
+
+ This feature is scheduled for removal in 4.17.
+
 # tagging formats
 config NET_DSA_TAG_BRCM
bool
diff --git a/net/dsa/Makefile b/net/dsa/Makefile
index 0e13c1f95d13..9e4d3536f977 100644
--- a/net/dsa/Makefile
+++ b/net/dsa/Makefile
@@ -1,7 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0

[PATCH net-next v2] net: dsa: Allow compiling out legacy support

2017-12-01 Thread Florian Fainelli
Introduce a configuration option: CONFIG_NET_DSA_LEGACY allowing to compile out
support for the old platform device and Device Tree binding registration.
Support for these configurations is scheduled to be removed in 4.17.

Signed-off-by: Florian Fainelli 
---
Changes in v2:
- make the option enabled by default
- make the .probe function part of NET_DSA_LEGACY
- make mv88e6060 depend on NET_DSA_LEGACY
- move dsa_legacy_fdb_{add,del} out of net/dsa/legacy.c

 drivers/net/dsa/Kconfig  |  2 +-
 drivers/net/dsa/mv88e6xxx/chip.c |  4 
 include/net/dsa.h| 11 +++
 net/dsa/Kconfig  |  9 +
 net/dsa/Makefile |  3 ++-
 net/dsa/dsa_priv.h   |  9 +
 net/dsa/legacy.c | 20 
 net/dsa/slave.c  | 20 
 8 files changed, 56 insertions(+), 22 deletions(-)

diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig
index 83a9bc892a3b..2b81b97e994f 100644
--- a/drivers/net/dsa/Kconfig
+++ b/drivers/net/dsa/Kconfig
@@ -33,7 +33,7 @@ config NET_DSA_MT7530
 
 config NET_DSA_MV88E6060
tristate "Marvell 88E6060 ethernet switch chip support"
-   depends on NET_DSA
+   depends on NET_DSA && NET_DSA_LEGACY
select NET_DSA_TAG_TRAILER
---help---
  This enables support for the Marvell 88E6060 ethernet switch
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 8171055fde7a..b2afbd730051 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -3739,6 +3739,7 @@ static enum dsa_tag_protocol 
mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
return chip->info->tag_protocol;
 }
 
+#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
 static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
   struct device *host_dev, int sw_addr,
   void **priv)
@@ -3786,6 +3787,7 @@ static const char *mv88e6xxx_drv_probe(struct device 
*dsa_dev,
 
return NULL;
 }
+#endif
 
 static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
  const struct switchdev_obj_port_mdb *mdb,
@@ -3827,7 +3829,9 @@ static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, 
int port,
 }
 
 static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
+#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
.probe  = mv88e6xxx_drv_probe,
+#endif
.get_tag_protocol   = mv88e6xxx_get_tag_protocol,
.setup  = mv88e6xxx_setup,
.adjust_link= mv88e6xxx_adjust_link,
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 2a05738570d8..e4326695653e 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -315,12 +315,14 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
 typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
  bool is_static, void *data);
 struct dsa_switch_ops {
+#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
/*
 * Legacy probing.
 */
const char  *(*probe)(struct device *dsa_dev,
  struct device *host_dev, int sw_addr,
  void **priv);
+#endif
 
enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds,
  int port);
@@ -472,11 +474,20 @@ struct dsa_switch_driver {
const struct dsa_switch_ops *ops;
 };
 
+#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
 /* Legacy driver registration */
 void register_switch_driver(struct dsa_switch_driver *type);
 void unregister_switch_driver(struct dsa_switch_driver *type);
 struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev);
 
+#else
+static inline void register_switch_driver(struct dsa_switch_driver *type) { }
+static inline void unregister_switch_driver(struct dsa_switch_driver *type) { }
+static inline struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev)
+{
+   return NULL;
+}
+#endif
 struct net_device *dsa_dev_to_net_device(struct device *dev);
 
 /* Keep inline for faster access in hot path */
diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index 03c3bdf25468..bbf2c82cf7b2 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -16,6 +16,15 @@ config NET_DSA
 
 if NET_DSA
 
+config NET_DSA_LEGACY
+   bool "Support for older platform device and Device Tree registration"
+   default y
+   ---help---
+ Say Y if you want to enable support for the older platform device and
+ deprecated Device Tree binding registration.
+
+ This feature is scheduled for removal in 4.17.
+
 # tagging formats
 config NET_DSA_TAG_BRCM
bool
diff --git a/net/dsa/Makefile b/net/dsa/Makefile
index 0e13c1f95d13..9e4d3536f977 100644
--- a/net/dsa/Makefile
+++ b/net/dsa/Makefile
@@ -1,7 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 # the core
 

RISC-V Memory Consistency Model Draft Specification

2017-12-01 Thread Palmer Dabbelt
I'm not sure what the best way to make sure this gets to all the right people 
is, so I've CC'd everyone I could find who contributed to our recent RISC-V 
related memory model discussions on LKML.  Sorry if this ends up blowing up 
someone's inbox.

Daniel Lustig, the chair of the RISC-V memory model task group, recently posted 
the first public draft of the RISC-V memory consistency model specification on 
the RISC-V ISA development mailing list.  As I'm sure many interested parties 
aren't subscribed to that list so I thought it'd be appropriate to bring it up 
on a Linux mailing list.

I'll copy the text of the message below, the actual specification is included 
as an attachment in the linked message.  Feel free to contribute either here or 
on isa-...@groups.riscv.org, Dan is on both threads.

https://groups.google.com/a/groups.riscv.org/forum/#!topic/isa-dev/hKywNHBkAXM

-
Hi everyone, 

We in the RISC-V memory model task group are ready to release the first
public draft of the memory consistency model specification that we've
been working on over the past few months.  For those of you who
attended the workshop this week, this document will fill in some of the
details.  For those of you who couldn't make it, I've attached my
presentation slides as well.  The video of my talk (and of all the other
talks) should be posted online within a week or so.

If anyone has any comments, questions, or feedback, feel free to respond
here, to reach out to us in the memory model task group, or even just to
respond to me directly.  I'm more than happy to take the feedback.

Over the next few weeks, assuming nobody uncovers any glaring errors,
we'll start working to merge this into the rest of the user-level ISA
spec (in some way or other, details TBD) so that we can aim to put forth
both together for official ratification in the coming months.  We'll
also of course fix any typos, bugs, or discrepancies that are found in
the meantime.

We're also actively communicating with the Linux maintainers, the gcc
and LLVM maintainers, and more so that we make sure that the memory
model interacts properly with all of the above.

Let us know what you think!


RISC-V Memory Consistency Model Draft Specification

2017-12-01 Thread Palmer Dabbelt
I'm not sure what the best way to make sure this gets to all the right people 
is, so I've CC'd everyone I could find who contributed to our recent RISC-V 
related memory model discussions on LKML.  Sorry if this ends up blowing up 
someone's inbox.

Daniel Lustig, the chair of the RISC-V memory model task group, recently posted 
the first public draft of the RISC-V memory consistency model specification on 
the RISC-V ISA development mailing list.  As I'm sure many interested parties 
aren't subscribed to that list so I thought it'd be appropriate to bring it up 
on a Linux mailing list.

I'll copy the text of the message below, the actual specification is included 
as an attachment in the linked message.  Feel free to contribute either here or 
on isa-...@groups.riscv.org, Dan is on both threads.

https://groups.google.com/a/groups.riscv.org/forum/#!topic/isa-dev/hKywNHBkAXM

-
Hi everyone, 

We in the RISC-V memory model task group are ready to release the first
public draft of the memory consistency model specification that we've
been working on over the past few months.  For those of you who
attended the workshop this week, this document will fill in some of the
details.  For those of you who couldn't make it, I've attached my
presentation slides as well.  The video of my talk (and of all the other
talks) should be posted online within a week or so.

If anyone has any comments, questions, or feedback, feel free to respond
here, to reach out to us in the memory model task group, or even just to
respond to me directly.  I'm more than happy to take the feedback.

Over the next few weeks, assuming nobody uncovers any glaring errors,
we'll start working to merge this into the rest of the user-level ISA
spec (in some way or other, details TBD) so that we can aim to put forth
both together for official ratification in the coming months.  We'll
also of course fix any typos, bugs, or discrepancies that are found in
the meantime.

We're also actively communicating with the Linux maintainers, the gcc
and LLVM maintainers, and more so that we make sure that the memory
model interacts properly with all of the above.

Let us know what you think!


[PATCH v1 3/6] ARM: davinci: don't use static clk_lookup

2017-12-01 Thread David Lechner
In preparation of moving to the common clock framework, usage of static
struct clk_lookup is removed. The common clock framework uses an opaque
struct clk, so we won't be able to use static tables as was previously
done.

Each CPU family is given a new CPU-specific init_time function that
registers the clocks individually via function calls instead of using
a clk_lookup table.

Signed-off-by: David Lechner 
---
 arch/arm/mach-davinci/board-da830-evm.c |   2 +-
 arch/arm/mach-davinci/board-da850-evm.c |   2 +-
 arch/arm/mach-davinci/board-dm355-evm.c |   2 +-
 arch/arm/mach-davinci/board-dm355-leopard.c |   2 +-
 arch/arm/mach-davinci/board-dm365-evm.c |   2 +-
 arch/arm/mach-davinci/board-dm644x-evm.c|   2 +-
 arch/arm/mach-davinci/board-dm646x-evm.c|   4 +-
 arch/arm/mach-davinci/board-mityomapl138.c  |   2 +-
 arch/arm/mach-davinci/board-neuros-osd2.c   |   2 +-
 arch/arm/mach-davinci/board-omapl138-hawk.c |   2 +-
 arch/arm/mach-davinci/board-sffsdr.c|   2 +-
 arch/arm/mach-davinci/clock.c   |  75 +++
 arch/arm/mach-davinci/clock.h   |   9 +-
 arch/arm/mach-davinci/da830.c   | 115 ---
 arch/arm/mach-davinci/da850.c   | 137 ++--
 arch/arm/mach-davinci/da8xx-dt.c|   2 +-
 arch/arm/mach-davinci/davinci.h |   4 +
 arch/arm/mach-davinci/devices-da8xx.c   |   5 +-
 arch/arm/mach-davinci/dm355.c   |  97 ++--
 arch/arm/mach-davinci/dm365.c   | 127 +-
 arch/arm/mach-davinci/dm644x.c  |  89 +-
 arch/arm/mach-davinci/dm646x.c  |  99 +++-
 arch/arm/mach-davinci/include/mach/common.h |   1 -
 arch/arm/mach-davinci/include/mach/da8xx.h  |   3 +
 arch/arm/mach-davinci/time.c|   8 --
 arch/arm/mach-davinci/usb-da8xx.c   |  15 +--
 26 files changed, 407 insertions(+), 403 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c 
b/arch/arm/mach-davinci/board-da830-evm.c
index db656d4..524049a 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -633,7 +633,7 @@ MACHINE_START(DAVINCI_DA830_EVM, "DaVinci 
DA830/OMAP-L137/AM17x EVM")
.atag_offset= 0x100,
.map_io = da830_map_io,
.init_irq   = cp_intc_init,
-   .init_time  = davinci_timer_init,
+   .init_time  = da830_init_time,
.init_machine   = da830_evm_init,
.init_late  = davinci_init_late,
.dma_zone_size  = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index 7333ade..f766823 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -1476,7 +1476,7 @@ MACHINE_START(DAVINCI_DA850_EVM, "DaVinci 
DA850/OMAP-L138/AM18x EVM")
.atag_offset= 0x100,
.map_io = da850_map_io,
.init_irq   = cp_intc_init,
-   .init_time  = davinci_timer_init,
+   .init_time  = da850_init_time,
.init_machine   = da850_evm_init,
.init_late  = davinci_init_late,
.dma_zone_size  = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-dm355-evm.c 
b/arch/arm/mach-davinci/board-dm355-evm.c
index da462e7..ef27f55 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -411,7 +411,7 @@ MACHINE_START(DAVINCI_DM355_EVM, "DaVinci DM355 EVM")
.atag_offset  = 0x100,
.map_io = dm355_map_io,
.init_irq = davinci_irq_init,
-   .init_time  = davinci_timer_init,
+   .init_time  = dm355_init_time,
.init_machine = dm355_evm_init,
.init_late  = davinci_init_late,
.dma_zone_size  = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c 
b/arch/arm/mach-davinci/board-dm355-leopard.c
index 21fd713..e705a6e 100644
--- a/arch/arm/mach-davinci/board-dm355-leopard.c
+++ b/arch/arm/mach-davinci/board-dm355-leopard.c
@@ -266,7 +266,7 @@ MACHINE_START(DM355_LEOPARD, "DaVinci DM355 leopard")
.atag_offset  = 0x100,
.map_io = dm355_map_io,
.init_irq = davinci_irq_init,
-   .init_time  = davinci_timer_init,
+   .init_time  = dm355_init_time,
.init_machine = dm355_leopard_init,
.init_late  = davinci_init_late,
.dma_zone_size  = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c 
b/arch/arm/mach-davinci/board-dm365-evm.c
index 4ec759b..4232c09 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -769,7 +769,7 @@ MACHINE_START(DAVINCI_DM365_EVM, "DaVinci DM365 EVM")
.atag_offset= 0x100,
.map_io = dm365_map_io,
.init_irq   = davinci_irq_init,
-   .init_time  = 

[PATCH v1 1/6] ARM: davinci: clean up map_io functions

2017-12-01 Thread David Lechner
This cleans up the map_io functions in the board init files for
mach-davinci.

Most of the boards had a wrapper function around _init(). This
wrapper is removed and the function is used directly. Additionally, the
_init() functions are renamed to _map_io() to match the
field name.

Signed-off-by: David Lechner 
---
 arch/arm/mach-davinci/board-da830-evm.c |  7 +--
 arch/arm/mach-davinci/board-da850-evm.c |  7 +--
 arch/arm/mach-davinci/board-dm355-evm.c |  7 +--
 arch/arm/mach-davinci/board-dm355-leopard.c |  7 +--
 arch/arm/mach-davinci/board-dm365-evm.c |  7 +--
 arch/arm/mach-davinci/board-dm644x-evm.c|  8 +---
 arch/arm/mach-davinci/board-dm646x-evm.c| 14 ++
 arch/arm/mach-davinci/board-mityomapl138.c  |  7 +--
 arch/arm/mach-davinci/board-neuros-osd2.c   |  7 +--
 arch/arm/mach-davinci/board-omapl138-hawk.c |  7 +--
 arch/arm/mach-davinci/board-sffsdr.c|  7 +--
 arch/arm/mach-davinci/da830.c   |  2 +-
 arch/arm/mach-davinci/da850.c   |  2 +-
 arch/arm/mach-davinci/da8xx-dt.c|  2 +-
 arch/arm/mach-davinci/davinci.h |  8 
 arch/arm/mach-davinci/dm355.c   |  2 +-
 arch/arm/mach-davinci/dm365.c   |  2 +-
 arch/arm/mach-davinci/dm644x.c  |  2 +-
 arch/arm/mach-davinci/dm646x.c  |  8 +++-
 arch/arm/mach-davinci/include/mach/da8xx.h  |  4 ++--
 20 files changed, 31 insertions(+), 86 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c 
b/arch/arm/mach-davinci/board-da830-evm.c
index f673cd7..db656d4 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -629,14 +629,9 @@ static int __init da830_evm_console_init(void)
 console_initcall(da830_evm_console_init);
 #endif
 
-static void __init da830_evm_map_io(void)
-{
-   da830_init();
-}
-
 MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137/AM17x EVM")
.atag_offset= 0x100,
-   .map_io = da830_evm_map_io,
+   .map_io = da830_map_io,
.init_irq   = cp_intc_init,
.init_time  = davinci_timer_init,
.init_machine   = da830_evm_init,
diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index cbde003..7333ade 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -1472,14 +1472,9 @@ static int __init da850_evm_console_init(void)
 console_initcall(da850_evm_console_init);
 #endif
 
-static void __init da850_evm_map_io(void)
-{
-   da850_init();
-}
-
 MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
.atag_offset= 0x100,
-   .map_io = da850_evm_map_io,
+   .map_io = da850_map_io,
.init_irq   = cp_intc_init,
.init_time  = davinci_timer_init,
.init_machine   = da850_evm_init,
diff --git a/arch/arm/mach-davinci/board-dm355-evm.c 
b/arch/arm/mach-davinci/board-dm355-evm.c
index 62e7bc3..da462e7 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -314,11 +314,6 @@ static struct platform_device *davinci_evm_devices[] 
__initdata = {
_nand_device,
 };
 
-static void __init dm355_evm_map_io(void)
-{
-   dm355_init();
-}
-
 static int dm355evm_mmc_get_cd(int module)
 {
if (!gpio_is_valid(dm355evm_mmc_gpios))
@@ -414,7 +409,7 @@ static __init void dm355_evm_init(void)
 
 MACHINE_START(DAVINCI_DM355_EVM, "DaVinci DM355 EVM")
.atag_offset  = 0x100,
-   .map_io   = dm355_evm_map_io,
+   .map_io = dm355_map_io,
.init_irq = davinci_irq_init,
.init_time  = davinci_timer_init,
.init_machine = dm355_evm_init,
diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c 
b/arch/arm/mach-davinci/board-dm355-leopard.c
index be99724..21fd713 100644
--- a/arch/arm/mach-davinci/board-dm355-leopard.c
+++ b/arch/arm/mach-davinci/board-dm355-leopard.c
@@ -174,11 +174,6 @@ static struct platform_device *davinci_leopard_devices[] 
__initdata = {
_nand_device,
 };
 
-static void __init dm355_leopard_map_io(void)
-{
-   dm355_init();
-}
-
 static int dm355leopard_mmc_get_cd(int module)
 {
if (!gpio_is_valid(leopard_mmc_gpio))
@@ -269,7 +264,7 @@ static __init void dm355_leopard_init(void)
 
 MACHINE_START(DM355_LEOPARD, "DaVinci DM355 leopard")
.atag_offset  = 0x100,
-   .map_io   = dm355_leopard_map_io,
+   .map_io = dm355_map_io,
.init_irq = davinci_irq_init,
.init_time  = davinci_timer_init,
.init_machine = dm355_leopard_init,
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c 
b/arch/arm/mach-davinci/board-dm365-evm.c
index e75741f..4ec759b 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -714,11 +714,6 @@ static 

[PATCH v1 3/6] ARM: davinci: don't use static clk_lookup

2017-12-01 Thread David Lechner
In preparation of moving to the common clock framework, usage of static
struct clk_lookup is removed. The common clock framework uses an opaque
struct clk, so we won't be able to use static tables as was previously
done.

Each CPU family is given a new CPU-specific init_time function that
registers the clocks individually via function calls instead of using
a clk_lookup table.

Signed-off-by: David Lechner 
---
 arch/arm/mach-davinci/board-da830-evm.c |   2 +-
 arch/arm/mach-davinci/board-da850-evm.c |   2 +-
 arch/arm/mach-davinci/board-dm355-evm.c |   2 +-
 arch/arm/mach-davinci/board-dm355-leopard.c |   2 +-
 arch/arm/mach-davinci/board-dm365-evm.c |   2 +-
 arch/arm/mach-davinci/board-dm644x-evm.c|   2 +-
 arch/arm/mach-davinci/board-dm646x-evm.c|   4 +-
 arch/arm/mach-davinci/board-mityomapl138.c  |   2 +-
 arch/arm/mach-davinci/board-neuros-osd2.c   |   2 +-
 arch/arm/mach-davinci/board-omapl138-hawk.c |   2 +-
 arch/arm/mach-davinci/board-sffsdr.c|   2 +-
 arch/arm/mach-davinci/clock.c   |  75 +++
 arch/arm/mach-davinci/clock.h   |   9 +-
 arch/arm/mach-davinci/da830.c   | 115 ---
 arch/arm/mach-davinci/da850.c   | 137 ++--
 arch/arm/mach-davinci/da8xx-dt.c|   2 +-
 arch/arm/mach-davinci/davinci.h |   4 +
 arch/arm/mach-davinci/devices-da8xx.c   |   5 +-
 arch/arm/mach-davinci/dm355.c   |  97 ++--
 arch/arm/mach-davinci/dm365.c   | 127 +-
 arch/arm/mach-davinci/dm644x.c  |  89 +-
 arch/arm/mach-davinci/dm646x.c  |  99 +++-
 arch/arm/mach-davinci/include/mach/common.h |   1 -
 arch/arm/mach-davinci/include/mach/da8xx.h  |   3 +
 arch/arm/mach-davinci/time.c|   8 --
 arch/arm/mach-davinci/usb-da8xx.c   |  15 +--
 26 files changed, 407 insertions(+), 403 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c 
b/arch/arm/mach-davinci/board-da830-evm.c
index db656d4..524049a 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -633,7 +633,7 @@ MACHINE_START(DAVINCI_DA830_EVM, "DaVinci 
DA830/OMAP-L137/AM17x EVM")
.atag_offset= 0x100,
.map_io = da830_map_io,
.init_irq   = cp_intc_init,
-   .init_time  = davinci_timer_init,
+   .init_time  = da830_init_time,
.init_machine   = da830_evm_init,
.init_late  = davinci_init_late,
.dma_zone_size  = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index 7333ade..f766823 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -1476,7 +1476,7 @@ MACHINE_START(DAVINCI_DA850_EVM, "DaVinci 
DA850/OMAP-L138/AM18x EVM")
.atag_offset= 0x100,
.map_io = da850_map_io,
.init_irq   = cp_intc_init,
-   .init_time  = davinci_timer_init,
+   .init_time  = da850_init_time,
.init_machine   = da850_evm_init,
.init_late  = davinci_init_late,
.dma_zone_size  = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-dm355-evm.c 
b/arch/arm/mach-davinci/board-dm355-evm.c
index da462e7..ef27f55 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -411,7 +411,7 @@ MACHINE_START(DAVINCI_DM355_EVM, "DaVinci DM355 EVM")
.atag_offset  = 0x100,
.map_io = dm355_map_io,
.init_irq = davinci_irq_init,
-   .init_time  = davinci_timer_init,
+   .init_time  = dm355_init_time,
.init_machine = dm355_evm_init,
.init_late  = davinci_init_late,
.dma_zone_size  = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c 
b/arch/arm/mach-davinci/board-dm355-leopard.c
index 21fd713..e705a6e 100644
--- a/arch/arm/mach-davinci/board-dm355-leopard.c
+++ b/arch/arm/mach-davinci/board-dm355-leopard.c
@@ -266,7 +266,7 @@ MACHINE_START(DM355_LEOPARD, "DaVinci DM355 leopard")
.atag_offset  = 0x100,
.map_io = dm355_map_io,
.init_irq = davinci_irq_init,
-   .init_time  = davinci_timer_init,
+   .init_time  = dm355_init_time,
.init_machine = dm355_leopard_init,
.init_late  = davinci_init_late,
.dma_zone_size  = SZ_128M,
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c 
b/arch/arm/mach-davinci/board-dm365-evm.c
index 4ec759b..4232c09 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -769,7 +769,7 @@ MACHINE_START(DAVINCI_DM365_EVM, "DaVinci DM365 EVM")
.atag_offset= 0x100,
.map_io = dm365_map_io,
.init_irq   = davinci_irq_init,
-   .init_time  = davinci_timer_init,
+   .init_time 

[PATCH v1 1/6] ARM: davinci: clean up map_io functions

2017-12-01 Thread David Lechner
This cleans up the map_io functions in the board init files for
mach-davinci.

Most of the boards had a wrapper function around _init(). This
wrapper is removed and the function is used directly. Additionally, the
_init() functions are renamed to _map_io() to match the
field name.

Signed-off-by: David Lechner 
---
 arch/arm/mach-davinci/board-da830-evm.c |  7 +--
 arch/arm/mach-davinci/board-da850-evm.c |  7 +--
 arch/arm/mach-davinci/board-dm355-evm.c |  7 +--
 arch/arm/mach-davinci/board-dm355-leopard.c |  7 +--
 arch/arm/mach-davinci/board-dm365-evm.c |  7 +--
 arch/arm/mach-davinci/board-dm644x-evm.c|  8 +---
 arch/arm/mach-davinci/board-dm646x-evm.c| 14 ++
 arch/arm/mach-davinci/board-mityomapl138.c  |  7 +--
 arch/arm/mach-davinci/board-neuros-osd2.c   |  7 +--
 arch/arm/mach-davinci/board-omapl138-hawk.c |  7 +--
 arch/arm/mach-davinci/board-sffsdr.c|  7 +--
 arch/arm/mach-davinci/da830.c   |  2 +-
 arch/arm/mach-davinci/da850.c   |  2 +-
 arch/arm/mach-davinci/da8xx-dt.c|  2 +-
 arch/arm/mach-davinci/davinci.h |  8 
 arch/arm/mach-davinci/dm355.c   |  2 +-
 arch/arm/mach-davinci/dm365.c   |  2 +-
 arch/arm/mach-davinci/dm644x.c  |  2 +-
 arch/arm/mach-davinci/dm646x.c  |  8 +++-
 arch/arm/mach-davinci/include/mach/da8xx.h  |  4 ++--
 20 files changed, 31 insertions(+), 86 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c 
b/arch/arm/mach-davinci/board-da830-evm.c
index f673cd7..db656d4 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -629,14 +629,9 @@ static int __init da830_evm_console_init(void)
 console_initcall(da830_evm_console_init);
 #endif
 
-static void __init da830_evm_map_io(void)
-{
-   da830_init();
-}
-
 MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137/AM17x EVM")
.atag_offset= 0x100,
-   .map_io = da830_evm_map_io,
+   .map_io = da830_map_io,
.init_irq   = cp_intc_init,
.init_time  = davinci_timer_init,
.init_machine   = da830_evm_init,
diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index cbde003..7333ade 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -1472,14 +1472,9 @@ static int __init da850_evm_console_init(void)
 console_initcall(da850_evm_console_init);
 #endif
 
-static void __init da850_evm_map_io(void)
-{
-   da850_init();
-}
-
 MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
.atag_offset= 0x100,
-   .map_io = da850_evm_map_io,
+   .map_io = da850_map_io,
.init_irq   = cp_intc_init,
.init_time  = davinci_timer_init,
.init_machine   = da850_evm_init,
diff --git a/arch/arm/mach-davinci/board-dm355-evm.c 
b/arch/arm/mach-davinci/board-dm355-evm.c
index 62e7bc3..da462e7 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -314,11 +314,6 @@ static struct platform_device *davinci_evm_devices[] 
__initdata = {
_nand_device,
 };
 
-static void __init dm355_evm_map_io(void)
-{
-   dm355_init();
-}
-
 static int dm355evm_mmc_get_cd(int module)
 {
if (!gpio_is_valid(dm355evm_mmc_gpios))
@@ -414,7 +409,7 @@ static __init void dm355_evm_init(void)
 
 MACHINE_START(DAVINCI_DM355_EVM, "DaVinci DM355 EVM")
.atag_offset  = 0x100,
-   .map_io   = dm355_evm_map_io,
+   .map_io = dm355_map_io,
.init_irq = davinci_irq_init,
.init_time  = davinci_timer_init,
.init_machine = dm355_evm_init,
diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c 
b/arch/arm/mach-davinci/board-dm355-leopard.c
index be99724..21fd713 100644
--- a/arch/arm/mach-davinci/board-dm355-leopard.c
+++ b/arch/arm/mach-davinci/board-dm355-leopard.c
@@ -174,11 +174,6 @@ static struct platform_device *davinci_leopard_devices[] 
__initdata = {
_nand_device,
 };
 
-static void __init dm355_leopard_map_io(void)
-{
-   dm355_init();
-}
-
 static int dm355leopard_mmc_get_cd(int module)
 {
if (!gpio_is_valid(leopard_mmc_gpio))
@@ -269,7 +264,7 @@ static __init void dm355_leopard_init(void)
 
 MACHINE_START(DM355_LEOPARD, "DaVinci DM355 leopard")
.atag_offset  = 0x100,
-   .map_io   = dm355_leopard_map_io,
+   .map_io = dm355_map_io,
.init_irq = davinci_irq_init,
.init_time  = davinci_timer_init,
.init_machine = dm355_leopard_init,
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c 
b/arch/arm/mach-davinci/board-dm365-evm.c
index e75741f..4ec759b 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -714,11 +714,6 @@ static void __init 

[PATCH v1 4/6] ARM: davinci: make davinci_clk_reset() static

2017-12-01 Thread David Lechner
This makes davinci_clk_reset() static. It is not used anywhere else.

Signed-off-by: David Lechner 
---
 arch/arm/mach-davinci/clock.c | 3 +--
 arch/arm/mach-davinci/clock.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index 5f0a31d..c149b24 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -59,7 +59,7 @@ void davinci_clk_disable(struct clk *clk)
davinci_clk_disable(clk->parent);
 }
 
-int davinci_clk_reset(struct clk *clk, bool reset)
+static int davinci_clk_reset(struct clk *clk, bool reset)
 {
unsigned long flags;
 
@@ -73,7 +73,6 @@ int davinci_clk_reset(struct clk *clk, bool reset)
 
return 0;
 }
-EXPORT_SYMBOL(davinci_clk_reset);
 
 int davinci_clk_reset_assert(struct clk *clk)
 {
diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h
index e4afaa9..bf60cdf 100644
--- a/arch/arm/mach-davinci/clock.h
+++ b/arch/arm/mach-davinci/clock.h
@@ -124,7 +124,6 @@ int davinci_set_pllrate(struct pll_data *pll, unsigned int 
prediv,
 int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate);
 int davinci_set_refclk_rate(unsigned long rate);
 int davinci_simple_set_rate(struct clk *clk, unsigned long rate);
-int davinci_clk_reset(struct clk *clk, bool reset);
 void davinci_clk_enable(struct clk *clk);
 void davinci_clk_disable(struct clk *clk);
 
-- 
2.7.4



[PATCH v1 4/6] ARM: davinci: make davinci_clk_reset() static

2017-12-01 Thread David Lechner
This makes davinci_clk_reset() static. It is not used anywhere else.

Signed-off-by: David Lechner 
---
 arch/arm/mach-davinci/clock.c | 3 +--
 arch/arm/mach-davinci/clock.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index 5f0a31d..c149b24 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -59,7 +59,7 @@ void davinci_clk_disable(struct clk *clk)
davinci_clk_disable(clk->parent);
 }
 
-int davinci_clk_reset(struct clk *clk, bool reset)
+static int davinci_clk_reset(struct clk *clk, bool reset)
 {
unsigned long flags;
 
@@ -73,7 +73,6 @@ int davinci_clk_reset(struct clk *clk, bool reset)
 
return 0;
 }
-EXPORT_SYMBOL(davinci_clk_reset);
 
 int davinci_clk_reset_assert(struct clk *clk)
 {
diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h
index e4afaa9..bf60cdf 100644
--- a/arch/arm/mach-davinci/clock.h
+++ b/arch/arm/mach-davinci/clock.h
@@ -124,7 +124,6 @@ int davinci_set_pllrate(struct pll_data *pll, unsigned int 
prediv,
 int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate);
 int davinci_set_refclk_rate(unsigned long rate);
 int davinci_simple_set_rate(struct clk *clk, unsigned long rate);
-int davinci_clk_reset(struct clk *clk, bool reset);
 void davinci_clk_enable(struct clk *clk);
 void davinci_clk_disable(struct clk *clk);
 
-- 
2.7.4



[PATCH v1 6/6] ARM: davinci: remove clock debugfs

2017-12-01 Thread David Lechner
This removed the debugfs entry for mach-davinci clocks. The clocks now use
the common clock framework, which provides debugfs already, so this code is
redundant.

Signed-off-by: David Lechner 
---
 arch/arm/mach-davinci/clock.c | 79 ---
 1 file changed, 79 deletions(-)

diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index 0e63d93..347902e 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -626,82 +626,3 @@ void __init davinci_clk_init(struct davinci_clk *clk, 
const char *con_id,
if (clk->flags & ALWAYS_ENABLED)
clk_prepare_enable(clk->hw.clk);
 }
-
-#ifdef CONFIG_DEBUG_FS
-
-#include 
-#include 
-
-#define CLKNAME_MAX10  /* longest clock name */
-#define NEST_DELTA 2
-#define NEST_MAX   4
-
-static void
-dump_clock(struct seq_file *s, unsigned nest, struct davinci_clk *parent)
-{
-   char*state;
-   charbuf[CLKNAME_MAX + NEST_DELTA * NEST_MAX];
-   struct davinci_clk *clk;
-   unsignedi;
-
-   if (parent->flags & CLK_PLL)
-   state = "pll";
-   else if (parent->flags & CLK_PSC)
-   state = "psc";
-   else
-   state = "";
-
-   /*  name  */
-   memset(buf, ' ', sizeof(buf) - 1);
-   buf[sizeof(buf) - 1] = 0;
-   i = strlen(parent->name);
-   memcpy(buf + nest, parent->name,
-   min(i, (unsigned)(sizeof(buf) - 1 - nest)));
-
-   seq_printf(s, "%s users=%2d %-3s %9ld Hz\n",
-  buf, parent->usecount, state, parent->rate);
-   /* REVISIT show device associations too */
-
-   /* cost is now small, but not linear... */
-   list_for_each_entry(clk, >children, childnode) {
-   dump_clock(s, nest + NEST_DELTA, clk);
-   }
-}
-
-static int davinci_ck_show(struct seq_file *m, void *v)
-{
-   struct davinci_clk *clk;
-
-   /*
-* Show clock tree; We trust nonzero usecounts equate to PSC enables...
-*/
-   mutex_lock(_mutex);
-   list_for_each_entry(clk, , node)
-   if (!clk->parent)
-   dump_clock(m, 0, clk);
-   mutex_unlock(_mutex);
-
-   return 0;
-}
-
-static int davinci_ck_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, davinci_ck_show, NULL);
-}
-
-static const struct file_operations davinci_ck_operations = {
-   .open   = davinci_ck_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
-static int __init davinci_clk_debugfs_init(void)
-{
-   debugfs_create_file("davinci_clocks", S_IFREG | S_IRUGO, NULL, NULL,
-   _ck_operations);
-   return 0;
-
-}
-device_initcall(davinci_clk_debugfs_init);
-#endif /* CONFIG_DEBUG_FS */
-- 
2.7.4



[PATCH v1 6/6] ARM: davinci: remove clock debugfs

2017-12-01 Thread David Lechner
This removed the debugfs entry for mach-davinci clocks. The clocks now use
the common clock framework, which provides debugfs already, so this code is
redundant.

Signed-off-by: David Lechner 
---
 arch/arm/mach-davinci/clock.c | 79 ---
 1 file changed, 79 deletions(-)

diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index 0e63d93..347902e 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -626,82 +626,3 @@ void __init davinci_clk_init(struct davinci_clk *clk, 
const char *con_id,
if (clk->flags & ALWAYS_ENABLED)
clk_prepare_enable(clk->hw.clk);
 }
-
-#ifdef CONFIG_DEBUG_FS
-
-#include 
-#include 
-
-#define CLKNAME_MAX10  /* longest clock name */
-#define NEST_DELTA 2
-#define NEST_MAX   4
-
-static void
-dump_clock(struct seq_file *s, unsigned nest, struct davinci_clk *parent)
-{
-   char*state;
-   charbuf[CLKNAME_MAX + NEST_DELTA * NEST_MAX];
-   struct davinci_clk *clk;
-   unsignedi;
-
-   if (parent->flags & CLK_PLL)
-   state = "pll";
-   else if (parent->flags & CLK_PSC)
-   state = "psc";
-   else
-   state = "";
-
-   /*  name  */
-   memset(buf, ' ', sizeof(buf) - 1);
-   buf[sizeof(buf) - 1] = 0;
-   i = strlen(parent->name);
-   memcpy(buf + nest, parent->name,
-   min(i, (unsigned)(sizeof(buf) - 1 - nest)));
-
-   seq_printf(s, "%s users=%2d %-3s %9ld Hz\n",
-  buf, parent->usecount, state, parent->rate);
-   /* REVISIT show device associations too */
-
-   /* cost is now small, but not linear... */
-   list_for_each_entry(clk, >children, childnode) {
-   dump_clock(s, nest + NEST_DELTA, clk);
-   }
-}
-
-static int davinci_ck_show(struct seq_file *m, void *v)
-{
-   struct davinci_clk *clk;
-
-   /*
-* Show clock tree; We trust nonzero usecounts equate to PSC enables...
-*/
-   mutex_lock(_mutex);
-   list_for_each_entry(clk, , node)
-   if (!clk->parent)
-   dump_clock(m, 0, clk);
-   mutex_unlock(_mutex);
-
-   return 0;
-}
-
-static int davinci_ck_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, davinci_ck_show, NULL);
-}
-
-static const struct file_operations davinci_ck_operations = {
-   .open   = davinci_ck_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
-static int __init davinci_clk_debugfs_init(void)
-{
-   debugfs_create_file("davinci_clocks", S_IFREG | S_IRUGO, NULL, NULL,
-   _ck_operations);
-   return 0;
-
-}
-device_initcall(davinci_clk_debugfs_init);
-#endif /* CONFIG_DEBUG_FS */
-- 
2.7.4



[PATCH v1 2/6] ARM: davinci: move davinci_clk_init() to init_time

2017-12-01 Thread David Lechner
This moves the call of davinci_clk_init() from map_io to init_time for all
boards.

This is the proper place to init clocks. This is also done in preparation
for moving to the common clock framework.

Signed-off-by: David Lechner 
---
 arch/arm/mach-davinci/da830.c  | 2 --
 arch/arm/mach-davinci/da850.c  | 2 --
 arch/arm/mach-davinci/dm355.c  | 1 -
 arch/arm/mach-davinci/dm365.c  | 1 -
 arch/arm/mach-davinci/dm644x.c | 1 -
 arch/arm/mach-davinci/dm646x.c | 7 ---
 arch/arm/mach-davinci/time.c   | 7 +++
 7 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 2e249f0..f28eda1 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -1220,6 +1220,4 @@ void __init da830_map_io(void)
 
da8xx_syscfg0_base = ioremap(DA8XX_SYSCFG0_BASE, SZ_4K);
WARN(!da8xx_syscfg0_base, "Unable to map syscfg0 module");
-
-   davinci_clk_init(davinci_soc_info_da830.cpu_clks);
 }
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 056b148..28d8ec2 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -1392,6 +1392,4 @@ void __init da850_map_io(void)
v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
v &= ~CFGCHIP3_PLL1_MASTER_LOCK;
__raw_writel(v, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
-
-   davinci_clk_init(davinci_soc_info_da850.cpu_clks);
 }
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index 88c3c80..164ff27 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -1043,7 +1043,6 @@ void __init dm355_map_io(void)
 {
davinci_common_init(_soc_info_dm355);
davinci_map_sysmod();
-   davinci_clk_init(davinci_soc_info_dm355.cpu_clks);
 }
 
 int __init dm355_init_video(struct vpfe_config *vpfe_cfg,
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index f979180..6076085 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -1166,7 +1166,6 @@ void __init dm365_map_io(void)
 {
davinci_common_init(_soc_info_dm365);
davinci_map_sysmod();
-   davinci_clk_init(davinci_soc_info_dm365.cpu_clks);
 }
 
 static struct resource dm365_vpss_resources[] = {
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index 80048c0..c5b1cf3 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -931,7 +931,6 @@ void __init dm644x_map_io(void)
 {
davinci_common_init(_soc_info_dm644x);
davinci_map_sysmod();
-   davinci_clk_init(davinci_soc_info_dm644x.cpu_clks);
 }
 
 int __init dm644x_init_video(struct vpfe_config *vpfe_cfg,
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index b3be5c8..a844f7b 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -17,7 +17,6 @@
 #include 
 #include 
 
-#include 
 #include 
 
 #include 
@@ -953,16 +952,10 @@ int __init dm646x_init_edma(struct edma_rsv_info *rsv)
return IS_ERR(edma_pdev) ? PTR_ERR(edma_pdev) : 0;
 }
 
-#define DM6467T_EVM_REF_FREQ   3300
-
 void __init dm646x_map_io(void)
 {
davinci_common_init(_soc_info_dm646x);
davinci_map_sysmod();
-   davinci_clk_init(davinci_soc_info_dm646x.cpu_clks);
-
-   if (machine_is_davinci_dm6467tevm())
-   davinci_set_refclk_rate(DM6467T_EVM_REF_FREQ);
 }
 
 static int __init dm646x_init_devices(void)
diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c
index 034f865..6ba156e 100644
--- a/arch/arm/mach-davinci/time.c
+++ b/arch/arm/mach-davinci/time.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -341,6 +342,7 @@ static struct clock_event_device clockevent_davinci = {
.set_state_oneshot  = davinci_set_oneshot,
 };
 
+#define DM6467T_EVM_REF_FREQ   3300
 
 void __init davinci_timer_init(void)
 {
@@ -350,6 +352,11 @@ void __init davinci_timer_init(void)
unsigned int clocksource_id;
int i;
 
+   davinci_clk_init(soc_info->cpu_clks);
+
+   if (machine_is_davinci_dm6467tevm())
+   davinci_set_refclk_rate(DM6467T_EVM_REF_FREQ);
+
clockevent_id = soc_info->timer_info->clockevent_id;
clocksource_id = soc_info->timer_info->clocksource_id;
 
-- 
2.7.4



[PATCH v1 2/6] ARM: davinci: move davinci_clk_init() to init_time

2017-12-01 Thread David Lechner
This moves the call of davinci_clk_init() from map_io to init_time for all
boards.

This is the proper place to init clocks. This is also done in preparation
for moving to the common clock framework.

Signed-off-by: David Lechner 
---
 arch/arm/mach-davinci/da830.c  | 2 --
 arch/arm/mach-davinci/da850.c  | 2 --
 arch/arm/mach-davinci/dm355.c  | 1 -
 arch/arm/mach-davinci/dm365.c  | 1 -
 arch/arm/mach-davinci/dm644x.c | 1 -
 arch/arm/mach-davinci/dm646x.c | 7 ---
 arch/arm/mach-davinci/time.c   | 7 +++
 7 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 2e249f0..f28eda1 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -1220,6 +1220,4 @@ void __init da830_map_io(void)
 
da8xx_syscfg0_base = ioremap(DA8XX_SYSCFG0_BASE, SZ_4K);
WARN(!da8xx_syscfg0_base, "Unable to map syscfg0 module");
-
-   davinci_clk_init(davinci_soc_info_da830.cpu_clks);
 }
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 056b148..28d8ec2 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -1392,6 +1392,4 @@ void __init da850_map_io(void)
v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
v &= ~CFGCHIP3_PLL1_MASTER_LOCK;
__raw_writel(v, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG));
-
-   davinci_clk_init(davinci_soc_info_da850.cpu_clks);
 }
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index 88c3c80..164ff27 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -1043,7 +1043,6 @@ void __init dm355_map_io(void)
 {
davinci_common_init(_soc_info_dm355);
davinci_map_sysmod();
-   davinci_clk_init(davinci_soc_info_dm355.cpu_clks);
 }
 
 int __init dm355_init_video(struct vpfe_config *vpfe_cfg,
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index f979180..6076085 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -1166,7 +1166,6 @@ void __init dm365_map_io(void)
 {
davinci_common_init(_soc_info_dm365);
davinci_map_sysmod();
-   davinci_clk_init(davinci_soc_info_dm365.cpu_clks);
 }
 
 static struct resource dm365_vpss_resources[] = {
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index 80048c0..c5b1cf3 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -931,7 +931,6 @@ void __init dm644x_map_io(void)
 {
davinci_common_init(_soc_info_dm644x);
davinci_map_sysmod();
-   davinci_clk_init(davinci_soc_info_dm644x.cpu_clks);
 }
 
 int __init dm644x_init_video(struct vpfe_config *vpfe_cfg,
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index b3be5c8..a844f7b 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -17,7 +17,6 @@
 #include 
 #include 
 
-#include 
 #include 
 
 #include 
@@ -953,16 +952,10 @@ int __init dm646x_init_edma(struct edma_rsv_info *rsv)
return IS_ERR(edma_pdev) ? PTR_ERR(edma_pdev) : 0;
 }
 
-#define DM6467T_EVM_REF_FREQ   3300
-
 void __init dm646x_map_io(void)
 {
davinci_common_init(_soc_info_dm646x);
davinci_map_sysmod();
-   davinci_clk_init(davinci_soc_info_dm646x.cpu_clks);
-
-   if (machine_is_davinci_dm6467tevm())
-   davinci_set_refclk_rate(DM6467T_EVM_REF_FREQ);
 }
 
 static int __init dm646x_init_devices(void)
diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c
index 034f865..6ba156e 100644
--- a/arch/arm/mach-davinci/time.c
+++ b/arch/arm/mach-davinci/time.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -341,6 +342,7 @@ static struct clock_event_device clockevent_davinci = {
.set_state_oneshot  = davinci_set_oneshot,
 };
 
+#define DM6467T_EVM_REF_FREQ   3300
 
 void __init davinci_timer_init(void)
 {
@@ -350,6 +352,11 @@ void __init davinci_timer_init(void)
unsigned int clocksource_id;
int i;
 
+   davinci_clk_init(soc_info->cpu_clks);
+
+   if (machine_is_davinci_dm6467tevm())
+   davinci_set_refclk_rate(DM6467T_EVM_REF_FREQ);
+
clockevent_id = soc_info->timer_info->clockevent_id;
clocksource_id = soc_info->timer_info->clocksource_id;
 
-- 
2.7.4



[PATCH v1 5/6] ARM: davinci: convert to common clock framework

2017-12-01 Thread David Lechner
This converts the clocks in mach-davinci to the common clock framework.

Most of the patch just involves renaming struct clk to struct davinci_clk.
There is also a struct clk_hw added to provide the bridge between the
existing clock implementation and the common clock framework.

In clock.c:
* The clk_get_parent and clk_set_parent callbacks are dropped because
  all clocks currently (effectively) have a single parent, in which
  case the common clock framework does not want you to implement these
  functions yourself.
* clk_unregister() is dropped because it is not used anywhere in
  mach-davinci.
* EXPORT_SYMBOL() is removed from functions not used outside of
  mach-davinci.

Signed-off-by: David Lechner 
---
 arch/arm/Kconfig   |   2 +-
 arch/arm/mach-davinci/clock.c  | 162 -
 arch/arm/mach-davinci/clock.h  |  40 ---
 arch/arm/mach-davinci/da830.c  | 100 +-
 arch/arm/mach-davinci/da850.c  | 153 +--
 arch/arm/mach-davinci/devices-da8xx.c  |   6 +-
 arch/arm/mach-davinci/dm355.c  |  84 +++
 arch/arm/mach-davinci/dm365.c  | 112 ++--
 arch/arm/mach-davinci/dm644x.c |  72 ++---
 arch/arm/mach-davinci/dm646x.c |  78 +++---
 arch/arm/mach-davinci/include/mach/clock.h |   3 -
 arch/arm/mach-davinci/usb-da8xx.c  |  48 +
 12 files changed, 425 insertions(+), 435 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7888c98..1bd667d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -611,7 +611,7 @@ config ARCH_S3C24XX
 config ARCH_DAVINCI
bool "TI DaVinci"
select ARCH_HAS_HOLES_MEMORYMODEL
-   select CLKDEV_LOOKUP
+   select COMMON_CLK
select CPU_ARM926T
select GENERIC_ALLOCATOR
select GENERIC_CLOCKEVENTS
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index c149b24..0e63d93 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -31,7 +31,7 @@ static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
 static DEFINE_SPINLOCK(clockfw_lock);
 
-void davinci_clk_enable(struct clk *clk)
+void davinci_clk_enable(struct davinci_clk *clk)
 {
if (clk->parent)
davinci_clk_enable(clk->parent);
@@ -44,7 +44,7 @@ void davinci_clk_enable(struct clk *clk)
}
 }
 
-void davinci_clk_disable(struct clk *clk)
+void davinci_clk_disable(struct davinci_clk *clk)
 {
if (WARN_ON(clk->usecount == 0))
return;
@@ -59,7 +59,7 @@ void davinci_clk_disable(struct clk *clk)
davinci_clk_disable(clk->parent);
 }
 
-static int davinci_clk_reset(struct clk *clk, bool reset)
+static int davinci_clk_reset(struct davinci_clk *clk, bool reset)
 {
unsigned long flags;
 
@@ -76,24 +76,29 @@ static int davinci_clk_reset(struct clk *clk, bool reset)
 
 int davinci_clk_reset_assert(struct clk *clk)
 {
-   if (clk == NULL || IS_ERR(clk) || !clk->reset)
+   struct davinci_clk *dclk = to_davinci_clk(__clk_get_hw(clk));
+
+   if (IS_ERR_OR_NULL(dclk) || !dclk->reset)
return -EINVAL;
 
-   return clk->reset(clk, true);
+   return dclk->reset(dclk, true);
 }
 EXPORT_SYMBOL(davinci_clk_reset_assert);
 
 int davinci_clk_reset_deassert(struct clk *clk)
 {
-   if (clk == NULL || IS_ERR(clk) || !clk->reset)
+   struct davinci_clk *dclk = to_davinci_clk(__clk_get_hw(clk));
+
+   if (IS_ERR_OR_NULL(dclk) || !dclk->reset)
return -EINVAL;
 
-   return clk->reset(clk, false);
+   return dclk->reset(dclk, false);
 }
 EXPORT_SYMBOL(davinci_clk_reset_deassert);
 
-int clk_enable(struct clk *clk)
+static int _clk_enable(struct clk_hw *hw)
 {
+   struct davinci_clk *clk = to_davinci_clk(hw);
unsigned long flags;
 
if (!clk)
@@ -107,10 +112,10 @@ int clk_enable(struct clk *clk)
 
return 0;
 }
-EXPORT_SYMBOL(clk_enable);
 
-void clk_disable(struct clk *clk)
+static void _clk_disable(struct clk_hw *hw)
 {
+   struct davinci_clk *clk = to_davinci_clk(hw);
unsigned long flags;
 
if (clk == NULL || IS_ERR(clk))
@@ -120,19 +125,26 @@ void clk_disable(struct clk *clk)
davinci_clk_disable(clk);
spin_unlock_irqrestore(_lock, flags);
 }
-EXPORT_SYMBOL(clk_disable);
 
-unsigned long clk_get_rate(struct clk *clk)
+static unsigned long _clk_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
 {
+   struct davinci_clk *clk = to_davinci_clk(hw);
+
if (clk == NULL || IS_ERR(clk))
return 0;
 
+   if (clk->recalc)
+   return clk->recalc(clk);
+
return clk->rate;
 }
-EXPORT_SYMBOL(clk_get_rate);
 
-long clk_round_rate(struct clk *clk, unsigned long rate)
+static 

[PATCH v1 5/6] ARM: davinci: convert to common clock framework

2017-12-01 Thread David Lechner
This converts the clocks in mach-davinci to the common clock framework.

Most of the patch just involves renaming struct clk to struct davinci_clk.
There is also a struct clk_hw added to provide the bridge between the
existing clock implementation and the common clock framework.

In clock.c:
* The clk_get_parent and clk_set_parent callbacks are dropped because
  all clocks currently (effectively) have a single parent, in which
  case the common clock framework does not want you to implement these
  functions yourself.
* clk_unregister() is dropped because it is not used anywhere in
  mach-davinci.
* EXPORT_SYMBOL() is removed from functions not used outside of
  mach-davinci.

Signed-off-by: David Lechner 
---
 arch/arm/Kconfig   |   2 +-
 arch/arm/mach-davinci/clock.c  | 162 -
 arch/arm/mach-davinci/clock.h  |  40 ---
 arch/arm/mach-davinci/da830.c  | 100 +-
 arch/arm/mach-davinci/da850.c  | 153 +--
 arch/arm/mach-davinci/devices-da8xx.c  |   6 +-
 arch/arm/mach-davinci/dm355.c  |  84 +++
 arch/arm/mach-davinci/dm365.c  | 112 ++--
 arch/arm/mach-davinci/dm644x.c |  72 ++---
 arch/arm/mach-davinci/dm646x.c |  78 +++---
 arch/arm/mach-davinci/include/mach/clock.h |   3 -
 arch/arm/mach-davinci/usb-da8xx.c  |  48 +
 12 files changed, 425 insertions(+), 435 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7888c98..1bd667d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -611,7 +611,7 @@ config ARCH_S3C24XX
 config ARCH_DAVINCI
bool "TI DaVinci"
select ARCH_HAS_HOLES_MEMORYMODEL
-   select CLKDEV_LOOKUP
+   select COMMON_CLK
select CPU_ARM926T
select GENERIC_ALLOCATOR
select GENERIC_CLOCKEVENTS
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index c149b24..0e63d93 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -31,7 +31,7 @@ static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
 static DEFINE_SPINLOCK(clockfw_lock);
 
-void davinci_clk_enable(struct clk *clk)
+void davinci_clk_enable(struct davinci_clk *clk)
 {
if (clk->parent)
davinci_clk_enable(clk->parent);
@@ -44,7 +44,7 @@ void davinci_clk_enable(struct clk *clk)
}
 }
 
-void davinci_clk_disable(struct clk *clk)
+void davinci_clk_disable(struct davinci_clk *clk)
 {
if (WARN_ON(clk->usecount == 0))
return;
@@ -59,7 +59,7 @@ void davinci_clk_disable(struct clk *clk)
davinci_clk_disable(clk->parent);
 }
 
-static int davinci_clk_reset(struct clk *clk, bool reset)
+static int davinci_clk_reset(struct davinci_clk *clk, bool reset)
 {
unsigned long flags;
 
@@ -76,24 +76,29 @@ static int davinci_clk_reset(struct clk *clk, bool reset)
 
 int davinci_clk_reset_assert(struct clk *clk)
 {
-   if (clk == NULL || IS_ERR(clk) || !clk->reset)
+   struct davinci_clk *dclk = to_davinci_clk(__clk_get_hw(clk));
+
+   if (IS_ERR_OR_NULL(dclk) || !dclk->reset)
return -EINVAL;
 
-   return clk->reset(clk, true);
+   return dclk->reset(dclk, true);
 }
 EXPORT_SYMBOL(davinci_clk_reset_assert);
 
 int davinci_clk_reset_deassert(struct clk *clk)
 {
-   if (clk == NULL || IS_ERR(clk) || !clk->reset)
+   struct davinci_clk *dclk = to_davinci_clk(__clk_get_hw(clk));
+
+   if (IS_ERR_OR_NULL(dclk) || !dclk->reset)
return -EINVAL;
 
-   return clk->reset(clk, false);
+   return dclk->reset(dclk, false);
 }
 EXPORT_SYMBOL(davinci_clk_reset_deassert);
 
-int clk_enable(struct clk *clk)
+static int _clk_enable(struct clk_hw *hw)
 {
+   struct davinci_clk *clk = to_davinci_clk(hw);
unsigned long flags;
 
if (!clk)
@@ -107,10 +112,10 @@ int clk_enable(struct clk *clk)
 
return 0;
 }
-EXPORT_SYMBOL(clk_enable);
 
-void clk_disable(struct clk *clk)
+static void _clk_disable(struct clk_hw *hw)
 {
+   struct davinci_clk *clk = to_davinci_clk(hw);
unsigned long flags;
 
if (clk == NULL || IS_ERR(clk))
@@ -120,19 +125,26 @@ void clk_disable(struct clk *clk)
davinci_clk_disable(clk);
spin_unlock_irqrestore(_lock, flags);
 }
-EXPORT_SYMBOL(clk_disable);
 
-unsigned long clk_get_rate(struct clk *clk)
+static unsigned long _clk_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
 {
+   struct davinci_clk *clk = to_davinci_clk(hw);
+
if (clk == NULL || IS_ERR(clk))
return 0;
 
+   if (clk->recalc)
+   return clk->recalc(clk);
+
return clk->rate;
 }
-EXPORT_SYMBOL(clk_get_rate);
 
-long clk_round_rate(struct clk *clk, unsigned long rate)
+static long 

[PATCH v1 0/6] ARM: davinci: convert to common clock framework

2017-12-01 Thread David Lechner
This series takes the first steps towards moving mach-davinci to the common
clock framework.

Basically, this series does some cleanup and rearranging to get things
ready for the conversion. Then in "ARM: davinci: convert to common clock
framework" we actually make the conversion. This is done by just creating
a thin layer around the existing mach clock code.

There is certainly more to be done to make full use of the common clock
framework, but this seems like the smallest logical set of patches to get
CONFIG_COMMON_CLK switched on. Otherwise, I think we would end up with a
series of 20+ patches that would be harder to review.

I have tested this on LEGO MINDSTORMS EV3 (TI AM1808), so I am confident
that I haven't broken anything (too badly) in da850. But, I don't have
other hardware to test.

David Lechner (6):
  ARM: davinci: clean up map_io functions
  ARM: davinci: move davinci_clk_init() to init_time
  ARM: davinci: don't use static clk_lookup
  ARM: davinci: make davinci_clk_reset() static
  ARM: davinci: convert to common clock framework
  ARM: davinci: remove clock debugfs

 arch/arm/Kconfig|   2 +-
 arch/arm/mach-davinci/board-da830-evm.c |   9 +-
 arch/arm/mach-davinci/board-da850-evm.c |   9 +-
 arch/arm/mach-davinci/board-dm355-evm.c |   9 +-
 arch/arm/mach-davinci/board-dm355-leopard.c |   9 +-
 arch/arm/mach-davinci/board-dm365-evm.c |   9 +-
 arch/arm/mach-davinci/board-dm644x-evm.c|  10 +-
 arch/arm/mach-davinci/board-dm646x-evm.c|  18 +-
 arch/arm/mach-davinci/board-mityomapl138.c  |   9 +-
 arch/arm/mach-davinci/board-neuros-osd2.c   |   9 +-
 arch/arm/mach-davinci/board-omapl138-hawk.c |   9 +-
 arch/arm/mach-davinci/board-sffsdr.c|   9 +-
 arch/arm/mach-davinci/clock.c   | 299 +---
 arch/arm/mach-davinci/clock.h   |  48 +++--
 arch/arm/mach-davinci/da830.c   | 217 ++--
 arch/arm/mach-davinci/da850.c   | 292 +--
 arch/arm/mach-davinci/da8xx-dt.c|   4 +-
 arch/arm/mach-davinci/davinci.h |  12 +-
 arch/arm/mach-davinci/devices-da8xx.c   |   9 +-
 arch/arm/mach-davinci/dm355.c   | 184 -
 arch/arm/mach-davinci/dm365.c   | 242 +++---
 arch/arm/mach-davinci/dm644x.c  | 164 +++
 arch/arm/mach-davinci/dm646x.c  | 180 +
 arch/arm/mach-davinci/include/mach/clock.h  |   3 -
 arch/arm/mach-davinci/include/mach/common.h |   1 -
 arch/arm/mach-davinci/include/mach/da8xx.h  |   7 +-
 arch/arm/mach-davinci/time.c|   1 -
 arch/arm/mach-davinci/usb-da8xx.c   |  57 +++---
 28 files changed, 841 insertions(+), 990 deletions(-)

-- 
2.7.4



[PATCH v1 0/6] ARM: davinci: convert to common clock framework

2017-12-01 Thread David Lechner
This series takes the first steps towards moving mach-davinci to the common
clock framework.

Basically, this series does some cleanup and rearranging to get things
ready for the conversion. Then in "ARM: davinci: convert to common clock
framework" we actually make the conversion. This is done by just creating
a thin layer around the existing mach clock code.

There is certainly more to be done to make full use of the common clock
framework, but this seems like the smallest logical set of patches to get
CONFIG_COMMON_CLK switched on. Otherwise, I think we would end up with a
series of 20+ patches that would be harder to review.

I have tested this on LEGO MINDSTORMS EV3 (TI AM1808), so I am confident
that I haven't broken anything (too badly) in da850. But, I don't have
other hardware to test.

David Lechner (6):
  ARM: davinci: clean up map_io functions
  ARM: davinci: move davinci_clk_init() to init_time
  ARM: davinci: don't use static clk_lookup
  ARM: davinci: make davinci_clk_reset() static
  ARM: davinci: convert to common clock framework
  ARM: davinci: remove clock debugfs

 arch/arm/Kconfig|   2 +-
 arch/arm/mach-davinci/board-da830-evm.c |   9 +-
 arch/arm/mach-davinci/board-da850-evm.c |   9 +-
 arch/arm/mach-davinci/board-dm355-evm.c |   9 +-
 arch/arm/mach-davinci/board-dm355-leopard.c |   9 +-
 arch/arm/mach-davinci/board-dm365-evm.c |   9 +-
 arch/arm/mach-davinci/board-dm644x-evm.c|  10 +-
 arch/arm/mach-davinci/board-dm646x-evm.c|  18 +-
 arch/arm/mach-davinci/board-mityomapl138.c  |   9 +-
 arch/arm/mach-davinci/board-neuros-osd2.c   |   9 +-
 arch/arm/mach-davinci/board-omapl138-hawk.c |   9 +-
 arch/arm/mach-davinci/board-sffsdr.c|   9 +-
 arch/arm/mach-davinci/clock.c   | 299 +---
 arch/arm/mach-davinci/clock.h   |  48 +++--
 arch/arm/mach-davinci/da830.c   | 217 ++--
 arch/arm/mach-davinci/da850.c   | 292 +--
 arch/arm/mach-davinci/da8xx-dt.c|   4 +-
 arch/arm/mach-davinci/davinci.h |  12 +-
 arch/arm/mach-davinci/devices-da8xx.c   |   9 +-
 arch/arm/mach-davinci/dm355.c   | 184 -
 arch/arm/mach-davinci/dm365.c   | 242 +++---
 arch/arm/mach-davinci/dm644x.c  | 164 +++
 arch/arm/mach-davinci/dm646x.c  | 180 +
 arch/arm/mach-davinci/include/mach/clock.h  |   3 -
 arch/arm/mach-davinci/include/mach/common.h |   1 -
 arch/arm/mach-davinci/include/mach/da8xx.h  |   7 +-
 arch/arm/mach-davinci/time.c|   1 -
 arch/arm/mach-davinci/usb-da8xx.c   |  57 +++---
 28 files changed, 841 insertions(+), 990 deletions(-)

-- 
2.7.4



Re: [PATCH] compiler, clang: handle randomizable anonymous structs

2017-12-01 Thread Alexei Starovoitov
On Thu, Nov 09, 2017 at 12:16:45PM +0530, Sandipan Das wrote:
> The GCC randomize layout plugin can randomize the member
> offsets of sensitive kernel data structures. To use this
> feature, certain annotations and members are added to the
> structures which affect the member offsets even if this
> plugin is not used.
> 
> All of these structures are completely randomized, except
> for task_struct which leaves out some of its members. All
> the other members are wrapped within an anonymous struct
> with the __randomize_layout attribute. This is done using
> the randomized_struct_fields_start and
> randomized_struct_fields_end defines. When the plugin is
> disabled, the behaviour of this attribute can vary based
> on the GCC version. For GCC 5.1+, this attribute maps to
> __designated_init otherwise it is just an empty define
> but the anonymous structure is still present. For other
> compilers, both randomized_struct_fields_start and
> randomized_struct_fields_end default to empty defines
> meaning the anonymous structure is not introduced at all.
> So, if a module compiled with Clang, such as a BPF program,
> needs to access task_struct fields such as pid and comm,
> the offsets of these members as recognized by Clang are
> different from those recognized by modules compiled with
> GCC. If GCC 4.6+ is used to build the kernel, this can be
> solved by introducing appropriate defines for Clang so
> that the anonymous structure is seen when determining the
> offsets for the members.
> 
> Signed-off-by: Sandipan Das 
> ---
>  include/linux/compiler-clang.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
> index 54dfef70a072..780b1242bf24 100644
> --- a/include/linux/compiler-clang.h
> +++ b/include/linux/compiler-clang.h
> @@ -16,3 +16,6 @@
>   * with any version that can compile the kernel
>   */
>  #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), 
> __COUNTER__)
> +
> +#define randomized_struct_fields_start   struct {
> +#define randomized_struct_fields_end };
> -- 
> 2.13.6

Andrew or Greg,
could you please pull this patch into 4.13 and 4.14 releases as well ?
Sorry we missed the stable tag when submitting it originally.
It is commit 4ca59b14e588 ("include/linux/compiler-clang.h: handle randomizable 
anonymous structs")
Thanks



Re: [PATCH] compiler, clang: handle randomizable anonymous structs

2017-12-01 Thread Alexei Starovoitov
On Thu, Nov 09, 2017 at 12:16:45PM +0530, Sandipan Das wrote:
> The GCC randomize layout plugin can randomize the member
> offsets of sensitive kernel data structures. To use this
> feature, certain annotations and members are added to the
> structures which affect the member offsets even if this
> plugin is not used.
> 
> All of these structures are completely randomized, except
> for task_struct which leaves out some of its members. All
> the other members are wrapped within an anonymous struct
> with the __randomize_layout attribute. This is done using
> the randomized_struct_fields_start and
> randomized_struct_fields_end defines. When the plugin is
> disabled, the behaviour of this attribute can vary based
> on the GCC version. For GCC 5.1+, this attribute maps to
> __designated_init otherwise it is just an empty define
> but the anonymous structure is still present. For other
> compilers, both randomized_struct_fields_start and
> randomized_struct_fields_end default to empty defines
> meaning the anonymous structure is not introduced at all.
> So, if a module compiled with Clang, such as a BPF program,
> needs to access task_struct fields such as pid and comm,
> the offsets of these members as recognized by Clang are
> different from those recognized by modules compiled with
> GCC. If GCC 4.6+ is used to build the kernel, this can be
> solved by introducing appropriate defines for Clang so
> that the anonymous structure is seen when determining the
> offsets for the members.
> 
> Signed-off-by: Sandipan Das 
> ---
>  include/linux/compiler-clang.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
> index 54dfef70a072..780b1242bf24 100644
> --- a/include/linux/compiler-clang.h
> +++ b/include/linux/compiler-clang.h
> @@ -16,3 +16,6 @@
>   * with any version that can compile the kernel
>   */
>  #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), 
> __COUNTER__)
> +
> +#define randomized_struct_fields_start   struct {
> +#define randomized_struct_fields_end };
> -- 
> 2.13.6

Andrew or Greg,
could you please pull this patch into 4.13 and 4.14 releases as well ?
Sorry we missed the stable tag when submitting it originally.
It is commit 4ca59b14e588 ("include/linux/compiler-clang.h: handle randomizable 
anonymous structs")
Thanks



[PATCH] mmap.2: MAP_FIXED is no longer discouraged

2017-12-01 Thread john . hubbard
From: John Hubbard 

MAP_FIXED has been widely used for a very long time, yet the man
page still claims that "the use of this option is discouraged".

The documentation assumes that "less portable" == "must be discouraged".

Instead of discouraging something that is so useful and widely used,
change the documentation to explain its limitations better.

Signed-off-by: John Hubbard 
---
While reviewing Michal Hocko's man page update for MAP_FIXED_SAFE,
I noticed that MAP_FIXED was no longer reflecting the current
situation, so here is a patch to bring it into the year 2017.

 man2/mmap.2 | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/man2/mmap.2 b/man2/mmap.2
index 385f3bfd5..a5a8eb47a 100644
--- a/man2/mmap.2
+++ b/man2/mmap.2
@@ -222,8 +222,10 @@ part of the existing mapping(s) will be discarded.
 If the specified address cannot be used,
 .BR mmap ()
 will fail.
-Because requiring a fixed address for a mapping is less portable,
-the use of this option is discouraged.
+Software that aspires to be portable should use this option with care, keeping
+in mind that the exact layout of a process' memory map is allowed to change
+significantly between kernel versions, C library versions, and operating system
+releases.
 .TP
 .B MAP_GROWSDOWN
 This flag is used for stacks.
-- 
2.15.1



[PATCH] mmap.2: MAP_FIXED is no longer discouraged

2017-12-01 Thread john . hubbard
From: John Hubbard 

MAP_FIXED has been widely used for a very long time, yet the man
page still claims that "the use of this option is discouraged".

The documentation assumes that "less portable" == "must be discouraged".

Instead of discouraging something that is so useful and widely used,
change the documentation to explain its limitations better.

Signed-off-by: John Hubbard 
---
While reviewing Michal Hocko's man page update for MAP_FIXED_SAFE,
I noticed that MAP_FIXED was no longer reflecting the current
situation, so here is a patch to bring it into the year 2017.

 man2/mmap.2 | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/man2/mmap.2 b/man2/mmap.2
index 385f3bfd5..a5a8eb47a 100644
--- a/man2/mmap.2
+++ b/man2/mmap.2
@@ -222,8 +222,10 @@ part of the existing mapping(s) will be discarded.
 If the specified address cannot be used,
 .BR mmap ()
 will fail.
-Because requiring a fixed address for a mapping is less portable,
-the use of this option is discouraged.
+Software that aspires to be portable should use this option with care, keeping
+in mind that the exact layout of a process' memory map is allowed to change
+significantly between kernel versions, C library versions, and operating system
+releases.
 .TP
 .B MAP_GROWSDOWN
 This flag is used for stacks.
-- 
2.15.1



Re: [GIT PULL] RISC-V Cleanups and ABI Fixes for 4.15-rc2

2017-12-01 Thread Palmer Dabbelt

On Fri, 01 Dec 2017 16:47:16 PST (-0800), Linus Torvalds wrote:

On Fri, Dec 1, 2017 at 4:39 PM, Palmer Dabbelt  wrote:


I've been maintaining the various cleanup patch sets I have as their own
branches, which I then merged together and signed.  Each merge commit
has a short summary of the changes, and each branch is based on your
latest tag (4.15-rc1, in this case).  If this isn't the right way to do
this then feel free to suggest something else, but it seems sane to me.


The individual branches with merges look fine.

What I don't really like is how very recent they are. Many of the
commits were done today, and thus clearly were never through the 0-day
robot etc.

I don't actually think the 0day robot does RISC-V at all, at least not
yet, so in this case it probably doesn't really matter, but in general
I _hate_ seeing pull requests that come in on a Friday afternoon where
a lot of the  commits clearly happened that same day. It's simply a
sign of things likely having been rushed, which in turn often leads to
issues down the line.


The 0-day robot doesn't do RISC-V, but we're working on getting better CI 
infrastructure setup now that we're upstream.  Olof has started running builds 
through his builder, which is where many of the fixes came from.  


I think we're probably not quite ready for the 0-day robot yet:
* We still have an allmodconfig failure, but there's a patch out to fix that.
* binutils-2.29.1 and gcc-7.2.0 have a handful of bugs that were found when 
 pushing on Linux, the next releases should have fixes for these.  We have 
 backports, so this might not be a big deal.
* There's no way to boot the kernel in an easy to automated fashion.  Our QEMU 
 port is a WIP, and I currently test our port by swapping SD cards.  This 
 might not be a big deal, since the port as it stands can't do much in the way 
 of a boot test anyway.


I'll ping kbuild-all with a better subject and figure out the right thing to 
do.



So the structure of the history looks ok, but I hope that "very
recently made" is a one-time thing rather than a pattern. Ok?


OK, sorry about that.  It sounds like this is a good excuse to figure out how 
we're going to stage commits in RISC-V land -- I've been a bit unprepared for 
the pace of kernel development on RISC-V, I didn't think I'd see so many people 
poking around in our port so quickly :).


If you'd like, I can let these bake for a few days?  I don't mind if they don't 
get in until rc3.  I can either ping this pull request or send another one, 
whatever's easier for you is OK for me.


Re: [GIT PULL] RISC-V Cleanups and ABI Fixes for 4.15-rc2

2017-12-01 Thread Palmer Dabbelt

On Fri, 01 Dec 2017 16:47:16 PST (-0800), Linus Torvalds wrote:

On Fri, Dec 1, 2017 at 4:39 PM, Palmer Dabbelt  wrote:


I've been maintaining the various cleanup patch sets I have as their own
branches, which I then merged together and signed.  Each merge commit
has a short summary of the changes, and each branch is based on your
latest tag (4.15-rc1, in this case).  If this isn't the right way to do
this then feel free to suggest something else, but it seems sane to me.


The individual branches with merges look fine.

What I don't really like is how very recent they are. Many of the
commits were done today, and thus clearly were never through the 0-day
robot etc.

I don't actually think the 0day robot does RISC-V at all, at least not
yet, so in this case it probably doesn't really matter, but in general
I _hate_ seeing pull requests that come in on a Friday afternoon where
a lot of the  commits clearly happened that same day. It's simply a
sign of things likely having been rushed, which in turn often leads to
issues down the line.


The 0-day robot doesn't do RISC-V, but we're working on getting better CI 
infrastructure setup now that we're upstream.  Olof has started running builds 
through his builder, which is where many of the fixes came from.  


I think we're probably not quite ready for the 0-day robot yet:
* We still have an allmodconfig failure, but there's a patch out to fix that.
* binutils-2.29.1 and gcc-7.2.0 have a handful of bugs that were found when 
 pushing on Linux, the next releases should have fixes for these.  We have 
 backports, so this might not be a big deal.
* There's no way to boot the kernel in an easy to automated fashion.  Our QEMU 
 port is a WIP, and I currently test our port by swapping SD cards.  This 
 might not be a big deal, since the port as it stands can't do much in the way 
 of a boot test anyway.


I'll ping kbuild-all with a better subject and figure out the right thing to 
do.



So the structure of the history looks ok, but I hope that "very
recently made" is a one-time thing rather than a pattern. Ok?


OK, sorry about that.  It sounds like this is a good excuse to figure out how 
we're going to stage commits in RISC-V land -- I've been a bit unprepared for 
the pace of kernel development on RISC-V, I didn't think I'd see so many people 
poking around in our port so quickly :).


If you'd like, I can let these bake for a few days?  I don't mind if they don't 
get in until rc3.  I can either ping this pull request or send another one, 
whatever's easier for you is OK for me.


[PATCH RT 0/9] Linux 4.4.102-rt117-rc1

2017-12-01 Thread Steven Rostedt

Dear RT Folks,

This is the RT stable review cycle of patch 4.4.102-rt117-rc1.

Please scream at me if I messed something up. Please test the patches too.

The -rc release will be uploaded to kernel.org and will be deleted when
the final release is out. This is just a review release (or release candidate).

The pre-releases will not be pushed to the git repository, only the
final release is.

If all goes well, this patch will be converted to the next main release
on 11/5/2017.

Enjoy,

-- Steve


To build 4.4.102-rt117-rc1 directly, the following patches should be applied:

  http://www.kernel.org/pub/linux/kernel/v4.x/linux-4.4.tar.xz

  http://www.kernel.org/pub/linux/kernel/v4.x/patch-4.4.102.xz

  
http://www.kernel.org/pub/linux/kernel/projects/rt/4.4/patch-4.4.102-rt117-rc1.patch.xz

You can also build from 4.4.102-rt116 by applying the incremental patch:

http://www.kernel.org/pub/linux/kernel/projects/rt/4.4/incr/patch-4.4.102-rt116-rt117-rc1.patch.xz


Changes from 4.4.102-rt116:

---


Alex Shi (1):
  cpu_pm: replace raw_notifier to atomic_notifier

Mike Galbraith (1):
  kernel/hrtimer/hotplug: don't wake ktimersoftd while holding the hrtimer 
base lock

Sebastian Andrzej Siewior (6):
  Revert "fs: jbd2: pull your plug when waiting for space"
  kernel/hrtimer: migrate deferred timer on CPU down
  kernel/hrtimer: don't wakeup a process while holding the hrtimer base lock
  Bluetooth: avoid recursive locking in hci_send_to_channel()
  rt/locking: allow recursive local_trylock()
  net: use trylock in icmp_sk

Steven Rostedt (VMware) (1):
  Linux 4.4.102-rt117-rc1


 fs/jbd2/checkpoint.c  |  2 --
 include/linux/locallock.h |  9 +
 kernel/cpu_pm.c   | 43 ++-
 kernel/time/hrtimer.c | 35 ++-
 localversion-rt   |  2 +-
 net/bluetooth/hci_sock.c  | 17 +++--
 net/ipv4/icmp.c   |  6 +-
 7 files changed, 58 insertions(+), 56 deletions(-)


[PATCH RT 0/9] Linux 4.4.102-rt117-rc1

2017-12-01 Thread Steven Rostedt

Dear RT Folks,

This is the RT stable review cycle of patch 4.4.102-rt117-rc1.

Please scream at me if I messed something up. Please test the patches too.

The -rc release will be uploaded to kernel.org and will be deleted when
the final release is out. This is just a review release (or release candidate).

The pre-releases will not be pushed to the git repository, only the
final release is.

If all goes well, this patch will be converted to the next main release
on 11/5/2017.

Enjoy,

-- Steve


To build 4.4.102-rt117-rc1 directly, the following patches should be applied:

  http://www.kernel.org/pub/linux/kernel/v4.x/linux-4.4.tar.xz

  http://www.kernel.org/pub/linux/kernel/v4.x/patch-4.4.102.xz

  
http://www.kernel.org/pub/linux/kernel/projects/rt/4.4/patch-4.4.102-rt117-rc1.patch.xz

You can also build from 4.4.102-rt116 by applying the incremental patch:

http://www.kernel.org/pub/linux/kernel/projects/rt/4.4/incr/patch-4.4.102-rt116-rt117-rc1.patch.xz


Changes from 4.4.102-rt116:

---


Alex Shi (1):
  cpu_pm: replace raw_notifier to atomic_notifier

Mike Galbraith (1):
  kernel/hrtimer/hotplug: don't wake ktimersoftd while holding the hrtimer 
base lock

Sebastian Andrzej Siewior (6):
  Revert "fs: jbd2: pull your plug when waiting for space"
  kernel/hrtimer: migrate deferred timer on CPU down
  kernel/hrtimer: don't wakeup a process while holding the hrtimer base lock
  Bluetooth: avoid recursive locking in hci_send_to_channel()
  rt/locking: allow recursive local_trylock()
  net: use trylock in icmp_sk

Steven Rostedt (VMware) (1):
  Linux 4.4.102-rt117-rc1


 fs/jbd2/checkpoint.c  |  2 --
 include/linux/locallock.h |  9 +
 kernel/cpu_pm.c   | 43 ++-
 kernel/time/hrtimer.c | 35 ++-
 localversion-rt   |  2 +-
 net/bluetooth/hci_sock.c  | 17 +++--
 net/ipv4/icmp.c   |  6 +-
 7 files changed, 58 insertions(+), 56 deletions(-)


[PATCH RT 2/9] cpu_pm: replace raw_notifier to atomic_notifier

2017-12-01 Thread Steven Rostedt
4.4.102-rt117-rc1 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Shi 

This patch replace a rwlock and raw notifier by atomic notifier which
protected by spin_lock and rcu.

The first to reason to have this replace is due to a 'scheduling while
 atomic' bug of RT kernel on arm/arm64 platform. On arm/arm64, rwlock
cpu_pm_notifier_lock in cpu_pm cause a potential schedule after irq
disable in idle call chain:

cpu_startup_entry
  cpu_idle_loop
local_irq_disable()
cpuidle_idle_call
  call_cpuidle
cpuidle_enter
  cpuidle_enter_state
->enter :arm_enter_idle_state
  cpu_pm_enter/exit
CPU_PM_CPU_IDLE_ENTER
  read_lock(_pm_notifier_lock); <-- sleep in idle
 __rt_spin_lock();
schedule();

The kernel panic is here:
[4.609601] BUG: scheduling while atomic: swapper/1/0/0x0002
[4.609608] [] arm_enter_idle_state+0x18/0x70
[4.609614] Modules linked in:
[4.609615] [] cpuidle_enter_state+0xf0/0x218
[4.609620] [] cpuidle_enter+0x18/0x20
[4.609626] Preemption disabled at:
[4.609627] [] call_cpuidle+0x24/0x40
[4.609635] [] schedule_preempt_disabled+0x1c/0x28
[4.609639] [] cpu_startup_entry+0x154/0x1f8
[4.609645] [] secondary_start_kernel+0x15c/0x1a0

Daniel Lezcano said this notification is needed on arm/arm64 platforms.
Sebastian suggested using atomic_notifier instead of rwlock, which is not
only removing the sleeping in idle, but also getting better latency
improvement.

This patch passed Fengguang's 0day testing.

Signed-off-by: Alex Shi 
Cc: Sebastian Andrzej Siewior 
Cc: Thomas Gleixner 
Cc: Anders Roxell 
Cc: Rik van Riel 
Cc: Steven Rostedt 
Cc: Rafael J. Wysocki 
Cc: Daniel Lezcano 
Cc: linux-rt-users 
Signed-off-by: Sebastian Andrzej Siewior 
---
 kernel/cpu_pm.c | 43 ++-
 1 file changed, 6 insertions(+), 37 deletions(-)

diff --git a/kernel/cpu_pm.c b/kernel/cpu_pm.c
index 009cc9a17d95..10f4640f991e 100644
--- a/kernel/cpu_pm.c
+++ b/kernel/cpu_pm.c
@@ -22,14 +22,13 @@
 #include 
 #include 
 
-static DEFINE_RWLOCK(cpu_pm_notifier_lock);
-static RAW_NOTIFIER_HEAD(cpu_pm_notifier_chain);
+static ATOMIC_NOTIFIER_HEAD(cpu_pm_notifier_chain);
 
 static int cpu_pm_notify(enum cpu_pm_event event, int nr_to_call, int 
*nr_calls)
 {
int ret;
 
-   ret = __raw_notifier_call_chain(_pm_notifier_chain, event, NULL,
+   ret = __atomic_notifier_call_chain(_pm_notifier_chain, event, NULL,
nr_to_call, nr_calls);
 
return notifier_to_errno(ret);
@@ -47,14 +46,7 @@ static int cpu_pm_notify(enum cpu_pm_event event, int 
nr_to_call, int *nr_calls)
  */
 int cpu_pm_register_notifier(struct notifier_block *nb)
 {
-   unsigned long flags;
-   int ret;
-
-   write_lock_irqsave(_pm_notifier_lock, flags);
-   ret = raw_notifier_chain_register(_pm_notifier_chain, nb);
-   write_unlock_irqrestore(_pm_notifier_lock, flags);
-
-   return ret;
+   return atomic_notifier_chain_register(_pm_notifier_chain, nb);
 }
 EXPORT_SYMBOL_GPL(cpu_pm_register_notifier);
 
@@ -69,14 +61,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_register_notifier);
  */
 int cpu_pm_unregister_notifier(struct notifier_block *nb)
 {
-   unsigned long flags;
-   int ret;
-
-   write_lock_irqsave(_pm_notifier_lock, flags);
-   ret = raw_notifier_chain_unregister(_pm_notifier_chain, nb);
-   write_unlock_irqrestore(_pm_notifier_lock, flags);
-
-   return ret;
+   return atomic_notifier_chain_unregister(_pm_notifier_chain, nb);
 }
 EXPORT_SYMBOL_GPL(cpu_pm_unregister_notifier);
 
@@ -100,7 +85,6 @@ int cpu_pm_enter(void)
int nr_calls;
int ret = 0;
 
-   read_lock(_pm_notifier_lock);
ret = cpu_pm_notify(CPU_PM_ENTER, -1, _calls);
if (ret)
/*
@@ -108,7 +92,6 @@ int cpu_pm_enter(void)
 * PM entry who are notified earlier to prepare for it.
 */
cpu_pm_notify(CPU_PM_ENTER_FAILED, nr_calls - 1, NULL);
-   read_unlock(_pm_notifier_lock);
 
return ret;
 }
@@ -128,13 +111,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_enter);
  */
 int cpu_pm_exit(void)
 {
-   int ret;
-
-   read_lock(_pm_notifier_lock);
-   ret = cpu_pm_notify(CPU_PM_EXIT, -1, NULL);
-   read_unlock(_pm_notifier_lock);
-
-   return ret;
+   return cpu_pm_notify(CPU_PM_EXIT, -1, NULL);
 }
 EXPORT_SYMBOL_GPL(cpu_pm_exit);
 
@@ -159,7 +136,6 @@ int cpu_cluster_pm_enter(void)
int nr_calls;
int ret = 0;
 
-   read_lock(_pm_notifier_lock);
ret = cpu_pm_notify(CPU_CLUSTER_PM_ENTER, -1, 

[PATCH RT 2/9] cpu_pm: replace raw_notifier to atomic_notifier

2017-12-01 Thread Steven Rostedt
4.4.102-rt117-rc1 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Shi 

This patch replace a rwlock and raw notifier by atomic notifier which
protected by spin_lock and rcu.

The first to reason to have this replace is due to a 'scheduling while
 atomic' bug of RT kernel on arm/arm64 platform. On arm/arm64, rwlock
cpu_pm_notifier_lock in cpu_pm cause a potential schedule after irq
disable in idle call chain:

cpu_startup_entry
  cpu_idle_loop
local_irq_disable()
cpuidle_idle_call
  call_cpuidle
cpuidle_enter
  cpuidle_enter_state
->enter :arm_enter_idle_state
  cpu_pm_enter/exit
CPU_PM_CPU_IDLE_ENTER
  read_lock(_pm_notifier_lock); <-- sleep in idle
 __rt_spin_lock();
schedule();

The kernel panic is here:
[4.609601] BUG: scheduling while atomic: swapper/1/0/0x0002
[4.609608] [] arm_enter_idle_state+0x18/0x70
[4.609614] Modules linked in:
[4.609615] [] cpuidle_enter_state+0xf0/0x218
[4.609620] [] cpuidle_enter+0x18/0x20
[4.609626] Preemption disabled at:
[4.609627] [] call_cpuidle+0x24/0x40
[4.609635] [] schedule_preempt_disabled+0x1c/0x28
[4.609639] [] cpu_startup_entry+0x154/0x1f8
[4.609645] [] secondary_start_kernel+0x15c/0x1a0

Daniel Lezcano said this notification is needed on arm/arm64 platforms.
Sebastian suggested using atomic_notifier instead of rwlock, which is not
only removing the sleeping in idle, but also getting better latency
improvement.

This patch passed Fengguang's 0day testing.

Signed-off-by: Alex Shi 
Cc: Sebastian Andrzej Siewior 
Cc: Thomas Gleixner 
Cc: Anders Roxell 
Cc: Rik van Riel 
Cc: Steven Rostedt 
Cc: Rafael J. Wysocki 
Cc: Daniel Lezcano 
Cc: linux-rt-users 
Signed-off-by: Sebastian Andrzej Siewior 
---
 kernel/cpu_pm.c | 43 ++-
 1 file changed, 6 insertions(+), 37 deletions(-)

diff --git a/kernel/cpu_pm.c b/kernel/cpu_pm.c
index 009cc9a17d95..10f4640f991e 100644
--- a/kernel/cpu_pm.c
+++ b/kernel/cpu_pm.c
@@ -22,14 +22,13 @@
 #include 
 #include 
 
-static DEFINE_RWLOCK(cpu_pm_notifier_lock);
-static RAW_NOTIFIER_HEAD(cpu_pm_notifier_chain);
+static ATOMIC_NOTIFIER_HEAD(cpu_pm_notifier_chain);
 
 static int cpu_pm_notify(enum cpu_pm_event event, int nr_to_call, int 
*nr_calls)
 {
int ret;
 
-   ret = __raw_notifier_call_chain(_pm_notifier_chain, event, NULL,
+   ret = __atomic_notifier_call_chain(_pm_notifier_chain, event, NULL,
nr_to_call, nr_calls);
 
return notifier_to_errno(ret);
@@ -47,14 +46,7 @@ static int cpu_pm_notify(enum cpu_pm_event event, int 
nr_to_call, int *nr_calls)
  */
 int cpu_pm_register_notifier(struct notifier_block *nb)
 {
-   unsigned long flags;
-   int ret;
-
-   write_lock_irqsave(_pm_notifier_lock, flags);
-   ret = raw_notifier_chain_register(_pm_notifier_chain, nb);
-   write_unlock_irqrestore(_pm_notifier_lock, flags);
-
-   return ret;
+   return atomic_notifier_chain_register(_pm_notifier_chain, nb);
 }
 EXPORT_SYMBOL_GPL(cpu_pm_register_notifier);
 
@@ -69,14 +61,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_register_notifier);
  */
 int cpu_pm_unregister_notifier(struct notifier_block *nb)
 {
-   unsigned long flags;
-   int ret;
-
-   write_lock_irqsave(_pm_notifier_lock, flags);
-   ret = raw_notifier_chain_unregister(_pm_notifier_chain, nb);
-   write_unlock_irqrestore(_pm_notifier_lock, flags);
-
-   return ret;
+   return atomic_notifier_chain_unregister(_pm_notifier_chain, nb);
 }
 EXPORT_SYMBOL_GPL(cpu_pm_unregister_notifier);
 
@@ -100,7 +85,6 @@ int cpu_pm_enter(void)
int nr_calls;
int ret = 0;
 
-   read_lock(_pm_notifier_lock);
ret = cpu_pm_notify(CPU_PM_ENTER, -1, _calls);
if (ret)
/*
@@ -108,7 +92,6 @@ int cpu_pm_enter(void)
 * PM entry who are notified earlier to prepare for it.
 */
cpu_pm_notify(CPU_PM_ENTER_FAILED, nr_calls - 1, NULL);
-   read_unlock(_pm_notifier_lock);
 
return ret;
 }
@@ -128,13 +111,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_enter);
  */
 int cpu_pm_exit(void)
 {
-   int ret;
-
-   read_lock(_pm_notifier_lock);
-   ret = cpu_pm_notify(CPU_PM_EXIT, -1, NULL);
-   read_unlock(_pm_notifier_lock);
-
-   return ret;
+   return cpu_pm_notify(CPU_PM_EXIT, -1, NULL);
 }
 EXPORT_SYMBOL_GPL(cpu_pm_exit);
 
@@ -159,7 +136,6 @@ int cpu_cluster_pm_enter(void)
int nr_calls;
int ret = 0;
 
-   read_lock(_pm_notifier_lock);
ret = cpu_pm_notify(CPU_CLUSTER_PM_ENTER, -1, _calls);
if (ret)
/*
@@ -167,7 +143,6 @@ int cpu_cluster_pm_enter(void)
 * PM entry who are notified earlier to prepare for it.
 */
cpu_pm_notify(CPU_CLUSTER_PM_ENTER_FAILED, nr_calls - 1, 

[PATCH RT 3/9] kernel/hrtimer: migrate deferred timer on CPU down

2017-12-01 Thread Steven Rostedt
4.4.102-rt117-rc1 stable review patch.
If anyone has any objections, please let me know.

--

From: Sebastian Andrzej Siewior 

hrtimers, which were deferred to the softirq context, and expire between
softirq shutdown and hrtimer migration are dangling around. If the CPU
goes back up the list head will be initialized and this corrupts the
timer's list. It will remain unnoticed until a hrtimer_cancel().
This moves those timers so they will expire.

Cc: stable...@vger.kernel.org
Reported-by: Mike Galbraith 
Tested-by: Mike Galbraith 
Signed-off-by: Sebastian Andrzej Siewior 
---
 kernel/time/hrtimer.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index ba3d60144838..759913626eec 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1880,6 +1880,11 @@ static void migrate_hrtimer_list(struct 
hrtimer_clock_base *old_base,
 */
enqueue_hrtimer(timer, new_base);
}
+#ifdef CONFIG_PREEMPT_RT_BASE
+   list_splice_tail(_base->expired, _base->expired);
+   if (!list_empty(_base->expired))
+   raise_softirq_irqoff(HRTIMER_SOFTIRQ);
+#endif
 }
 
 static void migrate_hrtimers(int scpu)
-- 
2.13.2




[PATCH v3] staging: xgifb: remove macros with hidden variable

2017-12-01 Thread Joshua Abraham
This patch removes macros in XGI_main.h that contain a xgifb_info
variable.  These macros hurt readability by hiding said variable
behind a define.  It also uses a temporary variable to keep the
replaced code from getting too long.

Signed-off-by: Joshua Abraham 
---
 drivers/staging/xgifb/XGI_main.h|  13 ---
 drivers/staging/xgifb/XGI_main_26.c | 223 +++-
 2 files changed, 118 insertions(+), 118 deletions(-)

diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h
index a3af1cbbf8ee..e19a8291cb2a 100644
--- a/drivers/staging/xgifb/XGI_main.h
+++ b/drivers/staging/xgifb/XGI_main.h
@@ -18,19 +18,6 @@ static const struct pci_device_id xgifb_pci_table[] = {
 
 MODULE_DEVICE_TABLE(pci, xgifb_pci_table);
 
-/* To be included in fb.h */
-#define XGISR(xgifb_info->dev_info.P3c4)
-#define XGICR(xgifb_info->dev_info.P3d4)
-#define XGIDACA  (xgifb_info->dev_info.P3c8)
-#define XGIDACD  (xgifb_info->dev_info.P3c9)
-#define XGIPART1 (xgifb_info->dev_info.Part1Port)
-#define XGIPART2 (xgifb_info->dev_info.Part2Port)
-#define XGIPART3 (xgifb_info->dev_info.Part3Port)
-#define XGIPART4 (xgifb_info->dev_info.Part4Port)
-#define XGIPART5 (xgifb_info->dev_info.Part5Port)
-#define XGIDAC2A  XGIPART5
-#define XGIDAC2D  (XGIPART5 + 1)
-
 #define IND_XGI_SCRATCH_REG_CR30  0x30  /* CRs */
 #define IND_XGI_SCRATCH_REG_CR31  0x31
 #define IND_XGI_SCRATCH_REG_CR32  0x32
diff --git a/drivers/staging/xgifb/XGI_main_26.c 
b/drivers/staging/xgifb/XGI_main_26.c
index 6feecc55d2bc..10107de0119a 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -32,18 +32,19 @@ static unsigned int refresh_rate;
 #ifdef DEBUG
 static void dumpVGAReg(struct xgifb_video_info *xgifb_info)
 {
+   struct vb_device_info *vb = _info->dev_info;
u8 i, reg;
 
-   xgifb_reg_set(XGISR, 0x05, 0x86);
+   xgifb_reg_set(vb->P3c4, 0x05, 0x86);
 
for (i = 0; i < 0x4f; i++) {
-   reg = xgifb_reg_get(XGISR, i);
+   reg = xgifb_reg_get(vb->P3c4, i);
pr_debug("o 3c4 %x\n", i);
pr_debug("i 3c5 => %x\n", reg);
}
 
for (i = 0; i < 0xF0; i++) {
-   reg = xgifb_reg_get(XGICR, i);
+   reg = xgifb_reg_get(vb->P3d4, i);
pr_debug("o 3d4 %x\n", i);
pr_debug("i 3d5 => %x\n", reg);
}
@@ -645,9 +646,10 @@ static void XGIfb_bpp_to_var(struct xgifb_video_info 
*xgifb_info,
 
 static void XGIfb_pre_setmode(struct xgifb_video_info *xgifb_info)
 {
+   struct vb_device_info *vb = _info->dev_info;
u8 cr30 = 0, cr31 = 0;
 
-   cr31 = xgifb_reg_get(XGICR, 0x31);
+   cr31 = xgifb_reg_get(vb->P3d4, 0x31);
cr31 &= ~0x60;
 
switch (xgifb_info->display2) {
@@ -684,14 +686,15 @@ static void XGIfb_pre_setmode(struct xgifb_video_info 
*xgifb_info)
cr31 |= (SIS_DRIVER_MODE | SIS_VB_OUTPUT_DISABLE);
}
 
-   xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR30, cr30);
-   xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR31, cr31);
-   xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR33,
+   xgifb_reg_set(vb->P3d4, IND_XGI_SCRATCH_REG_CR30, cr30);
+   xgifb_reg_set(vb->P3d4, IND_XGI_SCRATCH_REG_CR31, cr31);
+   xgifb_reg_set(vb->P3d4, IND_XGI_SCRATCH_REG_CR33,
  (xgifb_info->rate_idx & 0x0F));
 }
 
 static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info)
 {
+   struct vb_device_info *vb = _info->dev_info;
u8 reg;
unsigned char doit = 1;
 
@@ -714,7 +717,7 @@ static void XGIfb_post_setmode(struct xgifb_video_info 
*xgifb_info)
 
/* We can't switch off CRT1 if bridge is in slave mode */
if (xgifb_info->hasVB != HASVB_NONE) {
-   reg = xgifb_reg_get(XGIPART1, 0x00);
+   reg = xgifb_reg_get(vb->Part1Port, 0x00);
 
if ((reg & 0x50) == 0x10)
doit = 0;
@@ -723,18 +726,18 @@ static void XGIfb_post_setmode(struct xgifb_video_info 
*xgifb_info)
XGIfb_crt1off = 0;
}
 
-   reg = xgifb_reg_get(XGICR, 0x17);
+   reg = xgifb_reg_get(vb->P3d4, 0x17);
if ((XGIfb_crt1off) && (doit))
reg &= ~0x80;
else
reg |= 0x80;
-   xgifb_reg_set(XGICR, 0x17, reg);
+   xgifb_reg_set(vb->P3d4, 0x17, reg);
 
-   xgifb_reg_and(XGISR, IND_SIS_RAMDAC_CONTROL, ~0x04);
+   xgifb_reg_and(vb->P3c4, IND_SIS_RAMDAC_CONTROL, ~0x04);
 
if (xgifb_info->display2 == XGIFB_DISP_TV &&
xgifb_info->hasVB == HASVB_301) {
-   reg = xgifb_reg_get(XGIPART4, 0x01);
+   reg = xgifb_reg_get(vb->Part4Port, 0x01);
 
if (reg < 0xB0) { /* Set 

[PATCH RT 3/9] kernel/hrtimer: migrate deferred timer on CPU down

2017-12-01 Thread Steven Rostedt
4.4.102-rt117-rc1 stable review patch.
If anyone has any objections, please let me know.

--

From: Sebastian Andrzej Siewior 

hrtimers, which were deferred to the softirq context, and expire between
softirq shutdown and hrtimer migration are dangling around. If the CPU
goes back up the list head will be initialized and this corrupts the
timer's list. It will remain unnoticed until a hrtimer_cancel().
This moves those timers so they will expire.

Cc: stable...@vger.kernel.org
Reported-by: Mike Galbraith 
Tested-by: Mike Galbraith 
Signed-off-by: Sebastian Andrzej Siewior 
---
 kernel/time/hrtimer.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index ba3d60144838..759913626eec 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1880,6 +1880,11 @@ static void migrate_hrtimer_list(struct 
hrtimer_clock_base *old_base,
 */
enqueue_hrtimer(timer, new_base);
}
+#ifdef CONFIG_PREEMPT_RT_BASE
+   list_splice_tail(_base->expired, _base->expired);
+   if (!list_empty(_base->expired))
+   raise_softirq_irqoff(HRTIMER_SOFTIRQ);
+#endif
 }
 
 static void migrate_hrtimers(int scpu)
-- 
2.13.2




[PATCH v3] staging: xgifb: remove macros with hidden variable

2017-12-01 Thread Joshua Abraham
This patch removes macros in XGI_main.h that contain a xgifb_info
variable.  These macros hurt readability by hiding said variable
behind a define.  It also uses a temporary variable to keep the
replaced code from getting too long.

Signed-off-by: Joshua Abraham 
---
 drivers/staging/xgifb/XGI_main.h|  13 ---
 drivers/staging/xgifb/XGI_main_26.c | 223 +++-
 2 files changed, 118 insertions(+), 118 deletions(-)

diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h
index a3af1cbbf8ee..e19a8291cb2a 100644
--- a/drivers/staging/xgifb/XGI_main.h
+++ b/drivers/staging/xgifb/XGI_main.h
@@ -18,19 +18,6 @@ static const struct pci_device_id xgifb_pci_table[] = {
 
 MODULE_DEVICE_TABLE(pci, xgifb_pci_table);
 
-/* To be included in fb.h */
-#define XGISR(xgifb_info->dev_info.P3c4)
-#define XGICR(xgifb_info->dev_info.P3d4)
-#define XGIDACA  (xgifb_info->dev_info.P3c8)
-#define XGIDACD  (xgifb_info->dev_info.P3c9)
-#define XGIPART1 (xgifb_info->dev_info.Part1Port)
-#define XGIPART2 (xgifb_info->dev_info.Part2Port)
-#define XGIPART3 (xgifb_info->dev_info.Part3Port)
-#define XGIPART4 (xgifb_info->dev_info.Part4Port)
-#define XGIPART5 (xgifb_info->dev_info.Part5Port)
-#define XGIDAC2A  XGIPART5
-#define XGIDAC2D  (XGIPART5 + 1)
-
 #define IND_XGI_SCRATCH_REG_CR30  0x30  /* CRs */
 #define IND_XGI_SCRATCH_REG_CR31  0x31
 #define IND_XGI_SCRATCH_REG_CR32  0x32
diff --git a/drivers/staging/xgifb/XGI_main_26.c 
b/drivers/staging/xgifb/XGI_main_26.c
index 6feecc55d2bc..10107de0119a 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -32,18 +32,19 @@ static unsigned int refresh_rate;
 #ifdef DEBUG
 static void dumpVGAReg(struct xgifb_video_info *xgifb_info)
 {
+   struct vb_device_info *vb = _info->dev_info;
u8 i, reg;
 
-   xgifb_reg_set(XGISR, 0x05, 0x86);
+   xgifb_reg_set(vb->P3c4, 0x05, 0x86);
 
for (i = 0; i < 0x4f; i++) {
-   reg = xgifb_reg_get(XGISR, i);
+   reg = xgifb_reg_get(vb->P3c4, i);
pr_debug("o 3c4 %x\n", i);
pr_debug("i 3c5 => %x\n", reg);
}
 
for (i = 0; i < 0xF0; i++) {
-   reg = xgifb_reg_get(XGICR, i);
+   reg = xgifb_reg_get(vb->P3d4, i);
pr_debug("o 3d4 %x\n", i);
pr_debug("i 3d5 => %x\n", reg);
}
@@ -645,9 +646,10 @@ static void XGIfb_bpp_to_var(struct xgifb_video_info 
*xgifb_info,
 
 static void XGIfb_pre_setmode(struct xgifb_video_info *xgifb_info)
 {
+   struct vb_device_info *vb = _info->dev_info;
u8 cr30 = 0, cr31 = 0;
 
-   cr31 = xgifb_reg_get(XGICR, 0x31);
+   cr31 = xgifb_reg_get(vb->P3d4, 0x31);
cr31 &= ~0x60;
 
switch (xgifb_info->display2) {
@@ -684,14 +686,15 @@ static void XGIfb_pre_setmode(struct xgifb_video_info 
*xgifb_info)
cr31 |= (SIS_DRIVER_MODE | SIS_VB_OUTPUT_DISABLE);
}
 
-   xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR30, cr30);
-   xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR31, cr31);
-   xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR33,
+   xgifb_reg_set(vb->P3d4, IND_XGI_SCRATCH_REG_CR30, cr30);
+   xgifb_reg_set(vb->P3d4, IND_XGI_SCRATCH_REG_CR31, cr31);
+   xgifb_reg_set(vb->P3d4, IND_XGI_SCRATCH_REG_CR33,
  (xgifb_info->rate_idx & 0x0F));
 }
 
 static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info)
 {
+   struct vb_device_info *vb = _info->dev_info;
u8 reg;
unsigned char doit = 1;
 
@@ -714,7 +717,7 @@ static void XGIfb_post_setmode(struct xgifb_video_info 
*xgifb_info)
 
/* We can't switch off CRT1 if bridge is in slave mode */
if (xgifb_info->hasVB != HASVB_NONE) {
-   reg = xgifb_reg_get(XGIPART1, 0x00);
+   reg = xgifb_reg_get(vb->Part1Port, 0x00);
 
if ((reg & 0x50) == 0x10)
doit = 0;
@@ -723,18 +726,18 @@ static void XGIfb_post_setmode(struct xgifb_video_info 
*xgifb_info)
XGIfb_crt1off = 0;
}
 
-   reg = xgifb_reg_get(XGICR, 0x17);
+   reg = xgifb_reg_get(vb->P3d4, 0x17);
if ((XGIfb_crt1off) && (doit))
reg &= ~0x80;
else
reg |= 0x80;
-   xgifb_reg_set(XGICR, 0x17, reg);
+   xgifb_reg_set(vb->P3d4, 0x17, reg);
 
-   xgifb_reg_and(XGISR, IND_SIS_RAMDAC_CONTROL, ~0x04);
+   xgifb_reg_and(vb->P3c4, IND_SIS_RAMDAC_CONTROL, ~0x04);
 
if (xgifb_info->display2 == XGIFB_DISP_TV &&
xgifb_info->hasVB == HASVB_301) {
-   reg = xgifb_reg_get(XGIPART4, 0x01);
+   reg = xgifb_reg_get(vb->Part4Port, 0x01);
 
if (reg < 0xB0) { /* Set filter for XGI301 */

[PATCH RT 1/9] Revert "fs: jbd2: pull your plug when waiting for space"

2017-12-01 Thread Steven Rostedt
4.4.102-rt117-rc1 stable review patch.
If anyone has any objections, please let me know.

--

From: Sebastian Andrzej Siewior 

This reverts commit "fs: jbd2: pull your plug when waiting for space".
This was a duct-tape fix which shouldn't be needed since commit
"locking/rt-mutex: fix deadlock in device mapper / block-IO".

Cc: stable...@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior 
Signed-off-by: Steven Rostedt (VMware) 
---
 fs/jbd2/checkpoint.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
index 6e18a06aaabe..684996c8a3a4 100644
--- a/fs/jbd2/checkpoint.c
+++ b/fs/jbd2/checkpoint.c
@@ -116,8 +116,6 @@ void __jbd2_log_wait_for_space(journal_t *journal)
nblocks = jbd2_space_needed(journal);
while (jbd2_log_space_left(journal) < nblocks) {
write_unlock(>j_state_lock);
-   if (current->plug)
-   io_schedule();
mutex_lock(>j_checkpoint_mutex);
 
/*
-- 
2.13.2




[PATCH RT 4/9] kernel/hrtimer: dont wakeup a process while holding the hrtimer base lock

2017-12-01 Thread Steven Rostedt
4.4.102-rt117-rc1 stable review patch.
If anyone has any objections, please let me know.

--

From: Sebastian Andrzej Siewior 

We must not wake any process (and thus acquire the pi->lock) while
holding the hrtimer's base lock. This does not happen usually because
the hrtimer-callback is invoked in IRQ-context and so
raise_softirq_irqoff() does not wakeup a process.
However during CPU-hotplug it might get called from hrtimers_dead_cpu()
which would wakeup the thread immediately.

Reported-by: Mike Galbraith 
Signed-off-by: Sebastian Andrzej Siewior 
---
 kernel/time/hrtimer.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 759913626eec..78066f7ea2a2 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1461,7 +1461,7 @@ static inline int hrtimer_rt_defer(struct hrtimer *timer) 
{ return 0; }
 
 static enum hrtimer_restart hrtimer_wakeup(struct hrtimer *timer);
 
-static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t 
now)
+static int __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now)
 {
struct hrtimer_clock_base *base = cpu_base->clock_base;
unsigned int active = cpu_base->active_bases;
@@ -1511,8 +1511,7 @@ static void __hrtimer_run_queues(struct hrtimer_cpu_base 
*cpu_base, ktime_t now)
raise = 1;
}
}
-   if (raise)
-   raise_softirq_irqoff(HRTIMER_SOFTIRQ);
+   return raise;
 }
 
 #ifdef CONFIG_HIGH_RES_TIMERS
@@ -1526,6 +1525,7 @@ void hrtimer_interrupt(struct clock_event_device *dev)
struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(_bases);
ktime_t expires_next, now, entry_time, delta;
int retries = 0;
+   int raise;
 
BUG_ON(!cpu_base->hres_active);
cpu_base->nr_events++;
@@ -1544,7 +1544,7 @@ retry:
 */
cpu_base->expires_next.tv64 = KTIME_MAX;
 
-   __hrtimer_run_queues(cpu_base, now);
+   raise = __hrtimer_run_queues(cpu_base, now);
 
/* Reevaluate the clock bases for the next expiry */
expires_next = __hrtimer_get_next_event(cpu_base);
@@ -1555,6 +1555,8 @@ retry:
cpu_base->expires_next = expires_next;
cpu_base->in_hrtirq = 0;
raw_spin_unlock(_base->lock);
+   if (raise)
+   raise_softirq_irqoff(HRTIMER_SOFTIRQ);
 
/* Reprogramming necessary ? */
if (!tick_program_event(expires_next, 0)) {
@@ -1634,6 +1636,7 @@ void hrtimer_run_queues(void)
 {
struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(_bases);
ktime_t now;
+   int raise;
 
if (__hrtimer_hres_active(cpu_base))
return;
@@ -1652,8 +1655,10 @@ void hrtimer_run_queues(void)
 
raw_spin_lock(_base->lock);
now = hrtimer_update_base(cpu_base);
-   __hrtimer_run_queues(cpu_base, now);
+   raise = __hrtimer_run_queues(cpu_base, now);
raw_spin_unlock(_base->lock);
+   if (raise)
+   raise_softirq_irqoff(HRTIMER_SOFTIRQ);
 }
 
 /*
-- 
2.13.2




[PATCH RT 5/9] kernel/hrtimer/hotplug: dont wake ktimersoftd while holding the hrtimer base lock

2017-12-01 Thread Steven Rostedt
4.4.102-rt117-rc1 stable review patch.
If anyone has any objections, please let me know.

--

From: Mike Galbraith 

kernel/hrtimer: don't wakeup a process while holding the hrtimer base lock
missed a path, namely hrtimers_dead_cpu() -> migrate_hrtimer_list().  Defer
raising softirq until after base lock has been released there as well.

Signed-off-by: Mike Galbraith 
Signed-off-by: Sebastian Andrzej Siewior 
---
 kernel/time/hrtimer.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 78066f7ea2a2..120fc8932165 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1857,7 +1857,7 @@ static void init_hrtimers_cpu(int cpu)
 
 #ifdef CONFIG_HOTPLUG_CPU
 
-static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base,
+static int migrate_hrtimer_list(struct hrtimer_clock_base *old_base,
struct hrtimer_clock_base *new_base)
 {
struct hrtimer *timer;
@@ -1887,15 +1887,19 @@ static void migrate_hrtimer_list(struct 
hrtimer_clock_base *old_base,
}
 #ifdef CONFIG_PREEMPT_RT_BASE
list_splice_tail(_base->expired, _base->expired);
-   if (!list_empty(_base->expired))
-   raise_softirq_irqoff(HRTIMER_SOFTIRQ);
+   /*
+* Tell the caller to raise HRTIMER_SOFTIRQ.  We can't safely
+* acquire ktimersoftd->pi_lock while the base lock is held.
+*/
+   return !list_empty(_base->expired);
 #endif
+   return 0;
 }
 
 static void migrate_hrtimers(int scpu)
 {
struct hrtimer_cpu_base *old_base, *new_base;
-   int i;
+   int i, raise = 0;
 
BUG_ON(cpu_online(scpu));
tick_cancel_sched_timer(scpu);
@@ -1911,13 +1915,16 @@ static void migrate_hrtimers(int scpu)
raw_spin_lock_nested(_base->lock, SINGLE_DEPTH_NESTING);
 
for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
-   migrate_hrtimer_list(_base->clock_base[i],
-_base->clock_base[i]);
+   raise |= migrate_hrtimer_list(_base->clock_base[i],
+ _base->clock_base[i]);
}
 
raw_spin_unlock(_base->lock);
raw_spin_unlock(_base->lock);
 
+   if (raise)
+   raise_softirq_irqoff(HRTIMER_SOFTIRQ);
+
/* Check, if we got expired work to do */
__hrtimer_peek_ahead_timers();
local_irq_enable();
-- 
2.13.2




[PATCH RT 4/9] kernel/hrtimer: dont wakeup a process while holding the hrtimer base lock

2017-12-01 Thread Steven Rostedt
4.4.102-rt117-rc1 stable review patch.
If anyone has any objections, please let me know.

--

From: Sebastian Andrzej Siewior 

We must not wake any process (and thus acquire the pi->lock) while
holding the hrtimer's base lock. This does not happen usually because
the hrtimer-callback is invoked in IRQ-context and so
raise_softirq_irqoff() does not wakeup a process.
However during CPU-hotplug it might get called from hrtimers_dead_cpu()
which would wakeup the thread immediately.

Reported-by: Mike Galbraith 
Signed-off-by: Sebastian Andrzej Siewior 
---
 kernel/time/hrtimer.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 759913626eec..78066f7ea2a2 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1461,7 +1461,7 @@ static inline int hrtimer_rt_defer(struct hrtimer *timer) 
{ return 0; }
 
 static enum hrtimer_restart hrtimer_wakeup(struct hrtimer *timer);
 
-static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t 
now)
+static int __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now)
 {
struct hrtimer_clock_base *base = cpu_base->clock_base;
unsigned int active = cpu_base->active_bases;
@@ -1511,8 +1511,7 @@ static void __hrtimer_run_queues(struct hrtimer_cpu_base 
*cpu_base, ktime_t now)
raise = 1;
}
}
-   if (raise)
-   raise_softirq_irqoff(HRTIMER_SOFTIRQ);
+   return raise;
 }
 
 #ifdef CONFIG_HIGH_RES_TIMERS
@@ -1526,6 +1525,7 @@ void hrtimer_interrupt(struct clock_event_device *dev)
struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(_bases);
ktime_t expires_next, now, entry_time, delta;
int retries = 0;
+   int raise;
 
BUG_ON(!cpu_base->hres_active);
cpu_base->nr_events++;
@@ -1544,7 +1544,7 @@ retry:
 */
cpu_base->expires_next.tv64 = KTIME_MAX;
 
-   __hrtimer_run_queues(cpu_base, now);
+   raise = __hrtimer_run_queues(cpu_base, now);
 
/* Reevaluate the clock bases for the next expiry */
expires_next = __hrtimer_get_next_event(cpu_base);
@@ -1555,6 +1555,8 @@ retry:
cpu_base->expires_next = expires_next;
cpu_base->in_hrtirq = 0;
raw_spin_unlock(_base->lock);
+   if (raise)
+   raise_softirq_irqoff(HRTIMER_SOFTIRQ);
 
/* Reprogramming necessary ? */
if (!tick_program_event(expires_next, 0)) {
@@ -1634,6 +1636,7 @@ void hrtimer_run_queues(void)
 {
struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(_bases);
ktime_t now;
+   int raise;
 
if (__hrtimer_hres_active(cpu_base))
return;
@@ -1652,8 +1655,10 @@ void hrtimer_run_queues(void)
 
raw_spin_lock(_base->lock);
now = hrtimer_update_base(cpu_base);
-   __hrtimer_run_queues(cpu_base, now);
+   raise = __hrtimer_run_queues(cpu_base, now);
raw_spin_unlock(_base->lock);
+   if (raise)
+   raise_softirq_irqoff(HRTIMER_SOFTIRQ);
 }
 
 /*
-- 
2.13.2




[PATCH RT 5/9] kernel/hrtimer/hotplug: dont wake ktimersoftd while holding the hrtimer base lock

2017-12-01 Thread Steven Rostedt
4.4.102-rt117-rc1 stable review patch.
If anyone has any objections, please let me know.

--

From: Mike Galbraith 

kernel/hrtimer: don't wakeup a process while holding the hrtimer base lock
missed a path, namely hrtimers_dead_cpu() -> migrate_hrtimer_list().  Defer
raising softirq until after base lock has been released there as well.

Signed-off-by: Mike Galbraith 
Signed-off-by: Sebastian Andrzej Siewior 
---
 kernel/time/hrtimer.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 78066f7ea2a2..120fc8932165 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1857,7 +1857,7 @@ static void init_hrtimers_cpu(int cpu)
 
 #ifdef CONFIG_HOTPLUG_CPU
 
-static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base,
+static int migrate_hrtimer_list(struct hrtimer_clock_base *old_base,
struct hrtimer_clock_base *new_base)
 {
struct hrtimer *timer;
@@ -1887,15 +1887,19 @@ static void migrate_hrtimer_list(struct 
hrtimer_clock_base *old_base,
}
 #ifdef CONFIG_PREEMPT_RT_BASE
list_splice_tail(_base->expired, _base->expired);
-   if (!list_empty(_base->expired))
-   raise_softirq_irqoff(HRTIMER_SOFTIRQ);
+   /*
+* Tell the caller to raise HRTIMER_SOFTIRQ.  We can't safely
+* acquire ktimersoftd->pi_lock while the base lock is held.
+*/
+   return !list_empty(_base->expired);
 #endif
+   return 0;
 }
 
 static void migrate_hrtimers(int scpu)
 {
struct hrtimer_cpu_base *old_base, *new_base;
-   int i;
+   int i, raise = 0;
 
BUG_ON(cpu_online(scpu));
tick_cancel_sched_timer(scpu);
@@ -1911,13 +1915,16 @@ static void migrate_hrtimers(int scpu)
raw_spin_lock_nested(_base->lock, SINGLE_DEPTH_NESTING);
 
for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
-   migrate_hrtimer_list(_base->clock_base[i],
-_base->clock_base[i]);
+   raise |= migrate_hrtimer_list(_base->clock_base[i],
+ _base->clock_base[i]);
}
 
raw_spin_unlock(_base->lock);
raw_spin_unlock(_base->lock);
 
+   if (raise)
+   raise_softirq_irqoff(HRTIMER_SOFTIRQ);
+
/* Check, if we got expired work to do */
__hrtimer_peek_ahead_timers();
local_irq_enable();
-- 
2.13.2




[PATCH RT 1/9] Revert "fs: jbd2: pull your plug when waiting for space"

2017-12-01 Thread Steven Rostedt
4.4.102-rt117-rc1 stable review patch.
If anyone has any objections, please let me know.

--

From: Sebastian Andrzej Siewior 

This reverts commit "fs: jbd2: pull your plug when waiting for space".
This was a duct-tape fix which shouldn't be needed since commit
"locking/rt-mutex: fix deadlock in device mapper / block-IO".

Cc: stable...@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior 
Signed-off-by: Steven Rostedt (VMware) 
---
 fs/jbd2/checkpoint.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
index 6e18a06aaabe..684996c8a3a4 100644
--- a/fs/jbd2/checkpoint.c
+++ b/fs/jbd2/checkpoint.c
@@ -116,8 +116,6 @@ void __jbd2_log_wait_for_space(journal_t *journal)
nblocks = jbd2_space_needed(journal);
while (jbd2_log_space_left(journal) < nblocks) {
write_unlock(>j_state_lock);
-   if (current->plug)
-   io_schedule();
mutex_lock(>j_checkpoint_mutex);
 
/*
-- 
2.13.2




[PATCH RT 8/9] net: use trylock in icmp_sk

2017-12-01 Thread Steven Rostedt
4.4.102-rt117-rc1 stable review patch.
If anyone has any objections, please let me know.

--

From: Sebastian Andrzej Siewior 

The locking path can be recursive (same as for sk->sk_lock.slock) and
therefore we need a trylock version for the locallock, too.

Cc: stable...@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior 
Signed-off-by: Steven Rostedt (VMware) 
---
 net/ipv4/icmp.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index ff2593269089..2c1ce3e80ee4 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -219,7 +219,11 @@ static inline struct sock *icmp_xmit_lock(struct net *net)
 
local_bh_disable();
 
-   local_lock(icmp_sk_lock);
+   if (!local_trylock(icmp_sk_lock)) {
+   local_bh_enable();
+   return NULL;
+   }
+
sk = icmp_sk(net);
 
if (unlikely(!spin_trylock(>sk_lock.slock))) {
-- 
2.13.2




[PATCH RT 8/9] net: use trylock in icmp_sk

2017-12-01 Thread Steven Rostedt
4.4.102-rt117-rc1 stable review patch.
If anyone has any objections, please let me know.

--

From: Sebastian Andrzej Siewior 

The locking path can be recursive (same as for sk->sk_lock.slock) and
therefore we need a trylock version for the locallock, too.

Cc: stable...@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior 
Signed-off-by: Steven Rostedt (VMware) 
---
 net/ipv4/icmp.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index ff2593269089..2c1ce3e80ee4 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -219,7 +219,11 @@ static inline struct sock *icmp_xmit_lock(struct net *net)
 
local_bh_disable();
 
-   local_lock(icmp_sk_lock);
+   if (!local_trylock(icmp_sk_lock)) {
+   local_bh_enable();
+   return NULL;
+   }
+
sk = icmp_sk(net);
 
if (unlikely(!spin_trylock(>sk_lock.slock))) {
-- 
2.13.2




  1   2   3   4   5   6   7   8   9   10   >