Re: [RFC PATCH 4/7] kconfig: support new special property shell=

2018-02-09 Thread Ulf Magnusson
On Sat, Feb 10, 2018 at 04:12:13PM +0900, Masahiro Yamada wrote:
> 2018-02-10 14:48 GMT+09:00 Ulf Magnusson :
> > On Fri, Feb 09, 2018 at 12:46:54PM -0800, Kees Cook wrote:
> >> On Fri, Feb 9, 2018 at 4:46 AM, Ulf Magnusson  wrote:
> >> > One thing that makes Kconfig confusing (though it works well enough in
> >> > practice) is that .config files both record user selections (the saved
> >> > configuration) and serve as a configuration output format for make.
> >> >
> >> > It becomes easier to think about .config files once you realize that
> >> > assignments to promptless symbols never have an effect on Kconfig
> >> > itself: They're just configuration output, intermixed with the saved
> >> > user selections.
> >> >
> >> > Assume 'option env' symbols got written out for example:
> >> >
> >> > - For a non-user-assignable symbol, the entry in the .config
> >> >   file is just configuration output and ignored by Kconfig,
> >> >   which will fetch the value from the environment instead.
> >> >
> >> > - For an assignable 'option env' symbol, the entry in the
> >> >   .config file is a saved user selection (as well as
> >> >   configuration output), and will be respected by Kconfig.
> >>
> >> In the stack-protector case, this becomes quite important, since the
> >> goal is to record the user's selection regardless of compiler
> >> capability. For example, if someone selects _REGULAR, it shouldn't
> >> "upgrade" to _STRONG. (Similarly for _NONE.) Having _AUTO provides a
> >> way to pick "best possible for this compiler", though. If a user had
> >> previously selected _STRONG but they're doing builds with an older
> >> compiler (or a misconfigured newer compiler) without support, the goal
> >> is to _fail_ to build, not silently select _REGULAR.
> >>
> >> So, in this case, what's gained is the logic for _AUTO, and the logic
> >> to not show, say, _STRONG when it's not available in the compiler. But
> >> we must still fail to build if _STRONG was in the .config. It can't
> >> silently rewrite it to _REGULAR because the compiler support for
> >> _STRONG regressed.
> >>
> >> -Kees
> >>
> >> --
> >> Kees Cook
> >> Pixel Security
> >
> > Provided that would be the desired behavior:
> >
> > What about changing the meaning of the choice symbols from e.g. "select
> > -fstack-protector-strong" to "want -fstack-protector-strong"? Then the
> > user preference would always be remembered, regardless of what's
> > available.
> >
> > Here's a proof-of-concept. I realized that the fancy new 'imply' keyword
> > fits pretty well here, since it works like a dependency-respecting
> > select.
> >
> > config CC_HAS_STACKPROTECTOR_STRONG
> > bool
> > option shell="$CC -Werror -fstack-protector-strong -c -x c 
> > /dev/null"
> >
> > config CC_HAS_STACKPROTECTOR
> > bool
> > option shell="$CC -Werror -fstack-protector -c -x c 
> > /dev/null"
> >
> >
> > choice
> > prompt "Stack Protector buffer overflow detection"
> > default WANT_CC_STACKPROTECTOR_STRONG
> >
> > config WANT_CC_STACKPROTECTOR_STRONG
> > bool "Strong"
> > imply CC_STACKPROTECTOR_STRONG
> >
> > config WANT_CC_STACKPROTECTOR_REGULAR
> > bool "Regular"
> > imply CC_STACKPROTECTOR_REGULAR
> >
> > config WANT_CC_STACKPROTECTOR_NONE
> > bool "None"
> > imply CC_STACKPROTECTOR_NONE
> >
> > endchoice
> >
> >
> > config CC_STACKPROTECTOR_STRONG
> > bool
> > depends on CC_HAS_STACKPROTECTOR_STRONG
> 
> 
> Do you mean
> 
>  config CC_STACKPROTECTOR_STRONG
>  bool
>  depends on CC_HAS_STACKPROTECTOR_STRONG && \
> WANT_CC_STACKPROTECTOR_STRONG
> 
> or, maybe
> 
> 
>  config CC_STACKPROTECTOR_STRONG
>  bool
>  depends on CC_HAS_STACKPROTECTOR_STRONG
>  default WANT_CC_STACKPROTECTOR_STRONG
> 
> ?

With the 'imply', it should work with just the 'depends on'. I had your
last version earlier though, and it works too.

'imply' kinda makes sense, as in "turn on the strong stack protector if
its dependencies are satisfied".

> 
> 
> 
> 
> 
> > config CC_STACKPROTECTOR_REGULAR
> > bool
> > depends on CC_HAS_STACKPROTECTOR_REGULAR
> >
> > config CC_STACKPROTECTOR_NONE
> > bool
> >
> > This version has the drawback of always showing all the options, even if
> > some they wouldn't be available. Kconfig comments could be added to warn
> > if an option isn't available at least:
> >
> > comment "Warning: Your compiler does not support 
> > -fstack-protector-strong"
> > depends on !CC_HAS_STACKPROTECTOR_STRONG
> >
> >

Re: [RFC PATCH 4/7] kconfig: support new special property shell=

2018-02-09 Thread Ulf Magnusson
On Sat, Feb 10, 2018 at 04:12:13PM +0900, Masahiro Yamada wrote:
> 2018-02-10 14:48 GMT+09:00 Ulf Magnusson :
> > On Fri, Feb 09, 2018 at 12:46:54PM -0800, Kees Cook wrote:
> >> On Fri, Feb 9, 2018 at 4:46 AM, Ulf Magnusson  wrote:
> >> > One thing that makes Kconfig confusing (though it works well enough in
> >> > practice) is that .config files both record user selections (the saved
> >> > configuration) and serve as a configuration output format for make.
> >> >
> >> > It becomes easier to think about .config files once you realize that
> >> > assignments to promptless symbols never have an effect on Kconfig
> >> > itself: They're just configuration output, intermixed with the saved
> >> > user selections.
> >> >
> >> > Assume 'option env' symbols got written out for example:
> >> >
> >> > - For a non-user-assignable symbol, the entry in the .config
> >> >   file is just configuration output and ignored by Kconfig,
> >> >   which will fetch the value from the environment instead.
> >> >
> >> > - For an assignable 'option env' symbol, the entry in the
> >> >   .config file is a saved user selection (as well as
> >> >   configuration output), and will be respected by Kconfig.
> >>
> >> In the stack-protector case, this becomes quite important, since the
> >> goal is to record the user's selection regardless of compiler
> >> capability. For example, if someone selects _REGULAR, it shouldn't
> >> "upgrade" to _STRONG. (Similarly for _NONE.) Having _AUTO provides a
> >> way to pick "best possible for this compiler", though. If a user had
> >> previously selected _STRONG but they're doing builds with an older
> >> compiler (or a misconfigured newer compiler) without support, the goal
> >> is to _fail_ to build, not silently select _REGULAR.
> >>
> >> So, in this case, what's gained is the logic for _AUTO, and the logic
> >> to not show, say, _STRONG when it's not available in the compiler. But
> >> we must still fail to build if _STRONG was in the .config. It can't
> >> silently rewrite it to _REGULAR because the compiler support for
> >> _STRONG regressed.
> >>
> >> -Kees
> >>
> >> --
> >> Kees Cook
> >> Pixel Security
> >
> > Provided that would be the desired behavior:
> >
> > What about changing the meaning of the choice symbols from e.g. "select
> > -fstack-protector-strong" to "want -fstack-protector-strong"? Then the
> > user preference would always be remembered, regardless of what's
> > available.
> >
> > Here's a proof-of-concept. I realized that the fancy new 'imply' keyword
> > fits pretty well here, since it works like a dependency-respecting
> > select.
> >
> > config CC_HAS_STACKPROTECTOR_STRONG
> > bool
> > option shell="$CC -Werror -fstack-protector-strong -c -x c 
> > /dev/null"
> >
> > config CC_HAS_STACKPROTECTOR
> > bool
> > option shell="$CC -Werror -fstack-protector -c -x c 
> > /dev/null"
> >
> >
> > choice
> > prompt "Stack Protector buffer overflow detection"
> > default WANT_CC_STACKPROTECTOR_STRONG
> >
> > config WANT_CC_STACKPROTECTOR_STRONG
> > bool "Strong"
> > imply CC_STACKPROTECTOR_STRONG
> >
> > config WANT_CC_STACKPROTECTOR_REGULAR
> > bool "Regular"
> > imply CC_STACKPROTECTOR_REGULAR
> >
> > config WANT_CC_STACKPROTECTOR_NONE
> > bool "None"
> > imply CC_STACKPROTECTOR_NONE
> >
> > endchoice
> >
> >
> > config CC_STACKPROTECTOR_STRONG
> > bool
> > depends on CC_HAS_STACKPROTECTOR_STRONG
> 
> 
> Do you mean
> 
>  config CC_STACKPROTECTOR_STRONG
>  bool
>  depends on CC_HAS_STACKPROTECTOR_STRONG && \
> WANT_CC_STACKPROTECTOR_STRONG
> 
> or, maybe
> 
> 
>  config CC_STACKPROTECTOR_STRONG
>  bool
>  depends on CC_HAS_STACKPROTECTOR_STRONG
>  default WANT_CC_STACKPROTECTOR_STRONG
> 
> ?

With the 'imply', it should work with just the 'depends on'. I had your
last version earlier though, and it works too.

'imply' kinda makes sense, as in "turn on the strong stack protector if
its dependencies are satisfied".

> 
> 
> 
> 
> 
> > config CC_STACKPROTECTOR_REGULAR
> > bool
> > depends on CC_HAS_STACKPROTECTOR_REGULAR
> >
> > config CC_STACKPROTECTOR_NONE
> > bool
> >
> > This version has the drawback of always showing all the options, even if
> > some they wouldn't be available. Kconfig comments could be added to warn
> > if an option isn't available at least:
> >
> > comment "Warning: Your compiler does not support 
> > -fstack-protector-strong"
> > depends on !CC_HAS_STACKPROTECTOR_STRONG
> >
> > config WANT_CC_STACKPROTECTOR_STRONG

[PATCH v5] Documentation/ABI: update infiniband sysfs interfaces

2018-02-09 Thread Aishwarya Pant
Add documentation for core and hardware specific infiniband interfaces.
The descriptions have been collected from git commit logs, reading
through code and data sheets. Some drivers have incomplete doc and are
annotated with the comment '[to be documented]'.

Signed-off-by: Aishwarya Pant 
Reviewed-by: Hal Rosenstock 
---
Sorry, there were no changes in v4!

Changes in v5:
- Typo GODs -> GIDs
v3:
-  outbound -> inbound in description of port_rcv_constraint_errors
v2:
- Move infiniband interface from testing to stable
- Fix typos
- Update description of cap_mask, port_xmit_constraint_errors and
  port_rcv_constraint_errors
- Add doc for hw_counters
- Remove old documentation

 Documentation/ABI/stable/sysfs-class-infiniband  | 818 +++
 Documentation/ABI/testing/sysfs-class-infiniband |  16 -
 Documentation/infiniband/sysfs.txt   | 129 +---
 3 files changed, 820 insertions(+), 143 deletions(-)
 create mode 100644 Documentation/ABI/stable/sysfs-class-infiniband
 delete mode 100644 Documentation/ABI/testing/sysfs-class-infiniband

diff --git a/Documentation/ABI/stable/sysfs-class-infiniband 
b/Documentation/ABI/stable/sysfs-class-infiniband
new file mode 100644
index ..17211ceb9bf4
--- /dev/null
+++ b/Documentation/ABI/stable/sysfs-class-infiniband
@@ -0,0 +1,818 @@
+sysfs interface common for all infiniband devices
+-
+
+What:  /sys/class/infiniband//node_type
+What:  /sys/class/infiniband//node_guid
+What:  /sys/class/infiniband//sys_image_guid
+Date:  Apr, 2005
+KernelVersion: v2.6.12
+Contact:   linux-r...@vger.kernel.org
+Description:
+   node_type:  (RO) Node type (CA, RNIC, usNIC, usNIC UDP,
+   switch or router)
+
+   node_guid:  (RO) Node GUID
+
+   sys_image_guid: (RO) System image GUID
+
+
+What:  /sys/class/infiniband//node_desc
+Date:  Feb, 2006
+KernelVersion: v2.6.17
+Contact:   linux-r...@vger.kernel.org
+Description:
+   (RW) Update the node description with information such as the
+   node's hostname, so that IB network management software can tie
+   its view to the real world.
+
+
+What:  /sys/class/infiniband//fw_ver
+Date:  Jun, 2016
+KernelVersion: v4.10
+Contact:   linux-r...@vger.kernel.org
+Description:
+   (RO) Display firmware version
+
+
+What:  /sys/class/infiniband//ports//lid
+What:  /sys/class/infiniband//ports//rate
+What:  /sys/class/infiniband//ports//lid_mask_count
+What:  /sys/class/infiniband//ports//sm_sl
+What:  /sys/class/infiniband//ports//sm_lid
+What:  /sys/class/infiniband//ports//state
+What:  /sys/class/infiniband//ports//phys_state
+What:  /sys/class/infiniband//ports//cap_mask
+Date:  Apr, 2005
+KernelVersion: v2.6.12
+Contact:   linux-r...@vger.kernel.org
+Description:
+
+   lid:(RO) Port LID
+
+   rate:   (RO) Port data rate (active width * active
+   speed)
+
+   lid_mask_count: (RO) Port LID mask count
+
+   sm_sl:  (RO) Subnet manager SL for port's subnet
+
+   sm_lid: (RO) Subnet manager LID for port's subnet
+
+   state:  (RO) Port state (DOWN, INIT, ARMED, ACTIVE or
+   ACTIVE_DEFER)
+
+   phys_state: (RO) Port physical state (Sleep, Polling,
+   LinkUp, etc)
+
+   cap_mask:   (RO) Port capability mask. 2 bits here are
+   settable- IsCommunicationManagementSupported
+   (set when CM module is loaded) and IsSM (set via
+   open of issmN file).
+
+
+What:  /sys/class/infiniband//ports//link_layer
+Date:  Oct, 2010
+KernelVersion: v2.6.37
+Contact:   linux-r...@vger.kernel.org
+Description:
+   (RO) Link layer type information (Infiniband or Ethernet type)
+
+
+What:  
/sys/class/infiniband//ports//counters/symbol_error
+What:  
/sys/class/infiniband//ports//counters/port_rcv_errors
+What:  
/sys/class/infiniband//ports//counters/port_rcv_remote_physical_errors
+What:  
/sys/class/infiniband//ports//counters/port_rcv_switch_relay_errors
+What:  
/sys/class/infiniband//ports//counters/link_error_recovery
+What:  
/sys/class/infiniband//ports//counters/port_xmit_constraint_errors
+What:  
/sys/class/infiniband//ports//counters/port_rcv_contraint_errors
+What:  
/sys/class/infiniband//ports//counters/local_link_integrity_errors
+What:  
/sys/class/infiniband//ports//counters/excessive_buffer_overrun_errors
+What:  

[PATCH v5] Documentation/ABI: update infiniband sysfs interfaces

2018-02-09 Thread Aishwarya Pant
Add documentation for core and hardware specific infiniband interfaces.
The descriptions have been collected from git commit logs, reading
through code and data sheets. Some drivers have incomplete doc and are
annotated with the comment '[to be documented]'.

Signed-off-by: Aishwarya Pant 
Reviewed-by: Hal Rosenstock 
---
Sorry, there were no changes in v4!

Changes in v5:
- Typo GODs -> GIDs
v3:
-  outbound -> inbound in description of port_rcv_constraint_errors
v2:
- Move infiniband interface from testing to stable
- Fix typos
- Update description of cap_mask, port_xmit_constraint_errors and
  port_rcv_constraint_errors
- Add doc for hw_counters
- Remove old documentation

 Documentation/ABI/stable/sysfs-class-infiniband  | 818 +++
 Documentation/ABI/testing/sysfs-class-infiniband |  16 -
 Documentation/infiniband/sysfs.txt   | 129 +---
 3 files changed, 820 insertions(+), 143 deletions(-)
 create mode 100644 Documentation/ABI/stable/sysfs-class-infiniband
 delete mode 100644 Documentation/ABI/testing/sysfs-class-infiniband

diff --git a/Documentation/ABI/stable/sysfs-class-infiniband 
b/Documentation/ABI/stable/sysfs-class-infiniband
new file mode 100644
index ..17211ceb9bf4
--- /dev/null
+++ b/Documentation/ABI/stable/sysfs-class-infiniband
@@ -0,0 +1,818 @@
+sysfs interface common for all infiniband devices
+-
+
+What:  /sys/class/infiniband//node_type
+What:  /sys/class/infiniband//node_guid
+What:  /sys/class/infiniband//sys_image_guid
+Date:  Apr, 2005
+KernelVersion: v2.6.12
+Contact:   linux-r...@vger.kernel.org
+Description:
+   node_type:  (RO) Node type (CA, RNIC, usNIC, usNIC UDP,
+   switch or router)
+
+   node_guid:  (RO) Node GUID
+
+   sys_image_guid: (RO) System image GUID
+
+
+What:  /sys/class/infiniband//node_desc
+Date:  Feb, 2006
+KernelVersion: v2.6.17
+Contact:   linux-r...@vger.kernel.org
+Description:
+   (RW) Update the node description with information such as the
+   node's hostname, so that IB network management software can tie
+   its view to the real world.
+
+
+What:  /sys/class/infiniband//fw_ver
+Date:  Jun, 2016
+KernelVersion: v4.10
+Contact:   linux-r...@vger.kernel.org
+Description:
+   (RO) Display firmware version
+
+
+What:  /sys/class/infiniband//ports//lid
+What:  /sys/class/infiniband//ports//rate
+What:  /sys/class/infiniband//ports//lid_mask_count
+What:  /sys/class/infiniband//ports//sm_sl
+What:  /sys/class/infiniband//ports//sm_lid
+What:  /sys/class/infiniband//ports//state
+What:  /sys/class/infiniband//ports//phys_state
+What:  /sys/class/infiniband//ports//cap_mask
+Date:  Apr, 2005
+KernelVersion: v2.6.12
+Contact:   linux-r...@vger.kernel.org
+Description:
+
+   lid:(RO) Port LID
+
+   rate:   (RO) Port data rate (active width * active
+   speed)
+
+   lid_mask_count: (RO) Port LID mask count
+
+   sm_sl:  (RO) Subnet manager SL for port's subnet
+
+   sm_lid: (RO) Subnet manager LID for port's subnet
+
+   state:  (RO) Port state (DOWN, INIT, ARMED, ACTIVE or
+   ACTIVE_DEFER)
+
+   phys_state: (RO) Port physical state (Sleep, Polling,
+   LinkUp, etc)
+
+   cap_mask:   (RO) Port capability mask. 2 bits here are
+   settable- IsCommunicationManagementSupported
+   (set when CM module is loaded) and IsSM (set via
+   open of issmN file).
+
+
+What:  /sys/class/infiniband//ports//link_layer
+Date:  Oct, 2010
+KernelVersion: v2.6.37
+Contact:   linux-r...@vger.kernel.org
+Description:
+   (RO) Link layer type information (Infiniband or Ethernet type)
+
+
+What:  
/sys/class/infiniband//ports//counters/symbol_error
+What:  
/sys/class/infiniband//ports//counters/port_rcv_errors
+What:  
/sys/class/infiniband//ports//counters/port_rcv_remote_physical_errors
+What:  
/sys/class/infiniband//ports//counters/port_rcv_switch_relay_errors
+What:  
/sys/class/infiniband//ports//counters/link_error_recovery
+What:  
/sys/class/infiniband//ports//counters/port_xmit_constraint_errors
+What:  
/sys/class/infiniband//ports//counters/port_rcv_contraint_errors
+What:  
/sys/class/infiniband//ports//counters/local_link_integrity_errors
+What:  
/sys/class/infiniband//ports//counters/excessive_buffer_overrun_errors
+What:  
/sys/class/infiniband//ports//counters/port_xmit_data
+What:   

Re: [PATCH v3 01/11] dt-bindings: clock: Add Actions S900 clock bindings

2018-02-09 Thread Philippe Ombredanne
Dear Manivannan,

On Sat, Feb 10, 2018 at 3:41 AM, Manivannan Sadhasivam
 wrote:
> Add Actions Semi S900 clock bindings.
>
> Signed-off-by: Manivannan Sadhasivam 
> Acked-by: Rob Herring 



> diff --git a/include/dt-bindings/clock/actions,s900-cmu.h 
> b/include/dt-bindings/clock/actions,s900-cmu.h
> new file mode 100644
> index ..2fa94e19922b
> --- /dev/null
> +++ b/include/dt-bindings/clock/actions,s900-cmu.h
> @@ -0,0 +1,139 @@
> +/*
> + * Device Tree binding constants for Actions S900 Clock Management Unit
> + *
> + * Copyright (c) 2014 Actions Semi Inc.
> + * Copyright (c) 2017 Linaro Ltd.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */

Would you consider using the new SPDX license ids rather that this
time-tested but rather boring legalese?

The (still new and fresh) license documentation contributed by tglx
--the only maintainer that I know that understands both the innards of
Spectre and Meltdown and the beauty of reStructuredText -- is in:
Documentation/process/license-rules.rst

Practically this means replacing the above by a simple single line and
getting rid of a whopping 8 comment lines!

SPDX-License-Identifier: GPL-2.0+

You get to save a few tree as a bonus if you also do the same for all
Linaro-copyrighted files. Yes this is saving trees because I will use
less paper each time I print a listing of the kernel source code.
Which is something that I rarely if ever do: but somebody must do it
somewhere for sure.

If I do the math: we have ~60K files in the kernel, and say we can
remove roughly 5 lines of legalese per file on average. Each printed
source code page is roughly 60 lines : this will mean a saving of
about 6000 paper sheets saved on each printout! A letter-size paper
ream is 500 pages, about 2.5 Kg and costs about ~$8.  You can extract
about 10K to 20k sheets of paper per tree [1].
Therefore my Fermi estimate is that using shorter legalese in the
kernel will eventually save roughly ONE FULL smaller tree (6K pages)
each time someone prints the kernel code: incredible, right?

Thank  you for helping make the kernel a mostly legalese-free codebase
and saving trees at the same time!

[1] 
https://www.sierraclub.org/sierra/2014-4-july-august/green-life/how-much-paper-does-one-tree-produce
-- 
Cordially
Philippe Ombredanne


[PATCH v4] Documentation/ABI: update infiniband sysfs interfaces

2018-02-09 Thread Aishwarya Pant
Add documentation for core and hardware specific infiniband interfaces.
The descriptions have been collected from git commit logs, reading
through code and data sheets. Some drivers have incomplete doc and are
annotated with the comment '[to be documented]'.

Signed-off-by: Aishwarya Pant 
Reviewed-by: Hal Rosenstock 
---
Changes in v4:
- Typo GODs -> GIDs
v3:
-  outbound -> inbound in description of port_rcv_constraint_errors
v2:
- Move infiniband interface from testing to stable
- Fix typos
- Update description of cap_mask, port_xmit_constraint_errors and
  port_rcv_constraint_errors
- Add doc for hw_counters
- Remove old documentation

 Documentation/ABI/stable/sysfs-class-infiniband  | 818 +++
 Documentation/ABI/testing/sysfs-class-infiniband |  16 -
 Documentation/infiniband/sysfs.txt   | 129 +---
 3 files changed, 820 insertions(+), 143 deletions(-)
 create mode 100644 Documentation/ABI/stable/sysfs-class-infiniband
 delete mode 100644 Documentation/ABI/testing/sysfs-class-infiniband

diff --git a/Documentation/ABI/stable/sysfs-class-infiniband 
b/Documentation/ABI/stable/sysfs-class-infiniband
new file mode 100644
index ..f3acf3713a91
--- /dev/null
+++ b/Documentation/ABI/stable/sysfs-class-infiniband
@@ -0,0 +1,818 @@
+sysfs interface common for all infiniband devices
+-
+
+What:  /sys/class/infiniband//node_type
+What:  /sys/class/infiniband//node_guid
+What:  /sys/class/infiniband//sys_image_guid
+Date:  Apr, 2005
+KernelVersion: v2.6.12
+Contact:   linux-r...@vger.kernel.org
+Description:
+   node_type:  (RO) Node type (CA, RNIC, usNIC, usNIC UDP,
+   switch or router)
+
+   node_guid:  (RO) Node GUID
+
+   sys_image_guid: (RO) System image GUID
+
+
+What:  /sys/class/infiniband//node_desc
+Date:  Feb, 2006
+KernelVersion: v2.6.17
+Contact:   linux-r...@vger.kernel.org
+Description:
+   (RW) Update the node description with information such as the
+   node's hostname, so that IB network management software can tie
+   its view to the real world.
+
+
+What:  /sys/class/infiniband//fw_ver
+Date:  Jun, 2016
+KernelVersion: v4.10
+Contact:   linux-r...@vger.kernel.org
+Description:
+   (RO) Display firmware version
+
+
+What:  /sys/class/infiniband//ports//lid
+What:  /sys/class/infiniband//ports//rate
+What:  /sys/class/infiniband//ports//lid_mask_count
+What:  /sys/class/infiniband//ports//sm_sl
+What:  /sys/class/infiniband//ports//sm_lid
+What:  /sys/class/infiniband//ports//state
+What:  /sys/class/infiniband//ports//phys_state
+What:  /sys/class/infiniband//ports//cap_mask
+Date:  Apr, 2005
+KernelVersion: v2.6.12
+Contact:   linux-r...@vger.kernel.org
+Description:
+
+   lid:(RO) Port LID
+
+   rate:   (RO) Port data rate (active width * active
+   speed)
+
+   lid_mask_count: (RO) Port LID mask count
+
+   sm_sl:  (RO) Subnet manager SL for port's subnet
+
+   sm_lid: (RO) Subnet manager LID for port's subnet
+
+   state:  (RO) Port state (DOWN, INIT, ARMED, ACTIVE or
+   ACTIVE_DEFER)
+
+   phys_state: (RO) Port physical state (Sleep, Polling,
+   LinkUp, etc)
+
+   cap_mask:   (RO) Port capability mask. 2 bits here are
+   settable- IsCommunicationManagementSupported
+   (set when CM module is loaded) and IsSM (set via
+   open of issmN file).
+
+
+What:  /sys/class/infiniband//ports//link_layer
+Date:  Oct, 2010
+KernelVersion: v2.6.37
+Contact:   linux-r...@vger.kernel.org
+Description:
+   (RO) Link layer type information (Infiniband or Ethernet type)
+
+
+What:  
/sys/class/infiniband//ports//counters/symbol_error
+What:  
/sys/class/infiniband//ports//counters/port_rcv_errors
+What:  
/sys/class/infiniband//ports//counters/port_rcv_remote_physical_errors
+What:  
/sys/class/infiniband//ports//counters/port_rcv_switch_relay_errors
+What:  
/sys/class/infiniband//ports//counters/link_error_recovery
+What:  
/sys/class/infiniband//ports//counters/port_xmit_constraint_errors
+What:  
/sys/class/infiniband//ports//counters/port_rcv_contraint_errors
+What:  
/sys/class/infiniband//ports//counters/local_link_integrity_errors
+What:  
/sys/class/infiniband//ports//counters/excessive_buffer_overrun_errors
+What:  
/sys/class/infiniband//ports//counters/port_xmit_data
+What: 

Re: [PATCH v3 01/11] dt-bindings: clock: Add Actions S900 clock bindings

2018-02-09 Thread Philippe Ombredanne
Dear Manivannan,

On Sat, Feb 10, 2018 at 3:41 AM, Manivannan Sadhasivam
 wrote:
> Add Actions Semi S900 clock bindings.
>
> Signed-off-by: Manivannan Sadhasivam 
> Acked-by: Rob Herring 



> diff --git a/include/dt-bindings/clock/actions,s900-cmu.h 
> b/include/dt-bindings/clock/actions,s900-cmu.h
> new file mode 100644
> index ..2fa94e19922b
> --- /dev/null
> +++ b/include/dt-bindings/clock/actions,s900-cmu.h
> @@ -0,0 +1,139 @@
> +/*
> + * Device Tree binding constants for Actions S900 Clock Management Unit
> + *
> + * Copyright (c) 2014 Actions Semi Inc.
> + * Copyright (c) 2017 Linaro Ltd.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */

Would you consider using the new SPDX license ids rather that this
time-tested but rather boring legalese?

The (still new and fresh) license documentation contributed by tglx
--the only maintainer that I know that understands both the innards of
Spectre and Meltdown and the beauty of reStructuredText -- is in:
Documentation/process/license-rules.rst

Practically this means replacing the above by a simple single line and
getting rid of a whopping 8 comment lines!

SPDX-License-Identifier: GPL-2.0+

You get to save a few tree as a bonus if you also do the same for all
Linaro-copyrighted files. Yes this is saving trees because I will use
less paper each time I print a listing of the kernel source code.
Which is something that I rarely if ever do: but somebody must do it
somewhere for sure.

If I do the math: we have ~60K files in the kernel, and say we can
remove roughly 5 lines of legalese per file on average. Each printed
source code page is roughly 60 lines : this will mean a saving of
about 6000 paper sheets saved on each printout! A letter-size paper
ream is 500 pages, about 2.5 Kg and costs about ~$8.  You can extract
about 10K to 20k sheets of paper per tree [1].
Therefore my Fermi estimate is that using shorter legalese in the
kernel will eventually save roughly ONE FULL smaller tree (6K pages)
each time someone prints the kernel code: incredible, right?

Thank  you for helping make the kernel a mostly legalese-free codebase
and saving trees at the same time!

[1] 
https://www.sierraclub.org/sierra/2014-4-july-august/green-life/how-much-paper-does-one-tree-produce
-- 
Cordially
Philippe Ombredanne


[PATCH v4] Documentation/ABI: update infiniband sysfs interfaces

2018-02-09 Thread Aishwarya Pant
Add documentation for core and hardware specific infiniband interfaces.
The descriptions have been collected from git commit logs, reading
through code and data sheets. Some drivers have incomplete doc and are
annotated with the comment '[to be documented]'.

Signed-off-by: Aishwarya Pant 
Reviewed-by: Hal Rosenstock 
---
Changes in v4:
- Typo GODs -> GIDs
v3:
-  outbound -> inbound in description of port_rcv_constraint_errors
v2:
- Move infiniband interface from testing to stable
- Fix typos
- Update description of cap_mask, port_xmit_constraint_errors and
  port_rcv_constraint_errors
- Add doc for hw_counters
- Remove old documentation

 Documentation/ABI/stable/sysfs-class-infiniband  | 818 +++
 Documentation/ABI/testing/sysfs-class-infiniband |  16 -
 Documentation/infiniband/sysfs.txt   | 129 +---
 3 files changed, 820 insertions(+), 143 deletions(-)
 create mode 100644 Documentation/ABI/stable/sysfs-class-infiniband
 delete mode 100644 Documentation/ABI/testing/sysfs-class-infiniband

diff --git a/Documentation/ABI/stable/sysfs-class-infiniband 
b/Documentation/ABI/stable/sysfs-class-infiniband
new file mode 100644
index ..f3acf3713a91
--- /dev/null
+++ b/Documentation/ABI/stable/sysfs-class-infiniband
@@ -0,0 +1,818 @@
+sysfs interface common for all infiniband devices
+-
+
+What:  /sys/class/infiniband//node_type
+What:  /sys/class/infiniband//node_guid
+What:  /sys/class/infiniband//sys_image_guid
+Date:  Apr, 2005
+KernelVersion: v2.6.12
+Contact:   linux-r...@vger.kernel.org
+Description:
+   node_type:  (RO) Node type (CA, RNIC, usNIC, usNIC UDP,
+   switch or router)
+
+   node_guid:  (RO) Node GUID
+
+   sys_image_guid: (RO) System image GUID
+
+
+What:  /sys/class/infiniband//node_desc
+Date:  Feb, 2006
+KernelVersion: v2.6.17
+Contact:   linux-r...@vger.kernel.org
+Description:
+   (RW) Update the node description with information such as the
+   node's hostname, so that IB network management software can tie
+   its view to the real world.
+
+
+What:  /sys/class/infiniband//fw_ver
+Date:  Jun, 2016
+KernelVersion: v4.10
+Contact:   linux-r...@vger.kernel.org
+Description:
+   (RO) Display firmware version
+
+
+What:  /sys/class/infiniband//ports//lid
+What:  /sys/class/infiniband//ports//rate
+What:  /sys/class/infiniband//ports//lid_mask_count
+What:  /sys/class/infiniband//ports//sm_sl
+What:  /sys/class/infiniband//ports//sm_lid
+What:  /sys/class/infiniband//ports//state
+What:  /sys/class/infiniband//ports//phys_state
+What:  /sys/class/infiniband//ports//cap_mask
+Date:  Apr, 2005
+KernelVersion: v2.6.12
+Contact:   linux-r...@vger.kernel.org
+Description:
+
+   lid:(RO) Port LID
+
+   rate:   (RO) Port data rate (active width * active
+   speed)
+
+   lid_mask_count: (RO) Port LID mask count
+
+   sm_sl:  (RO) Subnet manager SL for port's subnet
+
+   sm_lid: (RO) Subnet manager LID for port's subnet
+
+   state:  (RO) Port state (DOWN, INIT, ARMED, ACTIVE or
+   ACTIVE_DEFER)
+
+   phys_state: (RO) Port physical state (Sleep, Polling,
+   LinkUp, etc)
+
+   cap_mask:   (RO) Port capability mask. 2 bits here are
+   settable- IsCommunicationManagementSupported
+   (set when CM module is loaded) and IsSM (set via
+   open of issmN file).
+
+
+What:  /sys/class/infiniband//ports//link_layer
+Date:  Oct, 2010
+KernelVersion: v2.6.37
+Contact:   linux-r...@vger.kernel.org
+Description:
+   (RO) Link layer type information (Infiniband or Ethernet type)
+
+
+What:  
/sys/class/infiniband//ports//counters/symbol_error
+What:  
/sys/class/infiniband//ports//counters/port_rcv_errors
+What:  
/sys/class/infiniband//ports//counters/port_rcv_remote_physical_errors
+What:  
/sys/class/infiniband//ports//counters/port_rcv_switch_relay_errors
+What:  
/sys/class/infiniband//ports//counters/link_error_recovery
+What:  
/sys/class/infiniband//ports//counters/port_xmit_constraint_errors
+What:  
/sys/class/infiniband//ports//counters/port_rcv_contraint_errors
+What:  
/sys/class/infiniband//ports//counters/local_link_integrity_errors
+What:  
/sys/class/infiniband//ports//counters/excessive_buffer_overrun_errors
+What:  
/sys/class/infiniband//ports//counters/port_xmit_data
+What:  

Re: [PATCH v2] printk: Relocate wake_klogd check close to the end of console_unlock()

2018-02-09 Thread Sergey Senozhatsky
Hello,

On (02/09/18 11:39), Petr Mladek wrote:
> On Fri 2018-02-09 12:28:30, Sergey Senozhatsky wrote:
> > On (02/08/18 17:48), Petr Mladek wrote:
> > By postponing klogd wakeup we don't really address logbuf_lock
> > contention. We have no guarantees that no new printk will come
> > while klogd is active. Besides, consoles don't really delay
> > klogd - I tend to ignore the impact of msg_print_text(), it should
> > be fast. We call console drivers outside of logbuf_lock scope, so
> > everything should fine (tm).
> 
> First, I am all for waking klogd earlier.
> 
> Second, sigh, I do not have much experience with kernel performace issues.
> It is very likely that we really do not need to mind about it.

I really don't think we need to bother.
klogd loggers are as important as consoles, we need to run them anyway.

> > Basically,
> > - if consoles are suspended, we also "suspend" user space klogd.
> >   Does it really make sense?
> > 
> > - if console_lock is acquired by a preemptible task and that task
> >   is getting scheduled out for a long time (OOM, etc) then we postpone
> >   user space logging for unknown period of time. First the console_lock
> >   will have to flush pending messages and only afterwards it will wakeup
> >   klogd. Does it really make sense?
> > 
> > - If current console_lock owner jumps to retry (new pending messages
> >   were appended to the logbuf) label, user space klogd wakeup is getting
> >   postponed even further.
> > 
> > So, the final question is - since there in only one legitimate way
> > (modulo user space writes to kmsg) to append new messages to the
> > logbuf, shall we put klogd wakeup there? IOW, to vprintk_emit().
> 
> Good points! In fact, if we wakeup klogd before calling consoles,
> we would need to do it for every new message. Otherwise, klogd
> processes might miss new messages that are added in parallel
> when console_lock is taken.
[..]
> Then klogd might start sleeping while new messages are still comming

Loggers sleep when `user->seq == log_next_seq' or when
`syslog_seq == log_next_seq'. We need to just wakeup them.
Once woken up they will check the condition again, if there
are no new messages, they will schedule.

> Now, your proposed solution looked fine. Just note that we do not need
> seen_seq. vprintk_emit() knows when log_next_seq is increased.
> It would always wake klogd in this case.

Probably can wake_up_klogd() unconditionally.

> Anyway, I think about slightly different way that would prevent
> scheduling klogd intead of the vprintk_emit() caller. The trick
> is to do the wakeup with preemtion disabled. I mean something like:
[..]
> @@ -1899,9 +1899,13 @@ asmlinkage int vprintk_emit(int facility, int level,
>*/
>   preempt_disable();
>   /*
> +  * Wake klogd with disabled preemtion so that they can run
> +  * in parallel but they could not delay console_handling.
> +  */
> + wake_up_klogd();
> + /*
>* Try to acquire and then immediately release the console
> -  * semaphore.  The release will print out buffers and wake up
> -  * /dev/kmsg and syslog() users.
> +  * semaphore.  The release will print out buffers.
>*/
>   if (console_trylock_spinning())
>   console_unlock();
[..]

It doesn't wakeup loggers for printk_deferred() output this way.
I want to wakeup them for every new logbuf message.

If logger preempts current printk() that it's for 1 message only.
printk() will return back and finish printing. If there will be another
printk()-s from other CPUs, then one of those CPUs will print messages
to the consoles - CPU that woke up logger had not acquired console_sem
before it was preempted by logger.

-ss


Re: [PATCH v2] printk: Relocate wake_klogd check close to the end of console_unlock()

2018-02-09 Thread Sergey Senozhatsky
Hello,

On (02/09/18 11:39), Petr Mladek wrote:
> On Fri 2018-02-09 12:28:30, Sergey Senozhatsky wrote:
> > On (02/08/18 17:48), Petr Mladek wrote:
> > By postponing klogd wakeup we don't really address logbuf_lock
> > contention. We have no guarantees that no new printk will come
> > while klogd is active. Besides, consoles don't really delay
> > klogd - I tend to ignore the impact of msg_print_text(), it should
> > be fast. We call console drivers outside of logbuf_lock scope, so
> > everything should fine (tm).
> 
> First, I am all for waking klogd earlier.
> 
> Second, sigh, I do not have much experience with kernel performace issues.
> It is very likely that we really do not need to mind about it.

I really don't think we need to bother.
klogd loggers are as important as consoles, we need to run them anyway.

> > Basically,
> > - if consoles are suspended, we also "suspend" user space klogd.
> >   Does it really make sense?
> > 
> > - if console_lock is acquired by a preemptible task and that task
> >   is getting scheduled out for a long time (OOM, etc) then we postpone
> >   user space logging for unknown period of time. First the console_lock
> >   will have to flush pending messages and only afterwards it will wakeup
> >   klogd. Does it really make sense?
> > 
> > - If current console_lock owner jumps to retry (new pending messages
> >   were appended to the logbuf) label, user space klogd wakeup is getting
> >   postponed even further.
> > 
> > So, the final question is - since there in only one legitimate way
> > (modulo user space writes to kmsg) to append new messages to the
> > logbuf, shall we put klogd wakeup there? IOW, to vprintk_emit().
> 
> Good points! In fact, if we wakeup klogd before calling consoles,
> we would need to do it for every new message. Otherwise, klogd
> processes might miss new messages that are added in parallel
> when console_lock is taken.
[..]
> Then klogd might start sleeping while new messages are still comming

Loggers sleep when `user->seq == log_next_seq' or when
`syslog_seq == log_next_seq'. We need to just wakeup them.
Once woken up they will check the condition again, if there
are no new messages, they will schedule.

> Now, your proposed solution looked fine. Just note that we do not need
> seen_seq. vprintk_emit() knows when log_next_seq is increased.
> It would always wake klogd in this case.

Probably can wake_up_klogd() unconditionally.

> Anyway, I think about slightly different way that would prevent
> scheduling klogd intead of the vprintk_emit() caller. The trick
> is to do the wakeup with preemtion disabled. I mean something like:
[..]
> @@ -1899,9 +1899,13 @@ asmlinkage int vprintk_emit(int facility, int level,
>*/
>   preempt_disable();
>   /*
> +  * Wake klogd with disabled preemtion so that they can run
> +  * in parallel but they could not delay console_handling.
> +  */
> + wake_up_klogd();
> + /*
>* Try to acquire and then immediately release the console
> -  * semaphore.  The release will print out buffers and wake up
> -  * /dev/kmsg and syslog() users.
> +  * semaphore.  The release will print out buffers.
>*/
>   if (console_trylock_spinning())
>   console_unlock();
[..]

It doesn't wakeup loggers for printk_deferred() output this way.
I want to wakeup them for every new logbuf message.

If logger preempts current printk() that it's for 1 message only.
printk() will return back and finish printing. If there will be another
printk()-s from other CPUs, then one of those CPUs will print messages
to the consoles - CPU that woke up logger had not acquired console_sem
before it was preempted by logger.

-ss


Re: [PATCH 4.9 46/92] x86/alternative: Print unadorned pointers

2018-02-09 Thread Greg Kroah-Hartman
On Fri, Feb 09, 2018 at 02:01:32PM -0800, Kees Cook wrote:
> On Fri, Feb 9, 2018 at 5:39 AM, Greg Kroah-Hartman
>  wrote:
> > 4.9-stable review patch.  If anyone has any objections, please let me know.
> >
> > --
> >
> > From: Borislav Petkov 
> >
> > (cherry picked from commit 0e6c16c652cadaffd25a6bb326ec10da5bcec6b4)
> >
> > After commit ad67b74d2469 ("printk: hash addresses printed with %p")
> > pointers are being hashed when printed. However, this makes the alternative
> > debug output completely useless. Switch to %px in order to see the
> > unadorned kernel pointers.
> 
> This missed a "Fixes:" tag so probably missed automated checking on
> how far back to port this. It shouldn't go back beyond 4.15 (where
> ad67b74d2469 first appeared).

Good point.  Should we instead be using %pK for this change instead?  Or
should we just backport commit ad67b74d2469 to 4.14?  :)

Thanks for letting me know this.

greg k-h


Re: [PATCH 4.9 46/92] x86/alternative: Print unadorned pointers

2018-02-09 Thread Greg Kroah-Hartman
On Fri, Feb 09, 2018 at 02:01:32PM -0800, Kees Cook wrote:
> On Fri, Feb 9, 2018 at 5:39 AM, Greg Kroah-Hartman
>  wrote:
> > 4.9-stable review patch.  If anyone has any objections, please let me know.
> >
> > --
> >
> > From: Borislav Petkov 
> >
> > (cherry picked from commit 0e6c16c652cadaffd25a6bb326ec10da5bcec6b4)
> >
> > After commit ad67b74d2469 ("printk: hash addresses printed with %p")
> > pointers are being hashed when printed. However, this makes the alternative
> > debug output completely useless. Switch to %px in order to see the
> > unadorned kernel pointers.
> 
> This missed a "Fixes:" tag so probably missed automated checking on
> how far back to port this. It shouldn't go back beyond 4.15 (where
> ad67b74d2469 first appeared).

Good point.  Should we instead be using %pK for this change instead?  Or
should we just backport commit ad67b74d2469 to 4.14?  :)

Thanks for letting me know this.

greg k-h


Re: [PATCH 4.15 00/23] 4.15.3-stable review

2018-02-09 Thread Greg Kroah-Hartman
On Fri, Feb 09, 2018 at 01:20:26PM -0700, Shuah Khan wrote:
> On 02/09/2018 06:39 AM, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 4.15.3 release.
> > There are 23 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> > 
> > Responses should be made by Sun Feb 11 13:39:20 UTC 2018.
> > Anything received after that time might be too late.
> > 
> > The whole patch series can be found in one patch at:
> > kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.15.3-rc1.gz
> > or in the git tree and branch at:
> >   git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> > linux-4.15.y
> > and the diffstat can be found below.
> > 
> > thanks,
> > 
> > greg k-h
> > 
> 
> Compiled and booted on my test system. No dmesg regressions.

Thanks for testing all 3 of these and letting me know.

greg k-h


Re: [PATCH 4.15 00/23] 4.15.3-stable review

2018-02-09 Thread Greg Kroah-Hartman
On Fri, Feb 09, 2018 at 02:40:41PM -0600, Dan Rue wrote:
> On Fri, Feb 09, 2018 at 02:39:58PM +0100, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 4.15.3 release.
> > There are 23 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> > 
> > Responses should be made by Sun Feb 11 13:39:20 UTC 2018.
> > Anything received after that time might be too late.
> > 
> > The whole patch series can be found in one patch at:
> > kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.15.3-rc1.gz
> > or in the git tree and branch at:
> >   git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> > linux-4.15.y
> > and the diffstat can be found below.
> 
> Results from Linaro’s test farm.
> No regressions on arm64, arm and x86_64.
> 
> Since the last RC, we have upgraded LTP from release version 20170929 to
> release version 20180118. The fanotify06 (and "runltp_syscalls")
> regressions listed below are due to a problem in LTP itself (see
> http://lists.linux.it/pipermail/ltp/2018-January/006915.html). We will
> either carry a patch to fix fanotify06, or skip it until the next LTP
> release. You'll see this noise in the other branches as well.

Ah, nice you upgraded LTP, lots of fixes are getting merged into there
lately.

And thanks for testing all of these and letting me know.

greg k-h


Re: [PATCH 4.15 00/23] 4.15.3-stable review

2018-02-09 Thread Greg Kroah-Hartman
On Fri, Feb 09, 2018 at 01:20:26PM -0700, Shuah Khan wrote:
> On 02/09/2018 06:39 AM, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 4.15.3 release.
> > There are 23 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> > 
> > Responses should be made by Sun Feb 11 13:39:20 UTC 2018.
> > Anything received after that time might be too late.
> > 
> > The whole patch series can be found in one patch at:
> > kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.15.3-rc1.gz
> > or in the git tree and branch at:
> >   git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> > linux-4.15.y
> > and the diffstat can be found below.
> > 
> > thanks,
> > 
> > greg k-h
> > 
> 
> Compiled and booted on my test system. No dmesg regressions.

Thanks for testing all 3 of these and letting me know.

greg k-h


Re: [PATCH 4.15 00/23] 4.15.3-stable review

2018-02-09 Thread Greg Kroah-Hartman
On Fri, Feb 09, 2018 at 02:40:41PM -0600, Dan Rue wrote:
> On Fri, Feb 09, 2018 at 02:39:58PM +0100, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 4.15.3 release.
> > There are 23 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> > 
> > Responses should be made by Sun Feb 11 13:39:20 UTC 2018.
> > Anything received after that time might be too late.
> > 
> > The whole patch series can be found in one patch at:
> > kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.15.3-rc1.gz
> > or in the git tree and branch at:
> >   git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> > linux-4.15.y
> > and the diffstat can be found below.
> 
> Results from Linaro’s test farm.
> No regressions on arm64, arm and x86_64.
> 
> Since the last RC, we have upgraded LTP from release version 20170929 to
> release version 20180118. The fanotify06 (and "runltp_syscalls")
> regressions listed below are due to a problem in LTP itself (see
> http://lists.linux.it/pipermail/ltp/2018-January/006915.html). We will
> either carry a patch to fix fanotify06, or skip it until the next LTP
> release. You'll see this noise in the other branches as well.

Ah, nice you upgraded LTP, lots of fixes are getting merged into there
lately.

And thanks for testing all of these and letting me know.

greg k-h


Re: [RFC PATCH 4/7] kconfig: support new special property shell=

2018-02-09 Thread Masahiro Yamada
2018-02-10 14:48 GMT+09:00 Ulf Magnusson :
> On Fri, Feb 09, 2018 at 12:46:54PM -0800, Kees Cook wrote:
>> On Fri, Feb 9, 2018 at 4:46 AM, Ulf Magnusson  wrote:
>> > One thing that makes Kconfig confusing (though it works well enough in
>> > practice) is that .config files both record user selections (the saved
>> > configuration) and serve as a configuration output format for make.
>> >
>> > It becomes easier to think about .config files once you realize that
>> > assignments to promptless symbols never have an effect on Kconfig
>> > itself: They're just configuration output, intermixed with the saved
>> > user selections.
>> >
>> > Assume 'option env' symbols got written out for example:
>> >
>> > - For a non-user-assignable symbol, the entry in the .config
>> >   file is just configuration output and ignored by Kconfig,
>> >   which will fetch the value from the environment instead.
>> >
>> > - For an assignable 'option env' symbol, the entry in the
>> >   .config file is a saved user selection (as well as
>> >   configuration output), and will be respected by Kconfig.
>>
>> In the stack-protector case, this becomes quite important, since the
>> goal is to record the user's selection regardless of compiler
>> capability. For example, if someone selects _REGULAR, it shouldn't
>> "upgrade" to _STRONG. (Similarly for _NONE.) Having _AUTO provides a
>> way to pick "best possible for this compiler", though. If a user had
>> previously selected _STRONG but they're doing builds with an older
>> compiler (or a misconfigured newer compiler) without support, the goal
>> is to _fail_ to build, not silently select _REGULAR.
>>
>> So, in this case, what's gained is the logic for _AUTO, and the logic
>> to not show, say, _STRONG when it's not available in the compiler. But
>> we must still fail to build if _STRONG was in the .config. It can't
>> silently rewrite it to _REGULAR because the compiler support for
>> _STRONG regressed.
>>
>> -Kees
>>
>> --
>> Kees Cook
>> Pixel Security
>
> Provided that would be the desired behavior:
>
> What about changing the meaning of the choice symbols from e.g. "select
> -fstack-protector-strong" to "want -fstack-protector-strong"? Then the
> user preference would always be remembered, regardless of what's
> available.
>
> Here's a proof-of-concept. I realized that the fancy new 'imply' keyword
> fits pretty well here, since it works like a dependency-respecting
> select.
>
> config CC_HAS_STACKPROTECTOR_STRONG
> bool
> option shell="$CC -Werror -fstack-protector-strong -c -x c 
> /dev/null"
>
> config CC_HAS_STACKPROTECTOR
> bool
> option shell="$CC -Werror -fstack-protector -c -x c /dev/null"
>
>
> choice
> prompt "Stack Protector buffer overflow detection"
> default WANT_CC_STACKPROTECTOR_STRONG
>
> config WANT_CC_STACKPROTECTOR_STRONG
> bool "Strong"
> imply CC_STACKPROTECTOR_STRONG
>
> config WANT_CC_STACKPROTECTOR_REGULAR
> bool "Regular"
> imply CC_STACKPROTECTOR_REGULAR
>
> config WANT_CC_STACKPROTECTOR_NONE
> bool "None"
> imply CC_STACKPROTECTOR_NONE
>
> endchoice
>
>
> config CC_STACKPROTECTOR_STRONG
> bool
> depends on CC_HAS_STACKPROTECTOR_STRONG


Do you mean

 config CC_STACKPROTECTOR_STRONG
 bool
 depends on CC_HAS_STACKPROTECTOR_STRONG && \
WANT_CC_STACKPROTECTOR_STRONG

or, maybe


 config CC_STACKPROTECTOR_STRONG
 bool
 depends on CC_HAS_STACKPROTECTOR_STRONG
 default WANT_CC_STACKPROTECTOR_STRONG

?





> config CC_STACKPROTECTOR_REGULAR
> bool
> depends on CC_HAS_STACKPROTECTOR_REGULAR
>
> config CC_STACKPROTECTOR_NONE
> bool
>
> This version has the drawback of always showing all the options, even if
> some they wouldn't be available. Kconfig comments could be added to warn
> if an option isn't available at least:
>
> comment "Warning: Your compiler does not support 
> -fstack-protector-strong"
> depends on !CC_HAS_STACKPROTECTOR_STRONG
>
> config WANT_CC_STACKPROTECTOR_STRONG
> ...
>
>
> comment "Warning: Your compiler does not support -fstack-protector"
> depends on !CC_HAS_STACKPROTECTOR_REGULAR
>
> config WANT_CC_STACKPROTECTOR_REGULAR
> ...
>
> This final comment might be nice to have too:
>
> comment "Warning: Selected stack protector not available"
> depends on !(CC_STACKPROTECTOR_STRONG ||
>  CC_STACKPROTECTOR_REGULAR ||
> 

Re: [RFC PATCH 4/7] kconfig: support new special property shell=

2018-02-09 Thread Masahiro Yamada
2018-02-10 14:48 GMT+09:00 Ulf Magnusson :
> On Fri, Feb 09, 2018 at 12:46:54PM -0800, Kees Cook wrote:
>> On Fri, Feb 9, 2018 at 4:46 AM, Ulf Magnusson  wrote:
>> > One thing that makes Kconfig confusing (though it works well enough in
>> > practice) is that .config files both record user selections (the saved
>> > configuration) and serve as a configuration output format for make.
>> >
>> > It becomes easier to think about .config files once you realize that
>> > assignments to promptless symbols never have an effect on Kconfig
>> > itself: They're just configuration output, intermixed with the saved
>> > user selections.
>> >
>> > Assume 'option env' symbols got written out for example:
>> >
>> > - For a non-user-assignable symbol, the entry in the .config
>> >   file is just configuration output and ignored by Kconfig,
>> >   which will fetch the value from the environment instead.
>> >
>> > - For an assignable 'option env' symbol, the entry in the
>> >   .config file is a saved user selection (as well as
>> >   configuration output), and will be respected by Kconfig.
>>
>> In the stack-protector case, this becomes quite important, since the
>> goal is to record the user's selection regardless of compiler
>> capability. For example, if someone selects _REGULAR, it shouldn't
>> "upgrade" to _STRONG. (Similarly for _NONE.) Having _AUTO provides a
>> way to pick "best possible for this compiler", though. If a user had
>> previously selected _STRONG but they're doing builds with an older
>> compiler (or a misconfigured newer compiler) without support, the goal
>> is to _fail_ to build, not silently select _REGULAR.
>>
>> So, in this case, what's gained is the logic for _AUTO, and the logic
>> to not show, say, _STRONG when it's not available in the compiler. But
>> we must still fail to build if _STRONG was in the .config. It can't
>> silently rewrite it to _REGULAR because the compiler support for
>> _STRONG regressed.
>>
>> -Kees
>>
>> --
>> Kees Cook
>> Pixel Security
>
> Provided that would be the desired behavior:
>
> What about changing the meaning of the choice symbols from e.g. "select
> -fstack-protector-strong" to "want -fstack-protector-strong"? Then the
> user preference would always be remembered, regardless of what's
> available.
>
> Here's a proof-of-concept. I realized that the fancy new 'imply' keyword
> fits pretty well here, since it works like a dependency-respecting
> select.
>
> config CC_HAS_STACKPROTECTOR_STRONG
> bool
> option shell="$CC -Werror -fstack-protector-strong -c -x c 
> /dev/null"
>
> config CC_HAS_STACKPROTECTOR
> bool
> option shell="$CC -Werror -fstack-protector -c -x c /dev/null"
>
>
> choice
> prompt "Stack Protector buffer overflow detection"
> default WANT_CC_STACKPROTECTOR_STRONG
>
> config WANT_CC_STACKPROTECTOR_STRONG
> bool "Strong"
> imply CC_STACKPROTECTOR_STRONG
>
> config WANT_CC_STACKPROTECTOR_REGULAR
> bool "Regular"
> imply CC_STACKPROTECTOR_REGULAR
>
> config WANT_CC_STACKPROTECTOR_NONE
> bool "None"
> imply CC_STACKPROTECTOR_NONE
>
> endchoice
>
>
> config CC_STACKPROTECTOR_STRONG
> bool
> depends on CC_HAS_STACKPROTECTOR_STRONG


Do you mean

 config CC_STACKPROTECTOR_STRONG
 bool
 depends on CC_HAS_STACKPROTECTOR_STRONG && \
WANT_CC_STACKPROTECTOR_STRONG

or, maybe


 config CC_STACKPROTECTOR_STRONG
 bool
 depends on CC_HAS_STACKPROTECTOR_STRONG
 default WANT_CC_STACKPROTECTOR_STRONG

?





> config CC_STACKPROTECTOR_REGULAR
> bool
> depends on CC_HAS_STACKPROTECTOR_REGULAR
>
> config CC_STACKPROTECTOR_NONE
> bool
>
> This version has the drawback of always showing all the options, even if
> some they wouldn't be available. Kconfig comments could be added to warn
> if an option isn't available at least:
>
> comment "Warning: Your compiler does not support 
> -fstack-protector-strong"
> depends on !CC_HAS_STACKPROTECTOR_STRONG
>
> config WANT_CC_STACKPROTECTOR_STRONG
> ...
>
>
> comment "Warning: Your compiler does not support -fstack-protector"
> depends on !CC_HAS_STACKPROTECTOR_REGULAR
>
> config WANT_CC_STACKPROTECTOR_REGULAR
> ...
>
> This final comment might be nice to have too:
>
> comment "Warning: Selected stack protector not available"
> depends on !(CC_STACKPROTECTOR_STRONG ||
>  CC_STACKPROTECTOR_REGULAR ||
>  CC_STACKPROTECTOR_NONE)
>
> Should 

[GIT PULL] chrome-platform updates for v4.16

2018-02-09 Thread Benson Leung
Hi Linus,

The following changes since commit 50c4c4e268a2d7a3e58ebb698ac74da0de40ae36:

  Linux 4.15-rc3 (2017-12-10 17:56:26 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/bleung/chrome-platform.git 
tags/chrome-platform-for-linus-4.16

for you to fetch changes up to d48b8c58c57f6edbe2965f0a5f62c5cf9593ca96:

  platform/chrome: Use proper protocol transfer function (2017-12-17 14:04:21 
-0800)


chrome-platform-for-linus-4.16

Moving cros_ec_dev to drivers/mfd.
Other small maintenance fixes.


Arnd Bergmann (1):
  cros_ec: fix nul-termination for firmware build info

Benson Leung (1):
  Merge branch 'ibs-for-chrome-platform-merged' into working-branch-for-4.16

Bhumika Goyal (1):
  platform/chrome: chromeos_laptop: make chromeos_laptop const

Colin Ian King (1):
  platform/chrome: cros_ec_lpc: remove redundant pointer request

Enric Balletbo i Serra (1):
  platform/chrome: cros_ec_lpc: Register the driver if ACPI entry is 
missing.

Shawn Nematbakhsh (1):
  platform/chrome: Use proper protocol transfer function

Thierry Escande (3):
  cros_ec: Split cros_ec_devs module
  cros_ec: Move cros_ec_dev module to drivers/mfd
  platform/chrome: cros_ec_lpc: Add support for Google Glimmer

 drivers/mfd/Kconfig| 10 ++
 drivers/mfd/Makefile   |  1 +
 drivers/mfd/cros_ec.c  |  4 +--
 drivers/{platform/chrome => mfd}/cros_ec_dev.c |  8 +++--
 drivers/{platform/chrome => mfd}/cros_ec_dev.h |  0
 drivers/platform/chrome/Kconfig| 10 ++
 drivers/platform/chrome/Makefile   |  7 ++--
 drivers/platform/chrome/chromeos_laptop.c  | 22 ++---
 drivers/platform/chrome/cros_ec_debugfs.c  |  5 ++-
 drivers/platform/chrome/cros_ec_debugfs.h  | 27 
 drivers/platform/chrome/cros_ec_lightbar.c |  6 ++--
 drivers/platform/chrome/cros_ec_lpc.c  | 44 +++---
 drivers/platform/chrome/cros_ec_proto.c|  8 +++--
 drivers/platform/chrome/cros_ec_sysfs.c|  7 ++--
 drivers/platform/chrome/cros_ec_vbc.c  |  1 +
 include/linux/mfd/cros_ec.h|  4 +++
 16 files changed, 94 insertions(+), 70 deletions(-)
 rename drivers/{platform/chrome => mfd}/cros_ec_dev.c (99%)
 rename drivers/{platform/chrome => mfd}/cros_ec_dev.h (100%)
 delete mode 100644 drivers/platform/chrome/cros_ec_debugfs.h

Thanks,
Benson

-- 
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
ble...@google.com
Chromium OS Project
ble...@chromium.org


signature.asc
Description: PGP signature


[GIT PULL] chrome-platform updates for v4.16

2018-02-09 Thread Benson Leung
Hi Linus,

The following changes since commit 50c4c4e268a2d7a3e58ebb698ac74da0de40ae36:

  Linux 4.15-rc3 (2017-12-10 17:56:26 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/bleung/chrome-platform.git 
tags/chrome-platform-for-linus-4.16

for you to fetch changes up to d48b8c58c57f6edbe2965f0a5f62c5cf9593ca96:

  platform/chrome: Use proper protocol transfer function (2017-12-17 14:04:21 
-0800)


chrome-platform-for-linus-4.16

Moving cros_ec_dev to drivers/mfd.
Other small maintenance fixes.


Arnd Bergmann (1):
  cros_ec: fix nul-termination for firmware build info

Benson Leung (1):
  Merge branch 'ibs-for-chrome-platform-merged' into working-branch-for-4.16

Bhumika Goyal (1):
  platform/chrome: chromeos_laptop: make chromeos_laptop const

Colin Ian King (1):
  platform/chrome: cros_ec_lpc: remove redundant pointer request

Enric Balletbo i Serra (1):
  platform/chrome: cros_ec_lpc: Register the driver if ACPI entry is 
missing.

Shawn Nematbakhsh (1):
  platform/chrome: Use proper protocol transfer function

Thierry Escande (3):
  cros_ec: Split cros_ec_devs module
  cros_ec: Move cros_ec_dev module to drivers/mfd
  platform/chrome: cros_ec_lpc: Add support for Google Glimmer

 drivers/mfd/Kconfig| 10 ++
 drivers/mfd/Makefile   |  1 +
 drivers/mfd/cros_ec.c  |  4 +--
 drivers/{platform/chrome => mfd}/cros_ec_dev.c |  8 +++--
 drivers/{platform/chrome => mfd}/cros_ec_dev.h |  0
 drivers/platform/chrome/Kconfig| 10 ++
 drivers/platform/chrome/Makefile   |  7 ++--
 drivers/platform/chrome/chromeos_laptop.c  | 22 ++---
 drivers/platform/chrome/cros_ec_debugfs.c  |  5 ++-
 drivers/platform/chrome/cros_ec_debugfs.h  | 27 
 drivers/platform/chrome/cros_ec_lightbar.c |  6 ++--
 drivers/platform/chrome/cros_ec_lpc.c  | 44 +++---
 drivers/platform/chrome/cros_ec_proto.c|  8 +++--
 drivers/platform/chrome/cros_ec_sysfs.c|  7 ++--
 drivers/platform/chrome/cros_ec_vbc.c  |  1 +
 include/linux/mfd/cros_ec.h|  4 +++
 16 files changed, 94 insertions(+), 70 deletions(-)
 rename drivers/{platform/chrome => mfd}/cros_ec_dev.c (99%)
 rename drivers/{platform/chrome => mfd}/cros_ec_dev.h (100%)
 delete mode 100644 drivers/platform/chrome/cros_ec_debugfs.h

Thanks,
Benson

-- 
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
ble...@google.com
Chromium OS Project
ble...@chromium.org


signature.asc
Description: PGP signature


Re: [PATCH 5/6] ARM: dts: tegra: apalis-tk1: copyright period, spurious newlines

2018-02-09 Thread Philippe Ombredanne
Marcel,

On Sat, Feb 10, 2018 at 2:38 AM, Marcel Ziswiler  wrote:
> From: Marcel Ziswiler 
>
> Update the copyright period and get rid of some spurious newlines.
>
> Signed-off-by: Marcel Ziswiler 
>
> ---
>
>  arch/arm/boot/dts/tegra124-apalis-eval.dts |  6 ++
>  arch/arm/boot/dts/tegra124-apalis.dtsi | 11 +--
>  2 files changed, 3 insertions(+), 14 deletions(-)
>
> diff --git a/arch/arm/boot/dts/tegra124-apalis-eval.dts 
> b/arch/arm/boot/dts/tegra124-apalis-eval.dts
> index f1010cefb993..a6ad759dddb4 100644
> --- a/arch/arm/boot/dts/tegra124-apalis-eval.dts
> +++ b/arch/arm/boot/dts/tegra124-apalis-eval.dts
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright 2016 Toradex AG
> + * Copyright 2016-2018 Toradex AG
>   *
>   * This file is dual-licensed: you can use it either under the terms
>   * of the GPL or the X11 license, at your option. Note that this dual

Since you are fixing copyrights, would you consider also fixing the
license to use a proper SPDX Id instead?

It would be super gentle of you!

And you will get extra good karma point if you feel like doing the
same for every Toradex-copyrighted files ;)

The (still new and fresh) license documentation contributed by tglx
--the only real-time docu-mentalist-- is in:
Documentation/process/license-rules.rst

Thanks!
-- 
Cordially
Philippe Ombredanne


Re: [PATCH 5/6] ARM: dts: tegra: apalis-tk1: copyright period, spurious newlines

2018-02-09 Thread Philippe Ombredanne
Marcel,

On Sat, Feb 10, 2018 at 2:38 AM, Marcel Ziswiler  wrote:
> From: Marcel Ziswiler 
>
> Update the copyright period and get rid of some spurious newlines.
>
> Signed-off-by: Marcel Ziswiler 
>
> ---
>
>  arch/arm/boot/dts/tegra124-apalis-eval.dts |  6 ++
>  arch/arm/boot/dts/tegra124-apalis.dtsi | 11 +--
>  2 files changed, 3 insertions(+), 14 deletions(-)
>
> diff --git a/arch/arm/boot/dts/tegra124-apalis-eval.dts 
> b/arch/arm/boot/dts/tegra124-apalis-eval.dts
> index f1010cefb993..a6ad759dddb4 100644
> --- a/arch/arm/boot/dts/tegra124-apalis-eval.dts
> +++ b/arch/arm/boot/dts/tegra124-apalis-eval.dts
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright 2016 Toradex AG
> + * Copyright 2016-2018 Toradex AG
>   *
>   * This file is dual-licensed: you can use it either under the terms
>   * of the GPL or the X11 license, at your option. Note that this dual

Since you are fixing copyrights, would you consider also fixing the
license to use a proper SPDX Id instead?

It would be super gentle of you!

And you will get extra good karma point if you feel like doing the
same for every Toradex-copyrighted files ;)

The (still new and fresh) license documentation contributed by tglx
--the only real-time docu-mentalist-- is in:
Documentation/process/license-rules.rst

Thanks!
-- 
Cordially
Philippe Ombredanne


Re: [PATCH 4.15 00/23] 4.15.3-stable review

2018-02-09 Thread Greg KH
On Sat, Feb 10, 2018 at 09:47:30AM +0300, Ozkan Sezer wrote:
> On 02/09/2018 06:39 AM, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 4.15.3 release.
> > There are 23 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> >
> > Responses should be made by Sun Feb 11 13:39:20 UTC 2018.
> > Anything received after that time might be too late.
> 
> I hope it's not too late for reverting 
> 5b54eddd3920e9f6f1a6d972454baf350cbae77e
> to fix the i915 "no reboot/no poweroff" regression:
> https://bugs.freedesktop.org/show_bug.cgi?id=104805
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20180209=b5a756a722286af9702d565501e1f690d075d16b

You seem to have dropped the stable@ address :(

No one asked me to apply that patch that I recall, I need some sort of
email from the maintainer/developer please.

thanks,

greg k-h


Re: [PATCH 4.15 00/23] 4.15.3-stable review

2018-02-09 Thread Greg KH
On Sat, Feb 10, 2018 at 09:47:30AM +0300, Ozkan Sezer wrote:
> On 02/09/2018 06:39 AM, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 4.15.3 release.
> > There are 23 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> >
> > Responses should be made by Sun Feb 11 13:39:20 UTC 2018.
> > Anything received after that time might be too late.
> 
> I hope it's not too late for reverting 
> 5b54eddd3920e9f6f1a6d972454baf350cbae77e
> to fix the i915 "no reboot/no poweroff" regression:
> https://bugs.freedesktop.org/show_bug.cgi?id=104805
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20180209=b5a756a722286af9702d565501e1f690d075d16b

You seem to have dropped the stable@ address :(

No one asked me to apply that patch that I recall, I need some sort of
email from the maintainer/developer please.

thanks,

greg k-h


Re: [PATCH 4.15 00/23] 4.15.3-stable review

2018-02-09 Thread Ozkan Sezer
On 02/09/2018 06:39 AM, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.15.3 release.
> There are 23 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>
> Responses should be made by Sun Feb 11 13:39:20 UTC 2018.
> Anything received after that time might be too late.

I hope it's not too late for reverting 5b54eddd3920e9f6f1a6d972454baf350cbae77e
to fix the i915 "no reboot/no poweroff" regression:
https://bugs.freedesktop.org/show_bug.cgi?id=104805
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20180209=b5a756a722286af9702d565501e1f690d075d16b

--
O.S.


Re: [PATCH 4.15 00/23] 4.15.3-stable review

2018-02-09 Thread Ozkan Sezer
On 02/09/2018 06:39 AM, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.15.3 release.
> There are 23 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>
> Responses should be made by Sun Feb 11 13:39:20 UTC 2018.
> Anything received after that time might be too late.

I hope it's not too late for reverting 5b54eddd3920e9f6f1a6d972454baf350cbae77e
to fix the i915 "no reboot/no poweroff" regression:
https://bugs.freedesktop.org/show_bug.cgi?id=104805
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20180209=b5a756a722286af9702d565501e1f690d075d16b

--
O.S.


[PATCH] ARM: dts: armada: netgear-rn*: fix rtc node name

2018-02-09 Thread Alexandre Belloni
The node name should be generic and must not contain the part number.

Signed-off-by: Alexandre Belloni 
---
 arch/arm/boot/dts/armada-370-netgear-rn102.dts | 2 +-
 arch/arm/boot/dts/armada-370-netgear-rn104.dts | 2 +-
 arch/arm/boot/dts/armada-xp-netgear-rn2120.dts | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/armada-370-netgear-rn102.dts 
b/arch/arm/boot/dts/armada-370-netgear-rn102.dts
index b1a96e95e921..d2225bd4a76f 100644
--- a/arch/arm/boot/dts/armada-370-netgear-rn102.dts
+++ b/arch/arm/boot/dts/armada-370-netgear-rn102.dts
@@ -103,7 +103,7 @@
 
status = "okay";
 
-   isl12057: isl12057@68 {
+   isl12057: rtc@68 {
compatible = "isil,isl12057";
reg = <0x68>;
wakeup-source;
diff --git a/arch/arm/boot/dts/armada-370-netgear-rn104.dts 
b/arch/arm/boot/dts/armada-370-netgear-rn104.dts
index d67e7aa42b54..b73cae836bc1 100644
--- a/arch/arm/boot/dts/armada-370-netgear-rn104.dts
+++ b/arch/arm/boot/dts/armada-370-netgear-rn104.dts
@@ -105,7 +105,7 @@
 
status = "okay";
 
-   isl12057: isl12057@68 {
+   isl12057: rtc@68 {
compatible = "isil,isl12057";
reg = <0x68>;
wakeup-source;
diff --git a/arch/arm/boot/dts/armada-xp-netgear-rn2120.dts 
b/arch/arm/boot/dts/armada-xp-netgear-rn2120.dts
index 40c6fe21e720..e66fe80cf279 100644
--- a/arch/arm/boot/dts/armada-xp-netgear-rn2120.dts
+++ b/arch/arm/boot/dts/armada-xp-netgear-rn2120.dts
@@ -115,7 +115,7 @@
reg = <0x4c>;
};
 
-   isl12057: isl12057@68 {
+   isl12057: rtc@68 {
compatible = "isil,isl12057";
reg = <0x68>;
wakeup-source;
-- 
2.16.1



[PATCH] ARM: dts: armada: netgear-rn*: fix rtc node name

2018-02-09 Thread Alexandre Belloni
The node name should be generic and must not contain the part number.

Signed-off-by: Alexandre Belloni 
---
 arch/arm/boot/dts/armada-370-netgear-rn102.dts | 2 +-
 arch/arm/boot/dts/armada-370-netgear-rn104.dts | 2 +-
 arch/arm/boot/dts/armada-xp-netgear-rn2120.dts | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/armada-370-netgear-rn102.dts 
b/arch/arm/boot/dts/armada-370-netgear-rn102.dts
index b1a96e95e921..d2225bd4a76f 100644
--- a/arch/arm/boot/dts/armada-370-netgear-rn102.dts
+++ b/arch/arm/boot/dts/armada-370-netgear-rn102.dts
@@ -103,7 +103,7 @@
 
status = "okay";
 
-   isl12057: isl12057@68 {
+   isl12057: rtc@68 {
compatible = "isil,isl12057";
reg = <0x68>;
wakeup-source;
diff --git a/arch/arm/boot/dts/armada-370-netgear-rn104.dts 
b/arch/arm/boot/dts/armada-370-netgear-rn104.dts
index d67e7aa42b54..b73cae836bc1 100644
--- a/arch/arm/boot/dts/armada-370-netgear-rn104.dts
+++ b/arch/arm/boot/dts/armada-370-netgear-rn104.dts
@@ -105,7 +105,7 @@
 
status = "okay";
 
-   isl12057: isl12057@68 {
+   isl12057: rtc@68 {
compatible = "isil,isl12057";
reg = <0x68>;
wakeup-source;
diff --git a/arch/arm/boot/dts/armada-xp-netgear-rn2120.dts 
b/arch/arm/boot/dts/armada-xp-netgear-rn2120.dts
index 40c6fe21e720..e66fe80cf279 100644
--- a/arch/arm/boot/dts/armada-xp-netgear-rn2120.dts
+++ b/arch/arm/boot/dts/armada-xp-netgear-rn2120.dts
@@ -115,7 +115,7 @@
reg = <0x4c>;
};
 
-   isl12057: isl12057@68 {
+   isl12057: rtc@68 {
compatible = "isil,isl12057";
reg = <0x68>;
wakeup-source;
-- 
2.16.1



Re: [RFC 1/2] sched: reduce migration cost between faster caches for idle_balance

2018-02-09 Thread Mike Galbraith
On Fri, 2018-02-09 at 11:08 -0500, Steven Sistare wrote:
> >> @@ -8804,7 +8803,8 @@ static int idle_balance(struct rq *this_rq, struct 
> >> rq_flags *rf)
> >>if (!(sd->flags & SD_LOAD_BALANCE))
> >>continue;
> >>  
> >> -  if (this_rq->avg_idle < curr_cost + sd->max_newidle_lb_cost) {
> >> +  if (this_rq->avg_idle < curr_cost + sd->max_newidle_lb_cost +
> >> +  sd->sched_migration_cost) {
> >>update_next_balance(sd, _balance);
> >>break;
> >>}
> > 
> > Ditto.
> 
> The old code did not migrate if the expected costs exceeded the expected idle
> time.  The new code just adds the sd-specific penalty (essentially loss of 
> cache 
> footprint) to the costs.  The for_each_domain loop visit smallest to largest
> sd's, hence visiting smallest to largest migration costs (though the tunables 
> do 
> not enforce an ordering), and bails at the first sd where the total cost is a 
> lose.

Hrm..

You're now adding a hypothetical cost to the measured cost of running
the LB machinery, which implies that the measurement is insufficient,
but you still don't say why it is insufficient.  What happens if you
don't do that?  I ask, because when I removed the...

   this_rq->avg_idle < sysctl_sched_migration_cost

...bits to check removal effect for Peter, the original reason for it
being added did not re-materialize, making me wonder why you need to
make this cutoff more aggressive.

-Mike


Re: [RFC 1/2] sched: reduce migration cost between faster caches for idle_balance

2018-02-09 Thread Mike Galbraith
On Fri, 2018-02-09 at 11:08 -0500, Steven Sistare wrote:
> >> @@ -8804,7 +8803,8 @@ static int idle_balance(struct rq *this_rq, struct 
> >> rq_flags *rf)
> >>if (!(sd->flags & SD_LOAD_BALANCE))
> >>continue;
> >>  
> >> -  if (this_rq->avg_idle < curr_cost + sd->max_newidle_lb_cost) {
> >> +  if (this_rq->avg_idle < curr_cost + sd->max_newidle_lb_cost +
> >> +  sd->sched_migration_cost) {
> >>update_next_balance(sd, _balance);
> >>break;
> >>}
> > 
> > Ditto.
> 
> The old code did not migrate if the expected costs exceeded the expected idle
> time.  The new code just adds the sd-specific penalty (essentially loss of 
> cache 
> footprint) to the costs.  The for_each_domain loop visit smallest to largest
> sd's, hence visiting smallest to largest migration costs (though the tunables 
> do 
> not enforce an ordering), and bails at the first sd where the total cost is a 
> lose.

Hrm..

You're now adding a hypothetical cost to the measured cost of running
the LB machinery, which implies that the measurement is insufficient,
but you still don't say why it is insufficient.  What happens if you
don't do that?  I ask, because when I removed the...

   this_rq->avg_idle < sysctl_sched_migration_cost

...bits to check removal effect for Peter, the original reason for it
being added did not re-materialize, making me wonder why you need to
make this cutoff more aggressive.

-Mike


[PATCH] staging: android: ion: Restrict cache maintenance to dma mapped memory

2018-02-09 Thread Liam Mark
The ION begin_cpu_access and end_cpu_access functions use the
dma_sync_sg_for_cpu and dma_sync_sg_for_device APIs to perform cache
maintenance.

Currently it is possible to apply cache maintenance, via the
begin_cpu_access and end_cpu_access APIs, to ION buffers which are not
dma mapped.

The dma sync sg APIs should not be called on sg lists which have not been
dma mapped as this can result in cache maintenance being applied to the
wrong address. If an sg list has not been dma mapped then its dma_address
field has not been populated, some dma ops such as the swiotlb_dma_ops ops
use the dma_address field to calculate the address onto which to apply
cache maintenance.

Fix the ION begin_cpu_access and end_cpu_access functions to only apply
cache maintenance to buffers which have been dma mapped.

Fixes: 2a55e7b5e544 ("staging: android: ion: Call dma_map_sg for syncing and 
mapping")
Signed-off-by: Liam Mark 
---
 drivers/staging/android/ion/ion.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index f480885e346b..e5df5272823d 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -214,6 +214,7 @@ struct ion_dma_buf_attachment {
struct device *dev;
struct sg_table *table;
struct list_head list;
+   bool dma_mapped;
 };
 
 static int ion_dma_buf_attach(struct dma_buf *dmabuf, struct device *dev,
@@ -235,6 +236,7 @@ static int ion_dma_buf_attach(struct dma_buf *dmabuf, 
struct device *dev,
 
a->table = table;
a->dev = dev;
+   a->dma_mapped = false;
INIT_LIST_HEAD(>list);
 
attachment->priv = a;
@@ -272,6 +274,7 @@ static struct sg_table *ion_map_dma_buf(struct 
dma_buf_attachment *attachment,
direction))
return ERR_PTR(-ENOMEM);
 
+   a->dma_mapped = true;
return table;
 }
 
@@ -279,7 +282,10 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment 
*attachment,
  struct sg_table *table,
  enum dma_data_direction direction)
 {
+   struct ion_dma_buf_attachment *a = attachment->priv;
+
dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
+   a->dma_mapped = false;
 }
 
 static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
@@ -345,8 +351,9 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf 
*dmabuf,
 
mutex_lock(>lock);
list_for_each_entry(a, >attachments, list) {
-   dma_sync_sg_for_cpu(a->dev, a->table->sgl, a->table->nents,
-   direction);
+   if (a->dma_mapped)
+   dma_sync_sg_for_cpu(a->dev, a->table->sgl,
+   a->table->nents, direction);
}
mutex_unlock(>lock);
 
@@ -367,8 +374,9 @@ static int ion_dma_buf_end_cpu_access(struct dma_buf 
*dmabuf,
 
mutex_lock(>lock);
list_for_each_entry(a, >attachments, list) {
-   dma_sync_sg_for_device(a->dev, a->table->sgl, a->table->nents,
-  direction);
+   if (a->dma_mapped)
+   dma_sync_sg_for_device(a->dev, a->table->sgl,
+  a->table->nents, direction);
}
mutex_unlock(>lock);
 
-- 
1.8.5.2


Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


[PATCH] staging: android: ion: Restrict cache maintenance to dma mapped memory

2018-02-09 Thread Liam Mark
The ION begin_cpu_access and end_cpu_access functions use the
dma_sync_sg_for_cpu and dma_sync_sg_for_device APIs to perform cache
maintenance.

Currently it is possible to apply cache maintenance, via the
begin_cpu_access and end_cpu_access APIs, to ION buffers which are not
dma mapped.

The dma sync sg APIs should not be called on sg lists which have not been
dma mapped as this can result in cache maintenance being applied to the
wrong address. If an sg list has not been dma mapped then its dma_address
field has not been populated, some dma ops such as the swiotlb_dma_ops ops
use the dma_address field to calculate the address onto which to apply
cache maintenance.

Fix the ION begin_cpu_access and end_cpu_access functions to only apply
cache maintenance to buffers which have been dma mapped.

Fixes: 2a55e7b5e544 ("staging: android: ion: Call dma_map_sg for syncing and 
mapping")
Signed-off-by: Liam Mark 
---
 drivers/staging/android/ion/ion.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index f480885e346b..e5df5272823d 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -214,6 +214,7 @@ struct ion_dma_buf_attachment {
struct device *dev;
struct sg_table *table;
struct list_head list;
+   bool dma_mapped;
 };
 
 static int ion_dma_buf_attach(struct dma_buf *dmabuf, struct device *dev,
@@ -235,6 +236,7 @@ static int ion_dma_buf_attach(struct dma_buf *dmabuf, 
struct device *dev,
 
a->table = table;
a->dev = dev;
+   a->dma_mapped = false;
INIT_LIST_HEAD(>list);
 
attachment->priv = a;
@@ -272,6 +274,7 @@ static struct sg_table *ion_map_dma_buf(struct 
dma_buf_attachment *attachment,
direction))
return ERR_PTR(-ENOMEM);
 
+   a->dma_mapped = true;
return table;
 }
 
@@ -279,7 +282,10 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment 
*attachment,
  struct sg_table *table,
  enum dma_data_direction direction)
 {
+   struct ion_dma_buf_attachment *a = attachment->priv;
+
dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
+   a->dma_mapped = false;
 }
 
 static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
@@ -345,8 +351,9 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf 
*dmabuf,
 
mutex_lock(>lock);
list_for_each_entry(a, >attachments, list) {
-   dma_sync_sg_for_cpu(a->dev, a->table->sgl, a->table->nents,
-   direction);
+   if (a->dma_mapped)
+   dma_sync_sg_for_cpu(a->dev, a->table->sgl,
+   a->table->nents, direction);
}
mutex_unlock(>lock);
 
@@ -367,8 +374,9 @@ static int ion_dma_buf_end_cpu_access(struct dma_buf 
*dmabuf,
 
mutex_lock(>lock);
list_for_each_entry(a, >attachments, list) {
-   dma_sync_sg_for_device(a->dev, a->table->sgl, a->table->nents,
-  direction);
+   if (a->dma_mapped)
+   dma_sync_sg_for_device(a->dev, a->table->sgl,
+  a->table->nents, direction);
}
mutex_unlock(>lock);
 
-- 
1.8.5.2


Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


[PATCH] staging: android: ion: Initialize dma_address of new sg list

2018-02-09 Thread Liam Mark
Fix the dup_sg_table function to initialize the dma_address of the new
sg list entries instead of the source dma_address entries.

Fixes: 17fd283f3870 ("staging: android: ion: Duplicate sg_table")
Signed-off-by: Liam Mark 
---
 drivers/staging/android/ion/ion.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index f480885e346b..3ace3a0d9210 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -197,7 +197,7 @@ static struct sg_table *dup_sg_table(struct sg_table *table)
new_sg = new_table->sgl;
for_each_sg(table->sgl, sg, table->nents, i) {
memcpy(new_sg, sg, sizeof(*sg));
-   sg->dma_address = 0;
+   new_sg->dma_address = 0;
new_sg = sg_next(new_sg);
}
 
-- 
1.8.5.2


Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


[PATCH] staging: android: ion: Initialize dma_address of new sg list

2018-02-09 Thread Liam Mark
Fix the dup_sg_table function to initialize the dma_address of the new
sg list entries instead of the source dma_address entries.

Fixes: 17fd283f3870 ("staging: android: ion: Duplicate sg_table")
Signed-off-by: Liam Mark 
---
 drivers/staging/android/ion/ion.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index f480885e346b..3ace3a0d9210 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -197,7 +197,7 @@ static struct sg_table *dup_sg_table(struct sg_table *table)
new_sg = new_table->sgl;
for_each_sg(table->sgl, sg, table->nents, i) {
memcpy(new_sg, sg, sizeof(*sg));
-   sg->dma_address = 0;
+   new_sg->dma_address = 0;
new_sg = sg_next(new_sg);
}
 
-- 
1.8.5.2


Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [RFC PATCH 4/7] kconfig: support new special property shell=

2018-02-09 Thread Ulf Magnusson
On Fri, Feb 09, 2018 at 12:46:54PM -0800, Kees Cook wrote:
> On Fri, Feb 9, 2018 at 4:46 AM, Ulf Magnusson  wrote:
> > One thing that makes Kconfig confusing (though it works well enough in
> > practice) is that .config files both record user selections (the saved
> > configuration) and serve as a configuration output format for make.
> >
> > It becomes easier to think about .config files once you realize that
> > assignments to promptless symbols never have an effect on Kconfig
> > itself: They're just configuration output, intermixed with the saved
> > user selections.
> >
> > Assume 'option env' symbols got written out for example:
> >
> > - For a non-user-assignable symbol, the entry in the .config
> >   file is just configuration output and ignored by Kconfig,
> >   which will fetch the value from the environment instead.
> >
> > - For an assignable 'option env' symbol, the entry in the
> >   .config file is a saved user selection (as well as
> >   configuration output), and will be respected by Kconfig.
> 
> In the stack-protector case, this becomes quite important, since the
> goal is to record the user's selection regardless of compiler
> capability. For example, if someone selects _REGULAR, it shouldn't
> "upgrade" to _STRONG. (Similarly for _NONE.) Having _AUTO provides a
> way to pick "best possible for this compiler", though. If a user had
> previously selected _STRONG but they're doing builds with an older
> compiler (or a misconfigured newer compiler) without support, the goal
> is to _fail_ to build, not silently select _REGULAR.
> 
> So, in this case, what's gained is the logic for _AUTO, and the logic
> to not show, say, _STRONG when it's not available in the compiler. But
> we must still fail to build if _STRONG was in the .config. It can't
> silently rewrite it to _REGULAR because the compiler support for
> _STRONG regressed.
> 
> -Kees
> 
> -- 
> Kees Cook
> Pixel Security

Provided that would be the desired behavior:

What about changing the meaning of the choice symbols from e.g. "select
-fstack-protector-strong" to "want -fstack-protector-strong"? Then the
user preference would always be remembered, regardless of what's
available.

Here's a proof-of-concept. I realized that the fancy new 'imply' keyword
fits pretty well here, since it works like a dependency-respecting
select.

config CC_HAS_STACKPROTECTOR_STRONG
bool
option shell="$CC -Werror -fstack-protector-strong -c -x c 
/dev/null"

config CC_HAS_STACKPROTECTOR
bool
option shell="$CC -Werror -fstack-protector -c -x c /dev/null"


choice
prompt "Stack Protector buffer overflow detection"
default WANT_CC_STACKPROTECTOR_STRONG

config WANT_CC_STACKPROTECTOR_STRONG
bool "Strong"
imply CC_STACKPROTECTOR_STRONG

config WANT_CC_STACKPROTECTOR_REGULAR
bool "Regular"
imply CC_STACKPROTECTOR_REGULAR

config WANT_CC_STACKPROTECTOR_NONE
bool "None"
imply CC_STACKPROTECTOR_NONE

endchoice


config CC_STACKPROTECTOR_STRONG
bool
depends on CC_HAS_STACKPROTECTOR_STRONG

config CC_STACKPROTECTOR_REGULAR
bool
depends on CC_HAS_STACKPROTECTOR_REGULAR

config CC_STACKPROTECTOR_NONE
bool

This version has the drawback of always showing all the options, even if
some they wouldn't be available. Kconfig comments could be added to warn
if an option isn't available at least:

comment "Warning: Your compiler does not support 
-fstack-protector-strong"
depends on !CC_HAS_STACKPROTECTOR_STRONG

config WANT_CC_STACKPROTECTOR_STRONG
...


comment "Warning: Your compiler does not support -fstack-protector"
depends on !CC_HAS_STACKPROTECTOR_REGULAR

config WANT_CC_STACKPROTECTOR_REGULAR
...

This final comment might be nice to have too:

comment "Warning: Selected stack protector not available"
depends on !(CC_STACKPROTECTOR_STRONG ||
 CC_STACKPROTECTOR_REGULAR ||
 CC_STACKPROTECTOR_NONE)

Should probably introduce a clear warning that tells the user what they
need to change in Kconfig if they build with a broken selection too.


CC_STACKPROTECTOR_AUTO could be added to the choice in a slightly kludgy
way too. Maybe there's something neater.

config CC_STACKPROTECTOR_AUTO
bool "Automatic"
imply CC_STACKPROTECTOR_STRONG
imply CC_STACKPROTECTOR_REGULAR if !CC_HAS_STACKPROTECTOR_STRONG
imply CC_STACKPROTECTOR_NONEif 

Re: [RFC PATCH 4/7] kconfig: support new special property shell=

2018-02-09 Thread Ulf Magnusson
On Fri, Feb 09, 2018 at 12:46:54PM -0800, Kees Cook wrote:
> On Fri, Feb 9, 2018 at 4:46 AM, Ulf Magnusson  wrote:
> > One thing that makes Kconfig confusing (though it works well enough in
> > practice) is that .config files both record user selections (the saved
> > configuration) and serve as a configuration output format for make.
> >
> > It becomes easier to think about .config files once you realize that
> > assignments to promptless symbols never have an effect on Kconfig
> > itself: They're just configuration output, intermixed with the saved
> > user selections.
> >
> > Assume 'option env' symbols got written out for example:
> >
> > - For a non-user-assignable symbol, the entry in the .config
> >   file is just configuration output and ignored by Kconfig,
> >   which will fetch the value from the environment instead.
> >
> > - For an assignable 'option env' symbol, the entry in the
> >   .config file is a saved user selection (as well as
> >   configuration output), and will be respected by Kconfig.
> 
> In the stack-protector case, this becomes quite important, since the
> goal is to record the user's selection regardless of compiler
> capability. For example, if someone selects _REGULAR, it shouldn't
> "upgrade" to _STRONG. (Similarly for _NONE.) Having _AUTO provides a
> way to pick "best possible for this compiler", though. If a user had
> previously selected _STRONG but they're doing builds with an older
> compiler (or a misconfigured newer compiler) without support, the goal
> is to _fail_ to build, not silently select _REGULAR.
> 
> So, in this case, what's gained is the logic for _AUTO, and the logic
> to not show, say, _STRONG when it's not available in the compiler. But
> we must still fail to build if _STRONG was in the .config. It can't
> silently rewrite it to _REGULAR because the compiler support for
> _STRONG regressed.
> 
> -Kees
> 
> -- 
> Kees Cook
> Pixel Security

Provided that would be the desired behavior:

What about changing the meaning of the choice symbols from e.g. "select
-fstack-protector-strong" to "want -fstack-protector-strong"? Then the
user preference would always be remembered, regardless of what's
available.

Here's a proof-of-concept. I realized that the fancy new 'imply' keyword
fits pretty well here, since it works like a dependency-respecting
select.

config CC_HAS_STACKPROTECTOR_STRONG
bool
option shell="$CC -Werror -fstack-protector-strong -c -x c 
/dev/null"

config CC_HAS_STACKPROTECTOR
bool
option shell="$CC -Werror -fstack-protector -c -x c /dev/null"


choice
prompt "Stack Protector buffer overflow detection"
default WANT_CC_STACKPROTECTOR_STRONG

config WANT_CC_STACKPROTECTOR_STRONG
bool "Strong"
imply CC_STACKPROTECTOR_STRONG

config WANT_CC_STACKPROTECTOR_REGULAR
bool "Regular"
imply CC_STACKPROTECTOR_REGULAR

config WANT_CC_STACKPROTECTOR_NONE
bool "None"
imply CC_STACKPROTECTOR_NONE

endchoice


config CC_STACKPROTECTOR_STRONG
bool
depends on CC_HAS_STACKPROTECTOR_STRONG

config CC_STACKPROTECTOR_REGULAR
bool
depends on CC_HAS_STACKPROTECTOR_REGULAR

config CC_STACKPROTECTOR_NONE
bool

This version has the drawback of always showing all the options, even if
some they wouldn't be available. Kconfig comments could be added to warn
if an option isn't available at least:

comment "Warning: Your compiler does not support 
-fstack-protector-strong"
depends on !CC_HAS_STACKPROTECTOR_STRONG

config WANT_CC_STACKPROTECTOR_STRONG
...


comment "Warning: Your compiler does not support -fstack-protector"
depends on !CC_HAS_STACKPROTECTOR_REGULAR

config WANT_CC_STACKPROTECTOR_REGULAR
...

This final comment might be nice to have too:

comment "Warning: Selected stack protector not available"
depends on !(CC_STACKPROTECTOR_STRONG ||
 CC_STACKPROTECTOR_REGULAR ||
 CC_STACKPROTECTOR_NONE)

Should probably introduce a clear warning that tells the user what they
need to change in Kconfig if they build with a broken selection too.


CC_STACKPROTECTOR_AUTO could be added to the choice in a slightly kludgy
way too. Maybe there's something neater.

config CC_STACKPROTECTOR_AUTO
bool "Automatic"
imply CC_STACKPROTECTOR_STRONG
imply CC_STACKPROTECTOR_REGULAR if !CC_HAS_STACKPROTECTOR_STRONG
imply CC_STACKPROTECTOR_NONEif 

Re: [PATCH v2 1/1] mm: initialize pages on demand during boot

2018-02-09 Thread kbuild test robot
Hi Pavel,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mmotm/master]
[also build test WARNING on next-20180209]
[cannot apply to v4.15]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Pavel-Tatashin/mm-initialize-pages-on-demand-during-boot/20180210-125104
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: i386-randconfig-x018-201805 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/asm-generic/bug.h:18:0,
from arch/x86/include/asm/bug.h:82,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:9,
from mm/page_alloc.c:18:
   mm/page_alloc.c: In function 'free_area_init_node':
   include/linux/kernel.h:792:16: warning: comparison of distinct pointer types 
lacks a cast
 (void) ( == );   \
   ^
   include/linux/kernel.h:801:2: note: in expansion of macro '__min'
 __min(typeof(x), typeof(y),   \
 ^
>> mm/page_alloc.c:6357:29: note: in expansion of macro 'min'
 pgdat->static_init_pgcnt = min(PAGES_PER_SECTION,
^~~

vim +/min +6357 mm/page_alloc.c

  6325  
  6326  void __paginginit free_area_init_node(int nid, unsigned long 
*zones_size,
  6327  unsigned long node_start_pfn, unsigned long 
*zholes_size)
  6328  {
  6329  pg_data_t *pgdat = NODE_DATA(nid);
  6330  unsigned long start_pfn = 0;
  6331  unsigned long end_pfn = 0;
  6332  
  6333  /* pg_data_t should be reset to zero when it's allocated */
  6334  WARN_ON(pgdat->nr_zones || pgdat->kswapd_classzone_idx);
  6335  
  6336  pgdat->node_id = nid;
  6337  pgdat->node_start_pfn = node_start_pfn;
  6338  pgdat->per_cpu_nodestats = NULL;
  6339  #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
  6340  get_pfn_range_for_nid(nid, _pfn, _pfn);
  6341  pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,
  6342  (u64)start_pfn << PAGE_SHIFT,
  6343  end_pfn ? ((u64)end_pfn << PAGE_SHIFT) - 1 : 0);
  6344  #else
  6345  start_pfn = node_start_pfn;
  6346  #endif
  6347  calculate_node_totalpages(pgdat, start_pfn, end_pfn,
  6348zones_size, zholes_size);
  6349  
  6350  alloc_node_mem_map(pgdat);
  6351  
  6352  #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
  6353  /*
  6354   * We start only with one section of pages, more pages are 
added as
  6355   * needed until the rest of deferred pages are initialized.
  6356   */
> 6357  pgdat->static_init_pgcnt = min(PAGES_PER_SECTION,
  6358 pgdat->node_spanned_pages);
  6359  pgdat->first_deferred_pfn = ULONG_MAX;
  6360  #endif
  6361  free_area_init_core(pgdat);
  6362  }
  6363  

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


.config.gz
Description: application/gzip


Re: [PATCH v2 1/1] mm: initialize pages on demand during boot

2018-02-09 Thread kbuild test robot
Hi Pavel,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mmotm/master]
[also build test WARNING on next-20180209]
[cannot apply to v4.15]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Pavel-Tatashin/mm-initialize-pages-on-demand-during-boot/20180210-125104
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: i386-randconfig-x018-201805 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/asm-generic/bug.h:18:0,
from arch/x86/include/asm/bug.h:82,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:9,
from mm/page_alloc.c:18:
   mm/page_alloc.c: In function 'free_area_init_node':
   include/linux/kernel.h:792:16: warning: comparison of distinct pointer types 
lacks a cast
 (void) ( == );   \
   ^
   include/linux/kernel.h:801:2: note: in expansion of macro '__min'
 __min(typeof(x), typeof(y),   \
 ^
>> mm/page_alloc.c:6357:29: note: in expansion of macro 'min'
 pgdat->static_init_pgcnt = min(PAGES_PER_SECTION,
^~~

vim +/min +6357 mm/page_alloc.c

  6325  
  6326  void __paginginit free_area_init_node(int nid, unsigned long 
*zones_size,
  6327  unsigned long node_start_pfn, unsigned long 
*zholes_size)
  6328  {
  6329  pg_data_t *pgdat = NODE_DATA(nid);
  6330  unsigned long start_pfn = 0;
  6331  unsigned long end_pfn = 0;
  6332  
  6333  /* pg_data_t should be reset to zero when it's allocated */
  6334  WARN_ON(pgdat->nr_zones || pgdat->kswapd_classzone_idx);
  6335  
  6336  pgdat->node_id = nid;
  6337  pgdat->node_start_pfn = node_start_pfn;
  6338  pgdat->per_cpu_nodestats = NULL;
  6339  #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
  6340  get_pfn_range_for_nid(nid, _pfn, _pfn);
  6341  pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,
  6342  (u64)start_pfn << PAGE_SHIFT,
  6343  end_pfn ? ((u64)end_pfn << PAGE_SHIFT) - 1 : 0);
  6344  #else
  6345  start_pfn = node_start_pfn;
  6346  #endif
  6347  calculate_node_totalpages(pgdat, start_pfn, end_pfn,
  6348zones_size, zholes_size);
  6349  
  6350  alloc_node_mem_map(pgdat);
  6351  
  6352  #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
  6353  /*
  6354   * We start only with one section of pages, more pages are 
added as
  6355   * needed until the rest of deferred pages are initialized.
  6356   */
> 6357  pgdat->static_init_pgcnt = min(PAGES_PER_SECTION,
  6358 pgdat->node_spanned_pages);
  6359  pgdat->first_deferred_pfn = ULONG_MAX;
  6360  #endif
  6361  free_area_init_core(pgdat);
  6362  }
  6363  

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


.config.gz
Description: application/gzip


Re: [PATCH v2 1/1] mm: initialize pages on demand during boot

2018-02-09 Thread kbuild test robot
Hi Pavel,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mmotm/master]
[also build test ERROR on next-20180209]
[cannot apply to v4.15]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Pavel-Tatashin/mm-initialize-pages-on-demand-during-boot/20180210-125104
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: x86_64-randconfig-x017-201805 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   mm/page_alloc.c: In function 'deferred_grow_zone':
>> mm/page_alloc.c:1590:18: error: 'struct zone' has no member named 'node'; 
>> did you mean 'name'?
 int nid = zone->node;
 ^~~~
 name

vim +1590 mm/page_alloc.c

  1578  
  1579  /*
  1580   * If this zone has deferred pages, try to grow it by initializing 
enough
  1581   * deferred pages to satisfy the allocation specified by order, rounded 
up to
  1582   * the nearest PAGES_PER_SECTION boundary.  So we're adding memory in 
increments
  1583   * of SECTION_SIZE bytes by initializing struct pages in increments of
  1584   * PAGES_PER_SECTION * sizeof(struct page) bytes.
  1585   */
  1586  static noinline bool __init
  1587  deferred_grow_zone(struct zone *zone, unsigned int order)
  1588  {
  1589  int zid = zone_idx(zone);
> 1590  int nid = zone->node;
  1591  pg_data_t *pgdat = NODE_DATA(nid);
  1592  unsigned long nr_pages_needed = ALIGN(1 << order, 
PAGES_PER_SECTION);
  1593  unsigned long nr_pages = 0;
  1594  unsigned long first_init_pfn, first_deferred_pfn, spfn, epfn, t;
  1595  phys_addr_t spa, epa;
  1596  u64 i;
  1597  
  1598  /* Only the last zone may have deferred pages */
  1599  if (zone_end_pfn(zone) != pgdat_end_pfn(pgdat))
  1600  return false;
  1601  
  1602  first_deferred_pfn = READ_ONCE(pgdat->first_deferred_pfn);
  1603  first_init_pfn = max(zone->zone_start_pfn, first_deferred_pfn);
  1604  
  1605  if (first_init_pfn >= pgdat_end_pfn(pgdat))
  1606  return false;
  1607  
  1608  spin_lock(_zone_grow_lock);
  1609  /*
  1610   * Bail if we raced with another thread that disabled on demand
  1611   * initialization.
  1612   */
  1613  if (!static_branch_unlikely(_pages)) {
  1614  spin_unlock(_zone_grow_lock);
  1615  return false;
  1616  }
  1617  
  1618  for_each_free_mem_range(i, nid, MEMBLOCK_NONE, , , 
NULL) {
  1619  spfn = max_t(unsigned long, first_init_pfn, 
PFN_UP(spa));
  1620  epfn = min_t(unsigned long, zone_end_pfn(zone), 
PFN_DOWN(epa));
  1621  
  1622  while (spfn < epfn && nr_pages < nr_pages_needed) {
  1623  t = ALIGN(spfn + PAGES_PER_SECTION, 
PAGES_PER_SECTION);
  1624  first_deferred_pfn = min(t, epfn);
  1625  nr_pages += deferred_init_pages(nid, zid, spfn,
  1626  
first_deferred_pfn);
  1627  spfn = first_deferred_pfn;
  1628  }
  1629  
  1630  if (nr_pages >= nr_pages_needed)
  1631  break;
  1632  }
  1633  
  1634  for_each_free_mem_range(i, nid, MEMBLOCK_NONE, , , 
NULL) {
  1635  spfn = max_t(unsigned long, first_init_pfn, 
PFN_UP(spa));
  1636  epfn = min_t(unsigned long, first_deferred_pfn, 
PFN_DOWN(epa));
  1637  deferred_free_pages(nid, zid, spfn, epfn);
  1638  
  1639  if (first_deferred_pfn == epfn)
  1640  break;
  1641  }
  1642  WRITE_ONCE(pgdat->first_deferred_pfn, first_deferred_pfn);
  1643  spin_unlock(_zone_grow_lock);
  1644  
  1645  return nr_pages >= nr_pages_needed;
  1646  }
  1647  

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


.config.gz
Description: application/gzip


Re: [PATCH v2 1/1] mm: initialize pages on demand during boot

2018-02-09 Thread kbuild test robot
Hi Pavel,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mmotm/master]
[also build test ERROR on next-20180209]
[cannot apply to v4.15]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Pavel-Tatashin/mm-initialize-pages-on-demand-during-boot/20180210-125104
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: x86_64-randconfig-x017-201805 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   mm/page_alloc.c: In function 'deferred_grow_zone':
>> mm/page_alloc.c:1590:18: error: 'struct zone' has no member named 'node'; 
>> did you mean 'name'?
 int nid = zone->node;
 ^~~~
 name

vim +1590 mm/page_alloc.c

  1578  
  1579  /*
  1580   * If this zone has deferred pages, try to grow it by initializing 
enough
  1581   * deferred pages to satisfy the allocation specified by order, rounded 
up to
  1582   * the nearest PAGES_PER_SECTION boundary.  So we're adding memory in 
increments
  1583   * of SECTION_SIZE bytes by initializing struct pages in increments of
  1584   * PAGES_PER_SECTION * sizeof(struct page) bytes.
  1585   */
  1586  static noinline bool __init
  1587  deferred_grow_zone(struct zone *zone, unsigned int order)
  1588  {
  1589  int zid = zone_idx(zone);
> 1590  int nid = zone->node;
  1591  pg_data_t *pgdat = NODE_DATA(nid);
  1592  unsigned long nr_pages_needed = ALIGN(1 << order, 
PAGES_PER_SECTION);
  1593  unsigned long nr_pages = 0;
  1594  unsigned long first_init_pfn, first_deferred_pfn, spfn, epfn, t;
  1595  phys_addr_t spa, epa;
  1596  u64 i;
  1597  
  1598  /* Only the last zone may have deferred pages */
  1599  if (zone_end_pfn(zone) != pgdat_end_pfn(pgdat))
  1600  return false;
  1601  
  1602  first_deferred_pfn = READ_ONCE(pgdat->first_deferred_pfn);
  1603  first_init_pfn = max(zone->zone_start_pfn, first_deferred_pfn);
  1604  
  1605  if (first_init_pfn >= pgdat_end_pfn(pgdat))
  1606  return false;
  1607  
  1608  spin_lock(_zone_grow_lock);
  1609  /*
  1610   * Bail if we raced with another thread that disabled on demand
  1611   * initialization.
  1612   */
  1613  if (!static_branch_unlikely(_pages)) {
  1614  spin_unlock(_zone_grow_lock);
  1615  return false;
  1616  }
  1617  
  1618  for_each_free_mem_range(i, nid, MEMBLOCK_NONE, , , 
NULL) {
  1619  spfn = max_t(unsigned long, first_init_pfn, 
PFN_UP(spa));
  1620  epfn = min_t(unsigned long, zone_end_pfn(zone), 
PFN_DOWN(epa));
  1621  
  1622  while (spfn < epfn && nr_pages < nr_pages_needed) {
  1623  t = ALIGN(spfn + PAGES_PER_SECTION, 
PAGES_PER_SECTION);
  1624  first_deferred_pfn = min(t, epfn);
  1625  nr_pages += deferred_init_pages(nid, zid, spfn,
  1626  
first_deferred_pfn);
  1627  spfn = first_deferred_pfn;
  1628  }
  1629  
  1630  if (nr_pages >= nr_pages_needed)
  1631  break;
  1632  }
  1633  
  1634  for_each_free_mem_range(i, nid, MEMBLOCK_NONE, , , 
NULL) {
  1635  spfn = max_t(unsigned long, first_init_pfn, 
PFN_UP(spa));
  1636  epfn = min_t(unsigned long, first_deferred_pfn, 
PFN_DOWN(epa));
  1637  deferred_free_pages(nid, zid, spfn, epfn);
  1638  
  1639  if (first_deferred_pfn == epfn)
  1640  break;
  1641  }
  1642  WRITE_ONCE(pgdat->first_deferred_pfn, first_deferred_pfn);
  1643  spin_unlock(_zone_grow_lock);
  1644  
  1645  return nr_pages >= nr_pages_needed;
  1646  }
  1647  

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


.config.gz
Description: application/gzip


[PATCH RFC v5] f2fs: flush cp pack except cp pack 2 page at first

2018-02-09 Thread Gao Xiang
Previously, we attempt to flush the whole cp pack in a single bio,
however, when suddenly powering off at this time, we could get into
an extreme scenario that cp pack 1 page and cp pack 2 page are updated
and latest, but payload or current summaries are still partially
outdated. (see reliable write in the UFS specification)

This patch submits the whole cp pack except cp pack 2 page at first,
and then writes the cp pack 2 page with an extra independent
bio with pre-io barrier.

Signed-off-by: Gao Xiang 
Reviewed-by: Chao Yu 
---
Change log from v4:
  - remove redundant "filemap_fdatawait_range"
  - filemap_fdatawait_range(NODE_MAPPING(sbi), 0, LLONG_MAX);
  - filemap_fdatawait_range(META_MAPPING(sbi), 0, LLONG_MAX);
  - move f2fs_flush_device_cache to a more suitable position
  - wait_on_all_pages_writeback after commit_checkpoint
  - since we remove lots of redundant code, I think it's acceptable
  - and it will ensure one checkpoint safety.
Change log from v3:
  - further review comments are applied from Jaegeuk and Chao
  - Tested on this patch (without multiple-device): mount, boot Android with 
f2fs userdata and make fragment
  - If any problem with this patch or I miss something, please kindly share 
your comments, thanks :)
Change log from v2:
  - Apply the review comments from Chao
Change log from v1:
  - Apply the review comments from Chao
  - time data from "finish block_ops" to " finish checkpoint" (tested on ARM64 
with TOSHIBA 128GB UFS):
 Before patch: 0.002273  0.001973  0.002789  0.005159  0.002050
 After patch: 0.002502  0.001624  0.002487  0.003049  0.002696

 fs/f2fs/checkpoint.c | 69 ++--
 1 file changed, 46 insertions(+), 23 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 512dca8..4e352cf 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -1162,6 +1162,39 @@ static void update_ckpt_flags(struct f2fs_sb_info *sbi, 
struct cp_control *cpc)
spin_unlock_irqrestore(>cp_lock, flags);
 }
 
+static void commit_checkpoint(struct f2fs_sb_info *sbi,
+   void *src, block_t blk_addr)
+{
+   struct writeback_control wbc = {
+   .for_reclaim = 0,
+   };
+
+   /*
+* pagevec_lookup_tag and lock_page again will take
+* some extra time. Therefore, update_meta_pages and
+* sync_meta_pages are combined in this function.
+*/
+   struct page *page = grab_meta_page(sbi, blk_addr);
+   int err;
+
+   memcpy(page_address(page), src, PAGE_SIZE);
+   set_page_dirty(page);
+
+   f2fs_wait_on_page_writeback(page, META, true);
+   f2fs_bug_on(sbi, PageWriteback(page));
+   if (unlikely(!clear_page_dirty_for_io(page)))
+   f2fs_bug_on(sbi, 1);
+
+   /* writeout cp pack 2 page */
+   err = __f2fs_write_meta_page(page, , FS_CP_META_IO);
+   f2fs_bug_on(sbi, err);
+
+   f2fs_put_page(page, 0);
+
+   /* submit checkpoint (with barrier if NOBARRIER is not set) */
+   f2fs_submit_merged_write(sbi, META_FLUSH);
+}
+
 static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 {
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
@@ -1264,16 +1297,6 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, 
struct cp_control *cpc)
}
}
 
-   /* need to wait for end_io results */
-   wait_on_all_pages_writeback(sbi);
-   if (unlikely(f2fs_cp_error(sbi)))
-   return -EIO;
-
-   /* flush all device cache */
-   err = f2fs_flush_device_cache(sbi);
-   if (err)
-   return err;
-
/* write out checkpoint buffer at block 0 */
update_meta_page(sbi, ckpt, start_blk++);
 
@@ -1301,26 +1324,26 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, 
struct cp_control *cpc)
start_blk += NR_CURSEG_NODE_TYPE;
}
 
-   /* writeout checkpoint block */
-   update_meta_page(sbi, ckpt, start_blk);
+   /* update user_block_counts */
+   sbi->last_valid_block_count = sbi->total_valid_block_count;
+   percpu_counter_set(>alloc_valid_block_count, 0);
 
-   /* wait for previous submitted node/meta pages writeback */
+   /* Here, we have one bio having CP pack except cp pack 2 page */
+   sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
+
+   /* wait for previous submitted meta pages writeback */
wait_on_all_pages_writeback(sbi);
 
if (unlikely(f2fs_cp_error(sbi)))
return -EIO;
 
-   filemap_fdatawait_range(NODE_MAPPING(sbi), 0, LLONG_MAX);
-   filemap_fdatawait_range(META_MAPPING(sbi), 0, LLONG_MAX);
-
-   /* update user_block_counts */
-   sbi->last_valid_block_count = sbi->total_valid_block_count;
-   percpu_counter_set(>alloc_valid_block_count, 0);
-
-   /* Here, we only have one bio having CP pack */
-   sync_meta_pages(sbi, META_FLUSH, 

[PATCH RFC v5] f2fs: flush cp pack except cp pack 2 page at first

2018-02-09 Thread Gao Xiang
Previously, we attempt to flush the whole cp pack in a single bio,
however, when suddenly powering off at this time, we could get into
an extreme scenario that cp pack 1 page and cp pack 2 page are updated
and latest, but payload or current summaries are still partially
outdated. (see reliable write in the UFS specification)

This patch submits the whole cp pack except cp pack 2 page at first,
and then writes the cp pack 2 page with an extra independent
bio with pre-io barrier.

Signed-off-by: Gao Xiang 
Reviewed-by: Chao Yu 
---
Change log from v4:
  - remove redundant "filemap_fdatawait_range"
  - filemap_fdatawait_range(NODE_MAPPING(sbi), 0, LLONG_MAX);
  - filemap_fdatawait_range(META_MAPPING(sbi), 0, LLONG_MAX);
  - move f2fs_flush_device_cache to a more suitable position
  - wait_on_all_pages_writeback after commit_checkpoint
  - since we remove lots of redundant code, I think it's acceptable
  - and it will ensure one checkpoint safety.
Change log from v3:
  - further review comments are applied from Jaegeuk and Chao
  - Tested on this patch (without multiple-device): mount, boot Android with 
f2fs userdata and make fragment
  - If any problem with this patch or I miss something, please kindly share 
your comments, thanks :)
Change log from v2:
  - Apply the review comments from Chao
Change log from v1:
  - Apply the review comments from Chao
  - time data from "finish block_ops" to " finish checkpoint" (tested on ARM64 
with TOSHIBA 128GB UFS):
 Before patch: 0.002273  0.001973  0.002789  0.005159  0.002050
 After patch: 0.002502  0.001624  0.002487  0.003049  0.002696

 fs/f2fs/checkpoint.c | 69 ++--
 1 file changed, 46 insertions(+), 23 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 512dca8..4e352cf 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -1162,6 +1162,39 @@ static void update_ckpt_flags(struct f2fs_sb_info *sbi, 
struct cp_control *cpc)
spin_unlock_irqrestore(>cp_lock, flags);
 }
 
+static void commit_checkpoint(struct f2fs_sb_info *sbi,
+   void *src, block_t blk_addr)
+{
+   struct writeback_control wbc = {
+   .for_reclaim = 0,
+   };
+
+   /*
+* pagevec_lookup_tag and lock_page again will take
+* some extra time. Therefore, update_meta_pages and
+* sync_meta_pages are combined in this function.
+*/
+   struct page *page = grab_meta_page(sbi, blk_addr);
+   int err;
+
+   memcpy(page_address(page), src, PAGE_SIZE);
+   set_page_dirty(page);
+
+   f2fs_wait_on_page_writeback(page, META, true);
+   f2fs_bug_on(sbi, PageWriteback(page));
+   if (unlikely(!clear_page_dirty_for_io(page)))
+   f2fs_bug_on(sbi, 1);
+
+   /* writeout cp pack 2 page */
+   err = __f2fs_write_meta_page(page, , FS_CP_META_IO);
+   f2fs_bug_on(sbi, err);
+
+   f2fs_put_page(page, 0);
+
+   /* submit checkpoint (with barrier if NOBARRIER is not set) */
+   f2fs_submit_merged_write(sbi, META_FLUSH);
+}
+
 static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 {
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
@@ -1264,16 +1297,6 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, 
struct cp_control *cpc)
}
}
 
-   /* need to wait for end_io results */
-   wait_on_all_pages_writeback(sbi);
-   if (unlikely(f2fs_cp_error(sbi)))
-   return -EIO;
-
-   /* flush all device cache */
-   err = f2fs_flush_device_cache(sbi);
-   if (err)
-   return err;
-
/* write out checkpoint buffer at block 0 */
update_meta_page(sbi, ckpt, start_blk++);
 
@@ -1301,26 +1324,26 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, 
struct cp_control *cpc)
start_blk += NR_CURSEG_NODE_TYPE;
}
 
-   /* writeout checkpoint block */
-   update_meta_page(sbi, ckpt, start_blk);
+   /* update user_block_counts */
+   sbi->last_valid_block_count = sbi->total_valid_block_count;
+   percpu_counter_set(>alloc_valid_block_count, 0);
 
-   /* wait for previous submitted node/meta pages writeback */
+   /* Here, we have one bio having CP pack except cp pack 2 page */
+   sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
+
+   /* wait for previous submitted meta pages writeback */
wait_on_all_pages_writeback(sbi);
 
if (unlikely(f2fs_cp_error(sbi)))
return -EIO;
 
-   filemap_fdatawait_range(NODE_MAPPING(sbi), 0, LLONG_MAX);
-   filemap_fdatawait_range(META_MAPPING(sbi), 0, LLONG_MAX);
-
-   /* update user_block_counts */
-   sbi->last_valid_block_count = sbi->total_valid_block_count;
-   percpu_counter_set(>alloc_valid_block_count, 0);
-
-   /* Here, we only have one bio having CP pack */
-   sync_meta_pages(sbi, META_FLUSH, LONG_MAX, FS_CP_META_IO);
+   /* flush all 

[PATCH 2/4] powerpc/vas: Fix cleanup when VAS is not configured

2018-02-09 Thread Sukadev Bhattiprolu
When VAS is not configured in the system, make sure to remove
the VAS debugfs directory and unregister the platform driver.

Signed-off-by: Sukadev Bhattiprolu 
---
 arch/powerpc/platforms/powernv/vas-debug.c | 5 +
 arch/powerpc/platforms/powernv/vas.c   | 5 -
 arch/powerpc/platforms/powernv/vas.h   | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/vas-debug.c 
b/arch/powerpc/platforms/powernv/vas-debug.c
index b4de4c6..e6e4067 100644
--- a/arch/powerpc/platforms/powernv/vas-debug.c
+++ b/arch/powerpc/platforms/powernv/vas-debug.c
@@ -207,3 +207,8 @@ void vas_init_dbgdir(void)
if (IS_ERR(vas_debugfs))
vas_debugfs = NULL;
 }
+
+void vas_cleanup_dbgdir(void)
+{
+   debugfs_remove_recursive(vas_debugfs);
+}
diff --git a/arch/powerpc/platforms/powernv/vas.c 
b/arch/powerpc/platforms/powernv/vas.c
index aebbe95..f83e27d8 100644
--- a/arch/powerpc/platforms/powernv/vas.c
+++ b/arch/powerpc/platforms/powernv/vas.c
@@ -169,8 +169,11 @@ static int __init vas_init(void)
found++;
}
 
-   if (!found)
+   if (!found) {
+   platform_driver_unregister(_driver);
+   vas_cleanup_dbgdir();
return -ENODEV;
+   }
 
pr_devel("Found %d instances\n", found);
 
diff --git a/arch/powerpc/platforms/powernv/vas.h 
b/arch/powerpc/platforms/powernv/vas.h
index ae0100f..2645613 100644
--- a/arch/powerpc/platforms/powernv/vas.h
+++ b/arch/powerpc/platforms/powernv/vas.h
@@ -406,6 +406,7 @@ extern struct mutex vas_mutex;
 
 extern struct vas_instance *find_vas_instance(int vasid);
 extern void vas_init_dbgdir(void);
+extern void vas_cleanup_dbgdir(void);
 extern void vas_instance_init_dbgdir(struct vas_instance *vinst);
 extern void vas_window_init_dbgdir(struct vas_window *win);
 extern void vas_window_free_dbgdir(struct vas_window *win);
-- 
2.7.4



[PATCH 4/4] powerpc/vas: Add a couple of trace points

2018-02-09 Thread Sukadev Bhattiprolu
Add a couple of trace points in the VAS driver

Signed-off-by: Sukadev Bhattiprolu 
---
Changelog [v2]
- Make TRACE_INCLUDE_PATH relative to 
---
 arch/powerpc/platforms/powernv/vas-trace.h  | 112 
 arch/powerpc/platforms/powernv/vas-window.c |   9 +++
 2 files changed, 121 insertions(+)
 create mode 100644 arch/powerpc/platforms/powernv/vas-trace.h

diff --git a/arch/powerpc/platforms/powernv/vas-trace.h 
b/arch/powerpc/platforms/powernv/vas-trace.h
new file mode 100644
index 000..939d85d
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/vas-trace.h
@@ -0,0 +1,112 @@
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM   vas
+
+#if !defined(_VAS_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+
+#define _VAS_TRACE_H
+#include 
+#include 
+#include 
+
+TRACE_EVENT(   vas_rx_win_open,
+
+   TP_PROTO(struct task_struct *tsk,
+int vasid,
+int cop,
+struct vas_rx_win_attr *rxattr),
+
+   TP_ARGS(tsk, vasid, cop, rxattr),
+
+   TP_STRUCT__entry(
+   __field(struct task_struct *, tsk)
+   __field(int, pid)
+   __field(int, cop)
+   __field(int, vasid)
+   __field(struct vas_rx_win_attr *, rxattr)
+   __field(int, lnotify_lpid)
+   __field(int, lnotify_pid)
+   __field(int, lnotify_tid)
+   ),
+
+   TP_fast_assign(
+   __entry->pid = tsk->pid;
+   __entry->vasid = vasid;
+   __entry->cop = cop;
+   __entry->lnotify_lpid = rxattr->lnotify_lpid;
+   __entry->lnotify_pid = rxattr->lnotify_pid;
+   __entry->lnotify_tid = rxattr->lnotify_tid;
+   ),
+
+   TP_printk("pid=%d, vasid=%d, cop=%d, lpid=%d, pid=%d, tid=%d",
+   __entry->pid, __entry->vasid, __entry->cop,
+   __entry->lnotify_lpid, __entry->lnotify_pid,
+   __entry->lnotify_tid)
+);
+
+TRACE_EVENT(   vas_tx_win_open,
+
+   TP_PROTO(struct task_struct *tsk,
+int vasid,
+int cop,
+struct vas_tx_win_attr *txattr),
+
+   TP_ARGS(tsk, vasid, cop, txattr),
+
+   TP_STRUCT__entry(
+   __field(struct task_struct *, tsk)
+   __field(int, pid)
+   __field(int, cop)
+   __field(int, vasid)
+   __field(struct vas_tx_win_attr *, txattr)
+   __field(int, lpid)
+   __field(int, pidr)
+   ),
+
+   TP_fast_assign(
+   __entry->pid = tsk->pid;
+   __entry->vasid = vasid;
+   __entry->cop = cop;
+   __entry->lpid = txattr->lpid;
+   __entry->pidr = txattr->pidr;
+   ),
+
+   TP_printk("pid=%d, vasid=%d, cop=%d, lpid=%d, pidr=%d",
+   __entry->pid, __entry->vasid, __entry->cop,
+   __entry->lpid, __entry->pidr)
+);
+
+TRACE_EVENT(   vas_paste_crb,
+
+   TP_PROTO(struct task_struct *tsk,
+   struct vas_window *win),
+
+   TP_ARGS(tsk, win),
+
+   TP_STRUCT__entry(
+   __field(struct task_struct *, tsk)
+   __field(struct vas_window *, win)
+   __field(int, pid)
+   __field(int, vasid)
+   __field(int, winid)
+   __field(unsigned long, paste_kaddr)
+   ),
+
+   TP_fast_assign(
+   __entry->pid = tsk->pid;
+   __entry->vasid = win->vinst->vas_id;
+   __entry->winid = win->winid;
+   __entry->paste_kaddr = (unsigned long)win->paste_kaddr
+   ),
+
+   TP_printk("pid=%d, vasid=%d, winid=%d, paste_kaddr=0x%016lx\n",
+   __entry->pid, __entry->vasid, __entry->winid,
+   __entry->paste_kaddr)
+);
+
+#endif /* _VAS_TRACE_H */
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH ../../arch/powerpc/platforms/powernv
+#define TRACE_INCLUDE_FILE vas-trace
+#include 
diff --git a/arch/powerpc/platforms/powernv/vas-window.c 
b/arch/powerpc/platforms/powernv/vas-window.c
index 2b3eb01..6b2de9e 100644
--- a/arch/powerpc/platforms/powernv/vas-window.c
+++ b/arch/powerpc/platforms/powernv/vas-window.c
@@ -21,6 +21,9 @@
 #include "vas.h"
 #include "copy-paste.h"
 
+#define CREATE_TRACE_POINTS
+#include "vas-trace.h"
+
 /*
  * Compute the paste address region for the window @window using 

[PATCH 2/4] powerpc/vas: Fix cleanup when VAS is not configured

2018-02-09 Thread Sukadev Bhattiprolu
When VAS is not configured in the system, make sure to remove
the VAS debugfs directory and unregister the platform driver.

Signed-off-by: Sukadev Bhattiprolu 
---
 arch/powerpc/platforms/powernv/vas-debug.c | 5 +
 arch/powerpc/platforms/powernv/vas.c   | 5 -
 arch/powerpc/platforms/powernv/vas.h   | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/vas-debug.c 
b/arch/powerpc/platforms/powernv/vas-debug.c
index b4de4c6..e6e4067 100644
--- a/arch/powerpc/platforms/powernv/vas-debug.c
+++ b/arch/powerpc/platforms/powernv/vas-debug.c
@@ -207,3 +207,8 @@ void vas_init_dbgdir(void)
if (IS_ERR(vas_debugfs))
vas_debugfs = NULL;
 }
+
+void vas_cleanup_dbgdir(void)
+{
+   debugfs_remove_recursive(vas_debugfs);
+}
diff --git a/arch/powerpc/platforms/powernv/vas.c 
b/arch/powerpc/platforms/powernv/vas.c
index aebbe95..f83e27d8 100644
--- a/arch/powerpc/platforms/powernv/vas.c
+++ b/arch/powerpc/platforms/powernv/vas.c
@@ -169,8 +169,11 @@ static int __init vas_init(void)
found++;
}
 
-   if (!found)
+   if (!found) {
+   platform_driver_unregister(_driver);
+   vas_cleanup_dbgdir();
return -ENODEV;
+   }
 
pr_devel("Found %d instances\n", found);
 
diff --git a/arch/powerpc/platforms/powernv/vas.h 
b/arch/powerpc/platforms/powernv/vas.h
index ae0100f..2645613 100644
--- a/arch/powerpc/platforms/powernv/vas.h
+++ b/arch/powerpc/platforms/powernv/vas.h
@@ -406,6 +406,7 @@ extern struct mutex vas_mutex;
 
 extern struct vas_instance *find_vas_instance(int vasid);
 extern void vas_init_dbgdir(void);
+extern void vas_cleanup_dbgdir(void);
 extern void vas_instance_init_dbgdir(struct vas_instance *vinst);
 extern void vas_window_init_dbgdir(struct vas_window *win);
 extern void vas_window_free_dbgdir(struct vas_window *win);
-- 
2.7.4



[PATCH 4/4] powerpc/vas: Add a couple of trace points

2018-02-09 Thread Sukadev Bhattiprolu
Add a couple of trace points in the VAS driver

Signed-off-by: Sukadev Bhattiprolu 
---
Changelog [v2]
- Make TRACE_INCLUDE_PATH relative to 
---
 arch/powerpc/platforms/powernv/vas-trace.h  | 112 
 arch/powerpc/platforms/powernv/vas-window.c |   9 +++
 2 files changed, 121 insertions(+)
 create mode 100644 arch/powerpc/platforms/powernv/vas-trace.h

diff --git a/arch/powerpc/platforms/powernv/vas-trace.h 
b/arch/powerpc/platforms/powernv/vas-trace.h
new file mode 100644
index 000..939d85d
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/vas-trace.h
@@ -0,0 +1,112 @@
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM   vas
+
+#if !defined(_VAS_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+
+#define _VAS_TRACE_H
+#include 
+#include 
+#include 
+
+TRACE_EVENT(   vas_rx_win_open,
+
+   TP_PROTO(struct task_struct *tsk,
+int vasid,
+int cop,
+struct vas_rx_win_attr *rxattr),
+
+   TP_ARGS(tsk, vasid, cop, rxattr),
+
+   TP_STRUCT__entry(
+   __field(struct task_struct *, tsk)
+   __field(int, pid)
+   __field(int, cop)
+   __field(int, vasid)
+   __field(struct vas_rx_win_attr *, rxattr)
+   __field(int, lnotify_lpid)
+   __field(int, lnotify_pid)
+   __field(int, lnotify_tid)
+   ),
+
+   TP_fast_assign(
+   __entry->pid = tsk->pid;
+   __entry->vasid = vasid;
+   __entry->cop = cop;
+   __entry->lnotify_lpid = rxattr->lnotify_lpid;
+   __entry->lnotify_pid = rxattr->lnotify_pid;
+   __entry->lnotify_tid = rxattr->lnotify_tid;
+   ),
+
+   TP_printk("pid=%d, vasid=%d, cop=%d, lpid=%d, pid=%d, tid=%d",
+   __entry->pid, __entry->vasid, __entry->cop,
+   __entry->lnotify_lpid, __entry->lnotify_pid,
+   __entry->lnotify_tid)
+);
+
+TRACE_EVENT(   vas_tx_win_open,
+
+   TP_PROTO(struct task_struct *tsk,
+int vasid,
+int cop,
+struct vas_tx_win_attr *txattr),
+
+   TP_ARGS(tsk, vasid, cop, txattr),
+
+   TP_STRUCT__entry(
+   __field(struct task_struct *, tsk)
+   __field(int, pid)
+   __field(int, cop)
+   __field(int, vasid)
+   __field(struct vas_tx_win_attr *, txattr)
+   __field(int, lpid)
+   __field(int, pidr)
+   ),
+
+   TP_fast_assign(
+   __entry->pid = tsk->pid;
+   __entry->vasid = vasid;
+   __entry->cop = cop;
+   __entry->lpid = txattr->lpid;
+   __entry->pidr = txattr->pidr;
+   ),
+
+   TP_printk("pid=%d, vasid=%d, cop=%d, lpid=%d, pidr=%d",
+   __entry->pid, __entry->vasid, __entry->cop,
+   __entry->lpid, __entry->pidr)
+);
+
+TRACE_EVENT(   vas_paste_crb,
+
+   TP_PROTO(struct task_struct *tsk,
+   struct vas_window *win),
+
+   TP_ARGS(tsk, win),
+
+   TP_STRUCT__entry(
+   __field(struct task_struct *, tsk)
+   __field(struct vas_window *, win)
+   __field(int, pid)
+   __field(int, vasid)
+   __field(int, winid)
+   __field(unsigned long, paste_kaddr)
+   ),
+
+   TP_fast_assign(
+   __entry->pid = tsk->pid;
+   __entry->vasid = win->vinst->vas_id;
+   __entry->winid = win->winid;
+   __entry->paste_kaddr = (unsigned long)win->paste_kaddr
+   ),
+
+   TP_printk("pid=%d, vasid=%d, winid=%d, paste_kaddr=0x%016lx\n",
+   __entry->pid, __entry->vasid, __entry->winid,
+   __entry->paste_kaddr)
+);
+
+#endif /* _VAS_TRACE_H */
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH ../../arch/powerpc/platforms/powernv
+#define TRACE_INCLUDE_FILE vas-trace
+#include 
diff --git a/arch/powerpc/platforms/powernv/vas-window.c 
b/arch/powerpc/platforms/powernv/vas-window.c
index 2b3eb01..6b2de9e 100644
--- a/arch/powerpc/platforms/powernv/vas-window.c
+++ b/arch/powerpc/platforms/powernv/vas-window.c
@@ -21,6 +21,9 @@
 #include "vas.h"
 #include "copy-paste.h"
 
+#define CREATE_TRACE_POINTS
+#include "vas-trace.h"
+
 /*
  * Compute the paste address region for the window @window using the
  * ->paste_base_addr 

[PATCH RESEND 3/4] powerpc/vas: Remove a stray line in Makefile

2018-02-09 Thread Sukadev Bhattiprolu
Remove a bogus line from arch/powerpc/platforms/powernv/Makefile that
was added by commit ece4e51 ("powerpc/vas: Export HVWC to debugfs").

Signed-off-by: Sukadev Bhattiprolu 
---
 arch/powerpc/platforms/powernv/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/Makefile 
b/arch/powerpc/platforms/powernv/Makefile
index 6c9d519..703a350 100644
--- a/arch/powerpc/platforms/powernv/Makefile
+++ b/arch/powerpc/platforms/powernv/Makefile
@@ -16,5 +16,4 @@ obj-$(CONFIG_OPAL_PRD)+= opal-prd.o
 obj-$(CONFIG_PERF_EVENTS) += opal-imc.o
 obj-$(CONFIG_PPC_MEMTRACE) += memtrace.o
 obj-$(CONFIG_PPC_VAS)  += vas.o vas-window.o vas-debug.o
-obj-$(CONFIG_PPC_FTW)  += nx-ftw.o
 obj-$(CONFIG_OCXL_BASE)+= ocxl.o
-- 
2.7.4



[PATCH RESEND 1/4] powerpc/vas: Fix order of cleanup in debugfs dir

2018-02-09 Thread Sukadev Bhattiprolu
Fix the order of cleanup to ensure we free the name buffer in case
of an error creating 'hvwc' or 'info' files.

Signed-off-by: Sukadev Bhattiprolu 
---
 arch/powerpc/platforms/powernv/vas-debug.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/vas-debug.c 
b/arch/powerpc/platforms/powernv/vas-debug.c
index ca22f1e..b4de4c6 100644
--- a/arch/powerpc/platforms/powernv/vas-debug.c
+++ b/arch/powerpc/platforms/powernv/vas-debug.c
@@ -166,13 +166,13 @@ void vas_window_init_dbgdir(struct vas_window *window)
 
return;
 
-free_name:
-   kfree(window->dbgname);
-   window->dbgname = NULL;
-
 remove_dir:
debugfs_remove_recursive(window->dbgdir);
window->dbgdir = NULL;
+
+free_name:
+   kfree(window->dbgname);
+   window->dbgname = NULL;
 }
 
 void vas_instance_init_dbgdir(struct vas_instance *vinst)
-- 
2.7.4



[PATCH RESEND 3/4] powerpc/vas: Remove a stray line in Makefile

2018-02-09 Thread Sukadev Bhattiprolu
Remove a bogus line from arch/powerpc/platforms/powernv/Makefile that
was added by commit ece4e51 ("powerpc/vas: Export HVWC to debugfs").

Signed-off-by: Sukadev Bhattiprolu 
---
 arch/powerpc/platforms/powernv/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/Makefile 
b/arch/powerpc/platforms/powernv/Makefile
index 6c9d519..703a350 100644
--- a/arch/powerpc/platforms/powernv/Makefile
+++ b/arch/powerpc/platforms/powernv/Makefile
@@ -16,5 +16,4 @@ obj-$(CONFIG_OPAL_PRD)+= opal-prd.o
 obj-$(CONFIG_PERF_EVENTS) += opal-imc.o
 obj-$(CONFIG_PPC_MEMTRACE) += memtrace.o
 obj-$(CONFIG_PPC_VAS)  += vas.o vas-window.o vas-debug.o
-obj-$(CONFIG_PPC_FTW)  += nx-ftw.o
 obj-$(CONFIG_OCXL_BASE)+= ocxl.o
-- 
2.7.4



[PATCH RESEND 1/4] powerpc/vas: Fix order of cleanup in debugfs dir

2018-02-09 Thread Sukadev Bhattiprolu
Fix the order of cleanup to ensure we free the name buffer in case
of an error creating 'hvwc' or 'info' files.

Signed-off-by: Sukadev Bhattiprolu 
---
 arch/powerpc/platforms/powernv/vas-debug.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/vas-debug.c 
b/arch/powerpc/platforms/powernv/vas-debug.c
index ca22f1e..b4de4c6 100644
--- a/arch/powerpc/platforms/powernv/vas-debug.c
+++ b/arch/powerpc/platforms/powernv/vas-debug.c
@@ -166,13 +166,13 @@ void vas_window_init_dbgdir(struct vas_window *window)
 
return;
 
-free_name:
-   kfree(window->dbgname);
-   window->dbgname = NULL;
-
 remove_dir:
debugfs_remove_recursive(window->dbgdir);
window->dbgdir = NULL;
+
+free_name:
+   kfree(window->dbgname);
+   window->dbgname = NULL;
 }
 
 void vas_instance_init_dbgdir(struct vas_instance *vinst)
-- 
2.7.4



Re: [PATCH 5/6] Documentation for Pmalloc

2018-02-09 Thread Matthew Wilcox
On Fri, Feb 02, 2018 at 05:56:29PM +0200, Igor Stoppa wrote:
> But what is the license for the documentation? It's not code, so GPL
> seems wrong. Creative commons?

I've done this as the first line of my new documentation files:

.. SPDX-License-Identifier: CC-BY-SA-4.0

I think this is the CC license that's closest in spirit to the GPL without
the unintended consequences of the GPL when used on documentation.  The
GFDL seems to be out of favour these days.


Re: [PATCH 5/6] Documentation for Pmalloc

2018-02-09 Thread Matthew Wilcox
On Fri, Feb 02, 2018 at 05:56:29PM +0200, Igor Stoppa wrote:
> But what is the license for the documentation? It's not code, so GPL
> seems wrong. Creative commons?

I've done this as the first line of my new documentation files:

.. SPDX-License-Identifier: CC-BY-SA-4.0

I think this is the CC license that's closest in spirit to the GPL without
the unintended consequences of the GPL when used on documentation.  The
GFDL seems to be out of favour these days.


Re: possible deadlock in get_user_pages_unlocked

2018-02-09 Thread Eric Biggers
Hi Al,

On Sat, Feb 10, 2018 at 01:36:40AM +, Al Viro wrote:
> On Fri, Feb 02, 2018 at 09:57:27AM +0100, Dmitry Vyukov wrote:
> 
> > syzbot tests for up to 5 minutes. However, if there is a race involved
> > then you may need more time because the crash is probabilistic.
> > But from what I see most of the time, if one can't reproduce it
> > easily, it's usually due to some differences in setup that just don't
> > allow the crash to happen at all.
> > FWIW syzbot re-runs each reproducer on a freshly booted dedicated VM
> > and what it provided is the kernel output it got during run of the
> > provided program. So we have reasonably high assurance that this
> > reproducer worked in at least one setup.
> 
> Could you guys check if the following fixes the reproducer?
> 
> diff --git a/mm/gup.c b/mm/gup.c
> index 61015793f952..058a9a8e4e2e 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -861,6 +861,9 @@ static __always_inline long 
> __get_user_pages_locked(struct task_struct *tsk,
>   BUG_ON(*locked != 1);
>   }
>  
> + if (flags & FOLL_NOWAIT)
> + locked = NULL;
> +
>   if (pages)
>   flags |= FOLL_GET;
>  

Yes that fixes the reproducer for me.

- Eric


Re: possible deadlock in get_user_pages_unlocked

2018-02-09 Thread Eric Biggers
Hi Al,

On Sat, Feb 10, 2018 at 01:36:40AM +, Al Viro wrote:
> On Fri, Feb 02, 2018 at 09:57:27AM +0100, Dmitry Vyukov wrote:
> 
> > syzbot tests for up to 5 minutes. However, if there is a race involved
> > then you may need more time because the crash is probabilistic.
> > But from what I see most of the time, if one can't reproduce it
> > easily, it's usually due to some differences in setup that just don't
> > allow the crash to happen at all.
> > FWIW syzbot re-runs each reproducer on a freshly booted dedicated VM
> > and what it provided is the kernel output it got during run of the
> > provided program. So we have reasonably high assurance that this
> > reproducer worked in at least one setup.
> 
> Could you guys check if the following fixes the reproducer?
> 
> diff --git a/mm/gup.c b/mm/gup.c
> index 61015793f952..058a9a8e4e2e 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -861,6 +861,9 @@ static __always_inline long 
> __get_user_pages_locked(struct task_struct *tsk,
>   BUG_ON(*locked != 1);
>   }
>  
> + if (flags & FOLL_NOWAIT)
> + locked = NULL;
> +
>   if (pages)
>   flags |= FOLL_GET;
>  

Yes that fixes the reproducer for me.

- Eric


Re: [PATCH V2 0/6]nvme-pci: fixes on nvme_timeout and nvme_dev_disable

2018-02-09 Thread jianchao.wang
Hi Keith

On 02/10/2018 10:32 AM, jianchao.wang wrote:
> Hi Keith
> 
> Thanks for your kindly response here.
> That's really appreciated.
> 
> On 02/10/2018 01:12 AM, Keith Busch wrote:
>> On Fri, Feb 09, 2018 at 09:50:58AM +0800, jianchao.wang wrote:
>>>
>>> if we set NVME_REQ_CANCELLED and return BLK_EH_HANDLED as the RESETTING 
>>> case,
>>> nvme_reset_work will hang forever, because no one could complete the 
>>> entered requests.
>>
>> Except it's no longer in the "RESETTING" case since you added the
>> "CONNECTING" state, so that's already broken for other reasons...
>>
> 
> Yes, but as your patch, we have to fail the IOs and even kill the controller.
> In fact, up to nvme_wait_freeze in nvme_reset_work, the RECONNECTING state 
> has been completed.
> We even could say it is in LIVE state. Maybe we should recover the controller 
> again instead
> of fail the IOs and kill the controller.
> 
> On the other hand, can you share with me why we cannot use 
> blk_set_preempt_only to replace
> blk_freeze_queue ? we just want to gate the new bios out of 
> generic_make_request and we 
> needn't use the preempt requests.
> 
> Looking forward your advice and directive.

Avoid wait_freeze in nvme_reset_work should be a better way to fix this defect.

> 
> Thanks
> Jianchao


Re: [PATCH V2 0/6]nvme-pci: fixes on nvme_timeout and nvme_dev_disable

2018-02-09 Thread jianchao.wang
Hi Keith

On 02/10/2018 10:32 AM, jianchao.wang wrote:
> Hi Keith
> 
> Thanks for your kindly response here.
> That's really appreciated.
> 
> On 02/10/2018 01:12 AM, Keith Busch wrote:
>> On Fri, Feb 09, 2018 at 09:50:58AM +0800, jianchao.wang wrote:
>>>
>>> if we set NVME_REQ_CANCELLED and return BLK_EH_HANDLED as the RESETTING 
>>> case,
>>> nvme_reset_work will hang forever, because no one could complete the 
>>> entered requests.
>>
>> Except it's no longer in the "RESETTING" case since you added the
>> "CONNECTING" state, so that's already broken for other reasons...
>>
> 
> Yes, but as your patch, we have to fail the IOs and even kill the controller.
> In fact, up to nvme_wait_freeze in nvme_reset_work, the RECONNECTING state 
> has been completed.
> We even could say it is in LIVE state. Maybe we should recover the controller 
> again instead
> of fail the IOs and kill the controller.
> 
> On the other hand, can you share with me why we cannot use 
> blk_set_preempt_only to replace
> blk_freeze_queue ? we just want to gate the new bios out of 
> generic_make_request and we 
> needn't use the preempt requests.
> 
> Looking forward your advice and directive.

Avoid wait_freeze in nvme_reset_work should be a better way to fix this defect.

> 
> Thanks
> Jianchao


[GIT PULL] Kbuild updates for v4.16 (2nd round)

2018-02-09 Thread Masahiro Yamada
Hi Linus,

Here are a little more Kbuild updates (including Kconfig changes).
Please pull!


The following changes since commit 4bf772b14675411a69b3c807f73006de0fe4b649:

  Merge tag 'drm-for-v4.16' of
git://people.freedesktop.org/~airlied/linux (2018-02-01 17:48:47
-0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
tags/kbuild-v4.16-2

for you to fetch changes up to 523ca58b7db2e30e3c185a7927dd80a30c1bc743:

  kconfig: remove const qualifier from sym_expand_string_value()
(2018-02-10 11:31:49 +0900)


Kbuild updates for v4.16 (2nd)

Makefile changes:
- enable unused-variable warning that was wrongly disabled for clang

Kconfig changes:
- warn blank 'help' and fix existing instances
- fix 'choice' behavior to not write out invisible symbols
- fix misc weirdness

Coccinell changes:
- fix false positive of free after managed memory alloc detection
- improve performance of NULL dereference detection


Julia Lawall (2):
  coccinelle: devm_free: reduce false positives
  coccinelle: deref_null: avoid useless computation

Masahiro Yamada (8):
  kconfig: do not write choice values when their dependency becomes n
  kconfig: show '?' prompt even if no help text is available
  kconfig: remove 'config*' pattern from .gitignnore
  kconfig: remove check_stdin()
  kconfig: echo stdin to stdout if either is redirected
  kconfig: send error messages to stderr
  kconfig: add xrealloc() helper
  kconfig: remove const qualifier from sym_expand_string_value()

Sodagudi Prasad (1):
  kbuild: clang: disable unused variable warnings only when constant

Ulf Magnusson (10):
  video: fbdev: kconfig: Remove blank help text
  mmc: kconfig: Remove blank help text
  Staging: rtl8192u: kconfig: Remove blank help text
  Staging: rtl8192e: kconfig: Remove blank help text
  lib/Kconfig.debug: Remove blank help text
  MIPS: BCM63XX: kconfig: Remove blank help text
  MIPS: kconfig: Remove blank help text
  arm: vt8500: kconfig: Remove blank help text
  nios2: kconfig: Remove blank help text
  kconfig: Warn if help text is blank

 Makefile  |  3 +-
 arch/arm/mach-vt8500/Kconfig  |  1 -
 arch/mips/Kconfig |  1 -
 arch/mips/bcm63xx/boards/Kconfig  |  1 -
 arch/nios2/Kconfig|  1 -
 drivers/mmc/host/Kconfig  |  1 -
 drivers/staging/rtl8192e/rtl8192e/Kconfig |  1 -
 drivers/staging/rtl8192u/Kconfig  |  1 -
 drivers/video/fbdev/Kconfig   |  1 -
 lib/Kconfig.debug |  1 -
 scripts/coccinelle/free/devm_free.cocci   | 55
+-
 scripts/coccinelle/null/deref_null.cocci  |  6 ++--
 scripts/kconfig/.gitignore|  1 -
 scripts/kconfig/conf.c| 40 -
 scripts/kconfig/confdata.c|  2 +-
 scripts/kconfig/expr.c|  4 +--
 scripts/kconfig/lkc.h |  1 +
 scripts/kconfig/lkc_proto.h   |  2 +-
 scripts/kconfig/nconf.gui.c   |  3 +-
 scripts/kconfig/symbol.c  | 22 +++---
 scripts/kconfig/util.c| 15 --
 scripts/kconfig/zconf.l   | 29 ++
 scripts/kconfig/zconf.y   |  6 
 23 files changed, 121 insertions(+), 77 deletions(-)


-- 
Best Regards
Masahiro Yamada


Re: [PATCH v2] tools/memory-model: Make compat with herd7 7.47 ("-" -> "_")

2018-02-09 Thread Akira Yokosawa
On 2018/02/10 10:07, Paul E. McKenney wrote:
> On Sat, Feb 10, 2018 at 08:46:25AM +0900, Akira Yokosawa wrote:
>> >From 7c1f497a9a51e8db1a94c8a7ef0b74b235aaab88 Mon Sep 17 00:00:00 2001
>> From: Akira Yokosawa 
>> Date: Fri, 9 Feb 2018 04:51:05 -0800
>> Subject: [PATCH v2] tools/memory-model: Make compat with herd7 7.47 ("-" -> 
>> "_")
>>
>> As of herd7 7.47, these '-'s are not permitted and end up in
>> errors such as:
>>
>> File "./linux-kernel.def", line 44, characters 29-30:
>> unexpected '-' (in macros)
>>
>> Partial revert of commit 2d5fba7782d6 ("linux-kernel*: Make RCU
>> identifiers match ASPLOS paper") in the repository at
>> https://github.com/aparri/memory-model can restore the compatibility
>> with herd7 7.47.
>>
>> Reported-by: Patrick Bellasi 
>> Suggested-by: Andrea Parri 
>> Signed-off-by: Akira Yokosawa 
>> ---
>> Paul,
>>
>> FWIW, this is a squashed version relative to patch 07/10 in the RFC series.
> 
> Thank you, Akira!
> 
> I am going to hold off on this for a bit to see if we can instead get
> a new release of herd7, but if we can't. this might well be a very good
> way to go.

Fair enough.

   Thanks, Akira

> 
>   Thanx, Paul
> 
>> Thanks, Akira
>> --
>>  tools/memory-model/linux-kernel.bell | 14 +++---
>>  tools/memory-model/linux-kernel.cat  |  2 +-
>>  tools/memory-model/linux-kernel.def  |  8 
>>  3 files changed, 12 insertions(+), 12 deletions(-)
>>
>> diff --git a/tools/memory-model/linux-kernel.bell 
>> b/tools/memory-model/linux-kernel.bell
>> index b984bbd..436791b 100644
>> --- a/tools/memory-model/linux-kernel.bell
>> +++ b/tools/memory-model/linux-kernel.bell
>> @@ -25,9 +25,9 @@ enum Barriers = 'wmb (*smp_wmb*) ||
>>  'rmb (*smp_rmb*) ||
>>  'mb (*smp_mb*) ||
>>  'rb_dep (*smp_read_barrier_depends*) ||
>> -'rcu-lock (*rcu_read_lock*)  ||
>> -'rcu-unlock (*rcu_read_unlock*) ||
>> -'sync-rcu (*synchronize_rcu*) ||
>> +'rcu_lock (*rcu_read_lock*)  ||
>> +'rcu_unlock (*rcu_read_unlock*) ||
>> +'sync_rcu (*synchronize_rcu*) ||
>>  'before_atomic (*smp_mb__before_atomic*) ||
>>  'after_atomic (*smp_mb__after_atomic*) ||
>>  'after_spinlock (*smp_mb__after_spinlock*)
>> @@ -35,8 +35,8 @@ instructions F[Barriers]
>>
>>  (* Compute matching pairs of nested Rcu-lock and Rcu-unlock *)
>>  let matched = let rec
>> -unmatched-locks = Rcu-lock \ domain(matched)
>> -and unmatched-unlocks = Rcu-unlock \ range(matched)
>> +unmatched-locks = Rcu_lock \ domain(matched)
>> +and unmatched-unlocks = Rcu_unlock \ range(matched)
>>  and unmatched = unmatched-locks | unmatched-unlocks
>>  and unmatched-po = [unmatched] ; po ; [unmatched]
>>  and unmatched-locks-to-unlocks =
>> @@ -46,8 +46,8 @@ let matched = let rec
>>  in matched
>>
>>  (* Validate nesting *)
>> -flag ~empty Rcu-lock \ domain(matched) as unbalanced-rcu-locking
>> -flag ~empty Rcu-unlock \ range(matched) as unbalanced-rcu-locking
>> +flag ~empty Rcu_lock \ domain(matched) as unbalanced-rcu-locking
>> +flag ~empty Rcu_unlock \ range(matched) as unbalanced-rcu-locking
>>
>>  (* Outermost level of nesting only *)
>>  let crit = matched \ (po^-1 ; matched ; po^-1)
>> diff --git a/tools/memory-model/linux-kernel.cat 
>> b/tools/memory-model/linux-kernel.cat
>> index babe2b3..d0085d5 100644
>> --- a/tools/memory-model/linux-kernel.cat
>> +++ b/tools/memory-model/linux-kernel.cat
>> @@ -32,7 +32,7 @@ let mb = ([M] ; fencerel(Mb) ; [M]) |
>>  ([M] ; fencerel(Before_atomic) ; [RMW] ; po? ; [M]) |
>>  ([M] ; po? ; [RMW] ; fencerel(After_atomic) ; [M]) |
>>  ([M] ; po? ; [LKW] ; fencerel(After_spinlock) ; [M])
>> -let gp = po ; [Sync-rcu] ; po?
>> +let gp = po ; [Sync_rcu] ; po?
>>
>>  let strong-fence = mb | gp
>>
>> diff --git a/tools/memory-model/linux-kernel.def 
>> b/tools/memory-model/linux-kernel.def
>> index a397387..fc08371 100644
>> --- a/tools/memory-model/linux-kernel.def
>> +++ b/tools/memory-model/linux-kernel.def
>> @@ -41,10 +41,10 @@ spin_unlock(X) { __unlock(X) ; }
>>  spin_trylock(X) __trylock(X)
>>
>>  // RCU
>> -rcu_read_lock() { __fence{rcu-lock}; }
>> -rcu_read_unlock() { __fence{rcu-unlock};}
>> -synchronize_rcu() { __fence{sync-rcu}; }
>> -synchronize_rcu_expedited() { __fence{sync-rcu}; }
>> +rcu_read_lock() { __fence{rcu_lock}; }
>> +rcu_read_unlock() { __fence{rcu_unlock};}
>> +synchronize_rcu() { __fence{sync_rcu}; }
>> +synchronize_rcu_expedited() { __fence{sync_rcu}; }
>>
>>  // Atomic
>>  atomic_read(X) READ_ONCE(*X)
>> -- 
>> 2.7.4
>>
>>
> 



[GIT PULL] Kbuild updates for v4.16 (2nd round)

2018-02-09 Thread Masahiro Yamada
Hi Linus,

Here are a little more Kbuild updates (including Kconfig changes).
Please pull!


The following changes since commit 4bf772b14675411a69b3c807f73006de0fe4b649:

  Merge tag 'drm-for-v4.16' of
git://people.freedesktop.org/~airlied/linux (2018-02-01 17:48:47
-0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
tags/kbuild-v4.16-2

for you to fetch changes up to 523ca58b7db2e30e3c185a7927dd80a30c1bc743:

  kconfig: remove const qualifier from sym_expand_string_value()
(2018-02-10 11:31:49 +0900)


Kbuild updates for v4.16 (2nd)

Makefile changes:
- enable unused-variable warning that was wrongly disabled for clang

Kconfig changes:
- warn blank 'help' and fix existing instances
- fix 'choice' behavior to not write out invisible symbols
- fix misc weirdness

Coccinell changes:
- fix false positive of free after managed memory alloc detection
- improve performance of NULL dereference detection


Julia Lawall (2):
  coccinelle: devm_free: reduce false positives
  coccinelle: deref_null: avoid useless computation

Masahiro Yamada (8):
  kconfig: do not write choice values when their dependency becomes n
  kconfig: show '?' prompt even if no help text is available
  kconfig: remove 'config*' pattern from .gitignnore
  kconfig: remove check_stdin()
  kconfig: echo stdin to stdout if either is redirected
  kconfig: send error messages to stderr
  kconfig: add xrealloc() helper
  kconfig: remove const qualifier from sym_expand_string_value()

Sodagudi Prasad (1):
  kbuild: clang: disable unused variable warnings only when constant

Ulf Magnusson (10):
  video: fbdev: kconfig: Remove blank help text
  mmc: kconfig: Remove blank help text
  Staging: rtl8192u: kconfig: Remove blank help text
  Staging: rtl8192e: kconfig: Remove blank help text
  lib/Kconfig.debug: Remove blank help text
  MIPS: BCM63XX: kconfig: Remove blank help text
  MIPS: kconfig: Remove blank help text
  arm: vt8500: kconfig: Remove blank help text
  nios2: kconfig: Remove blank help text
  kconfig: Warn if help text is blank

 Makefile  |  3 +-
 arch/arm/mach-vt8500/Kconfig  |  1 -
 arch/mips/Kconfig |  1 -
 arch/mips/bcm63xx/boards/Kconfig  |  1 -
 arch/nios2/Kconfig|  1 -
 drivers/mmc/host/Kconfig  |  1 -
 drivers/staging/rtl8192e/rtl8192e/Kconfig |  1 -
 drivers/staging/rtl8192u/Kconfig  |  1 -
 drivers/video/fbdev/Kconfig   |  1 -
 lib/Kconfig.debug |  1 -
 scripts/coccinelle/free/devm_free.cocci   | 55
+-
 scripts/coccinelle/null/deref_null.cocci  |  6 ++--
 scripts/kconfig/.gitignore|  1 -
 scripts/kconfig/conf.c| 40 -
 scripts/kconfig/confdata.c|  2 +-
 scripts/kconfig/expr.c|  4 +--
 scripts/kconfig/lkc.h |  1 +
 scripts/kconfig/lkc_proto.h   |  2 +-
 scripts/kconfig/nconf.gui.c   |  3 +-
 scripts/kconfig/symbol.c  | 22 +++---
 scripts/kconfig/util.c| 15 --
 scripts/kconfig/zconf.l   | 29 ++
 scripts/kconfig/zconf.y   |  6 
 23 files changed, 121 insertions(+), 77 deletions(-)


-- 
Best Regards
Masahiro Yamada


Re: [PATCH v2] tools/memory-model: Make compat with herd7 7.47 ("-" -> "_")

2018-02-09 Thread Akira Yokosawa
On 2018/02/10 10:07, Paul E. McKenney wrote:
> On Sat, Feb 10, 2018 at 08:46:25AM +0900, Akira Yokosawa wrote:
>> >From 7c1f497a9a51e8db1a94c8a7ef0b74b235aaab88 Mon Sep 17 00:00:00 2001
>> From: Akira Yokosawa 
>> Date: Fri, 9 Feb 2018 04:51:05 -0800
>> Subject: [PATCH v2] tools/memory-model: Make compat with herd7 7.47 ("-" -> 
>> "_")
>>
>> As of herd7 7.47, these '-'s are not permitted and end up in
>> errors such as:
>>
>> File "./linux-kernel.def", line 44, characters 29-30:
>> unexpected '-' (in macros)
>>
>> Partial revert of commit 2d5fba7782d6 ("linux-kernel*: Make RCU
>> identifiers match ASPLOS paper") in the repository at
>> https://github.com/aparri/memory-model can restore the compatibility
>> with herd7 7.47.
>>
>> Reported-by: Patrick Bellasi 
>> Suggested-by: Andrea Parri 
>> Signed-off-by: Akira Yokosawa 
>> ---
>> Paul,
>>
>> FWIW, this is a squashed version relative to patch 07/10 in the RFC series.
> 
> Thank you, Akira!
> 
> I am going to hold off on this for a bit to see if we can instead get
> a new release of herd7, but if we can't. this might well be a very good
> way to go.

Fair enough.

   Thanks, Akira

> 
>   Thanx, Paul
> 
>> Thanks, Akira
>> --
>>  tools/memory-model/linux-kernel.bell | 14 +++---
>>  tools/memory-model/linux-kernel.cat  |  2 +-
>>  tools/memory-model/linux-kernel.def  |  8 
>>  3 files changed, 12 insertions(+), 12 deletions(-)
>>
>> diff --git a/tools/memory-model/linux-kernel.bell 
>> b/tools/memory-model/linux-kernel.bell
>> index b984bbd..436791b 100644
>> --- a/tools/memory-model/linux-kernel.bell
>> +++ b/tools/memory-model/linux-kernel.bell
>> @@ -25,9 +25,9 @@ enum Barriers = 'wmb (*smp_wmb*) ||
>>  'rmb (*smp_rmb*) ||
>>  'mb (*smp_mb*) ||
>>  'rb_dep (*smp_read_barrier_depends*) ||
>> -'rcu-lock (*rcu_read_lock*)  ||
>> -'rcu-unlock (*rcu_read_unlock*) ||
>> -'sync-rcu (*synchronize_rcu*) ||
>> +'rcu_lock (*rcu_read_lock*)  ||
>> +'rcu_unlock (*rcu_read_unlock*) ||
>> +'sync_rcu (*synchronize_rcu*) ||
>>  'before_atomic (*smp_mb__before_atomic*) ||
>>  'after_atomic (*smp_mb__after_atomic*) ||
>>  'after_spinlock (*smp_mb__after_spinlock*)
>> @@ -35,8 +35,8 @@ instructions F[Barriers]
>>
>>  (* Compute matching pairs of nested Rcu-lock and Rcu-unlock *)
>>  let matched = let rec
>> -unmatched-locks = Rcu-lock \ domain(matched)
>> -and unmatched-unlocks = Rcu-unlock \ range(matched)
>> +unmatched-locks = Rcu_lock \ domain(matched)
>> +and unmatched-unlocks = Rcu_unlock \ range(matched)
>>  and unmatched = unmatched-locks | unmatched-unlocks
>>  and unmatched-po = [unmatched] ; po ; [unmatched]
>>  and unmatched-locks-to-unlocks =
>> @@ -46,8 +46,8 @@ let matched = let rec
>>  in matched
>>
>>  (* Validate nesting *)
>> -flag ~empty Rcu-lock \ domain(matched) as unbalanced-rcu-locking
>> -flag ~empty Rcu-unlock \ range(matched) as unbalanced-rcu-locking
>> +flag ~empty Rcu_lock \ domain(matched) as unbalanced-rcu-locking
>> +flag ~empty Rcu_unlock \ range(matched) as unbalanced-rcu-locking
>>
>>  (* Outermost level of nesting only *)
>>  let crit = matched \ (po^-1 ; matched ; po^-1)
>> diff --git a/tools/memory-model/linux-kernel.cat 
>> b/tools/memory-model/linux-kernel.cat
>> index babe2b3..d0085d5 100644
>> --- a/tools/memory-model/linux-kernel.cat
>> +++ b/tools/memory-model/linux-kernel.cat
>> @@ -32,7 +32,7 @@ let mb = ([M] ; fencerel(Mb) ; [M]) |
>>  ([M] ; fencerel(Before_atomic) ; [RMW] ; po? ; [M]) |
>>  ([M] ; po? ; [RMW] ; fencerel(After_atomic) ; [M]) |
>>  ([M] ; po? ; [LKW] ; fencerel(After_spinlock) ; [M])
>> -let gp = po ; [Sync-rcu] ; po?
>> +let gp = po ; [Sync_rcu] ; po?
>>
>>  let strong-fence = mb | gp
>>
>> diff --git a/tools/memory-model/linux-kernel.def 
>> b/tools/memory-model/linux-kernel.def
>> index a397387..fc08371 100644
>> --- a/tools/memory-model/linux-kernel.def
>> +++ b/tools/memory-model/linux-kernel.def
>> @@ -41,10 +41,10 @@ spin_unlock(X) { __unlock(X) ; }
>>  spin_trylock(X) __trylock(X)
>>
>>  // RCU
>> -rcu_read_lock() { __fence{rcu-lock}; }
>> -rcu_read_unlock() { __fence{rcu-unlock};}
>> -synchronize_rcu() { __fence{sync-rcu}; }
>> -synchronize_rcu_expedited() { __fence{sync-rcu}; }
>> +rcu_read_lock() { __fence{rcu_lock}; }
>> +rcu_read_unlock() { __fence{rcu_unlock};}
>> +synchronize_rcu() { __fence{sync_rcu}; }
>> +synchronize_rcu_expedited() { __fence{sync_rcu}; }
>>
>>  // Atomic
>>  atomic_read(X) READ_ONCE(*X)
>> -- 
>> 2.7.4
>>
>>
> 



Re: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum

2018-02-09 Thread Chao Yu
On 2018/2/10 9:41, Jaegeuk Kim wrote:
> On 02/01, Chao Yu wrote:
>>
>>
>> On 2018/2/1 6:15, Jaegeuk Kim wrote:
>>> On 01/31, Chao Yu wrote:
 On 2018/1/31 10:02, Jaegeuk Kim wrote:
> What if we want to add more entries in addition to node_checksum? Do we 
> have
> to add a new feature flag at every time? How about adding a layout value 
> instead

 Hmm.. for previous implementation, IMO, we'd better add a new feature flag 
 at
 every time, otherwise, w/ extra_nsize only, in current image, we can know a
 valid range of extended area in node block, but we don't know which
 fields/features are valid/enabled or not.

 One more thing is that if we can add one feature flag for each field, we 
 got one
 more chance to disable it dynamically.

> of extra_nsize? For example, layout #1 means node_checksum with 
> extra_nsize=X?
>
>
> What does 1017 mean? We need to make this structure more flexibly for new

 Yes, using raw 1017 is not appropriate here.

> entries. Like this?
>   union {
>   struct node_v1;
>   struct node_v2;
>   struct node_v3;
>   ...
>   struct direct_node dn;
>   struct indirect_node in;
>   };
>   };
>
>   struct node_v1 {
>   __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1];
>   __le32 node_checksum;
>   }
>
>   struct node_v2 {
>   __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];

 Hmm.. If we only need to add one more 4 bytes field in struct node_v2, but
 V2_NSIZE is defined as fixed 500, there must be 492 bytes wasted.

 Or we can define V2_NSIZE as 8, but if there comes more and more extended
 fields, node version count can be a large number, it results in complicated
 version recognization and handling.

 One more question is how can we control which fields are valid or not in
 comp[Vx_NSIZE]?


 Anyway, what I'm thinking is maybe we can restructure layout of node block 
 like
 the one used by f2fs_inode:

 struct f2fs_node {
union {
struct f2fs_inode i;
union {
struct {
__le32 node_checksum;
__le32 feature_field_1;
__le32 feature_field_2;

__le32 addr[];

};
struct direct_node dn;
struct indirect_node in;
};
};
struct node_footer footer;
 } __packed;

 Moving all extended fields to the head of f2fs_node, so we don't have to 
 use
 macro to indicate actual size of addr.
>>>
>>> Thinking what'd be the best way. My concern is, once getting more entries, 
>>> we
>>
>> OK, I think we need more discussion.. ;)
>>
>>> can't set each of features individually. Like the second entry should have
>>
>> Oh, that will be hard. If we have to avoid that, we have to tag in somewhere
>> e.g. f2fs_inode::i_flags2 to indicate which new field in f2fs_node is valid, 
>> for
>> example:
>>
>> #define F2FS_NODE_CHECKSUM   0x0001
>> #define F2FS_NODE_FIELD1 0x0002
>> #define F2FS_NODE_FIELD2 0x0004
>>
>>  union {
>>  struct {
>>  __le32 node_checksum;
>>  __le32 field_1;
>>  __le32 field_2;
>>  
>>  __le32 addr[];
>>  };
>>  struct direct_node dn;
>>  struct indirect_node in;
>>  };
>>
>> f2fs_inode::i_flags2 = F2FS_NODE_CHECKSUM | F2FS_NODE_FIELD1
>> indicates that f2fs_node::node_checksum and f2fs_node::field_1 are valid;
>>
>> f2fs_inode::i_flags2 = F2FS_NODE_FIELD1 | F2FS_NODE_FIELD2
>> indicates that f2fs_node::field_1 and f2fs_node::field_2 are valid.
> 
> So, that's why I thought we may need a sort of each formats.

Hmm.. if we have two new added fields, there are (2 << 2) combinations
of all formats, as:

struct original {
__le32 data[DEF_ADDRS_PER_BLOCK];
}

struct node_v1 {
__le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1];
__le32 field_1;
}

struct node_v2 {
__le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=1];
__le32 field_2;
}

struct node_v2 {
__le32 data[DEF_ADDRS_PER_BLOCK - V3_NSIZE=2];
__le32 field_1;
__le32 field_2;
}

If we add more new fields, the node version will increase sharply due
to there is (n << 2) combination with n fields. Right? Any thoughts to
reduce maintaining overhead on those node versions structures?

Thanks,

> 
>>
>> Any thoughts?
>>
>> Thanks,
>>
>>> enabled node_checksum, which we may not want to do.
>>>

 

Re: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum

2018-02-09 Thread Chao Yu
On 2018/2/10 9:41, Jaegeuk Kim wrote:
> On 02/01, Chao Yu wrote:
>>
>>
>> On 2018/2/1 6:15, Jaegeuk Kim wrote:
>>> On 01/31, Chao Yu wrote:
 On 2018/1/31 10:02, Jaegeuk Kim wrote:
> What if we want to add more entries in addition to node_checksum? Do we 
> have
> to add a new feature flag at every time? How about adding a layout value 
> instead

 Hmm.. for previous implementation, IMO, we'd better add a new feature flag 
 at
 every time, otherwise, w/ extra_nsize only, in current image, we can know a
 valid range of extended area in node block, but we don't know which
 fields/features are valid/enabled or not.

 One more thing is that if we can add one feature flag for each field, we 
 got one
 more chance to disable it dynamically.

> of extra_nsize? For example, layout #1 means node_checksum with 
> extra_nsize=X?
>
>
> What does 1017 mean? We need to make this structure more flexibly for new

 Yes, using raw 1017 is not appropriate here.

> entries. Like this?
>   union {
>   struct node_v1;
>   struct node_v2;
>   struct node_v3;
>   ...
>   struct direct_node dn;
>   struct indirect_node in;
>   };
>   };
>
>   struct node_v1 {
>   __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1];
>   __le32 node_checksum;
>   }
>
>   struct node_v2 {
>   __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];

 Hmm.. If we only need to add one more 4 bytes field in struct node_v2, but
 V2_NSIZE is defined as fixed 500, there must be 492 bytes wasted.

 Or we can define V2_NSIZE as 8, but if there comes more and more extended
 fields, node version count can be a large number, it results in complicated
 version recognization and handling.

 One more question is how can we control which fields are valid or not in
 comp[Vx_NSIZE]?


 Anyway, what I'm thinking is maybe we can restructure layout of node block 
 like
 the one used by f2fs_inode:

 struct f2fs_node {
union {
struct f2fs_inode i;
union {
struct {
__le32 node_checksum;
__le32 feature_field_1;
__le32 feature_field_2;

__le32 addr[];

};
struct direct_node dn;
struct indirect_node in;
};
};
struct node_footer footer;
 } __packed;

 Moving all extended fields to the head of f2fs_node, so we don't have to 
 use
 macro to indicate actual size of addr.
>>>
>>> Thinking what'd be the best way. My concern is, once getting more entries, 
>>> we
>>
>> OK, I think we need more discussion.. ;)
>>
>>> can't set each of features individually. Like the second entry should have
>>
>> Oh, that will be hard. If we have to avoid that, we have to tag in somewhere
>> e.g. f2fs_inode::i_flags2 to indicate which new field in f2fs_node is valid, 
>> for
>> example:
>>
>> #define F2FS_NODE_CHECKSUM   0x0001
>> #define F2FS_NODE_FIELD1 0x0002
>> #define F2FS_NODE_FIELD2 0x0004
>>
>>  union {
>>  struct {
>>  __le32 node_checksum;
>>  __le32 field_1;
>>  __le32 field_2;
>>  
>>  __le32 addr[];
>>  };
>>  struct direct_node dn;
>>  struct indirect_node in;
>>  };
>>
>> f2fs_inode::i_flags2 = F2FS_NODE_CHECKSUM | F2FS_NODE_FIELD1
>> indicates that f2fs_node::node_checksum and f2fs_node::field_1 are valid;
>>
>> f2fs_inode::i_flags2 = F2FS_NODE_FIELD1 | F2FS_NODE_FIELD2
>> indicates that f2fs_node::field_1 and f2fs_node::field_2 are valid.
> 
> So, that's why I thought we may need a sort of each formats.

Hmm.. if we have two new added fields, there are (2 << 2) combinations
of all formats, as:

struct original {
__le32 data[DEF_ADDRS_PER_BLOCK];
}

struct node_v1 {
__le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1];
__le32 field_1;
}

struct node_v2 {
__le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=1];
__le32 field_2;
}

struct node_v2 {
__le32 data[DEF_ADDRS_PER_BLOCK - V3_NSIZE=2];
__le32 field_1;
__le32 field_2;
}

If we add more new fields, the node version will increase sharply due
to there is (n << 2) combination with n fields. Right? Any thoughts to
reduce maintaining overhead on those node versions structures?

Thanks,

> 
>>
>> Any thoughts?
>>
>> Thanks,
>>
>>> enabled node_checksum, which we may not want to do.
>>>

 

[PATCH V2 0/3] audit: speed up audit syscall entry

2018-02-09 Thread Richard Guy Briggs
These fixes should speed up audit syscall entry by doing away with the
audit entry filter check, moving up the valid connection check before
filling in the context and not caring if there is a bug when audit is
disabled.

Richard Guy Briggs (3):
  audit: deprecate the AUDIT_FILTER_ENTRY filter
  audit: bail ASAP on syscall entry
  audit: bail before bug check if audit disabled

 kernel/auditfilter.c |  4 ++--
 kernel/auditsc.c | 22 ++
 2 files changed, 12 insertions(+), 14 deletions(-)

-- 
1.8.3.1



[PATCH V2 0/3] audit: speed up audit syscall entry

2018-02-09 Thread Richard Guy Briggs
These fixes should speed up audit syscall entry by doing away with the
audit entry filter check, moving up the valid connection check before
filling in the context and not caring if there is a bug when audit is
disabled.

Richard Guy Briggs (3):
  audit: deprecate the AUDIT_FILTER_ENTRY filter
  audit: bail ASAP on syscall entry
  audit: bail before bug check if audit disabled

 kernel/auditfilter.c |  4 ++--
 kernel/auditsc.c | 22 ++
 2 files changed, 12 insertions(+), 14 deletions(-)

-- 
1.8.3.1



[PATCH V2 3/3] audit: bail before bug check if audit disabled

2018-02-09 Thread Richard Guy Briggs
If audit is disabled, who cares if there is a bug indicating syscall in
process or names already recorded.  Bail immediately on audit disabled.

Signed-off-by: Richard Guy Briggs 
---
 kernel/auditsc.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index bc534bf..4e0a4ac 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1511,14 +1511,11 @@ void __audit_syscall_entry(int major, unsigned long a1, 
unsigned long a2,
struct audit_context *context = tsk->audit_context;
enum audit_state state;
 
-   if (!context)
+   if (!audit_enabled || !context)
return;
 
BUG_ON(context->in_syscall || context->name_count);
 
-   if (!audit_enabled)
-   return;
-
state = context->state;
if (state == AUDIT_DISABLED)
return;
-- 
1.8.3.1



[PATCH V2 1/3] audit: deprecate the AUDIT_FILTER_ENTRY filter

2018-02-09 Thread Richard Guy Briggs
The audit entry filter has been long deprecated with userspace support
finally removed in audit-v2.6.7 and plans to remove kernel support have
existed since kernel-v2.6.31.
Remove it.

Passes audit-testsuite.

See: https://github.com/linux-audit/audit-kernel/issues/6
Signed-off-by: Richard Guy Briggs 
---
 kernel/auditfilter.c | 4 ++--
 kernel/auditsc.c | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 4a1758a..1bbf5de 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -258,8 +258,8 @@ static inline struct audit_entry 
*audit_to_entry_common(struct audit_rule_data *
goto exit_err;
 #ifdef CONFIG_AUDITSYSCALL
case AUDIT_FILTER_ENTRY:
-   if (rule->action == AUDIT_ALWAYS)
-   goto exit_err;
+   pr_err("AUDIT_FILTER_ENTRY is deprecated\n");
+   goto exit_err;
case AUDIT_FILTER_EXIT:
case AUDIT_FILTER_TASK:
 #endif
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index e80459f..9348302 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1530,7 +1530,8 @@ void __audit_syscall_entry(int major, unsigned long a1, 
unsigned long a2,
context->dummy = !audit_n_rules;
if (!context->dummy && state == AUDIT_BUILD_CONTEXT) {
context->prio = 0;
-   state = audit_filter_syscall(tsk, context, 
_filter_list[AUDIT_FILTER_ENTRY]);
+   if (auditd_test_task(tsk))
+   return;
}
if (state == AUDIT_DISABLED)
return;
-- 
1.8.3.1



[PATCH V2 1/3] audit: deprecate the AUDIT_FILTER_ENTRY filter

2018-02-09 Thread Richard Guy Briggs
The audit entry filter has been long deprecated with userspace support
finally removed in audit-v2.6.7 and plans to remove kernel support have
existed since kernel-v2.6.31.
Remove it.

Passes audit-testsuite.

See: https://github.com/linux-audit/audit-kernel/issues/6
Signed-off-by: Richard Guy Briggs 
---
 kernel/auditfilter.c | 4 ++--
 kernel/auditsc.c | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 4a1758a..1bbf5de 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -258,8 +258,8 @@ static inline struct audit_entry 
*audit_to_entry_common(struct audit_rule_data *
goto exit_err;
 #ifdef CONFIG_AUDITSYSCALL
case AUDIT_FILTER_ENTRY:
-   if (rule->action == AUDIT_ALWAYS)
-   goto exit_err;
+   pr_err("AUDIT_FILTER_ENTRY is deprecated\n");
+   goto exit_err;
case AUDIT_FILTER_EXIT:
case AUDIT_FILTER_TASK:
 #endif
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index e80459f..9348302 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1530,7 +1530,8 @@ void __audit_syscall_entry(int major, unsigned long a1, 
unsigned long a2,
context->dummy = !audit_n_rules;
if (!context->dummy && state == AUDIT_BUILD_CONTEXT) {
context->prio = 0;
-   state = audit_filter_syscall(tsk, context, 
_filter_list[AUDIT_FILTER_ENTRY]);
+   if (auditd_test_task(tsk))
+   return;
}
if (state == AUDIT_DISABLED)
return;
-- 
1.8.3.1



[PATCH V2 3/3] audit: bail before bug check if audit disabled

2018-02-09 Thread Richard Guy Briggs
If audit is disabled, who cares if there is a bug indicating syscall in
process or names already recorded.  Bail immediately on audit disabled.

Signed-off-by: Richard Guy Briggs 
---
 kernel/auditsc.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index bc534bf..4e0a4ac 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1511,14 +1511,11 @@ void __audit_syscall_entry(int major, unsigned long a1, 
unsigned long a2,
struct audit_context *context = tsk->audit_context;
enum audit_state state;
 
-   if (!context)
+   if (!audit_enabled || !context)
return;
 
BUG_ON(context->in_syscall || context->name_count);
 
-   if (!audit_enabled)
-   return;
-
state = context->state;
if (state == AUDIT_DISABLED)
return;
-- 
1.8.3.1



[PATCH V2 2/3] audit: bail ASAP on syscall entry

2018-02-09 Thread Richard Guy Briggs
Since removing the audit entry filter, test for early return before
setting up any context state.

Signed-off-by: Richard Guy Briggs 
---
 kernel/auditsc.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 9348302..bc534bf 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1519,23 +1519,23 @@ void __audit_syscall_entry(int major, unsigned long a1, 
unsigned long a2,
if (!audit_enabled)
return;
 
-   context->arch   = syscall_get_arch();
-   context->major  = major;
-   context->argv[0]= a1;
-   context->argv[1]= a2;
-   context->argv[2]= a3;
-   context->argv[3]= a4;
-
state = context->state;
+   if (state == AUDIT_DISABLED)
+   return;
+
context->dummy = !audit_n_rules;
if (!context->dummy && state == AUDIT_BUILD_CONTEXT) {
context->prio = 0;
if (auditd_test_task(tsk))
return;
}
-   if (state == AUDIT_DISABLED)
-   return;
 
+   context->arch   = syscall_get_arch();
+   context->major  = major;
+   context->argv[0]= a1;
+   context->argv[1]= a2;
+   context->argv[2]= a3;
+   context->argv[3]= a4;
context->serial = 0;
context->ctime = current_kernel_time64();
context->in_syscall = 1;
-- 
1.8.3.1



[PATCH V2 2/3] audit: bail ASAP on syscall entry

2018-02-09 Thread Richard Guy Briggs
Since removing the audit entry filter, test for early return before
setting up any context state.

Signed-off-by: Richard Guy Briggs 
---
 kernel/auditsc.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 9348302..bc534bf 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1519,23 +1519,23 @@ void __audit_syscall_entry(int major, unsigned long a1, 
unsigned long a2,
if (!audit_enabled)
return;
 
-   context->arch   = syscall_get_arch();
-   context->major  = major;
-   context->argv[0]= a1;
-   context->argv[1]= a2;
-   context->argv[2]= a3;
-   context->argv[3]= a4;
-
state = context->state;
+   if (state == AUDIT_DISABLED)
+   return;
+
context->dummy = !audit_n_rules;
if (!context->dummy && state == AUDIT_BUILD_CONTEXT) {
context->prio = 0;
if (auditd_test_task(tsk))
return;
}
-   if (state == AUDIT_DISABLED)
-   return;
 
+   context->arch   = syscall_get_arch();
+   context->major  = major;
+   context->argv[0]= a1;
+   context->argv[1]= a2;
+   context->argv[2]= a3;
+   context->argv[3]= a4;
context->serial = 0;
context->ctime = current_kernel_time64();
context->in_syscall = 1;
-- 
1.8.3.1



Re: [PATCH] tracing/power: Don't share template for cpu_idle and cpu_frequency

2018-02-09 Thread Steven Rostedt
On Sat, 10 Feb 2018 09:37:04 +0800
changbin...@intel.com wrote:

> From: Changbin Du 
> 
> The type of state is signed int, convert it to unsigned int looks weird.
> (-1 become 4294967295)
>932.123 power:cpu_idle:state=1 cpu_id=0)
>932.125 power:cpu_idle:state=4294967295 cpu_id=0)
>932.132 power:cpu_idle:state=1 cpu_id=0)
>932.133 power:cpu_idle:state=4294967295 cpu_id=0)
> 
> Similarly for cpu_frequency as "state=%lu cpu_id=%lu". User need to read
> the code to understand what 'state' means.
> 
> No functional change in this patch.

That's not true. You split a class into two TRACE_EVENTS. Each
TRACE_EVENT adds approximately 5k of code and data. A DEFINE_EVENT()
adds around 300 bytes. There's better ways to do this,

Please don't add this patch.

-- Steve

> 
> Signed-off-by: Changbin Du 
> ---
>  include/trace/events/power.h | 32 +++-
>  1 file changed, 19 insertions(+), 13 deletions(-)
> 
> diff --git a/include/trace/events/power.h b/include/trace/events/power.h
> index 908977d..39bd6de 100644
> --- a/include/trace/events/power.h
> +++ b/include/trace/events/power.h
> @@ -12,14 +12,14 @@
>  
>  #define TPS(x)  tracepoint_string(x)
>  
> -DECLARE_EVENT_CLASS(cpu,
> +TRACE_EVENT(cpu_idle,
>  
> - TP_PROTO(unsigned int state, unsigned int cpu_id),
> + TP_PROTO(int state, unsigned int cpu_id),
>  
>   TP_ARGS(state, cpu_id),
>  
>   TP_STRUCT__entry(
> - __field(u32,state   )
> + __field(int,state   )
>   __field(u32,cpu_id  )
>   ),
>  
> @@ -28,17 +28,10 @@ DECLARE_EVENT_CLASS(cpu,
>   __entry->cpu_id = cpu_id;
>   ),
>  
> - TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
> + TP_printk("state=%d cpu_id=%lu", __entry->state,
> (unsigned long)__entry->cpu_id)
>  );
>  
> -DEFINE_EVENT(cpu, cpu_idle,
> -
> - TP_PROTO(unsigned int state, unsigned int cpu_id),
> -
> - TP_ARGS(state, cpu_id)
> -);
> -
>  TRACE_EVENT(powernv_throttle,
>  
>   TP_PROTO(int chip_id, const char *reason, int pmax),
> @@ -141,11 +134,24 @@ TRACE_EVENT(pstate_sample,
>   { PM_EVENT_RESTORE, "restore" }, \
>   { PM_EVENT_RECOVER, "recover" })
>  
> -DEFINE_EVENT(cpu, cpu_frequency,
> +TRACE_EVENT(cpu_frequency,
>  
>   TP_PROTO(unsigned int frequency, unsigned int cpu_id),
>  
> - TP_ARGS(frequency, cpu_id)
> + TP_ARGS(frequency, cpu_id),
> +
> + TP_STRUCT__entry(
> + __field(u32,frequency   )
> + __field(u32,cpu_id  )
> + ),
> +
> + TP_fast_assign(
> + __entry->frequency = frequency;
> + __entry->cpu_id = cpu_id;
> + ),
> +
> + TP_printk("frequency=%lu cpu_id=%lu", __entry->frequency,
> +   (unsigned long)__entry->cpu_id)
>  );
>  
>  TRACE_EVENT(device_pm_callback_start,



Re: [PATCH] tracing/power: Don't share template for cpu_idle and cpu_frequency

2018-02-09 Thread Steven Rostedt
On Sat, 10 Feb 2018 09:37:04 +0800
changbin...@intel.com wrote:

> From: Changbin Du 
> 
> The type of state is signed int, convert it to unsigned int looks weird.
> (-1 become 4294967295)
>932.123 power:cpu_idle:state=1 cpu_id=0)
>932.125 power:cpu_idle:state=4294967295 cpu_id=0)
>932.132 power:cpu_idle:state=1 cpu_id=0)
>932.133 power:cpu_idle:state=4294967295 cpu_id=0)
> 
> Similarly for cpu_frequency as "state=%lu cpu_id=%lu". User need to read
> the code to understand what 'state' means.
> 
> No functional change in this patch.

That's not true. You split a class into two TRACE_EVENTS. Each
TRACE_EVENT adds approximately 5k of code and data. A DEFINE_EVENT()
adds around 300 bytes. There's better ways to do this,

Please don't add this patch.

-- Steve

> 
> Signed-off-by: Changbin Du 
> ---
>  include/trace/events/power.h | 32 +++-
>  1 file changed, 19 insertions(+), 13 deletions(-)
> 
> diff --git a/include/trace/events/power.h b/include/trace/events/power.h
> index 908977d..39bd6de 100644
> --- a/include/trace/events/power.h
> +++ b/include/trace/events/power.h
> @@ -12,14 +12,14 @@
>  
>  #define TPS(x)  tracepoint_string(x)
>  
> -DECLARE_EVENT_CLASS(cpu,
> +TRACE_EVENT(cpu_idle,
>  
> - TP_PROTO(unsigned int state, unsigned int cpu_id),
> + TP_PROTO(int state, unsigned int cpu_id),
>  
>   TP_ARGS(state, cpu_id),
>  
>   TP_STRUCT__entry(
> - __field(u32,state   )
> + __field(int,state   )
>   __field(u32,cpu_id  )
>   ),
>  
> @@ -28,17 +28,10 @@ DECLARE_EVENT_CLASS(cpu,
>   __entry->cpu_id = cpu_id;
>   ),
>  
> - TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
> + TP_printk("state=%d cpu_id=%lu", __entry->state,
> (unsigned long)__entry->cpu_id)
>  );
>  
> -DEFINE_EVENT(cpu, cpu_idle,
> -
> - TP_PROTO(unsigned int state, unsigned int cpu_id),
> -
> - TP_ARGS(state, cpu_id)
> -);
> -
>  TRACE_EVENT(powernv_throttle,
>  
>   TP_PROTO(int chip_id, const char *reason, int pmax),
> @@ -141,11 +134,24 @@ TRACE_EVENT(pstate_sample,
>   { PM_EVENT_RESTORE, "restore" }, \
>   { PM_EVENT_RECOVER, "recover" })
>  
> -DEFINE_EVENT(cpu, cpu_frequency,
> +TRACE_EVENT(cpu_frequency,
>  
>   TP_PROTO(unsigned int frequency, unsigned int cpu_id),
>  
> - TP_ARGS(frequency, cpu_id)
> + TP_ARGS(frequency, cpu_id),
> +
> + TP_STRUCT__entry(
> + __field(u32,frequency   )
> + __field(u32,cpu_id  )
> + ),
> +
> + TP_fast_assign(
> + __entry->frequency = frequency;
> + __entry->cpu_id = cpu_id;
> + ),
> +
> + TP_printk("frequency=%lu cpu_id=%lu", __entry->frequency,
> +   (unsigned long)__entry->cpu_id)
>  );
>  
>  TRACE_EVENT(device_pm_callback_start,



[PATCH v3 11/11] clk: actions: Add S900 SoC clock support

2018-02-09 Thread Manivannan Sadhasivam
Add Actions Semi S900 SoC clock support.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/actions/Kconfig|  10 +
 drivers/clk/actions/Makefile   |   3 +
 drivers/clk/actions/owl-s900.c | 666 +
 drivers/clk/actions/owl-s900.h |  61 
 4 files changed, 740 insertions(+)
 create mode 100644 drivers/clk/actions/owl-s900.c
 create mode 100644 drivers/clk/actions/owl-s900.h

diff --git a/drivers/clk/actions/Kconfig b/drivers/clk/actions/Kconfig
index 13a3e5083d43..7924a7f54229 100644
--- a/drivers/clk/actions/Kconfig
+++ b/drivers/clk/actions/Kconfig
@@ -2,3 +2,13 @@ config CLK_ACTIONS
bool "Clock driver for Actions Semi SoCs"
depends on ARCH_ACTIONS || COMPILE_TEST
default ARCH_ACTIONS
+
+if CLK_ACTIONS
+
+# SoC Drivers
+
+config CLK_OWL_S900
+   tristate "Support for the Actions Semi OWL S900 clocks"
+   depends on (ARM64 && ARCH_ACTIONS) || COMPILE_TEST
+   default ARM64 && ARCH_ACTIONS
+endif
diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
index 31b68eab9309..76e431434d10 100644
--- a/drivers/clk/actions/Makefile
+++ b/drivers/clk/actions/Makefile
@@ -7,3 +7,6 @@ clk-owl-y   += owl-divider.o
 clk-owl-y  += owl-factor.o
 clk-owl-y  += owl-composite.o
 clk-owl-y  += owl-pll.o
+
+# SoC support
+obj-$(CONFIG_CLK_OWL_S900) += owl-s900.o
diff --git a/drivers/clk/actions/owl-s900.c b/drivers/clk/actions/owl-s900.c
new file mode 100644
index ..d5b0fbf7fe7d
--- /dev/null
+++ b/drivers/clk/actions/owl-s900.c
@@ -0,0 +1,666 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL S900 SoC clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+#include 
+
+#include "owl-common.h"
+#include "owl-composite.h"
+#include "owl-divider.h"
+#include "owl-factor.h"
+#include "owl-gate.h"
+#include "owl-mux.h"
+#include "owl-pll.h"
+#include "owl-s900.h"
+
+#include 
+
+static struct clk_pll_table clk_audio_pll_table[] = {
+   {0, 45158400}, {1, 49152000},
+   {0, 0},
+};
+
+static struct clk_pll_table clk_edp_pll_table[] = {
+   {0, 81000}, {1, 135000}, {2, 27},
+   {0, 0},
+};
+
+/* pll clocks */
+static OWL_PLL_NO_PARENT(core_pll_clk, "core_pll_clk", CMU_COREPLL, 2400, 
9, 0, 8, 5, 107, NULL, CLK_IGNORE_UNUSED);
+static OWL_PLL_NO_PARENT(dev_pll_clk, "dev_pll_clk", CMU_DEVPLL, 600, 8, 
0, 8, 20, 180, NULL, CLK_IGNORE_UNUSED);
+static OWL_PLL_NO_PARENT(ddr_pll_clk, "ddr_pll_clk", CMU_DDRPLL, 2400, 8, 
0, 8, 5, 45, NULL, CLK_IGNORE_UNUSED);
+static OWL_PLL_NO_PARENT(nand_pll_clk, "nand_pll_clk", CMU_NANDPLL, 600, 
8, 0, 8, 4, 100, NULL, CLK_IGNORE_UNUSED);
+static OWL_PLL_NO_PARENT(display_pll_clk, "display_pll_clk", CMU_DISPLAYPLL, 
600, 8, 0, 8, 20, 180, NULL, CLK_IGNORE_UNUSED);
+static OWL_PLL_NO_PARENT(assist_pll_clk, "assist_pll_clk", CMU_ASSISTPLL, 
5, 0, 0, 0, 0, 0, NULL, CLK_IGNORE_UNUSED);
+static OWL_PLL_NO_PARENT(audio_pll_clk, "audio_pll_clk", CMU_AUDIOPLL, 0, 4, 
0, 1, 0, 0, clk_audio_pll_table, CLK_IGNORE_UNUSED);
+static OWL_PLL(edp_pll_clk, "edp_pll_clk", "edp24M_clk", CMU_EDPCLK, 0, 9, 0, 
2, 0, 0, clk_edp_pll_table, CLK_IGNORE_UNUSED);
+
+static const char *cpu_clk_mux_p[] = { "losc", "hosc", "core_pll", };
+static const char *dev_clk_p[] = { "hosc", "dev_pll", };
+static const char *noc_clk_mux_p[] = { "dev_clk", "assist_pll", };
+static const char *dmm_clk_mux_p[] = { "dev_clk", "nand_pll", "assist_pll", 
"ddr_clk_src", };
+static const char *bisp_clk_mux_p[] = { "assist_pll", "dev_clk", };
+static const char *csi_clk_mux_p[] = { "display_pll", "dev_clk", };
+static const char *de_clk_mux_p[] = { "assist_pll", "dev_clk", };
+static const char *gpu_clk_mux_p[] = { "dev_clk", "display_pll", "", 
"ddr_clk_src", };
+static const char *hde_clk_mux_p[] = { "dev_clk", "display_pll", "", 
"ddr_clk_src", };
+static const char *imx_clk_mux_p[] = { "assist_pll", "dev_clk", };
+static const char *lcd_clk_mux_p[] = { "display_pll", "nand_pll", };
+static const char *nand_clk_mux_p[] = { "dev_clk", "nand_pll", };
+static const char *sd_clk_mux_p[] = { "dev_clk", "nand_pll", };
+static const char *sensor_clk_mux_p[] = { "hosc", "bisp", };
+static const char *uart_clk_mux_p[] = { "hosc", "dev_pll", };
+static const char *vce_clk_mux_p[] = { "dev_clk", "display_pll", "assist_pll", 
"ddr_clk_src", };
+static const char *i2s_clk_mux_p[] = { "audio_pll", };
+static const char *edp_clk_mux_p[] = { "assist_pll", "display_pll", };
+
+/* mux clocks */
+static OWL_MUX(cpu_clk, "cpu_clk", cpu_clk_mux_p, CMU_BUSCLK, 0, 2, 
CLK_SET_RATE_PARENT);
+static OWL_MUX(dev_clk, "dev_clk", dev_clk_p, CMU_DEVPLL, 12, 1, 
CLK_SET_RATE_PARENT);
+static 

[PATCH v3 11/11] clk: actions: Add S900 SoC clock support

2018-02-09 Thread Manivannan Sadhasivam
Add Actions Semi S900 SoC clock support.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/actions/Kconfig|  10 +
 drivers/clk/actions/Makefile   |   3 +
 drivers/clk/actions/owl-s900.c | 666 +
 drivers/clk/actions/owl-s900.h |  61 
 4 files changed, 740 insertions(+)
 create mode 100644 drivers/clk/actions/owl-s900.c
 create mode 100644 drivers/clk/actions/owl-s900.h

diff --git a/drivers/clk/actions/Kconfig b/drivers/clk/actions/Kconfig
index 13a3e5083d43..7924a7f54229 100644
--- a/drivers/clk/actions/Kconfig
+++ b/drivers/clk/actions/Kconfig
@@ -2,3 +2,13 @@ config CLK_ACTIONS
bool "Clock driver for Actions Semi SoCs"
depends on ARCH_ACTIONS || COMPILE_TEST
default ARCH_ACTIONS
+
+if CLK_ACTIONS
+
+# SoC Drivers
+
+config CLK_OWL_S900
+   tristate "Support for the Actions Semi OWL S900 clocks"
+   depends on (ARM64 && ARCH_ACTIONS) || COMPILE_TEST
+   default ARM64 && ARCH_ACTIONS
+endif
diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
index 31b68eab9309..76e431434d10 100644
--- a/drivers/clk/actions/Makefile
+++ b/drivers/clk/actions/Makefile
@@ -7,3 +7,6 @@ clk-owl-y   += owl-divider.o
 clk-owl-y  += owl-factor.o
 clk-owl-y  += owl-composite.o
 clk-owl-y  += owl-pll.o
+
+# SoC support
+obj-$(CONFIG_CLK_OWL_S900) += owl-s900.o
diff --git a/drivers/clk/actions/owl-s900.c b/drivers/clk/actions/owl-s900.c
new file mode 100644
index ..d5b0fbf7fe7d
--- /dev/null
+++ b/drivers/clk/actions/owl-s900.c
@@ -0,0 +1,666 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL S900 SoC clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+#include 
+
+#include "owl-common.h"
+#include "owl-composite.h"
+#include "owl-divider.h"
+#include "owl-factor.h"
+#include "owl-gate.h"
+#include "owl-mux.h"
+#include "owl-pll.h"
+#include "owl-s900.h"
+
+#include 
+
+static struct clk_pll_table clk_audio_pll_table[] = {
+   {0, 45158400}, {1, 49152000},
+   {0, 0},
+};
+
+static struct clk_pll_table clk_edp_pll_table[] = {
+   {0, 81000}, {1, 135000}, {2, 27},
+   {0, 0},
+};
+
+/* pll clocks */
+static OWL_PLL_NO_PARENT(core_pll_clk, "core_pll_clk", CMU_COREPLL, 2400, 
9, 0, 8, 5, 107, NULL, CLK_IGNORE_UNUSED);
+static OWL_PLL_NO_PARENT(dev_pll_clk, "dev_pll_clk", CMU_DEVPLL, 600, 8, 
0, 8, 20, 180, NULL, CLK_IGNORE_UNUSED);
+static OWL_PLL_NO_PARENT(ddr_pll_clk, "ddr_pll_clk", CMU_DDRPLL, 2400, 8, 
0, 8, 5, 45, NULL, CLK_IGNORE_UNUSED);
+static OWL_PLL_NO_PARENT(nand_pll_clk, "nand_pll_clk", CMU_NANDPLL, 600, 
8, 0, 8, 4, 100, NULL, CLK_IGNORE_UNUSED);
+static OWL_PLL_NO_PARENT(display_pll_clk, "display_pll_clk", CMU_DISPLAYPLL, 
600, 8, 0, 8, 20, 180, NULL, CLK_IGNORE_UNUSED);
+static OWL_PLL_NO_PARENT(assist_pll_clk, "assist_pll_clk", CMU_ASSISTPLL, 
5, 0, 0, 0, 0, 0, NULL, CLK_IGNORE_UNUSED);
+static OWL_PLL_NO_PARENT(audio_pll_clk, "audio_pll_clk", CMU_AUDIOPLL, 0, 4, 
0, 1, 0, 0, clk_audio_pll_table, CLK_IGNORE_UNUSED);
+static OWL_PLL(edp_pll_clk, "edp_pll_clk", "edp24M_clk", CMU_EDPCLK, 0, 9, 0, 
2, 0, 0, clk_edp_pll_table, CLK_IGNORE_UNUSED);
+
+static const char *cpu_clk_mux_p[] = { "losc", "hosc", "core_pll", };
+static const char *dev_clk_p[] = { "hosc", "dev_pll", };
+static const char *noc_clk_mux_p[] = { "dev_clk", "assist_pll", };
+static const char *dmm_clk_mux_p[] = { "dev_clk", "nand_pll", "assist_pll", 
"ddr_clk_src", };
+static const char *bisp_clk_mux_p[] = { "assist_pll", "dev_clk", };
+static const char *csi_clk_mux_p[] = { "display_pll", "dev_clk", };
+static const char *de_clk_mux_p[] = { "assist_pll", "dev_clk", };
+static const char *gpu_clk_mux_p[] = { "dev_clk", "display_pll", "", 
"ddr_clk_src", };
+static const char *hde_clk_mux_p[] = { "dev_clk", "display_pll", "", 
"ddr_clk_src", };
+static const char *imx_clk_mux_p[] = { "assist_pll", "dev_clk", };
+static const char *lcd_clk_mux_p[] = { "display_pll", "nand_pll", };
+static const char *nand_clk_mux_p[] = { "dev_clk", "nand_pll", };
+static const char *sd_clk_mux_p[] = { "dev_clk", "nand_pll", };
+static const char *sensor_clk_mux_p[] = { "hosc", "bisp", };
+static const char *uart_clk_mux_p[] = { "hosc", "dev_pll", };
+static const char *vce_clk_mux_p[] = { "dev_clk", "display_pll", "assist_pll", 
"ddr_clk_src", };
+static const char *i2s_clk_mux_p[] = { "audio_pll", };
+static const char *edp_clk_mux_p[] = { "assist_pll", "display_pll", };
+
+/* mux clocks */
+static OWL_MUX(cpu_clk, "cpu_clk", cpu_clk_mux_p, CMU_BUSCLK, 0, 2, 
CLK_SET_RATE_PARENT);
+static OWL_MUX(dev_clk, "dev_clk", dev_clk_p, CMU_DEVPLL, 12, 1, 
CLK_SET_RATE_PARENT);
+static OWL_MUX(noc_clk_mux, "noc_clk_mux", noc_clk_mux_p, CMU_BUSCLK, 7, 1, 
CLK_SET_RATE_PARENT);
+
+static struct 

[PATCH v3 08/11] clk: actions: Add factor clock support

2018-02-09 Thread Manivannan Sadhasivam
Add support for Actions Semi factor clock together with
helper functions to be used in composite clock.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/actions/Makefile |   1 +
 drivers/clk/actions/owl-factor.c | 222 +++
 drivers/clk/actions/owl-factor.h |  83 +++
 3 files changed, 306 insertions(+)
 create mode 100644 drivers/clk/actions/owl-factor.c
 create mode 100644 drivers/clk/actions/owl-factor.h

diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
index 5ce75df57e1a..994357fa560b 100644
--- a/drivers/clk/actions/Makefile
+++ b/drivers/clk/actions/Makefile
@@ -4,3 +4,4 @@ clk-owl-y   += owl-common.o
 clk-owl-y  += owl-gate.o
 clk-owl-y  += owl-mux.o
 clk-owl-y  += owl-divider.o
+clk-owl-y  += owl-factor.o
diff --git a/drivers/clk/actions/owl-factor.c b/drivers/clk/actions/owl-factor.c
new file mode 100644
index ..c48a2c8b479e
--- /dev/null
+++ b/drivers/clk/actions/owl-factor.c
@@ -0,0 +1,222 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL factor clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+#include 
+
+#include "owl-factor.h"
+
+static unsigned int _get_table_maxval(const struct clk_factor_table *table)
+{
+   unsigned int maxval = 0;
+   const struct clk_factor_table *clkt;
+
+   for (clkt = table; clkt->div; clkt++)
+   if (clkt->val > maxval)
+   maxval = clkt->val;
+   return maxval;
+}
+
+static int _get_table_div_mul(const struct clk_factor_table *table,
+   unsigned int val, unsigned int *mul, unsigned int *div)
+{
+   const struct clk_factor_table *clkt;
+
+   for (clkt = table; clkt->div; clkt++) {
+   if (clkt->val == val) {
+   *mul = clkt->mul;
+   *div = clkt->div;
+   return 1;
+   }
+   }
+
+   return 0;
+}
+
+static unsigned int _get_table_val(const struct clk_factor_table *table,
+   unsigned long rate, unsigned long parent_rate)
+{
+   const struct clk_factor_table *clkt;
+   int val = -1;
+   u64 calc_rate;
+
+   for (clkt = table; clkt->div; clkt++) {
+   calc_rate = parent_rate * clkt->mul;
+   do_div(calc_rate, clkt->div);
+
+   if ((unsigned long)calc_rate <= rate) {
+   val = clkt->val;
+   break;
+   }
+   }
+
+   if (val == -1)
+   val = _get_table_maxval(table);
+
+   return val;
+}
+
+static int clk_val_best(struct clk_hw *hw, unsigned long rate,
+   unsigned long *best_parent_rate)
+{
+   struct owl_factor *factor = hw_to_owl_factor(hw);
+   struct owl_factor_hw *factor_hw = >factor_hw;
+   const struct clk_factor_table *clkt = factor_hw->table;
+   unsigned long parent_rate, try_parent_rate, best = 0, cur_rate;
+   unsigned long parent_rate_saved = *best_parent_rate;
+   int bestval = 0;
+
+   if (!rate)
+   rate = 1;
+
+   if (!(clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) {
+   parent_rate = *best_parent_rate;
+   bestval = _get_table_val(clkt, rate, parent_rate);
+   return bestval;
+   }
+
+   for (clkt = factor_hw->table; clkt->div; clkt++) {
+   try_parent_rate = rate * clkt->div / clkt->mul;
+
+   if (try_parent_rate == parent_rate_saved) {
+   pr_debug("%s: [%d %d %d] found try_parent_rate %ld\n",
+   __func__, clkt->val, clkt->mul, clkt->div,
+   try_parent_rate);
+   /*
+* It's the most ideal case if the requested rate can be
+* divided from parent clock without any need to change
+* parent rate, so return the divider immediately.
+*/
+   *best_parent_rate = parent_rate_saved;
+   return clkt->val;
+   }
+
+   parent_rate = clk_hw_round_rate(clk_hw_get_parent(hw),
+   try_parent_rate);
+   cur_rate = DIV_ROUND_UP(parent_rate, clkt->div) * clkt->mul;
+   if (cur_rate <= rate && cur_rate > best) {
+   bestval = clkt->val;
+   best = cur_rate;
+   *best_parent_rate = parent_rate;
+   }
+   }
+
+   if (!bestval) {
+   bestval = _get_table_maxval(clkt);
+   *best_parent_rate = clk_hw_round_rate(
+  

[PATCH v3 10/11] clk: actions: Add pll clock support

2018-02-09 Thread Manivannan Sadhasivam
Add support for Actions Semi PLL clock

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/actions/Makefile  |   1 +
 drivers/clk/actions/owl-pll.c | 194 ++
 drivers/clk/actions/owl-pll.h |  92 
 3 files changed, 287 insertions(+)
 create mode 100644 drivers/clk/actions/owl-pll.c
 create mode 100644 drivers/clk/actions/owl-pll.h

diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
index 53431aef6e9c..31b68eab9309 100644
--- a/drivers/clk/actions/Makefile
+++ b/drivers/clk/actions/Makefile
@@ -6,3 +6,4 @@ clk-owl-y   += owl-mux.o
 clk-owl-y  += owl-divider.o
 clk-owl-y  += owl-factor.o
 clk-owl-y  += owl-composite.o
+clk-owl-y  += owl-pll.o
diff --git a/drivers/clk/actions/owl-pll.c b/drivers/clk/actions/owl-pll.c
new file mode 100644
index ..3560c7324f9c
--- /dev/null
+++ b/drivers/clk/actions/owl-pll.c
@@ -0,0 +1,194 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL pll clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "owl-pll.h"
+
+static u32 owl_pll_calculate_mul(struct owl_pll_hw *pll_hw, unsigned long rate)
+{
+   u32 mul;
+
+   mul = DIV_ROUND_CLOSEST(rate, pll_hw->bfreq);
+   if (mul < pll_hw->min_mul)
+   mul = pll_hw->min_mul;
+   else if (mul > pll_hw->max_mul)
+   mul = pll_hw->max_mul;
+
+   return mul &= mul_mask(pll_hw);
+}
+
+static unsigned int _get_table_rate(const struct clk_pll_table *table,
+   unsigned int val)
+{
+   const struct clk_pll_table *clkt;
+
+   for (clkt = table; clkt->rate; clkt++)
+   if (clkt->val == val)
+   return clkt->rate;
+
+   return 0;
+}
+
+static const struct clk_pll_table *_get_pll_table(
+   const struct clk_pll_table *table, unsigned long rate)
+{
+   const struct clk_pll_table *clkt;
+
+   for (clkt = table; clkt->rate; clkt++) {
+   if (clkt->rate == rate) {
+   table = clkt;
+   break;
+   } else if (clkt->rate < rate)
+   table = clkt;
+   }
+
+   return table;
+}
+
+static long owl_pll_round_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long *parent_rate)
+{
+   struct owl_pll *pll = hw_to_owl_pll(hw);
+   struct owl_pll_hw *pll_hw = >pll_hw;
+   const struct clk_pll_table *clkt;
+   u32 mul;
+
+   if (pll_hw->table) {
+   clkt = _get_pll_table(pll_hw->table, rate);
+   return clkt->rate;
+   }
+
+   /* fixed frequency */
+   if (pll_hw->width == 0)
+   return pll_hw->bfreq;
+
+   mul = owl_pll_calculate_mul(pll_hw, rate);
+
+   return pll_hw->bfreq * mul;
+}
+
+static unsigned long owl_pll_recalc_rate(struct clk_hw *hw,
+   unsigned long parent_rate)
+{
+   struct owl_pll *pll = hw_to_owl_pll(hw);
+   struct owl_pll_hw *pll_hw = >pll_hw;
+   const struct owl_clk_common *common = >common;
+   u32 val;
+
+   if (pll_hw->table) {
+   regmap_read(common->regmap, pll_hw->reg, );
+
+   val = val >> pll_hw->shift;
+   val &= mul_mask(pll_hw);
+
+   return _get_table_rate(pll_hw->table, val);
+   }
+
+   /* fixed frequency */
+   if (pll_hw->width == 0)
+   return pll_hw->bfreq;
+
+   regmap_read(common->regmap, pll_hw->reg, );
+
+   val = val >> pll_hw->shift;
+   val &= mul_mask(pll_hw);
+
+   return pll_hw->bfreq * val;
+}
+
+static int owl_pll_is_enabled(struct clk_hw *hw)
+{
+   struct owl_pll *pll = hw_to_owl_pll(hw);
+   struct owl_pll_hw *pll_hw = >pll_hw;
+   const struct owl_clk_common *common = >common;
+   u32 reg;
+
+   regmap_read(common->regmap, pll_hw->reg, );
+
+   return !!(reg & BIT(pll_hw->bit_idx));
+}
+
+static void owl_pll_set(const struct owl_clk_common *common,
+  const struct owl_pll_hw *pll_hw, bool enable)
+{
+   u32 reg;
+
+   regmap_read(common->regmap, pll_hw->reg, );
+
+   if (enable)
+   reg |= BIT(pll_hw->bit_idx);
+   else
+   reg &= ~BIT(pll_hw->bit_idx);
+
+   regmap_write(common->regmap, pll_hw->reg, reg);
+}
+
+static int owl_pll_enable(struct clk_hw *hw)
+{
+   struct owl_pll *pll = hw_to_owl_pll(hw);
+   const struct owl_clk_common *common = >common;
+
+   owl_pll_set(common, >pll_hw, true);
+
+   return 0;
+}
+
+static void owl_pll_disable(struct clk_hw *hw)
+{
+   struct owl_pll *pll = hw_to_owl_pll(hw);
+   const struct owl_clk_common 

[PATCH v3 08/11] clk: actions: Add factor clock support

2018-02-09 Thread Manivannan Sadhasivam
Add support for Actions Semi factor clock together with
helper functions to be used in composite clock.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/actions/Makefile |   1 +
 drivers/clk/actions/owl-factor.c | 222 +++
 drivers/clk/actions/owl-factor.h |  83 +++
 3 files changed, 306 insertions(+)
 create mode 100644 drivers/clk/actions/owl-factor.c
 create mode 100644 drivers/clk/actions/owl-factor.h

diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
index 5ce75df57e1a..994357fa560b 100644
--- a/drivers/clk/actions/Makefile
+++ b/drivers/clk/actions/Makefile
@@ -4,3 +4,4 @@ clk-owl-y   += owl-common.o
 clk-owl-y  += owl-gate.o
 clk-owl-y  += owl-mux.o
 clk-owl-y  += owl-divider.o
+clk-owl-y  += owl-factor.o
diff --git a/drivers/clk/actions/owl-factor.c b/drivers/clk/actions/owl-factor.c
new file mode 100644
index ..c48a2c8b479e
--- /dev/null
+++ b/drivers/clk/actions/owl-factor.c
@@ -0,0 +1,222 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL factor clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+#include 
+
+#include "owl-factor.h"
+
+static unsigned int _get_table_maxval(const struct clk_factor_table *table)
+{
+   unsigned int maxval = 0;
+   const struct clk_factor_table *clkt;
+
+   for (clkt = table; clkt->div; clkt++)
+   if (clkt->val > maxval)
+   maxval = clkt->val;
+   return maxval;
+}
+
+static int _get_table_div_mul(const struct clk_factor_table *table,
+   unsigned int val, unsigned int *mul, unsigned int *div)
+{
+   const struct clk_factor_table *clkt;
+
+   for (clkt = table; clkt->div; clkt++) {
+   if (clkt->val == val) {
+   *mul = clkt->mul;
+   *div = clkt->div;
+   return 1;
+   }
+   }
+
+   return 0;
+}
+
+static unsigned int _get_table_val(const struct clk_factor_table *table,
+   unsigned long rate, unsigned long parent_rate)
+{
+   const struct clk_factor_table *clkt;
+   int val = -1;
+   u64 calc_rate;
+
+   for (clkt = table; clkt->div; clkt++) {
+   calc_rate = parent_rate * clkt->mul;
+   do_div(calc_rate, clkt->div);
+
+   if ((unsigned long)calc_rate <= rate) {
+   val = clkt->val;
+   break;
+   }
+   }
+
+   if (val == -1)
+   val = _get_table_maxval(table);
+
+   return val;
+}
+
+static int clk_val_best(struct clk_hw *hw, unsigned long rate,
+   unsigned long *best_parent_rate)
+{
+   struct owl_factor *factor = hw_to_owl_factor(hw);
+   struct owl_factor_hw *factor_hw = >factor_hw;
+   const struct clk_factor_table *clkt = factor_hw->table;
+   unsigned long parent_rate, try_parent_rate, best = 0, cur_rate;
+   unsigned long parent_rate_saved = *best_parent_rate;
+   int bestval = 0;
+
+   if (!rate)
+   rate = 1;
+
+   if (!(clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) {
+   parent_rate = *best_parent_rate;
+   bestval = _get_table_val(clkt, rate, parent_rate);
+   return bestval;
+   }
+
+   for (clkt = factor_hw->table; clkt->div; clkt++) {
+   try_parent_rate = rate * clkt->div / clkt->mul;
+
+   if (try_parent_rate == parent_rate_saved) {
+   pr_debug("%s: [%d %d %d] found try_parent_rate %ld\n",
+   __func__, clkt->val, clkt->mul, clkt->div,
+   try_parent_rate);
+   /*
+* It's the most ideal case if the requested rate can be
+* divided from parent clock without any need to change
+* parent rate, so return the divider immediately.
+*/
+   *best_parent_rate = parent_rate_saved;
+   return clkt->val;
+   }
+
+   parent_rate = clk_hw_round_rate(clk_hw_get_parent(hw),
+   try_parent_rate);
+   cur_rate = DIV_ROUND_UP(parent_rate, clkt->div) * clkt->mul;
+   if (cur_rate <= rate && cur_rate > best) {
+   bestval = clkt->val;
+   best = cur_rate;
+   *best_parent_rate = parent_rate;
+   }
+   }
+
+   if (!bestval) {
+   bestval = _get_table_maxval(clkt);
+   *best_parent_rate = clk_hw_round_rate(
+   clk_hw_get_parent(hw), 1);
+   }
+
+   return bestval;
+}
+

[PATCH v3 10/11] clk: actions: Add pll clock support

2018-02-09 Thread Manivannan Sadhasivam
Add support for Actions Semi PLL clock

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/actions/Makefile  |   1 +
 drivers/clk/actions/owl-pll.c | 194 ++
 drivers/clk/actions/owl-pll.h |  92 
 3 files changed, 287 insertions(+)
 create mode 100644 drivers/clk/actions/owl-pll.c
 create mode 100644 drivers/clk/actions/owl-pll.h

diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
index 53431aef6e9c..31b68eab9309 100644
--- a/drivers/clk/actions/Makefile
+++ b/drivers/clk/actions/Makefile
@@ -6,3 +6,4 @@ clk-owl-y   += owl-mux.o
 clk-owl-y  += owl-divider.o
 clk-owl-y  += owl-factor.o
 clk-owl-y  += owl-composite.o
+clk-owl-y  += owl-pll.o
diff --git a/drivers/clk/actions/owl-pll.c b/drivers/clk/actions/owl-pll.c
new file mode 100644
index ..3560c7324f9c
--- /dev/null
+++ b/drivers/clk/actions/owl-pll.c
@@ -0,0 +1,194 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL pll clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "owl-pll.h"
+
+static u32 owl_pll_calculate_mul(struct owl_pll_hw *pll_hw, unsigned long rate)
+{
+   u32 mul;
+
+   mul = DIV_ROUND_CLOSEST(rate, pll_hw->bfreq);
+   if (mul < pll_hw->min_mul)
+   mul = pll_hw->min_mul;
+   else if (mul > pll_hw->max_mul)
+   mul = pll_hw->max_mul;
+
+   return mul &= mul_mask(pll_hw);
+}
+
+static unsigned int _get_table_rate(const struct clk_pll_table *table,
+   unsigned int val)
+{
+   const struct clk_pll_table *clkt;
+
+   for (clkt = table; clkt->rate; clkt++)
+   if (clkt->val == val)
+   return clkt->rate;
+
+   return 0;
+}
+
+static const struct clk_pll_table *_get_pll_table(
+   const struct clk_pll_table *table, unsigned long rate)
+{
+   const struct clk_pll_table *clkt;
+
+   for (clkt = table; clkt->rate; clkt++) {
+   if (clkt->rate == rate) {
+   table = clkt;
+   break;
+   } else if (clkt->rate < rate)
+   table = clkt;
+   }
+
+   return table;
+}
+
+static long owl_pll_round_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long *parent_rate)
+{
+   struct owl_pll *pll = hw_to_owl_pll(hw);
+   struct owl_pll_hw *pll_hw = >pll_hw;
+   const struct clk_pll_table *clkt;
+   u32 mul;
+
+   if (pll_hw->table) {
+   clkt = _get_pll_table(pll_hw->table, rate);
+   return clkt->rate;
+   }
+
+   /* fixed frequency */
+   if (pll_hw->width == 0)
+   return pll_hw->bfreq;
+
+   mul = owl_pll_calculate_mul(pll_hw, rate);
+
+   return pll_hw->bfreq * mul;
+}
+
+static unsigned long owl_pll_recalc_rate(struct clk_hw *hw,
+   unsigned long parent_rate)
+{
+   struct owl_pll *pll = hw_to_owl_pll(hw);
+   struct owl_pll_hw *pll_hw = >pll_hw;
+   const struct owl_clk_common *common = >common;
+   u32 val;
+
+   if (pll_hw->table) {
+   regmap_read(common->regmap, pll_hw->reg, );
+
+   val = val >> pll_hw->shift;
+   val &= mul_mask(pll_hw);
+
+   return _get_table_rate(pll_hw->table, val);
+   }
+
+   /* fixed frequency */
+   if (pll_hw->width == 0)
+   return pll_hw->bfreq;
+
+   regmap_read(common->regmap, pll_hw->reg, );
+
+   val = val >> pll_hw->shift;
+   val &= mul_mask(pll_hw);
+
+   return pll_hw->bfreq * val;
+}
+
+static int owl_pll_is_enabled(struct clk_hw *hw)
+{
+   struct owl_pll *pll = hw_to_owl_pll(hw);
+   struct owl_pll_hw *pll_hw = >pll_hw;
+   const struct owl_clk_common *common = >common;
+   u32 reg;
+
+   regmap_read(common->regmap, pll_hw->reg, );
+
+   return !!(reg & BIT(pll_hw->bit_idx));
+}
+
+static void owl_pll_set(const struct owl_clk_common *common,
+  const struct owl_pll_hw *pll_hw, bool enable)
+{
+   u32 reg;
+
+   regmap_read(common->regmap, pll_hw->reg, );
+
+   if (enable)
+   reg |= BIT(pll_hw->bit_idx);
+   else
+   reg &= ~BIT(pll_hw->bit_idx);
+
+   regmap_write(common->regmap, pll_hw->reg, reg);
+}
+
+static int owl_pll_enable(struct clk_hw *hw)
+{
+   struct owl_pll *pll = hw_to_owl_pll(hw);
+   const struct owl_clk_common *common = >common;
+
+   owl_pll_set(common, >pll_hw, true);
+
+   return 0;
+}
+
+static void owl_pll_disable(struct clk_hw *hw)
+{
+   struct owl_pll *pll = hw_to_owl_pll(hw);
+   const struct owl_clk_common *common = >common;
+
+   owl_pll_set(common, >pll_hw, false);
+}
+
+static int 

[PATCH v3 09/11] clk: actions: Add composite clock support

2018-02-09 Thread Manivannan Sadhasivam
Add support for Actions Semi composite clock. This clock
consists of gate, mux, divider and factor clocks.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/actions/Makefile|   1 +
 drivers/clk/actions/owl-composite.c | 155 
 drivers/clk/actions/owl-composite.h | 101 +++
 3 files changed, 257 insertions(+)
 create mode 100644 drivers/clk/actions/owl-composite.c
 create mode 100644 drivers/clk/actions/owl-composite.h

diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
index 994357fa560b..53431aef6e9c 100644
--- a/drivers/clk/actions/Makefile
+++ b/drivers/clk/actions/Makefile
@@ -5,3 +5,4 @@ clk-owl-y   += owl-gate.o
 clk-owl-y  += owl-mux.o
 clk-owl-y  += owl-divider.o
 clk-owl-y  += owl-factor.o
+clk-owl-y  += owl-composite.o
diff --git a/drivers/clk/actions/owl-composite.c 
b/drivers/clk/actions/owl-composite.c
new file mode 100644
index ..04fe1645a60d
--- /dev/null
+++ b/drivers/clk/actions/owl-composite.c
@@ -0,0 +1,155 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL composite clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+
+#include "owl-composite.h"
+
+static u8 owl_comp_get_parent(struct clk_hw *hw)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_mux_helper_get_parent(>common, >mux_hw);
+}
+
+static int owl_comp_set_parent(struct clk_hw *hw, u8 index)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_mux_helper_set_parent(>common, >mux_hw, index);
+}
+
+static void owl_comp_disable(struct clk_hw *hw)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+   struct owl_clk_common *common = >common;
+
+   clk_gate_set(common, >gate_hw, false);
+}
+
+static int owl_comp_enable(struct clk_hw *hw)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+   struct owl_clk_common *common = >common;
+
+   clk_gate_set(common, >gate_hw, true);
+
+   return 0;
+}
+
+static int owl_comp_is_enabled(struct clk_hw *hw)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+   struct owl_clk_common *common = >common;
+
+   return clk_is_enabled(common, >gate_hw);
+}
+
+static long owl_comp_div_round_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long *parent_rate)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_divider_helper_round_rate(>common, >rate.div_hw,
+   rate, parent_rate);
+}
+
+static unsigned long owl_comp_div_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_divider_helper_recalc_rate(>common, >rate.div_hw,
+   parent_rate);
+}
+
+static int owl_comp_div_set_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long parent_rate)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_divider_helper_set_rate(>common, >rate.div_hw,
+   rate, parent_rate);
+}
+
+static long owl_comp_fact_round_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long *parent_rate)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_factor_helper_round_rate(>common,
+   >rate.factor_hw,
+   rate, parent_rate);
+}
+
+static unsigned long owl_comp_fact_recalc_rate(struct clk_hw *hw,
+   unsigned long parent_rate)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_factor_helper_recalc_rate(>common,
+   >rate.factor_hw,
+   parent_rate);
+}
+
+static int owl_comp_fact_set_rate(struct clk_hw *hw, unsigned long rate,
+  unsigned long parent_rate)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_factor_helper_set_rate(>common,
+   >rate.factor_hw,
+   rate, parent_rate);
+}
+
+const struct clk_ops owl_comp_div_ops = {
+   /* mux_ops */
+   .get_parent = owl_comp_get_parent,
+   .set_parent = owl_comp_set_parent,
+
+   /* gate_ops */
+   .disable= owl_comp_disable,
+   .enable = owl_comp_enable,
+   .is_enabled = owl_comp_is_enabled,
+
+   /* div_ops */
+   .round_rate = owl_comp_div_round_rate,
+   

[PATCH v3 06/11] clk: actions: Add mux clock support

2018-02-09 Thread Manivannan Sadhasivam
Add support for Actions Semi mux clock together with helper
functions to be used in composite clock.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/actions/Makefile  |  1 +
 drivers/clk/actions/owl-mux.c | 60 ++
 drivers/clk/actions/owl-mux.h | 61 +++
 3 files changed, 122 insertions(+)
 create mode 100644 drivers/clk/actions/owl-mux.c
 create mode 100644 drivers/clk/actions/owl-mux.h

diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
index 1f0917872c9d..2d4aa8f35d90 100644
--- a/drivers/clk/actions/Makefile
+++ b/drivers/clk/actions/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_CLK_ACTIONS)   += clk-owl.o
 
 clk-owl-y  += owl-common.o
 clk-owl-y  += owl-gate.o
+clk-owl-y  += owl-mux.o
diff --git a/drivers/clk/actions/owl-mux.c b/drivers/clk/actions/owl-mux.c
new file mode 100644
index ..f9c6cf2540e4
--- /dev/null
+++ b/drivers/clk/actions/owl-mux.c
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL mux clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+
+#include "owl-mux.h"
+
+u8 owl_mux_helper_get_parent(const struct owl_clk_common *common,
+const struct owl_mux_hw *mux_hw)
+{
+   u32 reg;
+   u8 parent;
+
+   regmap_read(common->regmap, mux_hw->reg, );
+   parent = reg >> mux_hw->shift;
+   parent &= BIT(mux_hw->width) - 1;
+
+   return parent;
+}
+
+static u8 owl_mux_get_parent(struct clk_hw *hw)
+{
+   struct owl_mux *mux = hw_to_owl_mux(hw);
+
+   return owl_mux_helper_get_parent(>common, >mux_hw);
+}
+
+int owl_mux_helper_set_parent(const struct owl_clk_common *common,
+ struct owl_mux_hw *mux_hw, u8 index)
+{
+   u32 reg;
+
+   regmap_read(common->regmap, mux_hw->reg, );
+   reg &= ~GENMASK(mux_hw->width + mux_hw->shift - 1, mux_hw->shift);
+   regmap_write(common->regmap, mux_hw->reg,
+   reg | (index << mux_hw->shift));
+
+   return 0;
+}
+
+static int owl_mux_set_parent(struct clk_hw *hw, u8 index)
+{
+   struct owl_mux *mux = hw_to_owl_mux(hw);
+
+   return owl_mux_helper_set_parent(>common, >mux_hw, index);
+}
+
+const struct clk_ops owl_mux_ops = {
+   .get_parent = owl_mux_get_parent,
+   .set_parent = owl_mux_set_parent,
+   .determine_rate = __clk_mux_determine_rate,
+};
diff --git a/drivers/clk/actions/owl-mux.h b/drivers/clk/actions/owl-mux.h
new file mode 100644
index ..834284c8c3ae
--- /dev/null
+++ b/drivers/clk/actions/owl-mux.h
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL mux clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#ifndef _OWL_MUX_H_
+#define _OWL_MUX_H_
+
+#include "owl-common.h"
+
+struct owl_mux_hw {
+   u32 reg;
+   u8  shift;
+   u8  width;
+};
+
+struct owl_mux {
+   struct owl_mux_hw   mux_hw;
+   struct owl_clk_common   common;
+};
+
+#define OWL_MUX_HW(_reg, _shift, _width)   \
+   {   \
+   .reg= _reg, \
+   .shift  = _shift,   \
+   .width  = _width,   \
+   }
+
+#define OWL_MUX(_struct, _name, _parents, _reg,
\
+   _shift, _width, _flags) \
+   struct owl_mux _struct = {  \
+   .mux_hw = OWL_MUX_HW(_reg, _shift, _width), \
+   .common = { \
+   .regmap = NULL, \
+   .hw.init = CLK_HW_INIT_PARENTS(_name,   \
+  _parents,\
+  _mux_ops,\
+  _flags), \
+   },  \
+   }
+
+static inline struct owl_mux *hw_to_owl_mux(const struct clk_hw *hw)
+{
+   struct owl_clk_common *common = hw_to_owl_clk_common(hw);
+
+   return container_of(common, struct owl_mux, common);
+}
+
+u8 owl_mux_helper_get_parent(const struct owl_clk_common *common,
+const struct owl_mux_hw *mux_hw);
+int owl_mux_helper_set_parent(const struct 

[PATCH v3 07/11] clk: actions: Add divider clock support

2018-02-09 Thread Manivannan Sadhasivam
Add support for Actions Semi divider clock together with
helper functions to be used in composite clock.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/actions/Makefile  |  1 +
 drivers/clk/actions/owl-divider.c | 94 +++
 drivers/clk/actions/owl-divider.h | 75 +++
 3 files changed, 170 insertions(+)
 create mode 100644 drivers/clk/actions/owl-divider.c
 create mode 100644 drivers/clk/actions/owl-divider.h

diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
index 2d4aa8f35d90..5ce75df57e1a 100644
--- a/drivers/clk/actions/Makefile
+++ b/drivers/clk/actions/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_CLK_ACTIONS)   += clk-owl.o
 clk-owl-y  += owl-common.o
 clk-owl-y  += owl-gate.o
 clk-owl-y  += owl-mux.o
+clk-owl-y  += owl-divider.o
diff --git a/drivers/clk/actions/owl-divider.c 
b/drivers/clk/actions/owl-divider.c
new file mode 100644
index ..cddac00fe324
--- /dev/null
+++ b/drivers/clk/actions/owl-divider.c
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL divider clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+
+#include "owl-divider.h"
+
+long owl_divider_helper_round_rate(struct owl_clk_common *common,
+   const struct owl_divider_hw *div_hw,
+   unsigned long rate,
+   unsigned long *parent_rate)
+{
+   return divider_round_rate(>hw, rate, parent_rate,
+ div_hw->table, div_hw->width,
+ div_hw->div_flags);
+}
+
+static long owl_divider_round_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long *parent_rate)
+{
+   struct owl_divider *div = hw_to_owl_divider(hw);
+
+   return owl_divider_helper_round_rate(>common, >div_hw,
+rate, parent_rate);
+}
+
+unsigned long owl_divider_helper_recalc_rate(struct owl_clk_common *common,
+const struct owl_divider_hw *div_hw,
+unsigned long parent_rate)
+{
+   unsigned long val;
+   unsigned int reg;
+
+   regmap_read(common->regmap, div_hw->reg, );
+   val = reg >> div_hw->shift;
+   val &= (1 << div_hw->width) - 1;
+
+   return divider_recalc_rate(>hw, parent_rate,
+  val, div_hw->table,
+  div_hw->div_flags,
+  div_hw->width);
+}
+
+static unsigned long owl_divider_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+   struct owl_divider *div = hw_to_owl_divider(hw);
+
+   return owl_divider_helper_recalc_rate(>common,
+ >div_hw, parent_rate);
+}
+
+int owl_divider_helper_set_rate(const struct owl_clk_common *common,
+   const struct owl_divider_hw *div_hw,
+   unsigned long rate,
+   unsigned long parent_rate)
+{
+   unsigned long val;
+   unsigned int reg;
+
+   val = divider_get_val(rate, parent_rate, div_hw->table,
+ div_hw->width, 0);
+
+   regmap_read(common->regmap, div_hw->reg, );
+   reg &= ~GENMASK(div_hw->width + div_hw->shift - 1, div_hw->shift);
+
+   regmap_write(common->regmap, div_hw->reg,
+ reg | (val << div_hw->shift));
+
+   return 0;
+}
+
+static int owl_divider_set_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long parent_rate)
+{
+   struct owl_divider *div = hw_to_owl_divider(hw);
+
+   return owl_divider_helper_set_rate(>common, >div_hw,
+   rate, parent_rate);
+}
+
+const struct clk_ops owl_divider_ops = {
+   .recalc_rate = owl_divider_recalc_rate,
+   .round_rate = owl_divider_round_rate,
+   .set_rate = owl_divider_set_rate,
+};
diff --git a/drivers/clk/actions/owl-divider.h 
b/drivers/clk/actions/owl-divider.h
new file mode 100644
index ..92d3e3d23967
--- /dev/null
+++ b/drivers/clk/actions/owl-divider.h
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL divider clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#ifndef _OWL_DIVIDER_H_
+#define _OWL_DIVIDER_H_
+
+#include "owl-common.h"
+
+struct owl_divider_hw {
+   u32   

[PATCH v3 09/11] clk: actions: Add composite clock support

2018-02-09 Thread Manivannan Sadhasivam
Add support for Actions Semi composite clock. This clock
consists of gate, mux, divider and factor clocks.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/actions/Makefile|   1 +
 drivers/clk/actions/owl-composite.c | 155 
 drivers/clk/actions/owl-composite.h | 101 +++
 3 files changed, 257 insertions(+)
 create mode 100644 drivers/clk/actions/owl-composite.c
 create mode 100644 drivers/clk/actions/owl-composite.h

diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
index 994357fa560b..53431aef6e9c 100644
--- a/drivers/clk/actions/Makefile
+++ b/drivers/clk/actions/Makefile
@@ -5,3 +5,4 @@ clk-owl-y   += owl-gate.o
 clk-owl-y  += owl-mux.o
 clk-owl-y  += owl-divider.o
 clk-owl-y  += owl-factor.o
+clk-owl-y  += owl-composite.o
diff --git a/drivers/clk/actions/owl-composite.c 
b/drivers/clk/actions/owl-composite.c
new file mode 100644
index ..04fe1645a60d
--- /dev/null
+++ b/drivers/clk/actions/owl-composite.c
@@ -0,0 +1,155 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL composite clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+
+#include "owl-composite.h"
+
+static u8 owl_comp_get_parent(struct clk_hw *hw)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_mux_helper_get_parent(>common, >mux_hw);
+}
+
+static int owl_comp_set_parent(struct clk_hw *hw, u8 index)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_mux_helper_set_parent(>common, >mux_hw, index);
+}
+
+static void owl_comp_disable(struct clk_hw *hw)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+   struct owl_clk_common *common = >common;
+
+   clk_gate_set(common, >gate_hw, false);
+}
+
+static int owl_comp_enable(struct clk_hw *hw)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+   struct owl_clk_common *common = >common;
+
+   clk_gate_set(common, >gate_hw, true);
+
+   return 0;
+}
+
+static int owl_comp_is_enabled(struct clk_hw *hw)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+   struct owl_clk_common *common = >common;
+
+   return clk_is_enabled(common, >gate_hw);
+}
+
+static long owl_comp_div_round_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long *parent_rate)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_divider_helper_round_rate(>common, >rate.div_hw,
+   rate, parent_rate);
+}
+
+static unsigned long owl_comp_div_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_divider_helper_recalc_rate(>common, >rate.div_hw,
+   parent_rate);
+}
+
+static int owl_comp_div_set_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long parent_rate)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_divider_helper_set_rate(>common, >rate.div_hw,
+   rate, parent_rate);
+}
+
+static long owl_comp_fact_round_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long *parent_rate)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_factor_helper_round_rate(>common,
+   >rate.factor_hw,
+   rate, parent_rate);
+}
+
+static unsigned long owl_comp_fact_recalc_rate(struct clk_hw *hw,
+   unsigned long parent_rate)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_factor_helper_recalc_rate(>common,
+   >rate.factor_hw,
+   parent_rate);
+}
+
+static int owl_comp_fact_set_rate(struct clk_hw *hw, unsigned long rate,
+  unsigned long parent_rate)
+{
+   struct owl_composite *comp = hw_to_owl_comp(hw);
+
+   return owl_factor_helper_set_rate(>common,
+   >rate.factor_hw,
+   rate, parent_rate);
+}
+
+const struct clk_ops owl_comp_div_ops = {
+   /* mux_ops */
+   .get_parent = owl_comp_get_parent,
+   .set_parent = owl_comp_set_parent,
+
+   /* gate_ops */
+   .disable= owl_comp_disable,
+   .enable = owl_comp_enable,
+   .is_enabled = owl_comp_is_enabled,
+
+   /* div_ops */
+   .round_rate = owl_comp_div_round_rate,
+   .recalc_rate= owl_comp_div_recalc_rate,
+   .set_rate   = 

[PATCH v3 06/11] clk: actions: Add mux clock support

2018-02-09 Thread Manivannan Sadhasivam
Add support for Actions Semi mux clock together with helper
functions to be used in composite clock.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/actions/Makefile  |  1 +
 drivers/clk/actions/owl-mux.c | 60 ++
 drivers/clk/actions/owl-mux.h | 61 +++
 3 files changed, 122 insertions(+)
 create mode 100644 drivers/clk/actions/owl-mux.c
 create mode 100644 drivers/clk/actions/owl-mux.h

diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
index 1f0917872c9d..2d4aa8f35d90 100644
--- a/drivers/clk/actions/Makefile
+++ b/drivers/clk/actions/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_CLK_ACTIONS)   += clk-owl.o
 
 clk-owl-y  += owl-common.o
 clk-owl-y  += owl-gate.o
+clk-owl-y  += owl-mux.o
diff --git a/drivers/clk/actions/owl-mux.c b/drivers/clk/actions/owl-mux.c
new file mode 100644
index ..f9c6cf2540e4
--- /dev/null
+++ b/drivers/clk/actions/owl-mux.c
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL mux clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+
+#include "owl-mux.h"
+
+u8 owl_mux_helper_get_parent(const struct owl_clk_common *common,
+const struct owl_mux_hw *mux_hw)
+{
+   u32 reg;
+   u8 parent;
+
+   regmap_read(common->regmap, mux_hw->reg, );
+   parent = reg >> mux_hw->shift;
+   parent &= BIT(mux_hw->width) - 1;
+
+   return parent;
+}
+
+static u8 owl_mux_get_parent(struct clk_hw *hw)
+{
+   struct owl_mux *mux = hw_to_owl_mux(hw);
+
+   return owl_mux_helper_get_parent(>common, >mux_hw);
+}
+
+int owl_mux_helper_set_parent(const struct owl_clk_common *common,
+ struct owl_mux_hw *mux_hw, u8 index)
+{
+   u32 reg;
+
+   regmap_read(common->regmap, mux_hw->reg, );
+   reg &= ~GENMASK(mux_hw->width + mux_hw->shift - 1, mux_hw->shift);
+   regmap_write(common->regmap, mux_hw->reg,
+   reg | (index << mux_hw->shift));
+
+   return 0;
+}
+
+static int owl_mux_set_parent(struct clk_hw *hw, u8 index)
+{
+   struct owl_mux *mux = hw_to_owl_mux(hw);
+
+   return owl_mux_helper_set_parent(>common, >mux_hw, index);
+}
+
+const struct clk_ops owl_mux_ops = {
+   .get_parent = owl_mux_get_parent,
+   .set_parent = owl_mux_set_parent,
+   .determine_rate = __clk_mux_determine_rate,
+};
diff --git a/drivers/clk/actions/owl-mux.h b/drivers/clk/actions/owl-mux.h
new file mode 100644
index ..834284c8c3ae
--- /dev/null
+++ b/drivers/clk/actions/owl-mux.h
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL mux clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#ifndef _OWL_MUX_H_
+#define _OWL_MUX_H_
+
+#include "owl-common.h"
+
+struct owl_mux_hw {
+   u32 reg;
+   u8  shift;
+   u8  width;
+};
+
+struct owl_mux {
+   struct owl_mux_hw   mux_hw;
+   struct owl_clk_common   common;
+};
+
+#define OWL_MUX_HW(_reg, _shift, _width)   \
+   {   \
+   .reg= _reg, \
+   .shift  = _shift,   \
+   .width  = _width,   \
+   }
+
+#define OWL_MUX(_struct, _name, _parents, _reg,
\
+   _shift, _width, _flags) \
+   struct owl_mux _struct = {  \
+   .mux_hw = OWL_MUX_HW(_reg, _shift, _width), \
+   .common = { \
+   .regmap = NULL, \
+   .hw.init = CLK_HW_INIT_PARENTS(_name,   \
+  _parents,\
+  _mux_ops,\
+  _flags), \
+   },  \
+   }
+
+static inline struct owl_mux *hw_to_owl_mux(const struct clk_hw *hw)
+{
+   struct owl_clk_common *common = hw_to_owl_clk_common(hw);
+
+   return container_of(common, struct owl_mux, common);
+}
+
+u8 owl_mux_helper_get_parent(const struct owl_clk_common *common,
+const struct owl_mux_hw *mux_hw);
+int owl_mux_helper_set_parent(const struct owl_clk_common *common,
+ struct owl_mux_hw *mux_hw, u8 index);
+
+extern const struct clk_ops owl_mux_ops;
+
+#endif /* _OWL_MUX_H_ 

[PATCH v3 07/11] clk: actions: Add divider clock support

2018-02-09 Thread Manivannan Sadhasivam
Add support for Actions Semi divider clock together with
helper functions to be used in composite clock.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/actions/Makefile  |  1 +
 drivers/clk/actions/owl-divider.c | 94 +++
 drivers/clk/actions/owl-divider.h | 75 +++
 3 files changed, 170 insertions(+)
 create mode 100644 drivers/clk/actions/owl-divider.c
 create mode 100644 drivers/clk/actions/owl-divider.h

diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
index 2d4aa8f35d90..5ce75df57e1a 100644
--- a/drivers/clk/actions/Makefile
+++ b/drivers/clk/actions/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_CLK_ACTIONS)   += clk-owl.o
 clk-owl-y  += owl-common.o
 clk-owl-y  += owl-gate.o
 clk-owl-y  += owl-mux.o
+clk-owl-y  += owl-divider.o
diff --git a/drivers/clk/actions/owl-divider.c 
b/drivers/clk/actions/owl-divider.c
new file mode 100644
index ..cddac00fe324
--- /dev/null
+++ b/drivers/clk/actions/owl-divider.c
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL divider clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+
+#include "owl-divider.h"
+
+long owl_divider_helper_round_rate(struct owl_clk_common *common,
+   const struct owl_divider_hw *div_hw,
+   unsigned long rate,
+   unsigned long *parent_rate)
+{
+   return divider_round_rate(>hw, rate, parent_rate,
+ div_hw->table, div_hw->width,
+ div_hw->div_flags);
+}
+
+static long owl_divider_round_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long *parent_rate)
+{
+   struct owl_divider *div = hw_to_owl_divider(hw);
+
+   return owl_divider_helper_round_rate(>common, >div_hw,
+rate, parent_rate);
+}
+
+unsigned long owl_divider_helper_recalc_rate(struct owl_clk_common *common,
+const struct owl_divider_hw *div_hw,
+unsigned long parent_rate)
+{
+   unsigned long val;
+   unsigned int reg;
+
+   regmap_read(common->regmap, div_hw->reg, );
+   val = reg >> div_hw->shift;
+   val &= (1 << div_hw->width) - 1;
+
+   return divider_recalc_rate(>hw, parent_rate,
+  val, div_hw->table,
+  div_hw->div_flags,
+  div_hw->width);
+}
+
+static unsigned long owl_divider_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+   struct owl_divider *div = hw_to_owl_divider(hw);
+
+   return owl_divider_helper_recalc_rate(>common,
+ >div_hw, parent_rate);
+}
+
+int owl_divider_helper_set_rate(const struct owl_clk_common *common,
+   const struct owl_divider_hw *div_hw,
+   unsigned long rate,
+   unsigned long parent_rate)
+{
+   unsigned long val;
+   unsigned int reg;
+
+   val = divider_get_val(rate, parent_rate, div_hw->table,
+ div_hw->width, 0);
+
+   regmap_read(common->regmap, div_hw->reg, );
+   reg &= ~GENMASK(div_hw->width + div_hw->shift - 1, div_hw->shift);
+
+   regmap_write(common->regmap, div_hw->reg,
+ reg | (val << div_hw->shift));
+
+   return 0;
+}
+
+static int owl_divider_set_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long parent_rate)
+{
+   struct owl_divider *div = hw_to_owl_divider(hw);
+
+   return owl_divider_helper_set_rate(>common, >div_hw,
+   rate, parent_rate);
+}
+
+const struct clk_ops owl_divider_ops = {
+   .recalc_rate = owl_divider_recalc_rate,
+   .round_rate = owl_divider_round_rate,
+   .set_rate = owl_divider_set_rate,
+};
diff --git a/drivers/clk/actions/owl-divider.h 
b/drivers/clk/actions/owl-divider.h
new file mode 100644
index ..92d3e3d23967
--- /dev/null
+++ b/drivers/clk/actions/owl-divider.h
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL divider clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#ifndef _OWL_DIVIDER_H_
+#define _OWL_DIVIDER_H_
+
+#include "owl-common.h"
+
+struct owl_divider_hw {
+   u32 reg;
+   u8  shift;
+   u8  width;
+   u8  div_flags;
+   struct 

[PATCH v3 00/11] Add clock driver for Actions S900 SoC

2018-02-09 Thread Manivannan Sadhasivam
This patchset adds clock support for Actions Semi OWL series
S900 SoC with relevant clock bindings and device tree data.

Driver has been validated on Bubblegum-96 board.

Thanks,
Mani

Changes in V3:

* Completely refactored the clock driver based on sunxi-ng
  clock structure
* Removed all owl_ prefixed functions for registering the
  clock driver and used the registration functions directly
* Moved to SPDX based license tag
* Removed module dependencies from the driver
* Made I2C clocks as simple gate clocks due to the lack of
  information about factor rates
* Added Ack from Rob for DT bindings
* Sourced CMU clock for UART5

Changes in V2: (https://lkml.org/lkml/2017/11/6/840)

* Changed the directory structure to actions/ and used owl- prefix
  for sources.
* Fixed MAINTAINERS and added Andreas as Designated Reviewer (R:).
* Introduced new Kconfig for S900 code part (CONFIG_CLK_OWL_S900).
* Changed the license from GPLv2 to GPLv2+.
* Moved fixed clock sources to DT
* Changed clock-controller node name to cmu in DT
* Added clocks property to cmu node in DT
* Changed compatible property value to "actions,s900-cmu"
* Fixed example UART controller node in documentation
* Fixed tab vs space issue

Changes in V1: (https://lkml.org/lkml/2017/10/31/808)

* Addressed last year's review comments from Stephen
- https://patchwork.kernel.org/patch/9254471/

Manivannan Sadhasivam (11):
  dt-bindings: clock: Add Actions S900 clock bindings
  arm64: dts: actions: Add S900 clock management unit nodes
  arm64: dts: actions: Source CMU clock for UART5
  clk: actions: Add common clock driver support
  clk: actions: Add gate clock support
  clk: actions: Add mux clock support
  clk: actions: Add divider clock support
  clk: actions: Add factor clock support
  clk: actions: Add composite clock support
  clk: actions: Add pll clock support
  clk: actions: Add S900 SoC clock support

 .../devicetree/bindings/clock/actions,s900-cmu.txt |  47 ++
 arch/arm64/boot/dts/actions/s900-bubblegum-96.dts  |   8 +-
 arch/arm64/boot/dts/actions/s900.dtsi  |  20 +
 drivers/clk/Kconfig|   1 +
 drivers/clk/Makefile   |   1 +
 drivers/clk/actions/Kconfig|  14 +
 drivers/clk/actions/Makefile   |  12 +
 drivers/clk/actions/owl-common.c   |  84 +++
 drivers/clk/actions/owl-common.h   |  40 ++
 drivers/clk/actions/owl-composite.c| 155 +
 drivers/clk/actions/owl-composite.h| 101 
 drivers/clk/actions/owl-divider.c  |  94 +++
 drivers/clk/actions/owl-divider.h  |  75 +++
 drivers/clk/actions/owl-factor.c   | 222 +++
 drivers/clk/actions/owl-factor.h   |  83 +++
 drivers/clk/actions/owl-gate.c |  77 +++
 drivers/clk/actions/owl-gate.h |  73 +++
 drivers/clk/actions/owl-mux.c  |  60 ++
 drivers/clk/actions/owl-mux.h  |  61 ++
 drivers/clk/actions/owl-pll.c  | 194 ++
 drivers/clk/actions/owl-pll.h  |  92 +++
 drivers/clk/actions/owl-s900.c | 666 +
 drivers/clk/actions/owl-s900.h |  61 ++
 include/dt-bindings/clock/actions,s900-cmu.h   | 139 +
 24 files changed, 2373 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/actions,s900-cmu.txt
 create mode 100644 drivers/clk/actions/Kconfig
 create mode 100644 drivers/clk/actions/Makefile
 create mode 100644 drivers/clk/actions/owl-common.c
 create mode 100644 drivers/clk/actions/owl-common.h
 create mode 100644 drivers/clk/actions/owl-composite.c
 create mode 100644 drivers/clk/actions/owl-composite.h
 create mode 100644 drivers/clk/actions/owl-divider.c
 create mode 100644 drivers/clk/actions/owl-divider.h
 create mode 100644 drivers/clk/actions/owl-factor.c
 create mode 100644 drivers/clk/actions/owl-factor.h
 create mode 100644 drivers/clk/actions/owl-gate.c
 create mode 100644 drivers/clk/actions/owl-gate.h
 create mode 100644 drivers/clk/actions/owl-mux.c
 create mode 100644 drivers/clk/actions/owl-mux.h
 create mode 100644 drivers/clk/actions/owl-pll.c
 create mode 100644 drivers/clk/actions/owl-pll.h
 create mode 100644 drivers/clk/actions/owl-s900.c
 create mode 100644 drivers/clk/actions/owl-s900.h
 create mode 100644 include/dt-bindings/clock/actions,s900-cmu.h

-- 
2.14.1



[PATCH v3 02/11] arm64: dts: actions: Add S900 clock management unit nodes

2018-02-09 Thread Manivannan Sadhasivam
Add Actions Semi S900 Clock Management Unit (CMU) nodes

Signed-off-by: Manivannan Sadhasivam 
---
 arch/arm64/boot/dts/actions/s900.dtsi | 20 
 1 file changed, 20 insertions(+)

diff --git a/arch/arm64/boot/dts/actions/s900.dtsi 
b/arch/arm64/boot/dts/actions/s900.dtsi
index 11406f6d3a6d..fee0c9557656 100644
--- a/arch/arm64/boot/dts/actions/s900.dtsi
+++ b/arch/arm64/boot/dts/actions/s900.dtsi
@@ -4,6 +4,7 @@
  * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
  */
 
+#include 
 #include 
 
 / {
@@ -88,6 +89,18 @@
#clock-cells = <0>;
};
 
+   losc: losc {
+   compatible = "fixed-clock";
+   clock-frequency = <32768>;
+   #clock-cells = <0>;
+   };
+
+   diff24M: diff24M {
+   compatible = "fixed-clock";
+   clock-frequency = <2400>;
+   #clock-cells = <0>;
+   };
+
soc {
compatible = "simple-bus";
#address-cells = <2>;
@@ -154,6 +167,13 @@
status = "disabled";
};
 
+   cmu: clock-controller@e016 {
+   compatible = "actions,s900-cmu";
+   reg = <0x0 0xe016 0x0 0x1000>;
+   clocks = <>, <>;
+   #clock-cells = <1>;
+   };
+
timer: timer@e0228000 {
compatible = "actions,s900-timer";
reg = <0x0 0xe0228000 0x0 0x8000>;
-- 
2.14.1



[PATCH v3 00/11] Add clock driver for Actions S900 SoC

2018-02-09 Thread Manivannan Sadhasivam
This patchset adds clock support for Actions Semi OWL series
S900 SoC with relevant clock bindings and device tree data.

Driver has been validated on Bubblegum-96 board.

Thanks,
Mani

Changes in V3:

* Completely refactored the clock driver based on sunxi-ng
  clock structure
* Removed all owl_ prefixed functions for registering the
  clock driver and used the registration functions directly
* Moved to SPDX based license tag
* Removed module dependencies from the driver
* Made I2C clocks as simple gate clocks due to the lack of
  information about factor rates
* Added Ack from Rob for DT bindings
* Sourced CMU clock for UART5

Changes in V2: (https://lkml.org/lkml/2017/11/6/840)

* Changed the directory structure to actions/ and used owl- prefix
  for sources.
* Fixed MAINTAINERS and added Andreas as Designated Reviewer (R:).
* Introduced new Kconfig for S900 code part (CONFIG_CLK_OWL_S900).
* Changed the license from GPLv2 to GPLv2+.
* Moved fixed clock sources to DT
* Changed clock-controller node name to cmu in DT
* Added clocks property to cmu node in DT
* Changed compatible property value to "actions,s900-cmu"
* Fixed example UART controller node in documentation
* Fixed tab vs space issue

Changes in V1: (https://lkml.org/lkml/2017/10/31/808)

* Addressed last year's review comments from Stephen
- https://patchwork.kernel.org/patch/9254471/

Manivannan Sadhasivam (11):
  dt-bindings: clock: Add Actions S900 clock bindings
  arm64: dts: actions: Add S900 clock management unit nodes
  arm64: dts: actions: Source CMU clock for UART5
  clk: actions: Add common clock driver support
  clk: actions: Add gate clock support
  clk: actions: Add mux clock support
  clk: actions: Add divider clock support
  clk: actions: Add factor clock support
  clk: actions: Add composite clock support
  clk: actions: Add pll clock support
  clk: actions: Add S900 SoC clock support

 .../devicetree/bindings/clock/actions,s900-cmu.txt |  47 ++
 arch/arm64/boot/dts/actions/s900-bubblegum-96.dts  |   8 +-
 arch/arm64/boot/dts/actions/s900.dtsi  |  20 +
 drivers/clk/Kconfig|   1 +
 drivers/clk/Makefile   |   1 +
 drivers/clk/actions/Kconfig|  14 +
 drivers/clk/actions/Makefile   |  12 +
 drivers/clk/actions/owl-common.c   |  84 +++
 drivers/clk/actions/owl-common.h   |  40 ++
 drivers/clk/actions/owl-composite.c| 155 +
 drivers/clk/actions/owl-composite.h| 101 
 drivers/clk/actions/owl-divider.c  |  94 +++
 drivers/clk/actions/owl-divider.h  |  75 +++
 drivers/clk/actions/owl-factor.c   | 222 +++
 drivers/clk/actions/owl-factor.h   |  83 +++
 drivers/clk/actions/owl-gate.c |  77 +++
 drivers/clk/actions/owl-gate.h |  73 +++
 drivers/clk/actions/owl-mux.c  |  60 ++
 drivers/clk/actions/owl-mux.h  |  61 ++
 drivers/clk/actions/owl-pll.c  | 194 ++
 drivers/clk/actions/owl-pll.h  |  92 +++
 drivers/clk/actions/owl-s900.c | 666 +
 drivers/clk/actions/owl-s900.h |  61 ++
 include/dt-bindings/clock/actions,s900-cmu.h   | 139 +
 24 files changed, 2373 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/actions,s900-cmu.txt
 create mode 100644 drivers/clk/actions/Kconfig
 create mode 100644 drivers/clk/actions/Makefile
 create mode 100644 drivers/clk/actions/owl-common.c
 create mode 100644 drivers/clk/actions/owl-common.h
 create mode 100644 drivers/clk/actions/owl-composite.c
 create mode 100644 drivers/clk/actions/owl-composite.h
 create mode 100644 drivers/clk/actions/owl-divider.c
 create mode 100644 drivers/clk/actions/owl-divider.h
 create mode 100644 drivers/clk/actions/owl-factor.c
 create mode 100644 drivers/clk/actions/owl-factor.h
 create mode 100644 drivers/clk/actions/owl-gate.c
 create mode 100644 drivers/clk/actions/owl-gate.h
 create mode 100644 drivers/clk/actions/owl-mux.c
 create mode 100644 drivers/clk/actions/owl-mux.h
 create mode 100644 drivers/clk/actions/owl-pll.c
 create mode 100644 drivers/clk/actions/owl-pll.h
 create mode 100644 drivers/clk/actions/owl-s900.c
 create mode 100644 drivers/clk/actions/owl-s900.h
 create mode 100644 include/dt-bindings/clock/actions,s900-cmu.h

-- 
2.14.1



[PATCH v3 02/11] arm64: dts: actions: Add S900 clock management unit nodes

2018-02-09 Thread Manivannan Sadhasivam
Add Actions Semi S900 Clock Management Unit (CMU) nodes

Signed-off-by: Manivannan Sadhasivam 
---
 arch/arm64/boot/dts/actions/s900.dtsi | 20 
 1 file changed, 20 insertions(+)

diff --git a/arch/arm64/boot/dts/actions/s900.dtsi 
b/arch/arm64/boot/dts/actions/s900.dtsi
index 11406f6d3a6d..fee0c9557656 100644
--- a/arch/arm64/boot/dts/actions/s900.dtsi
+++ b/arch/arm64/boot/dts/actions/s900.dtsi
@@ -4,6 +4,7 @@
  * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
  */
 
+#include 
 #include 
 
 / {
@@ -88,6 +89,18 @@
#clock-cells = <0>;
};
 
+   losc: losc {
+   compatible = "fixed-clock";
+   clock-frequency = <32768>;
+   #clock-cells = <0>;
+   };
+
+   diff24M: diff24M {
+   compatible = "fixed-clock";
+   clock-frequency = <2400>;
+   #clock-cells = <0>;
+   };
+
soc {
compatible = "simple-bus";
#address-cells = <2>;
@@ -154,6 +167,13 @@
status = "disabled";
};
 
+   cmu: clock-controller@e016 {
+   compatible = "actions,s900-cmu";
+   reg = <0x0 0xe016 0x0 0x1000>;
+   clocks = <>, <>;
+   #clock-cells = <1>;
+   };
+
timer: timer@e0228000 {
compatible = "actions,s900-timer";
reg = <0x0 0xe0228000 0x0 0x8000>;
-- 
2.14.1



[PATCH v3 05/11] clk: actions: Add gate clock support

2018-02-09 Thread Manivannan Sadhasivam
Add support for Actions Semi gate clock together with helper
functions to be used in composite clock.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/actions/Makefile   |  1 +
 drivers/clk/actions/owl-gate.c | 77 ++
 drivers/clk/actions/owl-gate.h | 73 +++
 3 files changed, 151 insertions(+)
 create mode 100644 drivers/clk/actions/owl-gate.c
 create mode 100644 drivers/clk/actions/owl-gate.h

diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
index 64a50fc2d335..1f0917872c9d 100644
--- a/drivers/clk/actions/Makefile
+++ b/drivers/clk/actions/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_CLK_ACTIONS)  += clk-owl.o
 
 clk-owl-y  += owl-common.o
+clk-owl-y  += owl-gate.o
diff --git a/drivers/clk/actions/owl-gate.c b/drivers/clk/actions/owl-gate.c
new file mode 100644
index ..25dd94ac0f35
--- /dev/null
+++ b/drivers/clk/actions/owl-gate.c
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL gate clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+
+#include "owl-gate.h"
+
+void clk_gate_set(const struct owl_clk_common *common,
+const struct owl_gate_hw *gate_hw, bool enable)
+{
+   int set = gate_hw->gate_flags & CLK_GATE_SET_TO_DISABLE ? 1 : 0;
+   u32 reg;
+
+   set ^= enable;
+
+   regmap_read(common->regmap, gate_hw->reg, );
+
+   if (set)
+   reg |= BIT(gate_hw->bit_idx);
+   else
+   reg &= ~BIT(gate_hw->bit_idx);
+
+   regmap_write(common->regmap, gate_hw->reg, reg);
+}
+
+static void owl_gate_disable(struct clk_hw *hw)
+{
+   struct owl_gate *gate = hw_to_owl_gate(hw);
+   struct owl_clk_common *common = >common;
+
+   clk_gate_set(common, >gate_hw, false);
+}
+
+static int owl_gate_enable(struct clk_hw *hw)
+{
+   struct owl_gate *gate = hw_to_owl_gate(hw);
+   struct owl_clk_common *common = >common;
+
+   clk_gate_set(common, >gate_hw, true);
+
+   return 0;
+}
+
+int clk_is_enabled(const struct owl_clk_common *common,
+  const struct owl_gate_hw *gate_hw)
+{
+   u32 reg;
+
+   regmap_read(common->regmap, gate_hw->reg, );
+
+   if (gate_hw->gate_flags & CLK_GATE_SET_TO_DISABLE)
+   reg ^= BIT(gate_hw->bit_idx);
+
+   return !!(reg & BIT(gate_hw->bit_idx));
+}
+
+static int owl_gate_is_enabled(struct clk_hw *hw)
+{
+   struct owl_gate *gate = hw_to_owl_gate(hw);
+   struct owl_clk_common *common = >common;
+
+   return clk_is_enabled(common, >gate_hw);
+}
+
+const struct clk_ops owl_gate_ops = {
+   .disable= owl_gate_disable,
+   .enable = owl_gate_enable,
+   .is_enabled = owl_gate_is_enabled,
+};
diff --git a/drivers/clk/actions/owl-gate.h b/drivers/clk/actions/owl-gate.h
new file mode 100644
index ..4fc609647ae4
--- /dev/null
+++ b/drivers/clk/actions/owl-gate.h
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL gate clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#ifndef _OWL_GATE_H_
+#define _OWL_GATE_H_
+
+#include "owl-common.h"
+
+struct owl_gate_hw {
+   u32 reg;
+   u8  bit_idx;
+   u8  gate_flags;
+};
+
+struct owl_gate {
+   struct owl_gate_hw  gate_hw;
+   struct owl_clk_common   common;
+};
+
+#define OWL_GATE_HW(_reg, _bit_idx, _gate_flags)   \
+   {   \
+   .reg= _reg, \
+   .bit_idx= _bit_idx, \
+   .gate_flags = _gate_flags,  \
+   }
+
+#define OWL_GATE(_struct, _name, _parent, _reg,
\
+   _bit_idx, _gate_flags, _flags)  \
+   struct owl_gate _struct = { \
+   .gate_hw = OWL_GATE_HW(_reg, _bit_idx, _gate_flags),\
+   .common = { \
+   .regmap = NULL, \
+   .hw.init= CLK_HW_INIT(_name,\
+ _parent,  \
+ _gate_ops,\
+ _flags),  \
+   }   \
+   }   

[PATCH v3 04/11] clk: actions: Add common clock driver support

2018-02-09 Thread Manivannan Sadhasivam
Add support for Actions Semi common clock driver with generic structures
and interface functions.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/Kconfig  |  1 +
 drivers/clk/Makefile |  1 +
 drivers/clk/actions/Kconfig  |  4 ++
 drivers/clk/actions/Makefile |  3 ++
 drivers/clk/actions/owl-common.c | 84 
 drivers/clk/actions/owl-common.h | 40 +++
 6 files changed, 133 insertions(+)
 create mode 100644 drivers/clk/actions/Kconfig
 create mode 100644 drivers/clk/actions/Makefile
 create mode 100644 drivers/clk/actions/owl-common.c
 create mode 100644 drivers/clk/actions/owl-common.h

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 98ce9fc6e6c0..6313a4f4327a 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -238,6 +238,7 @@ config COMMON_CLK_VC5
  This driver supports the IDT VersaClock 5 and VersaClock 6
  programmable clock generators.
 
+source "drivers/clk/actions/Kconfig"
 source "drivers/clk/bcm/Kconfig"
 source "drivers/clk/hisilicon/Kconfig"
 source "drivers/clk/imgtec/Kconfig"
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 71ec41e6364f..554b67e4d0c6 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -56,6 +56,7 @@ obj-$(CONFIG_COMMON_CLK_WM831X)   += clk-wm831x.o
 obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o
 
 # please keep this section sorted lexicographically by directory path name
+obj-$(CONFIG_ARCH_ACTIONS) += actions/
 obj-$(CONFIG_COMMON_CLK_AT91)  += at91/
 obj-$(CONFIG_ARCH_ARTPEC)  += axis/
 obj-$(CONFIG_ARC_PLAT_AXS10X)  += axs10x/
diff --git a/drivers/clk/actions/Kconfig b/drivers/clk/actions/Kconfig
new file mode 100644
index ..13a3e5083d43
--- /dev/null
+++ b/drivers/clk/actions/Kconfig
@@ -0,0 +1,4 @@
+config CLK_ACTIONS
+   bool "Clock driver for Actions Semi SoCs"
+   depends on ARCH_ACTIONS || COMPILE_TEST
+   default ARCH_ACTIONS
diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
new file mode 100644
index ..64a50fc2d335
--- /dev/null
+++ b/drivers/clk/actions/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_CLK_ACTIONS)  += clk-owl.o
+
+clk-owl-y  += owl-common.o
diff --git a/drivers/clk/actions/owl-common.c b/drivers/clk/actions/owl-common.c
new file mode 100644
index ..a7cb698fdc86
--- /dev/null
+++ b/drivers/clk/actions/owl-common.c
@@ -0,0 +1,84 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL common clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+#include 
+
+#include "owl-common.h"
+
+static const struct regmap_config owl_regmap_config = {
+   .reg_bits   = 32,
+   .reg_stride = 4,
+   .val_bits   = 32,
+   .max_register   = 0x,
+   .fast_io= true,
+};
+
+static void owl_clk_set_regmap(const struct owl_clk_desc *desc,
+struct regmap *regmap)
+{
+   int i;
+   struct owl_clk_common *clks;
+
+   for (i = 0; i < desc->num_clks; i++) {
+   clks = desc->clks[i];
+   if (!clks)
+   continue;
+
+   clks->regmap = regmap;
+   }
+}
+
+int owl_clk_regmap_init(struct platform_device *pdev,
+const struct owl_clk_desc *desc)
+{
+   void __iomem *base;
+   struct device_node *node = pdev->dev.of_node;
+   struct regmap *regmap;
+
+   base = of_iomap(node, 0);
+   regmap = devm_regmap_init_mmio(>dev, base, _regmap_config);
+   if (IS_ERR_OR_NULL(regmap)) {
+   pr_err("failed to init regmap\n");
+   return PTR_ERR(regmap);
+   }
+
+   owl_clk_set_regmap(desc, regmap);
+
+   return 0;
+}
+
+int owl_clk_probe(struct device *dev, struct clk_hw_onecell_data *hw_clks)
+{
+   int i, ret;
+   struct clk_hw *hw;
+
+   for (i = 0; i < hw_clks->num; i++) {
+
+   hw = hw_clks->hws[i];
+
+   if (!hw)
+   continue;
+
+   ret = devm_clk_hw_register(dev, hw);
+   if (ret) {
+   dev_err(dev, "Couldn't register clock %d - %s\n",
+   i, hw->init->name);
+   return ret;
+   }
+   }
+
+   ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, hw_clks);
+   if (ret)
+   dev_err(dev, "Failed to add clock provider\n");
+
+   return ret;
+}
diff --git a/drivers/clk/actions/owl-common.h b/drivers/clk/actions/owl-common.h
new file mode 100644
index ..e7ea23a6c8f1
--- /dev/null
+++ b/drivers/clk/actions/owl-common.h
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: 

[PATCH v3 01/11] dt-bindings: clock: Add Actions S900 clock bindings

2018-02-09 Thread Manivannan Sadhasivam
Add Actions Semi S900 clock bindings.

Signed-off-by: Manivannan Sadhasivam 
Acked-by: Rob Herring 
---
 .../devicetree/bindings/clock/actions,s900-cmu.txt |  47 +++
 include/dt-bindings/clock/actions,s900-cmu.h   | 139 +
 2 files changed, 186 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/actions,s900-cmu.txt
 create mode 100644 include/dt-bindings/clock/actions,s900-cmu.h

diff --git a/Documentation/devicetree/bindings/clock/actions,s900-cmu.txt 
b/Documentation/devicetree/bindings/clock/actions,s900-cmu.txt
new file mode 100644
index ..93e4fb827cd6
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/actions,s900-cmu.txt
@@ -0,0 +1,47 @@
+* Actions S900 Clock Management Unit (CMU)
+
+The Actions S900 clock management unit generates and supplies clock to various
+controllers within the SoC. The clock binding described here is applicable to
+S900 SoC.
+
+Required Properties:
+
+- compatible: should be "actions,s900-cmu"
+- reg: physical base address of the controller and length of memory mapped
+  region.
+- clocks: Reference to the parent clocks ("hosc", "losc")
+- #clock-cells: should be 1.
+
+Each clock is assigned an identifier, and client nodes can use this identifier
+to specify the clock which they consume.
+
+All available clocks are defined as preprocessor macros in
+dt-bindings/clock/actions,s900-cmu.h header and can be used in device
+tree sources.
+
+External clocks:
+
+The hosc clock used as input for the plls is generated outside the SoC. It is
+expected that it is defined using standard clock bindings as "hosc".
+
+Actions S900 CMU also requires one more clock:
+ - "losc" - internal low frequency oscillator
+
+Example: Clock Management Unit node:
+
+cmu: clock-controller@e016 {
+compatible = "actions,s900-cmu";
+reg = <0x0 0xe016 0x0 0x1000>;
+clocks = <>, <>;
+#clock-cells = <1>;
+};
+
+Example: UART controller node that consumes clock generated by the clock
+management unit:
+
+uart: serial@e012a000 {
+compatible = "actions,s900-uart", "actions,owl-uart";
+reg = <0x0 0xe012a000 0x0 0x2000>;
+interrupts = ;
+clocks = < CLK_UART5>;
+};
diff --git a/include/dt-bindings/clock/actions,s900-cmu.h 
b/include/dt-bindings/clock/actions,s900-cmu.h
new file mode 100644
index ..2fa94e19922b
--- /dev/null
+++ b/include/dt-bindings/clock/actions,s900-cmu.h
@@ -0,0 +1,139 @@
+/*
+ * Device Tree binding constants for Actions S900 Clock Management Unit
+ *
+ * Copyright (c) 2014 Actions Semi Inc.
+ * Copyright (c) 2017 Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __DT_BINDINGS_CLOCK_S900_CMU_H
+#define __DT_BINDINGS_CLOCK_S900_CMU_H
+
+#define CLK_NONE   0
+
+/* fixed rate clocks */
+#define CLK_LOSC   1
+#define CLK_HOSC   2
+
+/* pll clocks */
+#define CLK_CORE_PLL   3
+#define CLK_DEV_PLL4
+#define CLK_DDR_PLL5
+#define CLK_NAND_PLL   6
+#define CLK_DISPLAY_PLL7
+#define CLK_DSI_PLL8
+#define CLK_ASSIST_PLL 9
+#define CLK_AUDIO_PLL  10
+
+/* system clock */
+#define CLK_CPU15
+#define CLK_DEV16
+#define CLK_NOC17
+#define CLK_NOC_MUX18
+#define CLK_NOC_DIV19
+#define CLK_AHB20
+#define CLK_APB21
+#define CLK_DMAC   22
+
+/* peripheral device clock */
+#define CLK_GPIO   23
+
+#define CLK_BISP   24
+#define CLK_CSI0   25
+#define CLK_CSI1   26
+
+#define CLK_DE027
+#define CLK_DE128
+#define CLK_DE229
+#define CLK_DE330
+#define CLK_DSI32
+
+#define CLK_GPU33
+#define CLK_GPU_CORE   34
+#define CLK_GPU_MEM35
+#define CLK_GPU_SYS36
+
+#define CLK_HDE

[PATCH v3 04/11] clk: actions: Add common clock driver support

2018-02-09 Thread Manivannan Sadhasivam
Add support for Actions Semi common clock driver with generic structures
and interface functions.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/Kconfig  |  1 +
 drivers/clk/Makefile |  1 +
 drivers/clk/actions/Kconfig  |  4 ++
 drivers/clk/actions/Makefile |  3 ++
 drivers/clk/actions/owl-common.c | 84 
 drivers/clk/actions/owl-common.h | 40 +++
 6 files changed, 133 insertions(+)
 create mode 100644 drivers/clk/actions/Kconfig
 create mode 100644 drivers/clk/actions/Makefile
 create mode 100644 drivers/clk/actions/owl-common.c
 create mode 100644 drivers/clk/actions/owl-common.h

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 98ce9fc6e6c0..6313a4f4327a 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -238,6 +238,7 @@ config COMMON_CLK_VC5
  This driver supports the IDT VersaClock 5 and VersaClock 6
  programmable clock generators.
 
+source "drivers/clk/actions/Kconfig"
 source "drivers/clk/bcm/Kconfig"
 source "drivers/clk/hisilicon/Kconfig"
 source "drivers/clk/imgtec/Kconfig"
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 71ec41e6364f..554b67e4d0c6 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -56,6 +56,7 @@ obj-$(CONFIG_COMMON_CLK_WM831X)   += clk-wm831x.o
 obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o
 
 # please keep this section sorted lexicographically by directory path name
+obj-$(CONFIG_ARCH_ACTIONS) += actions/
 obj-$(CONFIG_COMMON_CLK_AT91)  += at91/
 obj-$(CONFIG_ARCH_ARTPEC)  += axis/
 obj-$(CONFIG_ARC_PLAT_AXS10X)  += axs10x/
diff --git a/drivers/clk/actions/Kconfig b/drivers/clk/actions/Kconfig
new file mode 100644
index ..13a3e5083d43
--- /dev/null
+++ b/drivers/clk/actions/Kconfig
@@ -0,0 +1,4 @@
+config CLK_ACTIONS
+   bool "Clock driver for Actions Semi SoCs"
+   depends on ARCH_ACTIONS || COMPILE_TEST
+   default ARCH_ACTIONS
diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
new file mode 100644
index ..64a50fc2d335
--- /dev/null
+++ b/drivers/clk/actions/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_CLK_ACTIONS)  += clk-owl.o
+
+clk-owl-y  += owl-common.o
diff --git a/drivers/clk/actions/owl-common.c b/drivers/clk/actions/owl-common.c
new file mode 100644
index ..a7cb698fdc86
--- /dev/null
+++ b/drivers/clk/actions/owl-common.c
@@ -0,0 +1,84 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL common clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+#include 
+
+#include "owl-common.h"
+
+static const struct regmap_config owl_regmap_config = {
+   .reg_bits   = 32,
+   .reg_stride = 4,
+   .val_bits   = 32,
+   .max_register   = 0x,
+   .fast_io= true,
+};
+
+static void owl_clk_set_regmap(const struct owl_clk_desc *desc,
+struct regmap *regmap)
+{
+   int i;
+   struct owl_clk_common *clks;
+
+   for (i = 0; i < desc->num_clks; i++) {
+   clks = desc->clks[i];
+   if (!clks)
+   continue;
+
+   clks->regmap = regmap;
+   }
+}
+
+int owl_clk_regmap_init(struct platform_device *pdev,
+const struct owl_clk_desc *desc)
+{
+   void __iomem *base;
+   struct device_node *node = pdev->dev.of_node;
+   struct regmap *regmap;
+
+   base = of_iomap(node, 0);
+   regmap = devm_regmap_init_mmio(>dev, base, _regmap_config);
+   if (IS_ERR_OR_NULL(regmap)) {
+   pr_err("failed to init regmap\n");
+   return PTR_ERR(regmap);
+   }
+
+   owl_clk_set_regmap(desc, regmap);
+
+   return 0;
+}
+
+int owl_clk_probe(struct device *dev, struct clk_hw_onecell_data *hw_clks)
+{
+   int i, ret;
+   struct clk_hw *hw;
+
+   for (i = 0; i < hw_clks->num; i++) {
+
+   hw = hw_clks->hws[i];
+
+   if (!hw)
+   continue;
+
+   ret = devm_clk_hw_register(dev, hw);
+   if (ret) {
+   dev_err(dev, "Couldn't register clock %d - %s\n",
+   i, hw->init->name);
+   return ret;
+   }
+   }
+
+   ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, hw_clks);
+   if (ret)
+   dev_err(dev, "Failed to add clock provider\n");
+
+   return ret;
+}
diff --git a/drivers/clk/actions/owl-common.h b/drivers/clk/actions/owl-common.h
new file mode 100644
index ..e7ea23a6c8f1
--- /dev/null
+++ b/drivers/clk/actions/owl-common.h
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL common clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// 

[PATCH v3 01/11] dt-bindings: clock: Add Actions S900 clock bindings

2018-02-09 Thread Manivannan Sadhasivam
Add Actions Semi S900 clock bindings.

Signed-off-by: Manivannan Sadhasivam 
Acked-by: Rob Herring 
---
 .../devicetree/bindings/clock/actions,s900-cmu.txt |  47 +++
 include/dt-bindings/clock/actions,s900-cmu.h   | 139 +
 2 files changed, 186 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/actions,s900-cmu.txt
 create mode 100644 include/dt-bindings/clock/actions,s900-cmu.h

diff --git a/Documentation/devicetree/bindings/clock/actions,s900-cmu.txt 
b/Documentation/devicetree/bindings/clock/actions,s900-cmu.txt
new file mode 100644
index ..93e4fb827cd6
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/actions,s900-cmu.txt
@@ -0,0 +1,47 @@
+* Actions S900 Clock Management Unit (CMU)
+
+The Actions S900 clock management unit generates and supplies clock to various
+controllers within the SoC. The clock binding described here is applicable to
+S900 SoC.
+
+Required Properties:
+
+- compatible: should be "actions,s900-cmu"
+- reg: physical base address of the controller and length of memory mapped
+  region.
+- clocks: Reference to the parent clocks ("hosc", "losc")
+- #clock-cells: should be 1.
+
+Each clock is assigned an identifier, and client nodes can use this identifier
+to specify the clock which they consume.
+
+All available clocks are defined as preprocessor macros in
+dt-bindings/clock/actions,s900-cmu.h header and can be used in device
+tree sources.
+
+External clocks:
+
+The hosc clock used as input for the plls is generated outside the SoC. It is
+expected that it is defined using standard clock bindings as "hosc".
+
+Actions S900 CMU also requires one more clock:
+ - "losc" - internal low frequency oscillator
+
+Example: Clock Management Unit node:
+
+cmu: clock-controller@e016 {
+compatible = "actions,s900-cmu";
+reg = <0x0 0xe016 0x0 0x1000>;
+clocks = <>, <>;
+#clock-cells = <1>;
+};
+
+Example: UART controller node that consumes clock generated by the clock
+management unit:
+
+uart: serial@e012a000 {
+compatible = "actions,s900-uart", "actions,owl-uart";
+reg = <0x0 0xe012a000 0x0 0x2000>;
+interrupts = ;
+clocks = < CLK_UART5>;
+};
diff --git a/include/dt-bindings/clock/actions,s900-cmu.h 
b/include/dt-bindings/clock/actions,s900-cmu.h
new file mode 100644
index ..2fa94e19922b
--- /dev/null
+++ b/include/dt-bindings/clock/actions,s900-cmu.h
@@ -0,0 +1,139 @@
+/*
+ * Device Tree binding constants for Actions S900 Clock Management Unit
+ *
+ * Copyright (c) 2014 Actions Semi Inc.
+ * Copyright (c) 2017 Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __DT_BINDINGS_CLOCK_S900_CMU_H
+#define __DT_BINDINGS_CLOCK_S900_CMU_H
+
+#define CLK_NONE   0
+
+/* fixed rate clocks */
+#define CLK_LOSC   1
+#define CLK_HOSC   2
+
+/* pll clocks */
+#define CLK_CORE_PLL   3
+#define CLK_DEV_PLL4
+#define CLK_DDR_PLL5
+#define CLK_NAND_PLL   6
+#define CLK_DISPLAY_PLL7
+#define CLK_DSI_PLL8
+#define CLK_ASSIST_PLL 9
+#define CLK_AUDIO_PLL  10
+
+/* system clock */
+#define CLK_CPU15
+#define CLK_DEV16
+#define CLK_NOC17
+#define CLK_NOC_MUX18
+#define CLK_NOC_DIV19
+#define CLK_AHB20
+#define CLK_APB21
+#define CLK_DMAC   22
+
+/* peripheral device clock */
+#define CLK_GPIO   23
+
+#define CLK_BISP   24
+#define CLK_CSI0   25
+#define CLK_CSI1   26
+
+#define CLK_DE027
+#define CLK_DE128
+#define CLK_DE229
+#define CLK_DE330
+#define CLK_DSI32
+
+#define CLK_GPU33
+#define CLK_GPU_CORE   34
+#define CLK_GPU_MEM35
+#define CLK_GPU_SYS36
+
+#define CLK_HDE37
+#define CLK_I2C0   38

[PATCH v3 05/11] clk: actions: Add gate clock support

2018-02-09 Thread Manivannan Sadhasivam
Add support for Actions Semi gate clock together with helper
functions to be used in composite clock.

Signed-off-by: Manivannan Sadhasivam 
---
 drivers/clk/actions/Makefile   |  1 +
 drivers/clk/actions/owl-gate.c | 77 ++
 drivers/clk/actions/owl-gate.h | 73 +++
 3 files changed, 151 insertions(+)
 create mode 100644 drivers/clk/actions/owl-gate.c
 create mode 100644 drivers/clk/actions/owl-gate.h

diff --git a/drivers/clk/actions/Makefile b/drivers/clk/actions/Makefile
index 64a50fc2d335..1f0917872c9d 100644
--- a/drivers/clk/actions/Makefile
+++ b/drivers/clk/actions/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_CLK_ACTIONS)  += clk-owl.o
 
 clk-owl-y  += owl-common.o
+clk-owl-y  += owl-gate.o
diff --git a/drivers/clk/actions/owl-gate.c b/drivers/clk/actions/owl-gate.c
new file mode 100644
index ..25dd94ac0f35
--- /dev/null
+++ b/drivers/clk/actions/owl-gate.c
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL gate clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#include 
+#include 
+
+#include "owl-gate.h"
+
+void clk_gate_set(const struct owl_clk_common *common,
+const struct owl_gate_hw *gate_hw, bool enable)
+{
+   int set = gate_hw->gate_flags & CLK_GATE_SET_TO_DISABLE ? 1 : 0;
+   u32 reg;
+
+   set ^= enable;
+
+   regmap_read(common->regmap, gate_hw->reg, );
+
+   if (set)
+   reg |= BIT(gate_hw->bit_idx);
+   else
+   reg &= ~BIT(gate_hw->bit_idx);
+
+   regmap_write(common->regmap, gate_hw->reg, reg);
+}
+
+static void owl_gate_disable(struct clk_hw *hw)
+{
+   struct owl_gate *gate = hw_to_owl_gate(hw);
+   struct owl_clk_common *common = >common;
+
+   clk_gate_set(common, >gate_hw, false);
+}
+
+static int owl_gate_enable(struct clk_hw *hw)
+{
+   struct owl_gate *gate = hw_to_owl_gate(hw);
+   struct owl_clk_common *common = >common;
+
+   clk_gate_set(common, >gate_hw, true);
+
+   return 0;
+}
+
+int clk_is_enabled(const struct owl_clk_common *common,
+  const struct owl_gate_hw *gate_hw)
+{
+   u32 reg;
+
+   regmap_read(common->regmap, gate_hw->reg, );
+
+   if (gate_hw->gate_flags & CLK_GATE_SET_TO_DISABLE)
+   reg ^= BIT(gate_hw->bit_idx);
+
+   return !!(reg & BIT(gate_hw->bit_idx));
+}
+
+static int owl_gate_is_enabled(struct clk_hw *hw)
+{
+   struct owl_gate *gate = hw_to_owl_gate(hw);
+   struct owl_clk_common *common = >common;
+
+   return clk_is_enabled(common, >gate_hw);
+}
+
+const struct clk_ops owl_gate_ops = {
+   .disable= owl_gate_disable,
+   .enable = owl_gate_enable,
+   .is_enabled = owl_gate_is_enabled,
+};
diff --git a/drivers/clk/actions/owl-gate.h b/drivers/clk/actions/owl-gate.h
new file mode 100644
index ..4fc609647ae4
--- /dev/null
+++ b/drivers/clk/actions/owl-gate.h
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// OWL gate clock driver
+//
+// Copyright (c) 2014 Actions Semi Inc.
+// Author: David Liu 
+//
+// Copyright (c) 2018 Linaro Ltd.
+// Author: Manivannan Sadhasivam 
+
+#ifndef _OWL_GATE_H_
+#define _OWL_GATE_H_
+
+#include "owl-common.h"
+
+struct owl_gate_hw {
+   u32 reg;
+   u8  bit_idx;
+   u8  gate_flags;
+};
+
+struct owl_gate {
+   struct owl_gate_hw  gate_hw;
+   struct owl_clk_common   common;
+};
+
+#define OWL_GATE_HW(_reg, _bit_idx, _gate_flags)   \
+   {   \
+   .reg= _reg, \
+   .bit_idx= _bit_idx, \
+   .gate_flags = _gate_flags,  \
+   }
+
+#define OWL_GATE(_struct, _name, _parent, _reg,
\
+   _bit_idx, _gate_flags, _flags)  \
+   struct owl_gate _struct = { \
+   .gate_hw = OWL_GATE_HW(_reg, _bit_idx, _gate_flags),\
+   .common = { \
+   .regmap = NULL, \
+   .hw.init= CLK_HW_INIT(_name,\
+ _parent,  \
+ _gate_ops,\
+ _flags),  \
+   }   \
+   }   \
+
+#define OWL_GATE_NO_PARENT(_struct, _name, _reg,   \
+   _bit_idx, _gate_flags, _flags)

[PATCH v3 03/11] arm64: dts: actions: Source CMU clock for UART5

2018-02-09 Thread Manivannan Sadhasivam
Remove fixed clock and source CMU (Clock Management Unit) clock for
UART5 driver in Actions Semi S900 SoC.

Signed-off-by: Manivannan Sadhasivam 
---
 arch/arm64/boot/dts/actions/s900-bubblegum-96.dts | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/arch/arm64/boot/dts/actions/s900-bubblegum-96.dts 
b/arch/arm64/boot/dts/actions/s900-bubblegum-96.dts
index 21ca80f9941c..ff043c961d75 100644
--- a/arch/arm64/boot/dts/actions/s900-bubblegum-96.dts
+++ b/arch/arm64/boot/dts/actions/s900-bubblegum-96.dts
@@ -24,12 +24,6 @@
device_type = "memory";
reg = <0x0 0x0 0x0 0x8000>;
};
-
-   uart5_clk: uart5-clk {
-   compatible = "fixed-clock";
-   clock-frequency = <921600>;
-   #clock-cells = <0>;
-   };
 };
 
  {
@@ -38,5 +32,5 @@
 
  {
status = "okay";
-   clocks = <_clk>;
+   clocks = < CLK_UART5>;
 };
-- 
2.14.1



[PATCH v3 03/11] arm64: dts: actions: Source CMU clock for UART5

2018-02-09 Thread Manivannan Sadhasivam
Remove fixed clock and source CMU (Clock Management Unit) clock for
UART5 driver in Actions Semi S900 SoC.

Signed-off-by: Manivannan Sadhasivam 
---
 arch/arm64/boot/dts/actions/s900-bubblegum-96.dts | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/arch/arm64/boot/dts/actions/s900-bubblegum-96.dts 
b/arch/arm64/boot/dts/actions/s900-bubblegum-96.dts
index 21ca80f9941c..ff043c961d75 100644
--- a/arch/arm64/boot/dts/actions/s900-bubblegum-96.dts
+++ b/arch/arm64/boot/dts/actions/s900-bubblegum-96.dts
@@ -24,12 +24,6 @@
device_type = "memory";
reg = <0x0 0x0 0x0 0x8000>;
};
-
-   uart5_clk: uart5-clk {
-   compatible = "fixed-clock";
-   clock-frequency = <921600>;
-   #clock-cells = <0>;
-   };
 };
 
  {
@@ -38,5 +32,5 @@
 
  {
status = "okay";
-   clocks = <_clk>;
+   clocks = < CLK_UART5>;
 };
-- 
2.14.1



Re: [PATCH V2 0/6]nvme-pci: fixes on nvme_timeout and nvme_dev_disable

2018-02-09 Thread jianchao.wang
Hi Keith

Thanks for your kindly response here.
That's really appreciated.

On 02/10/2018 01:12 AM, Keith Busch wrote:
> On Fri, Feb 09, 2018 at 09:50:58AM +0800, jianchao.wang wrote:
>>
>> if we set NVME_REQ_CANCELLED and return BLK_EH_HANDLED as the RESETTING case,
>> nvme_reset_work will hang forever, because no one could complete the entered 
>> requests.
> 
> Except it's no longer in the "RESETTING" case since you added the
> "CONNECTING" state, so that's already broken for other reasons...
> 

Yes, but as your patch, we have to fail the IOs and even kill the controller.
In fact, up to nvme_wait_freeze in nvme_reset_work, the RECONNECTING state has 
been completed.
We even could say it is in LIVE state. Maybe we should recover the controller 
again instead
of fail the IOs and kill the controller.

On the other hand, can you share with me why we cannot use blk_set_preempt_only 
to replace
blk_freeze_queue ? we just want to gate the new bios out of 
generic_make_request and we 
needn't use the preempt requests.

Looking forward your advice and directive.

Thanks
Jianchao


> ___
> Linux-nvme mailing list
> linux-n...@lists.infradead.org
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.infradead.org_mailman_listinfo_linux-2Dnvme=DwICAg=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE=7WdAxUBeiTUTCy8v-7zXyr4qk7sx26ATvfo6QSTvZyQ=UqKQMB3A2ppfm2sN7PyisX0xTtXKsHlTBwjsS18qVx8=A2VMSm9IjQQXxM7foB6VUiRHLs-nIREF2_kMstwxlgw=
> 


Re: [PATCH V2 0/6]nvme-pci: fixes on nvme_timeout and nvme_dev_disable

2018-02-09 Thread jianchao.wang
Hi Keith

Thanks for your kindly response here.
That's really appreciated.

On 02/10/2018 01:12 AM, Keith Busch wrote:
> On Fri, Feb 09, 2018 at 09:50:58AM +0800, jianchao.wang wrote:
>>
>> if we set NVME_REQ_CANCELLED and return BLK_EH_HANDLED as the RESETTING case,
>> nvme_reset_work will hang forever, because no one could complete the entered 
>> requests.
> 
> Except it's no longer in the "RESETTING" case since you added the
> "CONNECTING" state, so that's already broken for other reasons...
> 

Yes, but as your patch, we have to fail the IOs and even kill the controller.
In fact, up to nvme_wait_freeze in nvme_reset_work, the RECONNECTING state has 
been completed.
We even could say it is in LIVE state. Maybe we should recover the controller 
again instead
of fail the IOs and kill the controller.

On the other hand, can you share with me why we cannot use blk_set_preempt_only 
to replace
blk_freeze_queue ? we just want to gate the new bios out of 
generic_make_request and we 
needn't use the preempt requests.

Looking forward your advice and directive.

Thanks
Jianchao


> ___
> Linux-nvme mailing list
> linux-n...@lists.infradead.org
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.infradead.org_mailman_listinfo_linux-2Dnvme=DwICAg=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE=7WdAxUBeiTUTCy8v-7zXyr4qk7sx26ATvfo6QSTvZyQ=UqKQMB3A2ppfm2sN7PyisX0xTtXKsHlTBwjsS18qVx8=A2VMSm9IjQQXxM7foB6VUiRHLs-nIREF2_kMstwxlgw=
> 


[PATCH] f2fs: handle quota for orphan inodes

2018-02-09 Thread Jaegeuk Kim
This is to fix missing dquot_initialize for orphan inodes.

Signed-off-by: Jaegeuk Kim 
---
 fs/f2fs/checkpoint.c | 28 
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 8b0945ba284d..e3bf753a47be 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -569,13 +569,8 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, 
nid_t ino)
struct node_info ni;
int err = acquire_orphan_inode(sbi);
 
-   if (err) {
-   set_sbi_flag(sbi, SBI_NEED_FSCK);
-   f2fs_msg(sbi->sb, KERN_WARNING,
-   "%s: orphan failed (ino=%x), run fsck to fix.",
-   __func__, ino);
-   return err;
-   }
+   if (err)
+   goto err_out;
 
__add_ino_entry(sbi, ino, 0, ORPHAN_INO);
 
@@ -589,6 +584,11 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, 
nid_t ino)
return PTR_ERR(inode);
}
 
+   err = dquot_initialize(inode);
+   if (err)
+   goto err_out;
+
+   dquot_initialize(inode);
clear_nlink(inode);
 
/* truncate all the data during iput */
@@ -598,14 +598,18 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, 
nid_t ino)
 
/* ENOMEM was fully retried in f2fs_evict_inode. */
if (ni.blk_addr != NULL_ADDR) {
-   set_sbi_flag(sbi, SBI_NEED_FSCK);
-   f2fs_msg(sbi->sb, KERN_WARNING,
-   "%s: orphan failed (ino=%x) by kernel, retry mount.",
-   __func__, ino);
-   return -EIO;
+   err = -EIO;
+   goto err_out;
}
__remove_ino_entry(sbi, ino, ORPHAN_INO);
return 0;
+
+err_out:
+   set_sbi_flag(sbi, SBI_NEED_FSCK);
+   f2fs_msg(sbi->sb, KERN_WARNING,
+   "%s: orphan failed (ino=%x), run fsck to fix.",
+   __func__, ino);
+   return err;
 }
 
 int recover_orphan_inodes(struct f2fs_sb_info *sbi)
-- 
2.15.0.531.g2ccb3012c9-goog



[PATCH] f2fs: handle quota for orphan inodes

2018-02-09 Thread Jaegeuk Kim
This is to fix missing dquot_initialize for orphan inodes.

Signed-off-by: Jaegeuk Kim 
---
 fs/f2fs/checkpoint.c | 28 
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 8b0945ba284d..e3bf753a47be 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -569,13 +569,8 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, 
nid_t ino)
struct node_info ni;
int err = acquire_orphan_inode(sbi);
 
-   if (err) {
-   set_sbi_flag(sbi, SBI_NEED_FSCK);
-   f2fs_msg(sbi->sb, KERN_WARNING,
-   "%s: orphan failed (ino=%x), run fsck to fix.",
-   __func__, ino);
-   return err;
-   }
+   if (err)
+   goto err_out;
 
__add_ino_entry(sbi, ino, 0, ORPHAN_INO);
 
@@ -589,6 +584,11 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, 
nid_t ino)
return PTR_ERR(inode);
}
 
+   err = dquot_initialize(inode);
+   if (err)
+   goto err_out;
+
+   dquot_initialize(inode);
clear_nlink(inode);
 
/* truncate all the data during iput */
@@ -598,14 +598,18 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, 
nid_t ino)
 
/* ENOMEM was fully retried in f2fs_evict_inode. */
if (ni.blk_addr != NULL_ADDR) {
-   set_sbi_flag(sbi, SBI_NEED_FSCK);
-   f2fs_msg(sbi->sb, KERN_WARNING,
-   "%s: orphan failed (ino=%x) by kernel, retry mount.",
-   __func__, ino);
-   return -EIO;
+   err = -EIO;
+   goto err_out;
}
__remove_ino_entry(sbi, ino, ORPHAN_INO);
return 0;
+
+err_out:
+   set_sbi_flag(sbi, SBI_NEED_FSCK);
+   f2fs_msg(sbi->sb, KERN_WARNING,
+   "%s: orphan failed (ino=%x), run fsck to fix.",
+   __func__, ino);
+   return err;
 }
 
 int recover_orphan_inodes(struct f2fs_sb_info *sbi)
-- 
2.15.0.531.g2ccb3012c9-goog



  1   2   3   4   5   6   7   8   9   10   >