[PATCH 05/22] docs: ipmb: place it at driver-api and convert to ReST

2019-07-22 Thread Mauro Carvalho Chehab
No new doc should be added at the main Documentation/ directory.

Instead, new docs should be added as ReST files, within the
Kernel documentation body.

Fixes: 51bd6f291583 ("Add support for IPMB driver")
Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/driver-api/index.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/driver-api/index.rst 
b/Documentation/driver-api/index.rst
index 37ac052ded85..38e638abe3eb 100644
--- a/Documentation/driver-api/index.rst
+++ b/Documentation/driver-api/index.rst
@@ -76,6 +76,7 @@ available subsections can be seen below.
dell_rbu
edid
eisa
+   ipmb
isa
isapnp
generic-counter
-- 
2.21.0



[PATCH 20/22] docs: net: convert two README files to ReST format

2019-07-22 Thread Mauro Carvalho Chehab
There are two README files there with doesn't have a .txt
extension nor are at ReST format.

In order to help with the docs conversion to ReST, rename those
and manually convert them to ReST format.

As there are lot more to be done for networking to be part of
the documentation body, for now mark those two files with
:orphan:, in order to supress a build warning.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../networking/caif/{README => caif.rst}  | 88 +--
 .../{README => mac80211_hwsim.rst}| 28 --
 MAINTAINERS   |  2 +-
 3 files changed, 81 insertions(+), 37 deletions(-)
 rename Documentation/networking/caif/{README => caif.rst} (70%)
 rename Documentation/networking/mac80211_hwsim/{README => mac80211_hwsim.rst} 
(81%)

diff --git a/Documentation/networking/caif/README 
b/Documentation/networking/caif/caif.rst
similarity index 70%
rename from Documentation/networking/caif/README
rename to Documentation/networking/caif/caif.rst
index 757ccfaa1385..07afc8063d4d 100644
--- a/Documentation/networking/caif/README
+++ b/Documentation/networking/caif/caif.rst
@@ -1,18 +1,31 @@
-Copyright (C) ST-Ericsson AB 2010
-Author: Sjur Brendeland/ sjur.brandel...@stericsson.com
-License terms: GNU General Public License (GPL) version 2
--
+:orphan:
 
-=== Start ===
-If you have compiled CAIF for modules do:
+.. SPDX-License-Identifier: GPL-2.0
+.. include:: 
 
-$modprobe crc_ccitt
-$modprobe caif
-$modprobe caif_socket
-$modprobe chnl_net
 
+
+Using Linux CAIF
+
 
-=== Preparing the setup with a STE modem ===
+
+:Copyright: |copy| ST-Ericsson AB 2010
+
+:Author: Sjur Brendeland/ sjur.brandel...@stericsson.com
+
+Start
+=
+
+If you have compiled CAIF for modules do::
+
+$modprobe crc_ccitt
+$modprobe caif
+$modprobe caif_socket
+$modprobe chnl_net
+
+
+Preparing the setup with a STE modem
+
 
 If you are working on integration of CAIF you should make sure
 that the kernel is built with module support.
@@ -32,24 +45,30 @@ module parameter "ser_use_stx".
 Normally Frame Checksum is always used on UART, but this is also provided as a
 module parameter "ser_use_fcs".
 
-$ modprobe caif_serial ser_ttyname=/dev/ttyS0 ser_use_stx=yes
-$ ifconfig caif_ttyS0 up
+::
 
-PLEASE NOTE:   There is a limitation in Android shell.
+$ modprobe caif_serial ser_ttyname=/dev/ttyS0 ser_use_stx=yes
+$ ifconfig caif_ttyS0 up
+
+PLEASE NOTE:
+   There is a limitation in Android shell.
It only accepts one argument to insmod/modprobe!
 
-=== Trouble shooting ===
+Trouble shooting
+
 
 There are debugfs parameters provided for serial communication.
 /sys/kernel/debug/caif_serial//
 
 * ser_state:   Prints the bit-mask status where
+
   - 0x02 means SENDING, this is a transient state.
   - 0x10 means FLOW_OFF_SENT, i.e. the previous frame has not been sent
-   and is blocking further send operation. Flow OFF has been propagated
-   to all CAIF Channels using this TTY.
+and is blocking further send operation. Flow OFF has been propagated
+to all CAIF Channels using this TTY.
 
 * tty_status: Prints the bit-mask tty status information
+
   - 0x01 - tty->warned is on.
   - 0x02 - tty->low_latency is on.
   - 0x04 - tty->packed is on.
@@ -58,13 +77,17 @@ There are debugfs parameters provided for serial 
communication.
   - 0x20 - tty->stopped is on.
 
 * last_tx_msg: Binary blob Prints the last transmitted frame.
-   This can be printed with
+
+  This can be printed with::
+
$od --format=x1 /sys/kernel/debug/caif_serial//last_rx_msg.
-   The first two tx messages sent look like this. Note: The initial
-   byte 02 is start of frame extension (STX) used for re-syncing
-   upon errors.
 
-  - Enumeration:
+  The first two tx messages sent look like this. Note: The initial
+  byte 02 is start of frame extension (STX) used for re-syncing
+  upon errors.
+
+  - Enumeration::
+
 000  02 05 00 00 03 01 d2 02
  |  | |  |  |  |
  STX(1)   |  |  |  |
@@ -73,7 +96,9 @@ There are debugfs parameters provided for serial 
communication.
  Command:Enumeration(1)
 Link-ID(1)
 Checksum(2)
-  - Channel Setup:
+
+  - Channel Setup::
+
 000  02 07 00 00 00 21 a1 00 48 df
  |  | |  |  |  |  |  |
  STX(1)   |  |  |  |  |  |
@@ -86,13 +111,18 @@ There are debugfs parameters provided for serial 
communication.
  Checksum(2)
 
 * last_rx_msg: Prints the last transmitted frame.
-   The RX messages for LinkSetup look almost identical but they have the
-   bit 0x20 set in the command bit, and Channel Setup has added one byte
-   before Checksum con

[PATCH 03/22] docs: w1: convert to ReST and add to the kAPI group of docs

2019-07-22 Thread Mauro Carvalho Chehab
The 1wire documentation was written with w1 developers in
mind, so, it makes sense to add it together with the driver-api
set.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/ABI/stable/sysfs-bus-w1 |  2 +-
 .../ABI/stable/sysfs-driver-w1_ds28e04|  4 +-
 .../ABI/stable/sysfs-driver-w1_ds28ea00   |  2 +-
 Documentation/index.rst   |  1 +
 Documentation/w1/index.rst| 21 +
 .../w1/masters/{ds2482 => ds2482.rst} | 16 +++-
 .../w1/masters/{ds2490 => ds2490.rst} |  6 +-
 Documentation/w1/masters/index.rst| 14 +++
 Documentation/w1/masters/mxc-w1   | 12 ---
 Documentation/w1/masters/mxc-w1.rst   | 17 
 .../w1/masters/{omap-hdq => omap-hdq.rst} | 12 +--
 .../w1/masters/{w1-gpio => w1-gpio.rst}   | 21 +++--
 Documentation/w1/slaves/index.rst | 16 
 .../w1/slaves/{w1_ds2406 => w1_ds2406.rst}|  4 +-
 .../w1/slaves/{w1_ds2413 => w1_ds2413.rst}|  9 ++
 Documentation/w1/slaves/w1_ds2423 | 47 --
 Documentation/w1/slaves/w1_ds2423.rst | 54 +++
 .../w1/slaves/{w1_ds2438 => w1_ds2438.rst}| 10 ++-
 .../w1/slaves/{w1_ds28e04 => w1_ds28e04.rst}  |  5 ++
 .../w1/slaves/{w1_ds28e17 => w1_ds28e17.rst}  | 16 ++--
 .../w1/slaves/{w1_therm => w1_therm.rst}  | 11 ++-
 .../w1/{w1.generic => w1-generic.rst} | 88 ++
 .../w1/{w1.netlink => w1-netlink.rst} | 89 +++
 23 files changed, 308 insertions(+), 169 deletions(-)
 create mode 100644 Documentation/w1/index.rst
 rename Documentation/w1/masters/{ds2482 => ds2482.rst} (71%)
 rename Documentation/w1/masters/{ds2490 => ds2490.rst} (98%)
 create mode 100644 Documentation/w1/masters/index.rst
 delete mode 100644 Documentation/w1/masters/mxc-w1
 create mode 100644 Documentation/w1/masters/mxc-w1.rst
 rename Documentation/w1/masters/{omap-hdq => omap-hdq.rst} (90%)
 rename Documentation/w1/masters/{w1-gpio => w1-gpio.rst} (75%)
 create mode 100644 Documentation/w1/slaves/index.rst
 rename Documentation/w1/slaves/{w1_ds2406 => w1_ds2406.rst} (96%)
 rename Documentation/w1/slaves/{w1_ds2413 => w1_ds2413.rst} (81%)
 delete mode 100644 Documentation/w1/slaves/w1_ds2423
 create mode 100644 Documentation/w1/slaves/w1_ds2423.rst
 rename Documentation/w1/slaves/{w1_ds2438 => w1_ds2438.rst} (93%)
 rename Documentation/w1/slaves/{w1_ds28e04 => w1_ds28e04.rst} (93%)
 rename Documentation/w1/slaves/{w1_ds28e17 => w1_ds28e17.rst} (88%)
 rename Documentation/w1/slaves/{w1_therm => w1_therm.rst} (95%)
 rename Documentation/w1/{w1.generic => w1-generic.rst} (59%)
 rename Documentation/w1/{w1.netlink => w1-netlink.rst} (77%)

diff --git a/Documentation/ABI/stable/sysfs-bus-w1 
b/Documentation/ABI/stable/sysfs-bus-w1
index 140d85b4ae92..992dfb183ed0 100644
--- a/Documentation/ABI/stable/sysfs-bus-w1
+++ b/Documentation/ABI/stable/sysfs-bus-w1
@@ -6,6 +6,6 @@ Description:Bus scanning interval, microseconds component.
control systems are attached/generate presence for as short as
100 ms - hence the tens-to-hundreds milliseconds scan intervals
are required.
-   see Documentation/w1/w1.generic for detailed information.
+   see Documentation/w1/w1-generic.rst for detailed information.
 Users: any user space application which wants to know bus scanning
interval
diff --git a/Documentation/ABI/stable/sysfs-driver-w1_ds28e04 
b/Documentation/ABI/stable/sysfs-driver-w1_ds28e04
index 26579ee868c9..3e1c1fa8d54d 100644
--- a/Documentation/ABI/stable/sysfs-driver-w1_ds28e04
+++ b/Documentation/ABI/stable/sysfs-driver-w1_ds28e04
@@ -2,7 +2,7 @@ What:   /sys/bus/w1/devices/.../pio
 Date:  May 2012
 Contact:   Markus Franke 
 Description:   read/write the contents of the two PIO's of the DS28E04-100
-   see Documentation/w1/slaves/w1_ds28e04 for detailed information
+   see Documentation/w1/slaves/w1_ds28e04.rst for detailed 
information
 Users: any user space application which wants to communicate with 
DS28E04-100
 
 
@@ -11,5 +11,5 @@ What: /sys/bus/w1/devices/.../eeprom
 Date:  May 2012
 Contact:   Markus Franke 
 Description:   read/write the contents of the EEPROM memory of the DS28E04-100
-   see Documentation/w1/slaves/w1_ds28e04 for detailed information
+   see Documentation/w1/slaves/w1_ds28e04.rst for detailed 
information
 Users: any user space application which wants to communicate with 
DS28E04-100
diff --git a/Documentation/ABI/stable/sysfs-driver-w1_ds28ea00 
b/Documentation/ABI/stable/sysfs-driver-w1_ds28ea00
index e928def14f28..534e63731a49 100644
--- a/Documentation/ABI/stable/sysfs-driver-w1_ds28ea00
+++ b/Documentation/ABI/stable/sysfs-driver-w1_ds28ea00
@@ -2,5 +2,5 @@ What:   /sys/bus/w1/devices/.../w1_seq
 Date:  Apr 2015
 Contact:   Matt

[PATCH 17/22] docs: mips: add to the documentation body as ReST

2019-07-22 Thread Mauro Carvalho Chehab
Manually convert the AU1xxx_IDE.README file to ReST and add
to a MIPS book as part of the main documentation body.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/index.rst   |  1 +
 .../{AU1xxx_IDE.README => au1xxx_ide.rst} | 89 +++
 Documentation/mips/index.rst  | 17 
 3 files changed, 70 insertions(+), 37 deletions(-)
 rename Documentation/mips/{AU1xxx_IDE.README => au1xxx_ide.rst} (67%)
 create mode 100644 Documentation/mips/index.rst

diff --git a/Documentation/index.rst b/Documentation/index.rst
index c0132ad9c4d9..09d24878ad14 100644
--- a/Documentation/index.rst
+++ b/Documentation/index.rst
@@ -150,6 +150,7 @@ implementation.
ia64/index
m68k/index
powerpc/index
+   mips/index
openrisc/index
parisc/index
riscv/index
diff --git a/Documentation/mips/AU1xxx_IDE.README 
b/Documentation/mips/au1xxx_ide.rst
similarity index 67%
rename from Documentation/mips/AU1xxx_IDE.README
rename to Documentation/mips/au1xxx_ide.rst
index ff675a1b1422..2f9c2cff6738 100644
--- a/Documentation/mips/AU1xxx_IDE.README
+++ b/Documentation/mips/au1xxx_ide.rst
@@ -1,7 +1,14 @@
-README for MIPS AU1XXX IDE driver - Released 2005-07-15
+.. include:: 
+
+==
+MIPS AU1XXX IDE driver
+==
+
+Released 2005-07-15
+
+About
+=
 
-ABOUT
--
 This file describes the 'drivers/ide/au1xxx-ide.c', related files and the
 services they provide.
 
@@ -10,17 +17,17 @@ the white or black list, go to the 'ADD NEW HARD DISC TO 
WHITE OR BLACK LIST'
 section.
 
 
-LICENSE

+License
+===
 
-Copyright (c) 2003-2005 AMD, Personal Connectivity Solutions
+:Copyright: |copy| 2003-2005 AMD, Personal Connectivity Solutions
 
 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+THIS SOFTWARE IS PROVIDED ``AS IS`` AND ANY EXPRESS OR IMPLIED WARRANTIES,
 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
@@ -35,31 +42,35 @@ You should have received a copy of the GNU General Public 
License along with
 this program; if not, write to the Free Software Foundation, Inc.,
 675 Mass Ave, Cambridge, MA 02139, USA.
 
-Note: for more information, please refer "AMD Alchemy Au1200/Au1550 IDE
+Note:
+  for more information, please refer "AMD Alchemy Au1200/Au1550 IDE
   Interface and Linux Device Driver" Application Note.
 
 
-FILES, CONFIGS AND COMPATIBILITY
-
+Files, Configs and Compatibility
+
 
 Two files are introduced:
 
   a) 'arch/mips/include/asm/mach-au1x00/au1xxx_ide.h'
  contains : struct _auide_hwif
- timing parameters for PIO mode 0/1/2/3/4
- timing parameters for MWDMA 0/1/2
+
+- timing parameters for PIO mode 0/1/2/3/4
+- timing parameters for MWDMA 0/1/2
 
   b) 'drivers/ide/mips/au1xxx-ide.c'
  contains the functionality of the AU1XXX IDE driver
 
 Following extra configs variables are introduced:
 
-  CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA- enable the PIO+DBDMA mode
-  CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA  - enable the MWDMA mode
+  CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
+   - enable the PIO+DBDMA mode
+  CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
+   - enable the MWDMA mode
 
 
-SUPPORTED IDE MODES

+Supported IDE Modes
+===
 
 The AU1XXX IDE driver supported all PIO modes - PIO mode 0/1/2/3/4 - and all
 MWDMA modes - MWDMA 0/1/2 -. There is no support for SWDMA and UDMA mode.
@@ -69,20 +80,21 @@ To change the PIO mode use the program hdparm with option 
-p, e.g.
 -X, e.g. 'hdparm -X32 [device]' for MWDMA mode 0.
 
 
-PERFORMANCE CONFIGURATIONS
---
+Performance Configurations
+==
 
-If the used system doesn't need USB support enable the following kernel 
configs:
+If the used system doesn't need USB support enable the following kernel
+configs::
 
-CONFIG_IDE=y
-CONFIG_BLK_DEV_IDE=y
-CONFIG_IDE_GENERIC=y
-CONFIG_BLK_DEV_IDEPCI=y
-CONFIG_BLK_DEV_GENERIC=y
-CONFIG_BLK_DEV_IDEDMA_PCI=y
-CONFIG_BLK_DEV_IDE_AU1XXX=y
-CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA=y
-CONFIG_BLK_DEV_IDEDMA=y
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+CONFIG_IDE_GENERIC=y
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_BLK_DEV_GENERIC=y
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+CONFIG_BLK_DEV_IDE_AU1XXX=y
+CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA=y
+CONFIG_BLK_DEV_IDEDMA=y
 
 Also define 'IDE_AU1XXX_BURSTMODE' in 'drivers/ide/mips/au1xxx-ide.c' to enable
 the burst support

[PATCH 09/22] docs: parisc: convert to ReST and add to documentation body

2019-07-22 Thread Mauro Carvalho Chehab
Manually convert the two PA-RISC documents to ReST, adding them
to the Linux documentation body.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/index.rst   |  1 +
 .../parisc/{debugging => debugging.rst}   |  7 +++
 Documentation/parisc/index.rst| 18 ++
 .../parisc/{registers => registers.rst}   | 59 +--
 4 files changed, 68 insertions(+), 17 deletions(-)
 rename Documentation/parisc/{debugging => debugging.rst} (94%)
 create mode 100644 Documentation/parisc/index.rst
 rename Documentation/parisc/{registers => registers.rst} (70%)

diff --git a/Documentation/index.rst b/Documentation/index.rst
index ef9543c2516d..9bb08d272bd5 100644
--- a/Documentation/index.rst
+++ b/Documentation/index.rst
@@ -149,6 +149,7 @@ implementation.
ia64/index
m68k/index
powerpc/index
+   parisc/index
riscv/index
s390/index
sh/index
diff --git a/Documentation/parisc/debugging b/Documentation/parisc/debugging.rst
similarity index 94%
rename from Documentation/parisc/debugging
rename to Documentation/parisc/debugging.rst
index 7d75223fa18d..de1b60402c5b 100644
--- a/Documentation/parisc/debugging
+++ b/Documentation/parisc/debugging.rst
@@ -1,8 +1,13 @@
+=
+PA-RISC Debugging
+=
+
 okay, here are some hints for debugging the lower-level parts of
 linux/parisc.
 
 
 1. Absolute addresses
+=
 
 A lot of the assembly code currently runs in real mode, which means
 absolute addresses are used instead of virtual addresses as in the
@@ -12,6 +17,7 @@ currently).
 
 
 2. HPMCs
+
 
 When real-mode code tries to access non-existent memory, you'll get
 an HPMC instead of a kernel oops.  To debug an HPMC, try to find
@@ -27,6 +33,7 @@ access it.
 
 
 3. Q bit fun
+
 
 Certain, very critical code has to clear the Q bit in the PSW.  What
 happens when the Q bit is cleared is the CPU does not update the
diff --git a/Documentation/parisc/index.rst b/Documentation/parisc/index.rst
new file mode 100644
index ..aa3ee0470425
--- /dev/null
+++ b/Documentation/parisc/index.rst
@@ -0,0 +1,18 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+
+PA-RISC Architecture
+
+
+.. toctree::
+   :maxdepth: 2
+
+   debugging
+   registers
+
+.. only::  subproject and html
+
+   Indices
+   ===
+
+   * :ref:`genindex`
diff --git a/Documentation/parisc/registers b/Documentation/parisc/registers.rst
similarity index 70%
rename from Documentation/parisc/registers
rename to Documentation/parisc/registers.rst
index 10c7d1730f5d..59c8ecf3e856 100644
--- a/Documentation/parisc/registers
+++ b/Documentation/parisc/registers.rst
@@ -1,11 +1,16 @@
+
 Register Usage for Linux/PA-RISC
+
 
 [ an asterisk is used for planned usage which is currently unimplemented ]
 
-   General Registers as specified by ABI
+General Registers as specified by ABI
+=
 
-   Control Registers
+Control Registers
+-
 
+===
===
 CR 0 (Recovery Counter)used for ptrace
 CR 1-CR 7(undefined)   unused
 CR 8 (Protection ID)   per-process value*
@@ -29,26 +34,35 @@ CR28 (TR 4) not used
 CR29 (TR 5)not used
 CR30 (TR 6)current / 0
 CR31 (TR 7)Temporary register, used in various places
+===
===
 
-   Space Registers (kernel mode)
+Space Registers (kernel mode)
+-
 
+===
===
 SR0temporary space register
 SR4-SR7set to 0
 SR1temporary space register
 SR2kernel should not clobber this
 SR3used for userspace accesses (current process)
+===
===
 
-   Space Registers (user mode)
+Space Registers (user mode)
+---
 
+===
===
 SR0temporary space register
 SR1 temporary space register
 SR2 holds space of linux gateway page
 SR3 holds user address space value while in kernel
 SR4-SR7 Defines short address space for user/kernel
+===
===
 
 
-   Processor Status Word
+Processor Status Word
+-
 
+===
==

[PATCH 00/22] ReST conversion of text files without .txt extension

2019-07-22 Thread Mauro Carvalho Chehab
This series converts the text files under Documentation with doesn't end
neither .txt or .rst and are not part of ABI or features[1].

This series is at:
https://git.linuxtv.org/mchehab/experimental.git/log/?h=rst_for_5_4_v2.1

And comes after the pending patches I had for v5.13 (some not applied
yet):

https://git.linuxtv.org/mchehab/experimental.git/log/?h=pending_docs_after_5.13-rc1

[1] I submitted already a series to handle ABI and features.
There are some files besides the ones there with, IMHO, it
doesn't make sense to convert.

So, I wrote a small ugly script to track the files waiting to be
converted:

  #!/bin/bash

  find Documentation/ -name '*.txt'|grep -vE 
'(features/|devicetree/|sphinx/|output/|dax-hv-api.txt|draft-ietf-cipso-ipsecurity-01.txt|translations)'
  for i in $(find Documentation/ -type f|grep -v translations/|grep -v 
output/|grep -v devicetree|grep -v -E 
"\.(rst|txt|py|pyc|pl|dot|conf|svg|sh|awk|gif|S|inf|c|csv|css|vim|exceptions|modes)$"|grep
 -v ABI/ |grep -v Documentation/EDID/hex|grep -v dontdiff|grep -v Kconfig|grep 
-v Makefile|grep -v Module.symvers|grep -vE 
'\b(CodingStyle|SubmittingPatches|target-export-device|hotplug-script|wusb-cbaf)\b'|grep
 -v -E 
'(LICENSE|COPY|gitignore|Makefile|AUTHORS|TODO|CHANGES|CREDITS|ChangeLog)'|grep 
-v Documentation/virtual/kvm/devices/README); do echo $i; done

After this patch series, the script reports 358 files missing conversion, all 
ending with .txt.

>From those, ~40 files are already at ReST format - the ones at 
>Documentation/*.txt - except
for a couple of files there.

So, there's around 320 files left to be converted after this series,
with gives me hope that we may finally finish the conversion this
year. Let's see.

Mauro Carvalho Chehab (22):
  docs: convert markdown documents to ReST
  docs: i2c: convert to ReST and add to driver-api bookset
  docs: w1: convert to ReST and add to the kAPI group of docs
  docs: spi: convert to ReST and add it to the kABI bookset
  docs: ipmb: place it at driver-api and convert to ReST
  docs: packing: move it to core-api book and adjust markups
  docs: admin-guide: add auxdisplay files to it after conversion to ReST
  docs: README.buddha: convert to ReST and add to m68k book
  docs: parisc: convert to ReST and add to documentation body
  docs: openrisc: convert to ReST and add to documentation body
  docs: isdn: convert to ReST and add to kAPI bookset
  docs: fs: cifs: convert to ReST and add to admin-guide book
  docs: fs: convert docs without extension to ReST
  docs: fs: convert porting to ReST
  docs: index.rst: don't use genindex for pdf output
  docs: wimax: convert to ReST and add to admin-guide
  docs: mips: add to the documentation body as ReST
  docs: hwmon: pxe1610: convert to ReST format and add to the index
  docs: nios2: add it to the main Documentation body
  docs: net: convert two README files to ReST format
  docs: rcu: convert some articles from html to ReST
  docs: ABI: remove extension from sysfs-class-mic.txt

 Documentation/ABI/stable/sysfs-bus-w1 |2 +-
 .../ABI/stable/sysfs-driver-w1_ds28e04|4 +-
 .../ABI/stable/sysfs-driver-w1_ds28ea00   |2 +-
 .../{sysfs-class-mic.txt => sysfs-class-mic}  |0
 .../Data-Structures/Data-Structures.html  | 1391 ---
 .../Data-Structures/Data-Structures.rst   | 1163 ++
 .../Expedited-Grace-Periods.html  |  668 
 .../Expedited-Grace-Periods.rst   |  521 +++
 .../Memory-Ordering/Tree-RCU-Diagram.html |9 -
 .../Tree-RCU-Memory-Ordering.html |  704 
 .../Tree-RCU-Memory-Ordering.rst  |  625 
 .../RCU/Design/Requirements/Requirements.html | 3330 -
 .../RCU/Design/Requirements/Requirements.rst  | 2662 +
 Documentation/RCU/index.rst   |5 +
 Documentation/RCU/whatisRCU.txt   |4 +-
 .../admin-guide/auxdisplay/cfag12864b.rst |   98 +
 .../admin-guide/auxdisplay/index.rst  |   16 +
 .../admin-guide/auxdisplay/ks0108.rst |   50 +
 .../AUTHORS => admin-guide/cifs/authors.rst}  |   64 +-
 .../CHANGES => admin-guide/cifs/changes.rst}  |4 +
 Documentation/admin-guide/cifs/index.rst  |   21 +
 .../cifs/introduction.rst}|8 +
 .../cifs/TODO => admin-guide/cifs/todo.rst}   |   87 +-
 .../README => admin-guide/cifs/usage.rst} |  560 +--
 .../cifs/winucase_convert.pl  |0
 Documentation/admin-guide/index.rst   |3 +
 .../wimax/i2400m.rst} |  145 +-
 Documentation/admin-guide/wimax/index.rst |   19 +
 .../wimax/wimax.rst}  |   36 +-
 Documentation/auxdisplay/cfag12864b   |  105 -
 Documentation/auxdisplay/ks0108   |   55 -
 Documentation/core-api/index.rst  |3 +-
 .../{packing.txt => core-api/packing.rst} |   81 +-
 .../devicetree/bindings/i2c/i2c-mux-gpmux.txt |2 +-
 Documentation/d

[PATCH 04/22] docs: spi: convert to ReST and add it to the kABI bookset

2019-07-22 Thread Mauro Carvalho Chehab
While there's one file there with briefily describes the uAPI,
the documentation was written just like most subsystems: focused
on kernel developers. So, add it together with driver-api books.

Signed-off-by: Mauro Carvalho Chehab 
Acked-by: Jonathan Cameron  # for iio
---
 Documentation/index.rst   |   1 +
 .../spi/{butterfly => butterfly.rst}  |  44 
 Documentation/spi/index.rst   |  22 
 Documentation/spi/{pxa2xx => pxa2xx.rst}  |  95 
 .../spi/{spi-lm70llp => spi-lm70llp.rst}  |  17 ++-
 .../spi/{spi-sc18is602 => spi-sc18is602.rst}  |   3 +
 .../spi/{spi-summary => spi-summary.rst}  | 105 ++
 Documentation/spi/{spidev => spidev.rst}  |  30 +++--
 drivers/iio/dummy/iio_simple_dummy.c  |   2 +-
 drivers/spi/Kconfig   |   2 +-
 drivers/spi/spi-butterfly.c   |   2 +-
 drivers/spi/spi-lm70llp.c |   2 +-
 include/linux/platform_data/sc18is602.h   |   2 +-
 13 files changed, 198 insertions(+), 129 deletions(-)
 rename Documentation/spi/{butterfly => butterfly.rst} (71%)
 create mode 100644 Documentation/spi/index.rst
 rename Documentation/spi/{pxa2xx => pxa2xx.rst} (83%)
 rename Documentation/spi/{spi-lm70llp => spi-lm70llp.rst} (88%)
 rename Documentation/spi/{spi-sc18is602 => spi-sc18is602.rst} (97%)
 rename Documentation/spi/{spi-summary => spi-summary.rst} (93%)
 rename Documentation/spi/{spidev => spidev.rst} (90%)

diff --git a/Documentation/index.rst b/Documentation/index.rst
index 8730c7455265..ef9543c2516d 100644
--- a/Documentation/index.rst
+++ b/Documentation/index.rst
@@ -115,6 +115,7 @@ needed).
power/index
target/index
timers/index
+   spi/index
w1/index
watchdog/index
virtual/index
diff --git a/Documentation/spi/butterfly b/Documentation/spi/butterfly.rst
similarity index 71%
rename from Documentation/spi/butterfly
rename to Documentation/spi/butterfly.rst
index 9927af7a629c..e614a589547c 100644
--- a/Documentation/spi/butterfly
+++ b/Documentation/spi/butterfly.rst
@@ -1,3 +1,4 @@
+===
 spi_butterfly - parport-to-butterfly adapter driver
 ===
 
@@ -27,25 +28,29 @@ need to reflash the firmware, and the pins are the standard 
Atmel "ISP"
 connector pins (used also on non-Butterfly AVR boards).  On the parport
 side this is like "sp12" programming cables.
 
+   ===   ===
SignalButterfly   Parport (DB-25)
-   ---   ---
-   SCK = J403.PB1/SCK  = pin 2/D0
-   RESET   = J403.nRST = pin 3/D1
-   VCC = J403.VCC_EXT  = pin 8/D6
-   MOSI= J403.PB2/MOSI = pin 9/D7
-   MISO= J403.PB3/MISO = pin 11/S7,nBUSY
-   GND = J403.GND  = pin 23/GND
+   ===   ===
+   SCK   J403.PB1/SCKpin 2/D0
+   RESET J403.nRST   pin 3/D1
+   VCC   J403.VCC_EXTpin 8/D6
+   MOSI  J403.PB2/MOSI   pin 9/D7
+   MISO  J403.PB3/MISO   pin 11/S7,nBUSY
+   GND   J403.GNDpin 23/GND
+   ===   ===
 
 Then to let Linux master that bus to talk to the DataFlash chip, you must
 (a) flash new firmware that disables SPI (set PRR.2, and disable pullups
 by clearing PORTB.[0-3]); (b) configure the mtd_dataflash driver; and
 (c) cable in the chipselect.
 
+   =====
SignalButterfly   Parport (DB-25)
-   ---   ---
-   VCC = J400.VCC_EXT  = pin 7/D5
-   SELECT  = J400.PB0/nSS  = pin 17/C3,nSELECT
-   GND = J400.GND  = pin 24/GND
+   =====
+   VCC   J400.VCC_EXTpin 7/D5
+   SELECTJ400.PB0/nSSpin 17/C3,nSELECT
+   GND   J400.GNDpin 24/GND
+   =====
 
 Or you could flash firmware making the AVR into an SPI slave (keeping the
 DataFlash in reset) and tweak the spi_butterfly driver to make it bind to
@@ -56,13 +61,14 @@ That would let you talk to the AVR using custom 
SPI-with-USI firmware,
 while letting either Linux or the AVR use the DataFlash.  There are plenty
 of spare parport pins to wire this one up, such as:
 
+   ===   ===
SignalButterfly   Parport (DB-25)
-   ---   ---
-   SCK = J403.PE4/USCK = pin 5/D3
-   MOSI= J403.PE5/DI   = pin 6/D4
-   MISO= J403.PE6/DO   = pin 12/S5,nPAPEROUT
-   GND = J403.GND  = pin 22/GND
-
-   IRQ = J402.PF4  = pin 10/S6,ACK
-   GND = J402.GND(P2)  = pin 25/GND
+   ===   ===
+   SCK   J403.PE4/USCK   pin 5/D

[PATCH 10/22] docs: openrisc: convert to ReST and add to documentation body

2019-07-22 Thread Mauro Carvalho Chehab
Manually convert the two openRisc documents to ReST, adding them
to the Linux documentation body.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/index.rst   |  1 +
 Documentation/openrisc/index.rst  | 18 +
 .../openrisc/{README => openrisc_port.rst}| 25 +--
 Documentation/openrisc/{TODO => todo.rst} |  9 ---
 4 files changed, 43 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/openrisc/index.rst
 rename Documentation/openrisc/{README => openrisc_port.rst} (80%)
 rename Documentation/openrisc/{TODO => todo.rst} (78%)

diff --git a/Documentation/index.rst b/Documentation/index.rst
index 9bb08d272bd5..5583b2e64692 100644
--- a/Documentation/index.rst
+++ b/Documentation/index.rst
@@ -149,6 +149,7 @@ implementation.
ia64/index
m68k/index
powerpc/index
+   openrisc/index
parisc/index
riscv/index
s390/index
diff --git a/Documentation/openrisc/index.rst b/Documentation/openrisc/index.rst
new file mode 100644
index ..748b3eea1707
--- /dev/null
+++ b/Documentation/openrisc/index.rst
@@ -0,0 +1,18 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+=
+OpenRISC Architecture
+=
+
+.. toctree::
+   :maxdepth: 2
+
+   openrisc_port
+   todo
+
+.. only::  subproject and html
+
+   Indices
+   ===
+
+   * :ref:`genindex`
diff --git a/Documentation/openrisc/README 
b/Documentation/openrisc/openrisc_port.rst
similarity index 80%
rename from Documentation/openrisc/README
rename to Documentation/openrisc/openrisc_port.rst
index 777a893d533d..a18747a8d191 100644
--- a/Documentation/openrisc/README
+++ b/Documentation/openrisc/openrisc_port.rst
@@ -1,3 +1,4 @@
+==
 OpenRISC Linux
 ==
 
@@ -6,8 +7,10 @@ target architecture, specifically, is the 32-bit OpenRISC 1000 
family (or1k).
 
 For information about OpenRISC processors and ongoing development:
 
+   === =
website http://openrisc.io
email   openr...@lists.librecores.org
+   === =
 
 -
 
@@ -24,13 +27,15 @@ Toolchain binaries can be obtained from openrisc.io or our 
github releases page.
 Instructions for building the different toolchains can be found on openrisc.io
 or Stafford's toolchain build and release scripts.
 
+   ==  =
binarieshttps://github.com/openrisc/or1k-gcc/releases
toolchains  https://openrisc.io/software
buildinghttps://github.com/stffrdhrn/or1k-toolchain-build
+   ==  =
 
 2) Building
 
-Build the Linux kernel as usual
+Build the Linux kernel as usual::
 
make ARCH=openrisc defconfig
make ARCH=openrisc
@@ -43,6 +48,8 @@ development board with the OpenRISC SoC.  During the build 
FPGA RTL is code
 downloaded from the FuseSoC IP cores repository and built using the FPGA vendor
 tools.  Binaries are loaded onto the board with openocd.
 
+::
+
git clone https://github.com/olofk/fusesoc
cd fusesoc
sudo pip install -e .
@@ -65,7 +72,9 @@ platform.  Please follow the OpenRISC instructions on the 
QEMU website to get
 Linux running on QEMU.  You can build QEMU yourself, but your Linux 
distribution
 likely provides binary packages to support OpenRISC.
 
+   =   ==
qemu openrisc   https://wiki.qemu.org/Documentation/Platforms/OpenRISC
+   =   ==
 
 -
 
@@ -75,36 +84,38 @@ Terminology
 In the code, the following particles are used on symbols to limit the scope
 to more or less specific processor implementations:
 
+= ===
 openrisc: the OpenRISC class of processors
 or1k: the OpenRISC 1000 family of processors
 or1200:   the OpenRISC 1200 processor
+= ===
 
 -
 
 History
 
 
-18. 11. 2003   Matjaz Breskvar (phoe...@bsemi.com)
+18-11-2003 Matjaz Breskvar (phoe...@bsemi.com)
initial port of linux to OpenRISC/or32 architecture.
 all the core stuff is implemented and seams usable.
 
-08. 12. 2003   Matjaz Breskvar (phoe...@bsemi.com)
+08-12-2003 Matjaz Breskvar (phoe...@bsemi.com)
complete change of TLB miss handling.
rewrite of exceptions handling.
fully functional sash-3.6 in default initrd.
a much improved version with changes all around.
 
-10. 04. 2004   Matjaz Breskvar (phoe...@bsemi.com)
+10-04-2004 Matjaz Breskvar (phoe...@bsemi.com)
alot of

[PATCH 16/22] docs: wimax: convert to ReST and add to admin-guide

2019-07-22 Thread Mauro Carvalho Chehab
Manually convert wimax documentation to ReST and add theit
to the Kernel doc body, inside the admin-guide.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/admin-guide/index.rst   |   1 +
 .../wimax/i2400m.rst} | 145 ++
 Documentation/admin-guide/wimax/index.rst |  19 +++
 .../wimax/wimax.rst}  |  36 +++--
 MAINTAINERS   |   4 +-
 5 files changed, 128 insertions(+), 77 deletions(-)
 rename Documentation/{wimax/README.i2400m => admin-guide/wimax/i2400m.rst} 
(69%)
 create mode 100644 Documentation/admin-guide/wimax/index.rst
 rename Documentation/{wimax/README.wimax => admin-guide/wimax/wimax.rst} (74%)

diff --git a/Documentation/admin-guide/index.rst 
b/Documentation/admin-guide/index.rst
index 4a9de9806eaf..6bd211832bd7 100644
--- a/Documentation/admin-guide/index.rst
+++ b/Documentation/admin-guide/index.rst
@@ -110,6 +110,7 @@ configure specific aspects of kernel behavior to your 
liking.
pnp
rtc
svga
+   wimax/index
video-output
 
 .. only::  subproject and html
diff --git a/Documentation/wimax/README.i2400m 
b/Documentation/admin-guide/wimax/i2400m.rst
similarity index 69%
rename from Documentation/wimax/README.i2400m
rename to Documentation/admin-guide/wimax/i2400m.rst
index 7dffd8919cb0..194388c0c351 100644
--- a/Documentation/wimax/README.i2400m
+++ b/Documentation/admin-guide/wimax/i2400m.rst
@@ -1,18 +1,23 @@
+.. include:: 
 
-   Driver for the Intel Wireless Wimax Connection 2400m
+
+Driver for the Intel Wireless Wimax Connection 2400m
+
 
-   (C) 2008 Intel Corporation < linux-wi...@intel.com >
+:Copyright: |copy| 2008 Intel Corporation < linux-wi...@intel.com >
 
This provides a driver for the Intel Wireless WiMAX Connection 2400m
and a basic Linux kernel WiMAX stack.
 
 1. Requirements
+===
 
  * Linux installation with Linux kernel 2.6.22 or newer (if building
from a separate tree)
  * Intel i2400m Echo Peak or Baxter Peak; this includes the Intel
Wireless WiMAX/WiFi Link 5x50 series.
  * build tools:
+
   + Linux kernel development package for the target kernel; to
 build against your currently running kernel, you need to have
 the kernel development package corresponding to the running
@@ -22,8 +27,10 @@
   + GNU C Compiler, make
 
 2. Compilation and installation
+===
 
 2.1. Compilation of the drivers included in the kernel
+--
 
Configure the kernel; to enable the WiMAX drivers select Drivers >
Networking Drivers > WiMAX device support. Enable all of them as
@@ -36,37 +43,39 @@
Compile and install your kernel as usual.
 
 2.2. Compilation of the drivers distributed as an standalone module
+---
 
-   To compile
+   To compile::
 
-$ cd source/directory
-$ make
+   $ cd source/directory
+   $ make
 
Once built you can load and unload using the provided load.sh script;
load.sh will load the modules, load.sh u will unload them.
 
To install in the default kernel directories (and enable auto loading
-   when the device is plugged):
+   when the device is plugged)::
 
-$ make install
-$ depmod -a
+   $ make install
+   $ depmod -a
 
If your kernel development files are located in a non standard
directory or if you want to build for a kernel that is not the
-   currently running one, set KDIR to the right location:
+   currently running one, set KDIR to the right location::
 
-$ make KDIR=/path/to/kernel/dev/tree
+   $ make KDIR=/path/to/kernel/dev/tree
 
For more information, please contact linux-wi...@intel.com.
 
 3. Installing the firmware
+--
 
The firmware can be obtained from http://linuxwimax.org or might have
been supplied with your hardware.
 
-   It has to be installed in the target system:
- *
-$ cp FIRMWAREFILE.sbcf /lib/firmware/i2400m-fw-BUSTYPE-1.3.sbcf
+   It has to be installed in the target system::
+
+   $ cp FIRMWAREFILE.sbcf /lib/firmware/i2400m-fw-BUSTYPE-1.3.sbcf
 
  * NOTE: if your firmware came in an .rpm or .deb file, just install
it as normal, with the rpm (rpm -i FIRMWARE.rpm) or dpkg
@@ -76,6 +85,7 @@ $ cp FIRMWAREFILE.sbcf 
/lib/firmware/i2400m-fw-BUSTYPE-1.3.sbcf
with other types.
 
 4. Design
+=
 
This package contains two major parts: a WiMAX kernel stack and a
driver for the Intel i2400m.
@@ -102,16 +112,17 @@ $ cp FIRMWAREFILE.sbcf 
/lib/firmware/i2400m-fw-BUSTYPE-1.3.sbcf
API calls should be replaced with the target OS's.
 
 5. Usage
+
 
To load the driver, follow the instructions in the install section;
once the driver is loaded, plug in the devi

[PATCH 01/22] docs: convert markdown documents to ReST

2019-07-22 Thread Mauro Carvalho Chehab
The documentation standard is ReST and not markdown.

Signed-off-by: Mauro Carvalho Chehab 
Acked-by: Rob Herring 
---
 Documentation/devicetree/writing-schema.md| 130 ---
 Documentation/devicetree/writing-schema.rst   | 153 ++
 ...entication.md => ubifs-authentication.rst} |  70 +---
 3 files changed, 197 insertions(+), 156 deletions(-)
 delete mode 100644 Documentation/devicetree/writing-schema.md
 create mode 100644 Documentation/devicetree/writing-schema.rst
 rename Documentation/filesystems/{ubifs-authentication.md => 
ubifs-authentication.rst} (95%)

diff --git a/Documentation/devicetree/writing-schema.md 
b/Documentation/devicetree/writing-schema.md
deleted file mode 100644
index dc032db36262..
--- a/Documentation/devicetree/writing-schema.md
+++ /dev/null
@@ -1,130 +0,0 @@
-# Writing DeviceTree Bindings in json-schema
-
-Devicetree bindings are written using json-schema vocabulary. Schema files are
-written in a JSON compatible subset of YAML. YAML is used instead of JSON as it
-considered more human readable and has some advantages such as allowing
-comments (Prefixed with '#').
-
-## Schema Contents
-
-Each schema doc is a structured json-schema which is defined by a set of
-top-level properties. Generally, there is one binding defined per file. The
-top-level json-schema properties used are:
-
-- __$id__ - A json-schema unique identifier string. The string must be a valid
-URI typically containing the binding's filename and path. For DT schema, it 
must
-begin with "http://devicetree.org/schemas/";. The URL is used in constructing
-references to other files specified in schema "$ref" properties. A $ref values
-with a leading '/' will have the hostname prepended. A $ref value a relative
-path or filename only will be prepended with the hostname and path components
-of the current schema file's '$id' value. A URL is used even for local files,
-but there may not actually be files present at those locations.
-
-- __$schema__ - Indicates the meta-schema the schema file adheres to.
-
-- __title__ - A one line description on the contents of the binding schema.
-
-- __maintainers__ - A DT specific property. Contains a list of email 
address(es)
-for maintainers of this binding.
-
-- __description__ - Optional. A multi-line text block containing any detailed
-information about this binding. It should contain things such as what the block
-or device does, standards the device conforms to, and links to datasheets for
-more information.
-
-- __select__ - Optional. A json-schema used to match nodes for applying the
-schema. By default without 'select', nodes are matched against their possible
-compatible string values or node name. Most bindings should not need select.
-
-- __allOf__ - Optional. A list of other schemas to include. This is used to
-include other schemas the binding conforms to. This may be schemas for a
-particular class of devices such as I2C or SPI controllers.
-
-- __properties__ - A set of sub-schema defining all the DT properties for the
-binding. The exact schema syntax depends on whether properties are known,
-common properties (e.g. 'interrupts') or are binding/vendor specific 
properties.
-
-  A property can also define a child DT node with child properties defined
-under it.
-
-  For more details on properties sections, see 'Property Schema' section.
-
-- __patternProperties__ - Optional. Similar to 'properties', but names are 
regex.
-
-- __required__ - A list of DT properties from the 'properties' section that
-must always be present.
-
-- __examples__ - Optional. A list of one or more DTS hunks implementing the
-binding. Note: YAML doesn't allow leading tabs, so spaces must be used instead.
-
-Unless noted otherwise, all properties are required.
-
-## Property Schema
-
-The 'properties' section of the schema contains all the DT properties for a
-binding. Each property contains a set of constraints using json-schema
-vocabulary for that property. The properties schemas are what is used for
-validation of DT files.
-
-For common properties, only additional constraints not covered by the common
-binding schema need to be defined such as how many values are valid or what
-possible values are valid.
-
-Vendor specific properties will typically need more detailed schema. With the
-exception of boolean properties, they should have a reference to a type in
-schemas/types.yaml. A "description" property is always required.
-
-The Devicetree schemas don't exactly match the YAML encoded DT data produced by
-dtc. They are simplified to make them more compact and avoid a bunch of
-boilerplate. The tools process the schema files to produce the final schema for
-validation. There are currently 2 transformations the tools perform.
-
-The default for arrays in json-schema is they are variable sized and allow more
-entries than explicitly defined. This can be restricted by defining 'minItems',
-'maxItems', and 'additionalItems'. However, for DeviceTre

[PATCH 18/22] docs: hwmon: pxe1610: convert to ReST format and add to the index

2019-07-22 Thread Mauro Carvalho Chehab
This document was recently introduced. Convert it to ReST
just like the other hwmon documents, adding it to the hwmon index.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/hwmon/index.rst|  1 +
 Documentation/hwmon/{pxe1610 => pxe1610.rst} | 33 +++-
 2 files changed, 26 insertions(+), 8 deletions(-)
 rename Documentation/hwmon/{pxe1610 => pxe1610.rst} (82%)

diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
index ee090e51653a..4d5f5fec43a3 100644
--- a/Documentation/hwmon/index.rst
+++ b/Documentation/hwmon/index.rst
@@ -130,6 +130,7 @@ Hardware Monitoring Kernel Drivers
pcf8591
pmbus
powr1220
+   pxe1610
pwm-fan
raspberrypi-hwmon
sch5627
diff --git a/Documentation/hwmon/pxe1610 b/Documentation/hwmon/pxe1610.rst
similarity index 82%
rename from Documentation/hwmon/pxe1610
rename to Documentation/hwmon/pxe1610.rst
index 211cedeefb44..4f2388840d06 100644
--- a/Documentation/hwmon/pxe1610
+++ b/Documentation/hwmon/pxe1610.rst
@@ -2,19 +2,29 @@ Kernel driver pxe1610
 =
 
 Supported chips:
+
   * Infineon PXE1610
+
 Prefix: 'pxe1610'
+
 Addresses scanned: -
+
 Datasheet: Datasheet is not publicly available.
 
   * Infineon PXE1110
+
 Prefix: 'pxe1110'
+
 Addresses scanned: -
+
 Datasheet: Datasheet is not publicly available.
 
   * Infineon PXM1310
+
 Prefix: 'pxm1310'
+
 Addresses scanned: -
+
 Datasheet: Datasheet is not publicly available.
 
 Author: Vijay Khemka 
@@ -25,14 +35,19 @@ Description
 
 PXE1610/PXE1110 are Multi-rail/Multiphase Digital Controllers
 and compliant to
-   -- Intel VR13 DC-DC converter specifications.
-   -- Intel SVID protocol.
+
+   - Intel VR13 DC-DC converter specifications.
+   - Intel SVID protocol.
+
 Used for Vcore power regulation for Intel VR13 based microprocessors
-   -- Servers, Workstations, and High-end desktops
+
+   - Servers, Workstations, and High-end desktops
 
 PXM1310 is a Multi-rail Controller and it is compliant to
-   -- Intel VR13 DC-DC converter specifications.
-   -- Intel SVID protocol.
+
+   - Intel VR13 DC-DC converter specifications.
+   - Intel SVID protocol.
+
 Used for DDR3/DDR4 Memory power regulation for Intel VR13 and
 IMVP8 based systems
 
@@ -44,10 +59,10 @@ This driver does not probe for PMBus devices. You will have
 to instantiate devices explicitly.
 
 Example: the following commands will load the driver for an PXE1610
-at address 0x70 on I2C bus #4:
+at address 0x70 on I2C bus #4::
 
-# modprobe pxe1610
-# echo pxe1610 0x70 > /sys/bus/i2c/devices/i2c-4/new_device
+# modprobe pxe1610
+# echo pxe1610 0x70 > /sys/bus/i2c/devices/i2c-4/new_device
 
 It can also be instantiated by declaring in device tree
 
@@ -55,6 +70,7 @@ It can also be instantiated by declaring in device tree
 Sysfs attributes
 
 
+==  
 curr1_label"iin"
 curr1_inputMeasured input current
 curr1_alarmCurrent high alarm
@@ -88,3 +104,4 @@ temp[1-3]_crit   Critical high temperature
 temp[1-3]_crit_alarm   Chip temperature critical high alarm
 temp[1-3]_max  Maximum temperature
 temp[1-3]_max_alarmChip temperature high alarm
+==  
-- 
2.21.0



[PATCH 07/22] docs: admin-guide: add auxdisplay files to it after conversion to ReST

2019-07-22 Thread Mauro Carvalho Chehab
Those two files describe userspace-faced information. While part of
it might fit on uAPI, it sounds to me that the admin guide is the
best place for them.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../admin-guide/auxdisplay/cfag12864b.rst |  98 
 .../admin-guide/auxdisplay/index.rst  |  16 +++
 .../admin-guide/auxdisplay/ks0108.rst |  50 +
 Documentation/admin-guide/index.rst   |   1 +
 Documentation/auxdisplay/cfag12864b   | 105 --
 Documentation/auxdisplay/ks0108   |  55 -
 MAINTAINERS   |   2 +-
 drivers/auxdisplay/Kconfig|   2 +-
 8 files changed, 167 insertions(+), 162 deletions(-)
 create mode 100644 Documentation/admin-guide/auxdisplay/cfag12864b.rst
 create mode 100644 Documentation/admin-guide/auxdisplay/index.rst
 create mode 100644 Documentation/admin-guide/auxdisplay/ks0108.rst
 delete mode 100644 Documentation/auxdisplay/cfag12864b
 delete mode 100644 Documentation/auxdisplay/ks0108

diff --git a/Documentation/admin-guide/auxdisplay/cfag12864b.rst 
b/Documentation/admin-guide/auxdisplay/cfag12864b.rst
new file mode 100644
index ..18c2865bd322
--- /dev/null
+++ b/Documentation/admin-guide/auxdisplay/cfag12864b.rst
@@ -0,0 +1,98 @@
+===
+cfag12864b LCD Driver Documentation
+===
+
+:License:  GPLv2
+:Author & Maintainer:  Miguel Ojeda Sandonis
+:Date: 2006-10-27
+
+
+
+.. INDEX
+
+   1. DRIVER INFORMATION
+   2. DEVICE INFORMATION
+   3. WIRING
+   4. USERSPACE PROGRAMMING
+
+1. Driver Information
+-
+
+This driver supports a cfag12864b LCD.
+
+
+2. Device Information
+-
+
+:Manufacturer: Crystalfontz
+:Device Name:  Crystalfontz 12864b LCD Series
+:Device Code:  cfag12864b
+:Webpage:  http://www.crystalfontz.com
+:Device Webpage: http://www.crystalfontz.com/products/12864b/
+:Type: LCD (Liquid Crystal Display)
+:Width:128
+:Height:   64
+:Colors:   2 (B/N)
+:Controller:   ks0108
+:Controllers:  2
+:Pages:8 each controller
+:Addresses:64 each page
+:Data size:1 byte each address
+:Memory size:  2 * 8 * 64 * 1 = 1024 bytes = 1 Kbyte
+
+
+3. Wiring
+-
+
+The cfag12864b LCD Series don't have official wiring.
+
+The common wiring is done to the parallel port as shown::
+
+  Parallel Port  cfag12864b
+
+Name Pin#Pin# Name
+
+  Strobe ( 1)--(17) Enable
+  Data 0 ( 2)--( 4) Data 0
+  Data 1 ( 3)--( 5) Data 1
+  Data 2 ( 4)--( 6) Data 2
+  Data 3 ( 5)--( 7) Data 3
+  Data 4 ( 6)--( 8) Data 4
+  Data 5 ( 7)--( 9) Data 5
+  Data 6 ( 8)--(10) Data 6
+  Data 7 ( 9)--(11) Data 7
+ (10)  [+5v]---( 1) Vdd
+ (11)  [GND]---( 2) Ground
+ (12)  [+5v]---(14) Reset
+ (13)  [GND]---(15) Read / Write
+Line (14)--(13) Controller Select 1
+ (15)
+Init (16)--(12) Controller Select 2
+  Select (17)--(16) Data / Instruction
+  Ground (18)---[GND]  [+5v]---(19) LED +
+  Ground (19)---[GND]
+  Ground (20)---[GND]  EA Values:
+  Ground (21)---[GND]   [GND]---[P1]---(18) Vee- R = Resistor = 22 ohm
+  Ground (22)---[GND]| - P1 = Preset = 10 Kohm
+  Ground (23)---[GND]      S --( 3) V0 - P2 = Preset = 1 Kohm
+  Ground (24)---[GND]   |  |
+  Ground (25)---[GND] [GND]---[P2]---[R]---(20) LED -
+
+
+4. Userspace Programming
+
+
+The cfag12864bfb describes a framebuffer device (/dev/fbX).
+
+It has a size of 1024 bytes = 1 Kbyte.
+Each bit represents one pixel. If the bit is high, the pixel will
+turn on. If the pixel is low, the pixel will turn off.
+
+You can use the framebuffer as a file: fopen, fwrite, fclose...
+Although the LCD won't get updated until the next refresh time arrives.
+
+Also, you can mmap the framebuffer: open & mmap, munmap & close...
+which is the best option for most uses.
+
+Check samples/auxdisplay/cfag12864b-example.c
+for a real working userspace complete program with usage examples.
diff --git a/Documentation/admin-guide/auxdisplay/index.rst 
b/Documentation/admin-guide/auxdisplay/index.rst
new file mode 100644
index ..e466f0595248
--- /dev/null
+++ b/Documentation/admin-guide/auxdisplay/index.rst
@@ -0,0 +1,16 @@
+=
+Auxiliary Display Support
+===

[PATCH 13/22] docs: fs: convert docs without extension to ReST

2019-07-22 Thread Mauro Carvalho Chehab
There are 3 remaining files without an extension inside the fs docs
dir.

Manually convert them to ReST.

In the case of the nfs/exporting.rst file, as the nfs docs
aren't ported yet, I opted to convert and add a :orphan: there,
with should be removed when it gets added into a nfs-specific
part of the fs documentation.

Signed-off-by: Mauro Carvalho Chehab 
---
 ...irectory-locking => directory-locking.rst} |  40 ++-
 Documentation/filesystems/index.rst   |   2 +
 .../filesystems/{Locking => locking.rst}  | 257 --
 .../nfs/{Exporting => exporting.rst}  |  31 ++-
 Documentation/filesystems/vfs.rst |   2 +-
 fs/cifs/export.c  |   2 +-
 fs/exportfs/expfs.c   |   2 +-
 fs/isofs/export.c |   2 +-
 fs/orangefs/file.c|   2 +-
 include/linux/dcache.h|   2 +-
 include/linux/exportfs.h  |   2 +-
 11 files changed, 225 insertions(+), 119 deletions(-)
 rename Documentation/filesystems/{directory-locking => directory-locking.rst} 
(86%)
 rename Documentation/filesystems/{Locking => locking.rst} (79%)
 rename Documentation/filesystems/nfs/{Exporting => exporting.rst} (91%)

diff --git a/Documentation/filesystems/directory-locking 
b/Documentation/filesystems/directory-locking.rst
similarity index 86%
rename from Documentation/filesystems/directory-locking
rename to Documentation/filesystems/directory-locking.rst
index 4e32cb961e5b..de12016ee419 100644
--- a/Documentation/filesystems/directory-locking
+++ b/Documentation/filesystems/directory-locking.rst
@@ -1,12 +1,17 @@
-   Locking scheme used for directory operations is based on two
+=
+Directory Locking
+=
+
+
+Locking scheme used for directory operations is based on two
 kinds of locks - per-inode (->i_rwsem) and per-filesystem
 (->s_vfs_rename_mutex).
 
-   When taking the i_rwsem on multiple non-directory objects, we
+When taking the i_rwsem on multiple non-directory objects, we
 always acquire the locks in order by increasing address.  We'll call
 that "inode pointer" order in the following.
 
-   For our purposes all operations fall in 5 classes:
+For our purposes all operations fall in 5 classes:
 
 1) read access.  Locking rules: caller locks directory we are accessing.
 The lock is taken shared.
@@ -27,25 +32,29 @@ NB: we might get away with locking the the source (and 
target in exchange
 case) shared.
 
 5) link creation.  Locking rules:
+
* lock parent
* check that source is not a directory
* lock source
* call the method.
+
 All locks are exclusive.
 
 6) cross-directory rename.  The trickiest in the whole bunch.  Locking
 rules:
+
* lock the filesystem
* lock parents in "ancestors first" order.
* find source and target.
* if old parent is equal to or is a descendent of target
-   fail with -ENOTEMPTY
+ fail with -ENOTEMPTY
* if new parent is equal to or is a descendent of source
-   fail with -ELOOP
+ fail with -ELOOP
* If it's an exchange, lock both the source and the target.
* If the target exists, lock it.  If the source is a non-directory,
  lock it.  If we need to lock both, do so in inode pointer order.
* call the method.
+
 All ->i_rwsem are taken exclusive.  Again, we might get away with locking
 the the source (and target in exchange case) shared.
 
@@ -54,10 +63,11 @@ read, modified or removed by method will be locked by 
caller.
 
 
 If no directory is its own ancestor, the scheme above is deadlock-free.
+
 Proof:
 
First of all, at any moment we have a partial ordering of the
-objects - A < B iff A is an ancestor of B.
+   objects - A < B iff A is an ancestor of B.
 
That ordering can change.  However, the following is true:
 
@@ -77,32 +87,32 @@ objects - A < B iff A is an ancestor of B.
 non-directory object, except renames, which take locks on source and
 target in inode pointer order in the case they are not directories.)
 
-   Now consider the minimal deadlock.  Each process is blocked on
+Now consider the minimal deadlock.  Each process is blocked on
 attempt to acquire some lock and already holds at least one lock.  Let's
 consider the set of contended locks.  First of all, filesystem lock is
 not contended, since any process blocked on it is not holding any locks.
 Thus all processes are blocked on ->i_rwsem.
 
-   By (3), any process holding a non-directory lock can only be
+By (3), any process holding a non-directory lock can only be
 waiting on another non-directory lock with a larger address.  Therefore
 the process holding the "largest" such lock can always make progress, and
 non-directory objects are not included in the set of contended locks.
 
-   Thus link creation can't be a part of deadlock - it can't b

[PATCH 06/22] docs: packing: move it to core-api book and adjust markups

2019-07-22 Thread Mauro Carvalho Chehab
The packing.txt file was misplaced, as docs should be part of
a documentation book, and not at the root dir.

So, move it to the core-api directory and add to its index.

Also, ensure that the file will be properly parsed and the bitmap
ascii artwork will use a monotonic font.

Fixes: 554aae35007e ("lib: Add support for generic packing operations")
Signed-off-by: Mauro Carvalho Chehab 
Reviewed-by: Vladimir Oltean 
Tested-by: Vladimir Oltean 
Reviewed-by: Mike Rapoport 
---
 Documentation/core-api/index.rst  |  1 +
 .../{packing.txt => core-api/packing.rst} | 81 +++
 MAINTAINERS   |  2 +-
 3 files changed, 51 insertions(+), 33 deletions(-)
 rename Documentation/{packing.txt => core-api/packing.rst} (61%)

diff --git a/Documentation/core-api/index.rst b/Documentation/core-api/index.rst
index da0ed972d224..dfd8fad1e1ec 100644
--- a/Documentation/core-api/index.rst
+++ b/Documentation/core-api/index.rst
@@ -25,6 +25,7 @@ Core utilities
librs
genalloc
errseq
+   packing
printk-formats
circular-buffers
generic-radix-tree
diff --git a/Documentation/packing.txt b/Documentation/core-api/packing.rst
similarity index 61%
rename from Documentation/packing.txt
rename to Documentation/core-api/packing.rst
index f830c98645f1..d8c341fe383e 100644
--- a/Documentation/packing.txt
+++ b/Documentation/core-api/packing.rst
@@ -30,6 +30,7 @@ The solution
 
 
 This API deals with 2 basic operations:
+
   - Packing a CPU-usable number into a memory buffer (with hardware
 constraints/quirks)
   - Unpacking a memory buffer (which has hardware constraints/quirks)
@@ -49,10 +50,12 @@ What the examples show is where the logical bytes and bits 
sit.
 
 1. Normally (no quirks), we would do it like this:
 
-63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 
37 36 35 34 33 32
-7   6   54
-31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  
5  4  3  2  1  0
-3   2   10
+::
+
+  63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 
38 37 36 35 34 33 32
+  7   6   54
+  31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  
6  5  4  3  2  1  0
+  3   2   10
 
 That is, the MSByte (7) of the CPU-usable u64 sits at memory offset 0, and the
 LSByte (0) of the u64 sits at memory offset 7.
@@ -63,10 +66,12 @@ comments as "logical" notation.
 
 2. If QUIRK_MSB_ON_THE_RIGHT is set, we do it like this:
 
-56 57 58 59 60 61 62 63 48 49 50 51 52 53 54 55 40 41 42 43 44 45 46 47 32 33 
34 35 36 37 38 39
-7   65   4
-24 25 26 27 28 29 30 31 16 17 18 19 20 21 22 23  8  9 10 11 12 13 14 15  0  1  
2  3  4  5  6  7
-3   21   0
+::
+
+  56 57 58 59 60 61 62 63 48 49 50 51 52 53 54 55 40 41 42 43 44 45 46 47 32 
33 34 35 36 37 38 39
+  7   65   4
+  24 25 26 27 28 29 30 31 16 17 18 19 20 21 22 23  8  9 10 11 12 13 14 15  0  
1  2  3  4  5  6  7
+  3   21   0
 
 That is, QUIRK_MSB_ON_THE_RIGHT does not affect byte positioning, but
 inverts bit offsets inside a byte.
@@ -74,10 +79,12 @@ inverts bit offsets inside a byte.
 
 3. If QUIRK_LITTLE_ENDIAN is set, we do it like this:
 
-39 38 37 36 35 34 33 32 47 46 45 44 43 42 41 40 55 54 53 52 51 50 49 48 63 62 
61 60 59 58 57 56
-4   5   6   7
-7  6  5  4  3  2  1  0  15 14 13 12 11 10  9  8 23 22 21 20 19 18 17 16 31 30 
29 28 27 26 25 24
-0   1   2   3
+::
+
+  39 38 37 36 35 34 33 32 47 46 45 44 43 42 41 40 55 54 53 52 51 50 49 48 63 
62 61 60 59 58 57 56
+  4   5   6   7
+  7  6  5  4  3  2  1  0  15 14 13 12 11 10  9  8 23 22 21 20 19 18 17 16 31 
30 29 28 27 26 25 24
+  0   1   2   3
 
 Therefore, QUIRK_LITTLE_ENDIAN means that inside the memory region, every
 byte from each 4-byte word is placed at its mirrored position compared to
@@ -86,18 +93,22 @@ the boundary of that word.
 4. If QUIRK_MSB_ON_THE_RIGHT and QUIRK_LITTLE_ENDIAN are both set, we do it
like this:
 
-32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 
58 59 60 61 62 63
-4   5   6   7
-0  1  2  3  4  5  6  7  8   9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
26 27 28 29 30 31
-0   1   

[PATCH 19/22] docs: nios2: add it to the main Documentation body

2019-07-22 Thread Mauro Carvalho Chehab
Rename and add the nios2 documentation to the documentation
body.

The nios2 document is already on an ReST compatible format.
All it needs is that the title of the document to be promoted
one level.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/index.rst   | 1 +
 Documentation/nios2/{README => nios2.rst} | 1 +
 2 files changed, 2 insertions(+)
 rename Documentation/nios2/{README => nios2.rst} (96%)

diff --git a/Documentation/index.rst b/Documentation/index.rst
index 09d24878ad14..0a564f3c336e 100644
--- a/Documentation/index.rst
+++ b/Documentation/index.rst
@@ -151,6 +151,7 @@ implementation.
m68k/index
powerpc/index
mips/index
+   nios2/nios2
openrisc/index
parisc/index
riscv/index
diff --git a/Documentation/nios2/README b/Documentation/nios2/nios2.rst
similarity index 96%
rename from Documentation/nios2/README
rename to Documentation/nios2/nios2.rst
index 054a67d55563..43da3f7cee76 100644
--- a/Documentation/nios2/README
+++ b/Documentation/nios2/nios2.rst
@@ -1,3 +1,4 @@
+=
 Linux on the Nios II architecture
 =
 
-- 
2.21.0



[PATCH 12/22] docs: fs: cifs: convert to ReST and add to admin-guide book

2019-07-22 Thread Mauro Carvalho Chehab
The filenames for cifs documentation is not using the same
convention as almost all Kernel documents is using. So,
rename them to a more appropriate name. Then, manually convert
the documentation files for CIFS to ReST.

By doing a manual conversion, we can preserve the original
author's style, while making it to look more like the other
Kernel documents.

Most of the conversion here is trivial. The most complex one was
the README file (which was renamed to usage.rst).

Signed-off-by: Mauro Carvalho Chehab 
---
 .../AUTHORS => admin-guide/cifs/authors.rst}  |  64 +-
 .../CHANGES => admin-guide/cifs/changes.rst}  |   4 +
 Documentation/admin-guide/cifs/index.rst  |  21 +
 .../cifs/introduction.rst}|   8 +
 .../cifs/TODO => admin-guide/cifs/todo.rst}   |  87 +--
 .../README => admin-guide/cifs/usage.rst} | 560 +++---
 .../cifs/winucase_convert.pl  |   0
 Documentation/admin-guide/index.rst   |   1 +
 MAINTAINERS   |   2 +-
 9 files changed, 460 insertions(+), 287 deletions(-)
 rename Documentation/{filesystems/cifs/AUTHORS => 
admin-guide/cifs/authors.rst} (60%)
 rename Documentation/{filesystems/cifs/CHANGES => 
admin-guide/cifs/changes.rst} (91%)
 create mode 100644 Documentation/admin-guide/cifs/index.rst
 rename Documentation/{filesystems/cifs/cifs.txt => 
admin-guide/cifs/introduction.rst} (98%)
 rename Documentation/{filesystems/cifs/TODO => admin-guide/cifs/todo.rst} (58%)
 rename Documentation/{filesystems/cifs/README => admin-guide/cifs/usage.rst} 
(72%)
 rename Documentation/{filesystems => admin-guide}/cifs/winucase_convert.pl 
(100%)

diff --git a/Documentation/filesystems/cifs/AUTHORS 
b/Documentation/admin-guide/cifs/authors.rst
similarity index 60%
rename from Documentation/filesystems/cifs/AUTHORS
rename to Documentation/admin-guide/cifs/authors.rst
index 75865da2ce14..b02d6dd6c070 100644
--- a/Documentation/filesystems/cifs/AUTHORS
+++ b/Documentation/admin-guide/cifs/authors.rst
@@ -1,5 +1,10 @@
+===
+Authors
+===
+
 Original Author
-===
+---
+
 Steve French (sfre...@samba.org)
 
 The author wishes to express his appreciation and thanks to:
@@ -12,7 +17,7 @@ side of the original CIFS Unix extensions and reviewing and 
implementing
 portions of the newer CIFS POSIX extensions into the Samba 3 file server. Thank
 Dave Boutcher of IBM Rochester (author of the OS/400 smb/cifs filesystem 
client)
 for proving years ago that very good smb/cifs clients could be done on 
Unix-like
-operating systems.  Volker Lendecke, Andrew Tridgell, Urban Widmark, John 
+operating systems.  Volker Lendecke, Andrew Tridgell, Urban Widmark, John
 Newbigin and others for their work on the Linux smbfs module.  Thanks to
 the other members of the Storage Network Industry Association CIFS Technical
 Workgroup for their work specifying this highly complex protocol and finally
@@ -20,33 +25,34 @@ thanks to the Samba team for their technical advice and 
encouragement.
 
 Patch Contributors
 --
-Zwane Mwaikambo
-Andi Kleen
-Amrut Joshi
-Shobhit Dayal
-Sergey Vlasov
-Richard Hughes
-Yury Umanets
-Mark Hamzy (for some of the early cifs IPv6 work)
-Domen Puncer
-Jesper Juhl (in particular for lots of whitespace/formatting cleanup)
-Vince Negri and Dave Stahl (for finding an important caching bug)
-Adrian Bunk (kcalloc cleanups)
-Miklos Szeredi 
-Kazeon team for various fixes especially for 2.4 version.
-Asser Ferno (Change Notify support)
-Shaggy (Dave Kleikamp) for innumerable small fs suggestions and some good 
cleanup
-Gunter Kukkukk (testing and suggestions for support of old servers)
-Igor Mammedov (DFS support)
-Jeff Layton (many, many fixes, as well as great work on the cifs Kerberos code)
-Scott Lovenberg
-Pavel Shilovsky (for great work adding SMB2 support, and various SMB3 features)
-Aurelien Aptel (for DFS SMB3 work and some key bug fixes)
-Ronnie Sahlberg (for SMB3 xattr work, bug fixes, and lots of great work on 
compounding)
-Shirish Pargaonkar (for many ACL patches over the years)
-Sachin Prabhu (many bug fixes, including for reconnect, copy offload and 
security)
-Paulo Alcantara
-Long Li (some great work on RDMA, SMB Direct)
+
+- Zwane Mwaikambo
+- Andi Kleen
+- Amrut Joshi
+- Shobhit Dayal
+- Sergey Vlasov
+- Richard Hughes
+- Yury Umanets
+- Mark Hamzy (for some of the early cifs IPv6 work)
+- Domen Puncer
+- Jesper Juhl (in particular for lots of whitespace/formatting cleanup)
+- Vince Negri and Dave Stahl (for finding an important caching bug)
+- Adrian Bunk (kcalloc cleanups)
+- Miklos Szeredi
+- Kazeon team for various fixes especially for 2.4 version.
+- Asser Ferno (Change Notify support)
+- Shaggy (Dave Kleikamp) for innumerable small fs suggestions and some good 
cleanup
+- Gunter Kukkukk (testing and suggestions for support of old servers)
+- Igor Mammedov (DFS support)
+- Jeff Layton (many, many fixes, as well as great work on the cifs Kerberos 
code)
+- S

[PATCH 08/22] docs: README.buddha: convert to ReST and add to m68k book

2019-07-22 Thread Mauro Carvalho Chehab
Adjust the file for it to be properly parsed by Sphinx, adding
it to the index of the book it belongs.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../m68k/{README.buddha => buddha-driver.rst} | 95 +--
 Documentation/m68k/index.rst  |  1 +
 2 files changed, 48 insertions(+), 48 deletions(-)
 rename Documentation/m68k/{README.buddha => buddha-driver.rst} (73%)

diff --git a/Documentation/m68k/README.buddha 
b/Documentation/m68k/buddha-driver.rst
similarity index 73%
rename from Documentation/m68k/README.buddha
rename to Documentation/m68k/buddha-driver.rst
index 3ea9827ba3c7..20e401413991 100644
--- a/Documentation/m68k/README.buddha
+++ b/Documentation/m68k/buddha-driver.rst
@@ -1,3 +1,6 @@
+=
+Amiga Buddha and Catweasel IDE Driver
+=
 
 The Amiga Buddha and Catweasel IDE Driver (part of ide.c) was written by
 Geert Uytterhoeven based on the following specifications:
@@ -12,12 +15,12 @@ described  in  their  manuals, no tricks have been used (for
 example leaving some address lines out of the equations...).
 If you want to configure the board yourself (for example let
 a  Linux  kernel  configure the card), look at the Commodore
-Docs.  Reading the nibbles should give this information:
+Docs.  Reading the nibbles should give this information::
 
-Vendor number: 4626 ($1212)
-product number: 0 (42 for Catweasel Z-II)
-Serial number: 0
-Rom-vector: $1000
+  Vendor number: 4626 ($1212)
+  product number: 0 (42 for Catweasel Z-II)
+  Serial number: 0
+  Rom-vector: $1000
 
 The  card  should be a Z-II board, size 64K, not for freemem
 list, Rom-Vektor is valid, no second Autoconfig-board on the
@@ -34,6 +37,7 @@ otherwise your chance is only 1:16 to find the board :-).
 
 The local memory-map is even active when mapped to $e8:
 
+==  ===
 $0-$7e Autokonfig-space, see Z-II docs.
 
 $80-$7fd   reserved
@@ -50,50 +54,51 @@ $a00-$aff   IDE-Select 2 (Port 1, Register set 0)
 $b00-$bff  IDE-Select 3 (Port 1, Register set 1)
 
 $c00-$cff  IDE-Select 4 (Port 2, Register set 0,
-  Catweasel only!)
+Catweasel only!)
 
 $d00-$dff  IDE-Select 5 (Port 3, Register set 1,
- Catweasel only!)
+   Catweasel only!)
 
-$e00-$eff  local expansion port, on Catweasel Z-II the 
+$e00-$eff  local expansion port, on Catweasel Z-II the
Catweasel registers are also mapped here.
Never touch, use multidisk.device!
-   
-$f00   read only, Byte-access: Bit 7 shows the 
-   level of the IRQ-line of IDE port 0. 
+
+$f00   read only, Byte-access: Bit 7 shows the
+   level of the IRQ-line of IDE port 0.
 
 $f01-$f3f  mirror of $f00
 
-$f40   read only, Byte-access: Bit 7 shows the 
-   level of the IRQ-line of IDE port 1. 
+$f40   read only, Byte-access: Bit 7 shows the
+   level of the IRQ-line of IDE port 1.
 
 $f41-$f7f  mirror of $f40
 
-$f80   read only, Byte-access: Bit 7 shows the 
-   level of the IRQ-line of IDE port 2. 
+$f80   read only, Byte-access: Bit 7 shows the
+   level of the IRQ-line of IDE port 2.
(Catweasel only!)
 
 $f81-$fbf  mirror of $f80
 
 $fc0   write-only: Writing any value to this
-   register enables IRQs to be passed from the 
-   IDE ports to the Zorro bus. This mechanism 
-   has been implemented to be compatible with 
+   register enables IRQs to be passed from the
+   IDE ports to the Zorro bus. This mechanism
+   has been implemented to be compatible with
harddisks that are either defective or have
-   a buggy firmware and pull the IRQ line up 
-   while starting up. If interrupts would 
-   always be passed to the bus, the computer 
-   might not start up. Once enabled, this flag 
-   can not be disabled again. The level of the 
-   flag can not be determined by software 
+   a buggy firmware and pull the IRQ line up
+   while starting up. If interrupts would
+   always be passed to the bus, the computer
+   might not start up. Once enabled, this flag
+   can not be disabled again. The level of the
+   flag can not be determined by software
(what for? Write to me if it's necessary!).
 
 $fc1-$fff  mirror of $fc0
 
 $1000-$Buddha-Rom with offset $1000 in the rom
-   chip. The addresses $0 to $fff of the rom 
+   chip. The addresses $0 to $fff of the rom
chip cannot be read. Rom is Byte-wide and
mapped to even addresses.
+==  ===

[PATCH 11/22] docs: isdn: convert to ReST and add to kAPI bookset

2019-07-22 Thread Mauro Carvalho Chehab
The ISDN documentation is a mix of admin guide, uAPI and kAPI.

Ideally, it should be split. Yet, not sure if it would worth
the troble. Anyway, we have the same kind of mix on several
drivers specific documentation. So, just like the others, keep
the directory at the root Documentation/ tree, just adding a
pointer to it at the kAPI section, as the documentation was
written with the Kernel developers in mind.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/index.rst   |   1 +
 .../isdn/{README.avmb1 => avmb1.rst}  | 231 --
 Documentation/isdn/{CREDITS => credits.rst}   |   7 +-
 .../isdn/{README.gigaset => gigaset.rst}  | 290 +++---
 .../isdn/{README.hysdn => hysdn.rst}  | 125 
 Documentation/isdn/index.rst  |  24 ++
 .../{INTERFACE.CAPI => interface_capi.rst}| 182 +++
 .../isdn/{README.mISDN => m_isdn.rst} |   5 +-
 drivers/staging/isdn/hysdn/Kconfig|   2 +-
 9 files changed, 536 insertions(+), 331 deletions(-)
 rename Documentation/isdn/{README.avmb1 => avmb1.rst} (50%)
 rename Documentation/isdn/{CREDITS => credits.rst} (96%)
 rename Documentation/isdn/{README.gigaset => gigaset.rst} (74%)
 rename Documentation/isdn/{README.hysdn => hysdn.rst} (80%)
 create mode 100644 Documentation/isdn/index.rst
 rename Documentation/isdn/{INTERFACE.CAPI => interface_capi.rst} (75%)
 rename Documentation/isdn/{README.mISDN => m_isdn.rst} (89%)

diff --git a/Documentation/index.rst b/Documentation/index.rst
index 5583b2e64692..c0132ad9c4d9 100644
--- a/Documentation/index.rst
+++ b/Documentation/index.rst
@@ -106,6 +106,7 @@ needed).
hid/index
i2c/index
iio/index
+   isdn/index
infiniband/index
leds/index
media/index
diff --git a/Documentation/isdn/README.avmb1 b/Documentation/isdn/avmb1.rst
similarity index 50%
rename from Documentation/isdn/README.avmb1
rename to Documentation/isdn/avmb1.rst
index 9e075484ef1e..de3961e67553 100644
--- a/Documentation/isdn/README.avmb1
+++ b/Documentation/isdn/avmb1.rst
@@ -1,4 +1,6 @@
-Driver for active AVM Controller.
+
+Driver for active AVM Controller
+
 
 The driver provides a kernel capi2.0 Interface (kernelcapi) and
 on top of this a User-Level-CAPI2.0-interface (capi)
@@ -11,25 +13,28 @@ The command avmcapictrl is part of the isdn4k-utils.
 t4-files can be found at ftp://ftp.avm.de/cardware/b1/linux/firmware
 
 Currently supported cards:
-   B1 ISA (all versions)
-   B1 PCI
-   T1/T1B (HEMA card)
-   M1
-   M2
-   B1 PCMCIA
+
+   - B1 ISA (all versions)
+   - B1 PCI
+   - T1/T1B (HEMA card)
+   - M1
+   - M2
+   - B1 PCMCIA
 
 Installing
 --
 
 You need at least /dev/capi20 to load the firmware.
 
-mknod /dev/capi20 c 68 0
-mknod /dev/capi20.00 c 68 1
-mknod /dev/capi20.01 c 68 2
-.
-.
-.
-mknod /dev/capi20.19 c 68 20
+::
+
+mknod /dev/capi20 c 68 0
+mknod /dev/capi20.00 c 68 1
+mknod /dev/capi20.01 c 68 2
+.
+.
+.
+mknod /dev/capi20.19 c 68 20
 
 Running
 ---
@@ -38,45 +43,58 @@ To use the card you need the t4-files to download the 
firmware.
 AVM GmbH provides several t4-files for the different D-channel
 protocols (b1.t4 for Euro-ISDN). Install these file in /lib/isdn.
 
-if you configure as modules load the modules this way:
-
-insmod /lib/modules/current/misc/capiutil.o
-insmod /lib/modules/current/misc/b1.o
-insmod /lib/modules/current/misc/kernelcapi.o
-insmod /lib/modules/current/misc/capidrv.o
-insmod /lib/modules/current/misc/capi.o
-
-if you have an B1-PCI card load the module b1pci.o
-insmod /lib/modules/current/misc/b1pci.o
-and load the firmware with
-avmcapictrl load /lib/isdn/b1.t4 1
+if you configure as modules load the modules this way::
+
+insmod /lib/modules/current/misc/capiutil.o
+insmod /lib/modules/current/misc/b1.o
+insmod /lib/modules/current/misc/kernelcapi.o
+insmod /lib/modules/current/misc/capidrv.o
+insmod /lib/modules/current/misc/capi.o
+
+if you have an B1-PCI card load the module b1pci.o::
+
+insmod /lib/modules/current/misc/b1pci.o
+
+and load the firmware with::
+
+avmcapictrl load /lib/isdn/b1.t4 1
 
 if you have an B1-ISA card load the module b1isa.o
-and add the card by calling
-avmcapictrl add 0x150 15
-and load the firmware by calling
-avmcapictrl load /lib/isdn/b1.t4 1
+and add the card by calling::
+
+avmcapictrl add 0x150 15
+
+and load the firmware by calling::
+
+avmcapictrl load /lib/isdn/b1.t4 1
 
 if you have an T1-ISA card load the module t1isa.o
-and add the card by calling
-avmcapictrl add 0x450 15 T1 0
-and load the firmware by calling
-avmcapictrl load /lib/isdn/t1.t4 1
+and add the card by calling::
+
+avmcapictrl add 0x450 15 T1 0
+
+and load the firmware by calling::
+
+avmcapictrl load /lib/isdn/t1.t4 1
 
 if you have an PCMCIA card (B1/M1/M2) load the module b1pcmcia.o
 befo

[PATCH 14/22] docs: fs: convert porting to ReST

2019-07-22 Thread Mauro Carvalho Chehab
This file has its own proper style, except that, after a while,
the coding style gets violated and whitespaces are placed on
different ways.

As Sphinx and ReST are very sentitive to whitespace differences,
I had to opt if each entry after required/mandatory/... fields
should start with zero spaces or with a tab. I opted to start them
all from the zero position, in order to avoid needing to break lines
with more than 80 columns, with would make harder for review.

Most of the other changes at porting.rst were made to use an unified
notation with works nice as a text file while also produce a good html
output after being parsed.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/filesystems/index.rst   |   2 +
 Documentation/filesystems/porting | 686 -
 Documentation/filesystems/porting.rst | 852 ++
 fs/orangefs/orangefs-kernel.h |   2 +-
 4 files changed, 855 insertions(+), 687 deletions(-)
 delete mode 100644 Documentation/filesystems/porting
 create mode 100644 Documentation/filesystems/porting.rst

diff --git a/Documentation/filesystems/index.rst 
b/Documentation/filesystems/index.rst
index 08320c35d03b..96653ebefd7e 100644
--- a/Documentation/filesystems/index.rst
+++ b/Documentation/filesystems/index.rst
@@ -23,6 +23,8 @@ algorithms work.
locking
directory-locking
 
+   porting
+
 Filesystem support layers
 =
 
diff --git a/Documentation/filesystems/porting 
b/Documentation/filesystems/porting
deleted file mode 100644
index 6b7a41cfcaed..
--- a/Documentation/filesystems/porting
+++ /dev/null
@@ -1,686 +0,0 @@
-Changes since 2.5.0:
-

-[recommended]
-
-New helpers: sb_bread(), sb_getblk(), sb_find_get_block(), set_bh(),
-   sb_set_blocksize() and sb_min_blocksize().
-
-Use them.
-
-(sb_find_get_block() replaces 2.4's get_hash_table())
-

-[recommended]
-
-New methods: ->alloc_inode() and ->destroy_inode().
-
-Remove inode->u.foo_inode_i
-Declare
-   struct foo_inode_info {
-   /* fs-private stuff */
-   struct inode vfs_inode;
-   };
-   static inline struct foo_inode_info *FOO_I(struct inode *inode)
-   {
-   return list_entry(inode, struct foo_inode_info, vfs_inode);
-   }
-
-Use FOO_I(inode) instead of &inode->u.foo_inode_i;
-
-Add foo_alloc_inode() and foo_destroy_inode() - the former should allocate
-foo_inode_info and return the address of ->vfs_inode, the latter should free
-FOO_I(inode) (see in-tree filesystems for examples).
-
-Make them ->alloc_inode and ->destroy_inode in your super_operations.
-
-Keep in mind that now you need explicit initialization of private data
-typically between calling iget_locked() and unlocking the inode.
-
-At some point that will become mandatory.
-

-[mandatory]
-
-Change of file_system_type method (->read_super to ->get_sb)
-
-->read_super() is no more.  Ditto for DECLARE_FSTYPE and DECLARE_FSTYPE_DEV.
-
-Turn your foo_read_super() into a function that would return 0 in case of
-success and negative number in case of error (-EINVAL unless you have more
-informative error value to report).  Call it foo_fill_super().  Now declare
-
-int foo_get_sb(struct file_system_type *fs_type,
-   int flags, const char *dev_name, void *data, struct vfsmount *mnt)
-{
-   return get_sb_bdev(fs_type, flags, dev_name, data, foo_fill_super,
-  mnt);
-}
-
-(or similar with s/bdev/nodev/ or s/bdev/single/, depending on the kind of
-filesystem).
-
-Replace DECLARE_FSTYPE... with explicit initializer and have ->get_sb set as
-foo_get_sb.
-

-[mandatory]
-
-Locking change: ->s_vfs_rename_sem is taken only by cross-directory renames.
-Most likely there is no need to change anything, but if you relied on
-global exclusion between renames for some internal purpose - you need to
-change your internal locking.  Otherwise exclusion warranties remain the
-same (i.e. parents and victim are locked, etc.).
-

-[informational]
-
-Now we have the exclusion between ->lookup() and directory removal (by
-->rmdir() and ->rename()).  If you used to need that exclusion and do
-it by internal locking (most of filesystems couldn't care less) - you
-can relax your locking.
-

-[mandatory]
-
-->lookup(), ->truncate(), ->create(), ->unlink(), ->mknod(), ->mkdir(),
-->rmdir(), ->link(), ->lseek(), ->symlink(), ->rename()
-and ->readdir() are called without BKL now.  Grab it on entry, drop upon return
-- that will guarantee the same locking you used to have.  If your method or its
-parts do not need BKL - better yet, now you can shift lock_kernel() and
-unlock_kernel() so that they would protect exactly what needs to be
-protected.
-

-[mandatory]
-
-BKL is also moved from around sb operations. BKL should have been shifted into
-individual fs sb_op functions.  If you don't need it, remove it.
-

-[informational]
-
-check for ->link() target not being a directory is done by callers.  

[PATCH 15/22] docs: index.rst: don't use genindex for pdf output

2019-07-22 Thread Mauro Carvalho Chehab
The genindex logic is meant to be used only for html output, as
pdf build has its own way to generate indexes.

Signed-off-by: Mauro Carvalho Chehab 
---
 Documentation/core-api/index.rst  | 2 +-
 Documentation/driver-api/dmaengine/index.rst  | 2 +-
 Documentation/driver-api/soundwire/index.rst  | 2 +-
 Documentation/networking/device_drivers/index.rst | 2 +-
 Documentation/networking/index.rst| 2 +-
 Documentation/sound/index.rst | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Documentation/core-api/index.rst b/Documentation/core-api/index.rst
index dfd8fad1e1ec..fa16a0538dcb 100644
--- a/Documentation/core-api/index.rst
+++ b/Documentation/core-api/index.rst
@@ -49,7 +49,7 @@ Interfaces for kernel debugging
debug-objects
tracepoint
 
-.. only::  subproject
+.. only:: subproject and html
 
Indices
===
diff --git a/Documentation/driver-api/dmaengine/index.rst 
b/Documentation/driver-api/dmaengine/index.rst
index 3026fa975937..b9df904d0a79 100644
--- a/Documentation/driver-api/dmaengine/index.rst
+++ b/Documentation/driver-api/dmaengine/index.rst
@@ -47,7 +47,7 @@ This book adds some notes about PXA DMA
 
pxa_dma
 
-.. only::  subproject
+.. only::  subproject and html
 
Indices
===
diff --git a/Documentation/driver-api/soundwire/index.rst 
b/Documentation/driver-api/soundwire/index.rst
index 6db026028f27..234911a0db99 100644
--- a/Documentation/driver-api/soundwire/index.rst
+++ b/Documentation/driver-api/soundwire/index.rst
@@ -10,7 +10,7 @@ SoundWire Documentation
error_handling
locking
 
-.. only::  subproject
+.. only::  subproject and html
 
Indices
===
diff --git a/Documentation/networking/device_drivers/index.rst 
b/Documentation/networking/device_drivers/index.rst
index 2b7fefe72351..f724b7c69b9e 100644
--- a/Documentation/networking/device_drivers/index.rst
+++ b/Documentation/networking/device_drivers/index.rst
@@ -24,7 +24,7 @@ Contents:
google/gve
mellanox/mlx5
 
-.. only::  subproject
+.. only::  subproject and html
 
Indices
===
diff --git a/Documentation/networking/index.rst 
b/Documentation/networking/index.rst
index a46fca264bee..6739066acadb 100644
--- a/Documentation/networking/index.rst
+++ b/Documentation/networking/index.rst
@@ -31,7 +31,7 @@ Contents:
tls
tls-offload
 
-.. only::  subproject
+.. only::  subproject and html
 
Indices
===
diff --git a/Documentation/sound/index.rst b/Documentation/sound/index.rst
index 47b89f014e69..4d7d42acf6df 100644
--- a/Documentation/sound/index.rst
+++ b/Documentation/sound/index.rst
@@ -12,7 +12,7 @@ Linux Sound Subsystem Documentation
hd-audio/index
cards/index
 
-.. only::  subproject
+.. only::  subproject and html
 
Indices
===
-- 
2.21.0



Re: [PATCH 04/22] docs: spi: convert to ReST and add it to the kABI bookset

2019-07-22 Thread Mark Brown
On Mon, Jul 22, 2019 at 08:07:31AM -0300, Mauro Carvalho Chehab wrote:
> While there's one file there with briefily describes the uAPI,
> the documentation was written just like most subsystems: focused
> on kernel developers. So, add it together with driver-api books.

Please use subject lines matching the style for the subsystem.  This
makes it easier for people to identify relevant patches.

>  Documentation/spi/{spidev => spidev.rst}  |  30 +++--

This is clearly a userspace focused document rather than a kernel
internal one.


signature.asc
Description: PGP signature


Re: [PATCH] mm, slab: Extend slab/shrink to shrink all the memcg caches

2019-07-22 Thread peter enderborg
On 7/2/19 8:37 PM, Waiman Long wrote:
> Currently, a value of '1" is written to /sys/kernel/slab//shrink
> file to shrink the slab by flushing all the per-cpu slabs and free
> slabs in partial lists. This applies only to the root caches, though.
>
> Extends this capability by shrinking all the child memcg caches and
> the root cache when a value of '2' is written to the shrink sysfs file.
>
> On a 4-socket 112-core 224-thread x86-64 system after a parallel kernel
> build, the the amount of memory occupied by slabs before shrinking
> slabs were:
>
>  # grep task_struct /proc/slabinfo
>  task_struct 7114   7296   774448 : tunables00
>  0 : slabdata   1824   1824  0
>  # grep "^S[lRU]" /proc/meminfo
>  Slab:1310444 kB
>  SReclaimable: 377604 kB
>  SUnreclaim:   932840 kB
>
> After shrinking slabs:
>
>  # grep "^S[lRU]" /proc/meminfo
>  Slab: 695652 kB
>  SReclaimable: 322796 kB
>  SUnreclaim:   372856 kB
>  # grep task_struct /proc/slabinfo
>  task_struct 2262   2572   774448 : tunables00
>  0 : slabdata643643  0


What is the time between this measurement points? Should not the shrinked 
memory show up as reclaimable?


> Signed-off-by: Waiman Long 
> ---
>  Documentation/ABI/testing/sysfs-kernel-slab | 10 +++--
>  mm/slab.h   |  1 +
>  mm/slab_common.c| 43 +
>  mm/slub.c   |  2 +
>  4 files changed, 52 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/ABI/testing/sysfs-kernel-slab 
> b/Documentation/ABI/testing/sysfs-kernel-slab
> index 29601d93a1c2..2a3d0fc4b4ac 100644
> --- a/Documentation/ABI/testing/sysfs-kernel-slab
> +++ b/Documentation/ABI/testing/sysfs-kernel-slab
> @@ -429,10 +429,12 @@ KernelVersion:  2.6.22
>  Contact: Pekka Enberg ,
>   Christoph Lameter 
>  Description:
> - The shrink file is written when memory should be reclaimed from
> - a cache.  Empty partial slabs are freed and the partial list is
> - sorted so the slabs with the fewest available objects are used
> - first.
> + A value of '1' is written to the shrink file when memory should
> + be reclaimed from a cache.  Empty partial slabs are freed and
> + the partial list is sorted so the slabs with the fewest
> + available objects are used first.  When a value of '2' is
> + written, all the corresponding child memory cgroup caches
> + should be shrunk as well.  All other values are invalid.
>  
>  What:/sys/kernel/slab/cache/slab_size
>  Date:May 2007
> diff --git a/mm/slab.h b/mm/slab.h
> index 3b22931bb557..a16b2c7ff4dd 100644
> --- a/mm/slab.h
> +++ b/mm/slab.h
> @@ -174,6 +174,7 @@ int __kmem_cache_shrink(struct kmem_cache *);
>  void __kmemcg_cache_deactivate(struct kmem_cache *s);
>  void __kmemcg_cache_deactivate_after_rcu(struct kmem_cache *s);
>  void slab_kmem_cache_release(struct kmem_cache *);
> +int kmem_cache_shrink_all(struct kmem_cache *s);
>  
>  struct seq_file;
>  struct file;
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 464faaa9fd81..493697ba1da5 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -981,6 +981,49 @@ int kmem_cache_shrink(struct kmem_cache *cachep)
>  }
>  EXPORT_SYMBOL(kmem_cache_shrink);
>  
> +/**
> + * kmem_cache_shrink_all - shrink a cache and all its memcg children
> + * @s: The root cache to shrink.
> + *
> + * Return: 0 if successful, -EINVAL if not a root cache
> + */
> +int kmem_cache_shrink_all(struct kmem_cache *s)
> +{
> + struct kmem_cache *c;
> +
> + if (!IS_ENABLED(CONFIG_MEMCG_KMEM)) {
> + kmem_cache_shrink(s);
> + return 0;
> + }
> + if (!is_root_cache(s))
> + return -EINVAL;
> +
> + /*
> +  * The caller should have a reference to the root cache and so
> +  * we don't need to take the slab_mutex. We have to take the
> +  * slab_mutex, however, to iterate the memcg caches.
> +  */
> + get_online_cpus();
> + get_online_mems();
> + kasan_cache_shrink(s);
> + __kmem_cache_shrink(s);
> +
> + mutex_lock(&slab_mutex);
> + for_each_memcg_cache(c, s) {
> + /*
> +  * Don't need to shrink deactivated memcg caches.
> +  */
> + if (s->flags & SLAB_DEACTIVATED)
> + continue;
> + kasan_cache_shrink(c);
> + __kmem_cache_shrink(c);
> + }
> + mutex_unlock(&slab_mutex);
> + put_online_mems();
> + put_online_cpus();
> + return 0;
> +}
> +
>  bool slab_is_available(void)
>  {
>   return slab_state >= UP;
> diff --git a/mm/slub.c b/mm/slub.c
> index a384228ff6d3..5d7b0004c51f 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -5298,6 +5298,8 @@ static ssize_t shrink_store(struct kmem_cac

Re: [PATCH 04/22] docs: spi: convert to ReST and add it to the kABI bookset

2019-07-22 Thread Mauro Carvalho Chehab
Em Mon, 22 Jul 2019 13:11:51 +0100
Mark Brown  escreveu:

> On Mon, Jul 22, 2019 at 08:07:31AM -0300, Mauro Carvalho Chehab wrote:
> > While there's one file there with briefily describes the uAPI,
> > the documentation was written just like most subsystems: focused
> > on kernel developers. So, add it together with driver-api books.  
> 
> Please use subject lines matching the style for the subsystem.  This
> makes it easier for people to identify relevant patches.

Sure. Do you prefer this prefixed by:

spi: docs:

Or with something else?

> >  Documentation/spi/{spidev => spidev.rst}  |  30 +++--  
> 
> This is clearly a userspace focused document rather than a kernel
> internal one.

True. What I've been doing so far is, for all drivers that I'm converting
with carries more than one documentation type (kABI, uABI and/or 
admin-guide) is to keep the directory as-is, adding them under
this section at Documentation/index.rst:

Kernel API documentation


That's the case of media, input, hwmon, and so many other subsystems.

Yet, you're right: this implies that there will be some things
to be done, as the long-term documentation should be like:

Documentation/admin-guide/{media, input, hwmon, spi, ...}
Documentation/userspace-api/{media, input, hwmon, spi, ...}
Documentation/driver-api/{media, input, hwmon, spi, ...}

Btw, if you look at spidev file, it contains stuff for both
userspace-api:

"SPI devices have a limited userspace API, supporting basic half-duplex
 read() and write() access to SPI slave devices.  Using ioctl() 
requests,"

And for admin-guide:

"For a SPI device with chipselect C on bus B, you should see:

/dev/spidevB.C ... character special device, major number 153 with
a dynamically chosen minor device number. "

So, if we're willing to move it, the best is to do on a separate patch
with would split its contents into two files: admin-guide/spi-devices.rst and 
userspace-api/spi-api.rst.

-

There are a couple of reasons why I opted for this strategy:

1) There are *lots* of docs that contain all 3 types of information
   on it on a single file.

2) On media, we use SPHINXDIRS to produce the media book from our
   devel tree:
https://linuxtv.org/downloads/v4l-dvb-apis-new/index.html

   When documents are built with either PDF SPHINXDIRS, each subdir
   will be on a different book and all inter-book cross-references
   will break.
   
   For this to be fixed, we'll likely need to use something like
   intersphinx extension, but this would probably require a
   per-subsystem mapping (for example, saying that, for media, the
   site used to resolve broken cross references is linuxtv.org). 
   Maintaining it can be painful.

3) So far, I was unable to split even the media docs! Shame on
   me! The reason is that this is not an easy task.


One interesting example is at what we consider to be the media
uAPI book. It actually contains both sysadmin and uAPI documentation.

For example, at:

Documentation/media/uapi/v4l/open.rst

You'll see that, while most things there belong to the admin
guide (device node descriptions, multiple opens, etc), it
mentions the Kernel userspace API - open(), read(), close() syscalls.

Splitting this file on two separate books won't be that easy.

Ideally, we should split what's there at media/uapi into admin-guide
and userspace-api, but this would mean *a lot* of efforts. Not sure
if it is worth the effort.


Thanks,
Mauro


Re: [PATCH 01/22] docs: convert markdown documents to ReST

2019-07-22 Thread Rob Herring
On Mon, Jul 22, 2019 at 5:08 AM Mauro Carvalho Chehab
 wrote:
>
> The documentation standard is ReST and not markdown.
>
> Signed-off-by: Mauro Carvalho Chehab 
> Acked-by: Rob Herring 
> ---
>  Documentation/devicetree/writing-schema.md| 130 ---
>  Documentation/devicetree/writing-schema.rst   | 153 ++

Thinking about this some more, can you split this to a separate patch
for me to apply. I may have some changes to this file this cycle.

>  ...entication.md => ubifs-authentication.rst} |  70 +---
>  3 files changed, 197 insertions(+), 156 deletions(-)
>  delete mode 100644 Documentation/devicetree/writing-schema.md
>  create mode 100644 Documentation/devicetree/writing-schema.rst
>  rename Documentation/filesystems/{ubifs-authentication.md => 
> ubifs-authentication.rst} (95%)


Re: [PATCH 04/22] docs: spi: convert to ReST and add it to the kABI bookset

2019-07-22 Thread Mark Brown
On Mon, Jul 22, 2019 at 10:10:35AM -0300, Mauro Carvalho Chehab wrote:
> Mark Brown  escreveu:

> > On Mon, Jul 22, 2019 at 08:07:31AM -0300, Mauro Carvalho Chehab wrote:
> > > While there's one file there with briefily describes the uAPI,
> > > the documentation was written just like most subsystems: focused
> > > on kernel developers. So, add it together with driver-api books.  

> > Please use subject lines matching the style for the subsystem.  This
> > makes it easier for people to identify relevant patches.

> Sure. Do you prefer this prefixed by:

>   spi: docs:

> Or with something else?

Anything starting with spi:

> > >  Documentation/spi/{spidev => spidev.rst}  |  30 +++--  
> > 
> > This is clearly a userspace focused document rather than a kernel
> > internal one.
> 
> True. What I've been doing so far is, for all drivers that I'm converting
> with carries more than one documentation type (kABI, uABI and/or 
> admin-guide) is to keep the directory as-is, adding them under
> this section at Documentation/index.rst:
> 
>   Kernel API documentation
>   
> 
> That's the case of media, input, hwmon, and so many other subsystems.

> Yet, you're right: this implies that there will be some things
> to be done, as the long-term documentation should be like:
> 
>   Documentation/admin-guide/{media, input, hwmon, spi, ...}
>   Documentation/userspace-api/{media, input, hwmon, spi, ...}
>   Documentation/driver-api/{media, input, hwmon, spi, ...}

> Btw, if you look at spidev file, it contains stuff for both
> userspace-api:
> 
>   "SPI devices have a limited userspace API, supporting basic half-duplex
>read() and write() access to SPI slave devices.  Using ioctl() 
> requests,"

> And for admin-guide:

>   "For a SPI device with chipselect C on bus B, you should see:
> 
>   /dev/spidevB.C ... character special device, major number 153 with
>   a dynamically chosen minor device number. "

I think that split is higly artificial...

> So, if we're willing to move it, the best is to do on a separate patch
> with would split its contents into two files: admin-guide/spi-devices.rst and 
> userspace-api/spi-api.rst.

...

> Ideally, we should split what's there at media/uapi into admin-guide
> and userspace-api, but this would mean *a lot* of efforts. Not sure
> if it is worth the effort.

Is the admin/API stuff even sensible for things that are more embedded
or desktop focused?  It feels very arbatrary and unhelpful for things
like spidev where theuser is going to be writing a program.


signature.asc
Description: PGP signature


Re: [PATCH 04/22] docs: spi: convert to ReST and add it to the kABI bookset

2019-07-22 Thread Mauro Carvalho Chehab
Em Mon, 22 Jul 2019 16:21:10 +0100
Mark Brown  escreveu:

> On Mon, Jul 22, 2019 at 10:10:35AM -0300, Mauro Carvalho Chehab wrote:
> > Mark Brown  escreveu:  
> 
> > > On Mon, Jul 22, 2019 at 08:07:31AM -0300, Mauro Carvalho Chehab wrote:  
> > > > While there's one file there with briefily describes the uAPI,
> > > > the documentation was written just like most subsystems: focused
> > > > on kernel developers. So, add it together with driver-api books.
> 
> > > Please use subject lines matching the style for the subsystem.  This
> > > makes it easier for people to identify relevant patches.  
> 
> > Sure. Do you prefer this prefixed by:  
> 
> > spi: docs:  
> 
> > Or with something else?  
> 
> Anything starting with spi:

Ok.

> 
> > > >  Documentation/spi/{spidev => spidev.rst}  |  30 +++--
> > > 
> > > This is clearly a userspace focused document rather than a kernel
> > > internal one.  
> > 
> > True. What I've been doing so far is, for all drivers that I'm converting
> > with carries more than one documentation type (kABI, uABI and/or 
> > admin-guide) is to keep the directory as-is, adding them under
> > this section at Documentation/index.rst:

...

> > Btw, if you look at spidev file, it contains stuff for both
> > userspace-api:
> > 
> > "SPI devices have a limited userspace API, supporting basic half-duplex
> >  read() and write() access to SPI slave devices.  Using ioctl() 
> > requests,"  
> 
> > And for admin-guide:  
> 
> > "For a SPI device with chipselect C on bus B, you should see:
> > 
> > /dev/spidevB.C ... character special device, major number 153 with
> > a dynamically chosen minor device number. "  
> 
> I think that split is higly artificial...
> 
> > So, if we're willing to move it, the best is to do on a separate patch
> > with would split its contents into two files: admin-guide/spi-devices.rst 
> > and 
> > userspace-api/spi-api.rst.  
> 
> ...
> 
> > Ideally, we should split what's there at media/uapi into admin-guide
> > and userspace-api, but this would mean *a lot* of efforts. Not sure
> > if it is worth the effort.  
> 
> Is the admin/API stuff even sensible for things that are more embedded
> or desktop focused?  

Yes. Btw, the plan is to add everything under Documentation/ABI at the
admin guide (parsed via some scripts).

> It feels very arbatrary and unhelpful for things
> like spidev where theuser is going to be writing a program.

I tend to agree with you. Doing such split may actually make things
worse for app developers, without providing much benefit for sysadmins.

I sent today an e-mail to the KS discussion ML about that, as, IMHO,
this is something that we should discuss at the Documentation track
there.

While the idea of having users/sysadmin-faced stuff at admin-guide
seems to be nice, doing it for driver-specific stuff could be overkill,
and will mean a lot of extra work.

Thanks,
Mauro


Re: [PATCH v5] Documentation/checkpatch: Prefer strscpy/strscpy_pad over strcpy/strlcpy/strncpy

2019-07-22 Thread Kees Cook
On Wed, Jul 17, 2019 at 10:00:05AM +0530, NitinGote wrote:
> From: Nitin Gote 
> 
> Added check in checkpatch.pl to
> 1. Deprecate strcpy() in favor of strscpy().
> 2. Deprecate strlcpy() in favor of strscpy().
> 3. Deprecate strncpy() in favor of strscpy() or strscpy_pad().
> 
> Updated strncpy() section in Documentation/process/deprecated.rst
> to cover strscpy_pad() case.
> 
> Signed-off-by: Nitin Gote 

Reviewed-by: Kees Cook 

Joe, does this address your checkpatch concerns?

-Kees

> ---
>  Documentation/process/deprecated.rst |  6 +++---
>  scripts/checkpatch.pl| 24 
>  2 files changed, 27 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/process/deprecated.rst 
> b/Documentation/process/deprecated.rst
> index 49e0f64a3427..c348ef9d44f5 100644
> --- a/Documentation/process/deprecated.rst
> +++ b/Documentation/process/deprecated.rst
> @@ -93,9 +93,9 @@ will be NUL terminated. This can lead to various linear 
> read overflows
>  and other misbehavior due to the missing termination. It also NUL-pads the
>  destination buffer if the source contents are shorter than the destination
>  buffer size, which may be a needless performance penalty for callers using
> -only NUL-terminated strings. The safe replacement is :c:func:`strscpy`.
> -(Users of :c:func:`strscpy` still needing NUL-padding will need an
> -explicit :c:func:`memset` added.)
> +only NUL-terminated strings. In this case, the safe replacement is
> +strscpy(). If, however, the destination buffer still needs NUL-padding,
> +the safe replacement is strscpy_pad().
> 
>  If a caller is using non-NUL-terminated strings, :c:func:`strncpy()` can
>  still be used, but destinations should be marked with the `__nonstring
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index bb28b178d929..1bb12127115d 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -605,6 +605,20 @@ foreach my $entry (keys %deprecated_apis) {
>  }
>  $deprecated_apis_search = "(?:${deprecated_apis_search})";
> 
> +our %deprecated_string_apis = (
> +"strcpy" => "strscpy",
> +"strlcpy"=> "strscpy",
> +"strncpy"=> "strscpy, strscpy_pad or for 
> non-NUL-terminated strings, strncpy() can still be used, but destinations 
> should be marked with __nonstring",
> +);
> +
> +#Create a search pattern for all these strings apis to speed up a loop below
> +our $deprecated_string_apis_search = "";
> +foreach my $entry (keys %deprecated_string_apis) {
> +$deprecated_string_apis_search .= '|' if 
> ($deprecated_string_apis_search ne "");
> +$deprecated_string_apis_search .= $entry;
> +}
> +$deprecated_string_apis_search = "(?:${deprecated_string_apis_search})";
> +
>  our $mode_perms_world_writable = qr{
>   S_IWUGO |
>   S_IWOTH |
> @@ -6446,6 +6460,16 @@ sub process {
>"Deprecated use of '$deprecated_api', prefer 
> '$new_api' instead\n" . $herecurr);
>   }
> 
> +# check for string deprecated apis
> + if ($line =~ /\b($deprecated_string_apis_search)\b\s*\(/) {
> + my $deprecated_string_api = $1;
> + my $new_api = 
> $deprecated_string_apis{$deprecated_string_api};
> + my $msg_level = \&WARN;
> + $msg_level = \&CHK if ($file);
> + &{$msg_level}("DEPRECATED_API",
> +   "Deprecated use of 
> '$deprecated_string_api', prefer '$new_api' instead\n" . $herecurr);
> + }
> +
>  # check for various structs that are normally const (ops, kgdb, device_tree)
>  # and avoid what seem like struct definitions 'struct foo {'
>   if ($line !~ /\bconst\b/ &&
> --
> 2.17.1
> 

-- 
Kees Cook


Re: [RFC PATCH] string.h: Add stracpy/stracpy_pad (was: Re: [PATCH] checkpatch: Added warnings in favor of strscpy().)

2019-07-22 Thread Kees Cook
On Thu, Jul 04, 2019 at 05:15:57PM -0700, Joe Perches wrote:
> On Thu, 2019-07-04 at 13:46 -0700, Joe Perches wrote:
> > On Thu, 2019-07-04 at 11:24 +0530, Nitin Gote wrote:
> > > Added warnings in checkpatch.pl script to :
> > > 
> > > 1. Deprecate strcpy() in favor of strscpy().
> > > 2. Deprecate strlcpy() in favor of strscpy().
> > > 3. Deprecate strncpy() in favor of strscpy() or strscpy_pad().
> > > 
> > > Updated strncpy() section in Documentation/process/deprecated.rst
> > > to cover strscpy_pad() case.
> 
> []
> 
> I sent a patch series for some strscpy/strlcpy misuses.
> 
> How about adding a macro helper to avoid the misuses like:
> ---
>  include/linux/string.h | 16 
>  1 file changed, 16 insertions(+)
> 
> diff --git a/include/linux/string.h b/include/linux/string.h
> index 4deb11f7976b..ef01bd6f19df 100644
> --- a/include/linux/string.h
> +++ b/include/linux/string.h
> @@ -35,6 +35,22 @@ ssize_t strscpy(char *, const char *, size_t);
>  /* Wraps calls to strscpy()/memset(), no arch specific code required */
>  ssize_t strscpy_pad(char *dest, const char *src, size_t count);
>  
> +#define stracpy(to, from)\
> +({   \
> + size_t size = ARRAY_SIZE(to);   \
> + BUILD_BUG_ON(!__same_type(typeof(*to), char));  \
> + \
> + strscpy(to, from, size);\
> +})
> +
> +#define stracpy_pad(to, from)\
> +({   \
> + size_t size = ARRAY_SIZE(to);   \
> + BUILD_BUG_ON(!__same_type(typeof(*to), char));  \
> + \
> + strscpy_pad(to, from, size);\
> +})
> +
>  #ifndef __HAVE_ARCH_STRCAT
>  extern char * strcat(char *, const char *);
>  #endif

This seems like a reasonable addition, yes. I think Coccinelle might
actually be able to find all the existing strscpy(dst, src, sizeof(dst))
cases to jump-start this conversion.

Devil's advocate: this adds yet more string handling functions... will
this cause even more confusion?

-- 
Kees Cook


Re: [PATCH v5] Documentation/checkpatch: Prefer strscpy/strscpy_pad over strcpy/strlcpy/strncpy

2019-07-22 Thread Joe Perches
On Mon, 2019-07-22 at 10:30 -0700, Kees Cook wrote:
> On Wed, Jul 17, 2019 at 10:00:05AM +0530, NitinGote wrote:
> > From: Nitin Gote 
> > 
> > Added check in checkpatch.pl to
> > 1. Deprecate strcpy() in favor of strscpy().
> > 2. Deprecate strlcpy() in favor of strscpy().
> > 3. Deprecate strncpy() in favor of strscpy() or strscpy_pad().
> > 
> > Updated strncpy() section in Documentation/process/deprecated.rst
> > to cover strscpy_pad() case.
> > 
> > Signed-off-by: Nitin Gote 
> 
> Reviewed-by: Kees Cook 
> 
> Joe, does this address your checkpatch concerns?

Well, kinda.

strscpy_pad isn't used anywhere in the kernel.

And

+"strncpy"  => "strscpy, strscpy_pad or for 
non-NUL-terminated strings, strncpy() can still be used, but destinations 
should be marked with __nonstring",

is a bit verbose.  This could be simply:

+"strncpy" => "strscpy - for non-NUL-terminated uses, strncpy() dst 
should be __nonstring",

And I still prefer adding stracpy as it
reduces code verbosity and eliminates defects.




Re: [RFC PATCH] string.h: Add stracpy/stracpy_pad (was: Re: [PATCH] checkpatch: Added warnings in favor of strscpy().)

2019-07-22 Thread Joe Perches
On Mon, 2019-07-22 at 10:33 -0700, Kees Cook wrote:
> On Thu, Jul 04, 2019 at 05:15:57PM -0700, Joe Perches wrote:
> > On Thu, 2019-07-04 at 13:46 -0700, Joe Perches wrote:
> > > On Thu, 2019-07-04 at 11:24 +0530, Nitin Gote wrote:
> > > > Added warnings in checkpatch.pl script to :
> > > > 
> > > > 1. Deprecate strcpy() in favor of strscpy().
> > > > 2. Deprecate strlcpy() in favor of strscpy().
> > > > 3. Deprecate strncpy() in favor of strscpy() or strscpy_pad().
> > > > 
> > > > Updated strncpy() section in Documentation/process/deprecated.rst
> > > > to cover strscpy_pad() case.
> > 
> > []
> > 
> > I sent a patch series for some strscpy/strlcpy misuses.
> > 
> > How about adding a macro helper to avoid the misuses like:
> > ---
> >  include/linux/string.h | 16 
> >  1 file changed, 16 insertions(+)
> > 
> > diff --git a/include/linux/string.h b/include/linux/string.h
> > index 4deb11f7976b..ef01bd6f19df 100644
> > --- a/include/linux/string.h
> > +++ b/include/linux/string.h
> > @@ -35,6 +35,22 @@ ssize_t strscpy(char *, const char *, size_t);
> >  /* Wraps calls to strscpy()/memset(), no arch specific code required */
> >  ssize_t strscpy_pad(char *dest, const char *src, size_t count);
> >  
> > +#define stracpy(to, from)  \
> > +({ \
> > +   size_t size = ARRAY_SIZE(to);   \
> > +   BUILD_BUG_ON(!__same_type(typeof(*to), char));  \
> > +   \
> > +   strscpy(to, from, size);\
> > +})
> > +
> > +#define stracpy_pad(to, from)  \
> > +({ \
> > +   size_t size = ARRAY_SIZE(to);   \
> > +   BUILD_BUG_ON(!__same_type(typeof(*to), char));  \
> > +   \
> > +   strscpy_pad(to, from, size);\
> > +})
> > +
> >  #ifndef __HAVE_ARCH_STRCAT
> >  extern char * strcat(char *, const char *);
> >  #endif
> 
> This seems like a reasonable addition, yes. I think Coccinelle might
> actually be able to find all the existing strscpy(dst, src, sizeof(dst))
> cases to jump-start this conversion.

I did that.  It works.  It's a lot of conversions.

$ cat str.cpy.cocci
@@
expression e1;
expression e2;
@@

- strscpy(e1, e2, sizeof(e1))
+ stracpy(e1, e2)

@@
expression e1;
expression e2;
@@

- strlcpy(e1, e2, sizeof(e1))
+ stracpy(e1, e2)

> Devil's advocate: this adds yet more string handling functions... will
> this cause even more confusion?

Documentation is good.
Actual in-kernel use and examples better.





Re: [PATCH 17/22] docs: mips: add to the documentation body as ReST

2019-07-22 Thread Paul Burton
Hi Mauro,

On Mon, Jul 22, 2019 at 08:07:44AM -0300, Mauro Carvalho Chehab wrote:
> Manually convert the AU1xxx_IDE.README file to ReST and add
> to a MIPS book as part of the main documentation body.
> 
> Signed-off-by: Mauro Carvalho Chehab 
> ---
>  Documentation/index.rst   |  1 +
>  .../{AU1xxx_IDE.README => au1xxx_ide.rst} | 89 +++
>  Documentation/mips/index.rst  | 17 
>  3 files changed, 70 insertions(+), 37 deletions(-)
>  rename Documentation/mips/{AU1xxx_IDE.README => au1xxx_ide.rst} (67%)
>  create mode 100644 Documentation/mips/index.rst

Acked-by: Paul Burton 

Thanks,
Paul


Re: [RFC PATCH] string.h: Add stracpy/stracpy_pad (was: Re: [PATCH] checkpatch: Added warnings in favor of strscpy().)

2019-07-22 Thread Joe Perches
On Mon, 2019-07-22 at 10:43 -0700, Joe Perches wrote:
> On Mon, 2019-07-22 at 10:33 -0700, Kees Cook wrote:
> > On Thu, Jul 04, 2019 at 05:15:57PM -0700, Joe Perches wrote:
> > > On Thu, 2019-07-04 at 13:46 -0700, Joe Perches wrote:
> > > > On Thu, 2019-07-04 at 11:24 +0530, Nitin Gote wrote:
> > > > > Added warnings in checkpatch.pl script to :
> > > > > 
> > > > > 1. Deprecate strcpy() in favor of strscpy().
> > > > > 2. Deprecate strlcpy() in favor of strscpy().
> > > > > 3. Deprecate strncpy() in favor of strscpy() or strscpy_pad().
> > > > > 
> > > > > Updated strncpy() section in Documentation/process/deprecated.rst
> > > > > to cover strscpy_pad() case.
> > > 
> > > []
> > > 
> > > I sent a patch series for some strscpy/strlcpy misuses.
> > > 
> > > How about adding a macro helper to avoid the misuses like:
> > > ---
> > >  include/linux/string.h | 16 
> > >  1 file changed, 16 insertions(+)
> > > 
> > > diff --git a/include/linux/string.h b/include/linux/string.h
> > > index 4deb11f7976b..ef01bd6f19df 100644
> > > --- a/include/linux/string.h
> > > +++ b/include/linux/string.h
> > > @@ -35,6 +35,22 @@ ssize_t strscpy(char *, const char *, size_t);
> > >  /* Wraps calls to strscpy()/memset(), no arch specific code required */
> > >  ssize_t strscpy_pad(char *dest, const char *src, size_t count);
> > >  
> > > +#define stracpy(to, from)\
> > > +({   \
> > > + size_t size = ARRAY_SIZE(to);   \
> > > + BUILD_BUG_ON(!__same_type(typeof(*to), char));  \
> > > + \
> > > + strscpy(to, from, size);\
> > > +})
> > > +
> > > +#define stracpy_pad(to, from)\
> > > +({   \
> > > + size_t size = ARRAY_SIZE(to);   \
> > > + BUILD_BUG_ON(!__same_type(typeof(*to), char));  \
> > > + \
> > > + strscpy_pad(to, from, size);\
> > > +})
> > > +
> > >  #ifndef __HAVE_ARCH_STRCAT
> > >  extern char * strcat(char *, const char *);
> > >  #endif
> > 
> > This seems like a reasonable addition, yes. I think Coccinelle might
> > actually be able to find all the existing strscpy(dst, src, sizeof(dst))
> > cases to jump-start this conversion.
> 
> I did that.  It works.  It's a lot of conversions.
> 
> $ cat str.cpy.cocci
> @@
> expression e1;
> expression e2;
> @@
> 
> - strscpy(e1, e2, sizeof(e1))
> + stracpy(e1, e2)
> 
> @@
> expression e1;
> expression e2;
> @@
> 
> - strlcpy(e1, e2, sizeof(e1))
> + stracpy(e1, e2)
> 
> > Devil's advocate: this adds yet more string handling functions... will
> > this cause even more confusion?
> 
> Documentation is good.
> Actual in-kernel use and examples better.

btw: I just ran this again and it produces:

$ spatch --in-place -sp-file str.cpy.cocci .
$ git checkout tools/
$ git diff --shortstat
 958 files changed, 2179 insertions(+), 2655 deletions(-)




Re: [RFC PATCH] string.h: Add stracpy/stracpy_pad (was: Re: [PATCH] checkpatch: Added warnings in favor of strscpy().)

2019-07-22 Thread Kees Cook
On Mon, Jul 22, 2019 at 10:58:15AM -0700, Joe Perches wrote:
> On Mon, 2019-07-22 at 10:43 -0700, Joe Perches wrote:
> > On Mon, 2019-07-22 at 10:33 -0700, Kees Cook wrote:
> > > On Thu, Jul 04, 2019 at 05:15:57PM -0700, Joe Perches wrote:
> > > > On Thu, 2019-07-04 at 13:46 -0700, Joe Perches wrote:
> > > > > On Thu, 2019-07-04 at 11:24 +0530, Nitin Gote wrote:
> > > > > > Added warnings in checkpatch.pl script to :
> > > > > > 
> > > > > > 1. Deprecate strcpy() in favor of strscpy().
> > > > > > 2. Deprecate strlcpy() in favor of strscpy().
> > > > > > 3. Deprecate strncpy() in favor of strscpy() or strscpy_pad().
> > > > > > 
> > > > > > Updated strncpy() section in Documentation/process/deprecated.rst
> > > > > > to cover strscpy_pad() case.
> > > > 
> > > > []
> > > > 
> > > > I sent a patch series for some strscpy/strlcpy misuses.
> > > > 
> > > > How about adding a macro helper to avoid the misuses like:
> > > > ---
> > > >  include/linux/string.h | 16 
> > > >  1 file changed, 16 insertions(+)
> > > > 
> > > > diff --git a/include/linux/string.h b/include/linux/string.h
> > > > index 4deb11f7976b..ef01bd6f19df 100644
> > > > --- a/include/linux/string.h
> > > > +++ b/include/linux/string.h
> > > > @@ -35,6 +35,22 @@ ssize_t strscpy(char *, const char *, size_t);
> > > >  /* Wraps calls to strscpy()/memset(), no arch specific code required */
> > > >  ssize_t strscpy_pad(char *dest, const char *src, size_t count);
> > > >  
> > > > +#define stracpy(to, from)  \
> > > > +({ \
> > > > +   size_t size = ARRAY_SIZE(to);   \
> > > > +   BUILD_BUG_ON(!__same_type(typeof(*to), char));  \
> > > > +   \
> > > > +   strscpy(to, from, size);\
> > > > +})
> > > > +
> > > > +#define stracpy_pad(to, from)  \
> > > > +({ \
> > > > +   size_t size = ARRAY_SIZE(to);   \
> > > > +   BUILD_BUG_ON(!__same_type(typeof(*to), char));  \
> > > > +   \
> > > > +   strscpy_pad(to, from, size);\
> > > > +})
> > > > +
> > > >  #ifndef __HAVE_ARCH_STRCAT
> > > >  extern char * strcat(char *, const char *);
> > > >  #endif
> > > 
> > > This seems like a reasonable addition, yes. I think Coccinelle might
> > > actually be able to find all the existing strscpy(dst, src, sizeof(dst))
> > > cases to jump-start this conversion.
> > 
> > I did that.  It works.  It's a lot of conversions.
> > 
> > $ cat str.cpy.cocci
> > @@
> > expression e1;
> > expression e2;
> > @@
> > 
> > - strscpy(e1, e2, sizeof(e1))
> > + stracpy(e1, e2)
> > 
> > @@
> > expression e1;
> > expression e2;
> > @@
> > 
> > - strlcpy(e1, e2, sizeof(e1))
> > + stracpy(e1, e2)
> > 
> > > Devil's advocate: this adds yet more string handling functions... will
> > > this cause even more confusion?
> > 
> > Documentation is good.
> > Actual in-kernel use and examples better.
> 
> btw: I just ran this again and it produces:
> 
> $ spatch --in-place -sp-file str.cpy.cocci .
> $ git checkout tools/
> $ git diff --shortstat
>  958 files changed, 2179 insertions(+), 2655 deletions(-)

Cool. Well, assuming no one hates this, let's do it. :) Can you send a
more complete patch with docs, etc? Maybe Linus will take it for late
in the next merge window, perhaps?

-- 
Kees Cook


Re: [RFC PATCH] string.h: Add stracpy/stracpy_pad (was: Re: [PATCH] checkpatch: Added warnings in favor of strscpy().)

2019-07-22 Thread Matthew Wilcox
On Mon, Jul 22, 2019 at 10:58:15AM -0700, Joe Perches wrote:
> On Mon, 2019-07-22 at 10:43 -0700, Joe Perches wrote:
> > On Mon, 2019-07-22 at 10:33 -0700, Kees Cook wrote:
> > > On Thu, Jul 04, 2019 at 05:15:57PM -0700, Joe Perches wrote:
> > > > On Thu, 2019-07-04 at 13:46 -0700, Joe Perches wrote:
> > > > > On Thu, 2019-07-04 at 11:24 +0530, Nitin Gote wrote:
> > > > > > Added warnings in checkpatch.pl script to :
> > > > > > 
> > > > > > 1. Deprecate strcpy() in favor of strscpy().
> > > > > > 2. Deprecate strlcpy() in favor of strscpy().
> > > > > > 3. Deprecate strncpy() in favor of strscpy() or strscpy_pad().
> > > > > > 
> > > > > > Updated strncpy() section in Documentation/process/deprecated.rst
> > > > > > to cover strscpy_pad() case.
> > > > 
> > > > []
> > > > 
> > > > I sent a patch series for some strscpy/strlcpy misuses.
> > > > 
> > > > How about adding a macro helper to avoid the misuses like:
> > > > ---
> > > >  include/linux/string.h | 16 
> > > >  1 file changed, 16 insertions(+)
> > > > 
> > > > diff --git a/include/linux/string.h b/include/linux/string.h
> > > > index 4deb11f7976b..ef01bd6f19df 100644
> > > > --- a/include/linux/string.h
> > > > +++ b/include/linux/string.h
> > > > @@ -35,6 +35,22 @@ ssize_t strscpy(char *, const char *, size_t);
> > > >  /* Wraps calls to strscpy()/memset(), no arch specific code required */
> > > >  ssize_t strscpy_pad(char *dest, const char *src, size_t count);
> > > >  
> > > > +#define stracpy(to, from)  \
> > > > +({ \
> > > > +   size_t size = ARRAY_SIZE(to);   \
> > > > +   BUILD_BUG_ON(!__same_type(typeof(*to), char));  \
> > > > +   \
> > > > +   strscpy(to, from, size);\
> > > > +})

Where does the 'a' in 'stracpy' come from?  Googling around finds other
people using a function called stracpy, but it takes different arguments.
http://stracpy.blogspot.com/ takes a size argument, as does
https://docs.polserver.com/doxygen/html/d5/dce/stracpy_8cpp_source.html

The one in the 'Links' webbrowser (can't find a link to its source) seems
like a strdup clone.



Re: [RFC PATCH] string.h: Add stracpy/stracpy_pad (was: Re: [PATCH] checkpatch: Added warnings in favor of strscpy().)

2019-07-22 Thread Joe Perches
On Mon, 2019-07-22 at 11:27 -0700, Matthew Wilcox wrote:
> On Mon, Jul 22, 2019 at 10:58:15AM -0700, Joe Perches wrote:
> > On Mon, 2019-07-22 at 10:43 -0700, Joe Perches wrote:
> > > On Mon, 2019-07-22 at 10:33 -0700, Kees Cook wrote:
> > > > On Thu, Jul 04, 2019 at 05:15:57PM -0700, Joe Perches wrote:
> > > > > On Thu, 2019-07-04 at 13:46 -0700, Joe Perches wrote:
[]
> > > > > +#define stracpy(to, from)\
> > > > > +({   \
> > > > > + size_t size = ARRAY_SIZE(to);   \
> > > > > + BUILD_BUG_ON(!__same_type(typeof(*to), char));  \
> > > > > + \
> > > > > + strscpy(to, from, size);\
> > > > > +})
> 
> Where does the 'a' in 'stracpy' come from?

No place in particular.

I used it because dst has to be an 'a'rray rather
than a pointer.




Re: [PATCH 07/22] docs: admin-guide: add auxdisplay files to it after conversion to ReST

2019-07-22 Thread Miguel Ojeda
On Mon, Jul 22, 2019 at 1:08 PM Mauro Carvalho Chehab
 wrote:
>
> Those two files describe userspace-faced information. While part of
> it might fit on uAPI, it sounds to me that the admin guide is the
> best place for them.

Acked-by: Miguel Ojeda 

Thanks a lot for all the work on the Docs, Mauro!

On the topic of these files: don't worry too much about these, they
are old drivers (they used the parallel port, which probably nobody
has anymore :-) so I should remove them at some point, I guess.

Cheers,
Miguel


Re: [PATCH 1/2] doc:it_IT: align translation to mainline

2019-07-22 Thread Jonathan Corbet
On Thu, 18 Jul 2019 09:47:24 +0200
Federico Vaga  wrote:

> The patch translates the following patches in Italian:
> 
> d9d7c0c497b8 docs: Note that :c:func: should no longer be used
> 83e8b971f81c sphinx.rst: Add note about code snippets embedded in the text
> cca5e0b8a430 Documentation: PGP: update for newer HW devices
> 
> Signed-off-by: Federico Vaga 

Applied (and the second one as well), thanks.

jon


Re: [PATCH] docs/vm: transhuge: fix typo in madvise reference

2019-07-22 Thread Jonathan Corbet
On Tue, 16 Jul 2019 10:49:08 -0400
Jeremy Cline  wrote:

> Fix an off-by-one typo in the transparent huge pages admin
> documentation.
> 
> Signed-off-by: Jeremy Cline 

Applied, thanks.

jon


[PATCH v1 2/2] doc: Update documentation for page_idle virtual address indexing

2019-07-22 Thread Joel Fernandes (Google)
This patch updates the documentation with the new page_idle tracking
feature which uses virtual address indexing.

Signed-off-by: Joel Fernandes (Google) 
---
 .../admin-guide/mm/idle_page_tracking.rst | 41 +++
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/Documentation/admin-guide/mm/idle_page_tracking.rst 
b/Documentation/admin-guide/mm/idle_page_tracking.rst
index df9394fb39c2..70d3bf6f1f8c 100644
--- a/Documentation/admin-guide/mm/idle_page_tracking.rst
+++ b/Documentation/admin-guide/mm/idle_page_tracking.rst
@@ -19,10 +19,14 @@ It is enabled by CONFIG_IDLE_PAGE_TRACKING=y.
 
 User API
 
+There are 2 ways to access the idle page tracking API. One uses physical
+address indexing, another uses a simpler virtual address indexing scheme.
 
-The idle page tracking API is located at ``/sys/kernel/mm/page_idle``.
-Currently, it consists of the only read-write file,
-``/sys/kernel/mm/page_idle/bitmap``.
+Physical address indexing
+-
+The idle page tracking API for physical address indexing using page frame
+numbers (PFN) is located at ``/sys/kernel/mm/page_idle``.  Currently, it
+consists of the only read-write file, ``/sys/kernel/mm/page_idle/bitmap``.
 
 The file implements a bitmap where each bit corresponds to a memory page. The
 bitmap is represented by an array of 8-byte integers, and the page at PFN #i is
@@ -74,6 +78,29 @@ See :ref:`Documentation/admin-guide/mm/pagemap.rst 
` for more
 information about ``/proc/pid/pagemap``, ``/proc/kpageflags``, and
 ``/proc/kpagecgroup``.
 
+Virtual address indexing
+
+The idle page tracking API for virtual address indexing using virtual page
+frame numbers (VFN) is located at ``/proc//page_idle``. It is a bitmap
+that follows the same semantics as ``/sys/kernel/mm/page_idle/bitmap``
+except that it uses virtual instead of physical frame numbers.
+
+This idle page tracking API can be simpler to use than physical address
+indexing, since the ``pagemap`` for a process does not need to be looked up to
+mark or read a page's idle bit. It is also more accurate than physical address
+indexing since in physical address indexing, address space changes can occur
+between reading the ``pagemap`` and reading the ``bitmap``. In virtual address
+indexing, the process's ``mmap_sem`` is held for the duration of the access.
+
+To estimate the amount of pages that are not used by a workload one should:
+
+ 1. Mark all the workload's pages as idle by setting corresponding bits in
+``/proc//page_idle``.
+
+ 2. Wait until the workload accesses its working set.
+
+ 3. Read ``/proc//page_idle`` and count the number of bits set.
+
 .. _impl_details:
 
 Implementation Details
@@ -99,10 +126,10 @@ When a dirty page is written to swap or disk as a result 
of memory reclaim or
 exceeding the dirty memory limit, it is not marked referenced.
 
 The idle memory tracking feature adds a new page flag, the Idle flag. This flag
-is set manually, by writing to ``/sys/kernel/mm/page_idle/bitmap`` (see the
-:ref:`User API `
-section), and cleared automatically whenever a page is referenced as defined
-above.
+is set manually, by writing to ``/sys/kernel/mm/page_idle/bitmap`` for physical
+addressing or by writing to ``/proc//page_idle`` for virtual
+addressing (see the :ref:`User API ` section), and cleared
+automatically whenever a page is referenced as defined above.
 
 When a page is marked idle, the Accessed bit must be cleared in all PTEs it is
 mapped to, otherwise we will not be able to detect accesses to the page coming
-- 
2.22.0.657.g960e92d24f-goog



[PATCH v1 1/2] mm/page_idle: Add support for per-pid page_idle using virtual indexing

2019-07-22 Thread Joel Fernandes (Google)
The page_idle tracking feature currently requires looking up the pagemap
for a process followed by interacting with /sys/kernel/mm/page_idle.
This is quite cumbersome and can be error-prone too. If between
accessing the per-PID pagemap and the global page_idle bitmap, if
something changes with the page then the information is not accurate.
More over looking up PFN from pagemap in Android devices is not
supported by unprivileged process and requires SYS_ADMIN and gives 0 for
the PFN.

This patch adds support to directly interact with page_idle tracking at
the PID level by introducing a /proc//page_idle file. This
eliminates the need for userspace to calculate the mapping of the page.
It follows the exact same semantics as the global
/sys/kernel/mm/page_idle, however it is easier to use for some usecases
where looking up PFN is not needed and also does not require SYS_ADMIN.
It ended up simplifying userspace code, solving the security issue
mentioned and works quite well. SELinux does not need to be turned off
since no pagemap look up is needed.

In Android, we are using this for the heap profiler (heapprofd) which
profiles and pin points code paths which allocates and leaves memory
idle for long periods of time.

Documentation material:
The idle page tracking API for virtual address indexing using virtual page
frame numbers (VFN) is located at /proc//page_idle. It is a bitmap
that follows the same semantics as /sys/kernel/mm/page_idle/bitmap
except that it uses virtual instead of physical frame numbers.

This idle page tracking API can be simpler to use than physical address
indexing, since the pagemap for a process does not need to be looked up
to mark or read a page's idle bit. It is also more accurate than
physical address indexing since in physical address indexing, address
space changes can occur between reading the pagemap and reading the
bitmap. In virtual address indexing, the process's mmap_sem is held for
the duration of the access.

Cc: vdavydov@gmail.com
Cc: Brendan Gregg 
Cc: kernel-t...@android.com
Signed-off-by: Joel Fernandes (Google) 

---
Internal review -> v1:
Fixes from Suren.
Corrections to change log, docs (Florian, Sandeep)

 fs/proc/base.c|   3 +
 fs/proc/internal.h|   1 +
 fs/proc/task_mmu.c|  57 +++
 include/linux/page_idle.h |   4 +
 mm/page_idle.c| 305 +-
 5 files changed, 330 insertions(+), 40 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 77eb628ecc7f..a58dd74606e9 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -3021,6 +3021,9 @@ static const struct pid_entry tgid_base_stuff[] = {
REG("smaps",  S_IRUGO, proc_pid_smaps_operations),
REG("smaps_rollup", S_IRUGO, proc_pid_smaps_rollup_operations),
REG("pagemap",S_IRUSR, proc_pagemap_operations),
+#ifdef CONFIG_IDLE_PAGE_TRACKING
+   REG("page_idle", S_IRUSR|S_IWUSR, proc_page_idle_operations),
+#endif
 #endif
 #ifdef CONFIG_SECURITY
DIR("attr",   S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, 
proc_attr_dir_operations),
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index cd0c8d5ce9a1..bc9371880c63 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -293,6 +293,7 @@ extern const struct file_operations 
proc_pid_smaps_operations;
 extern const struct file_operations proc_pid_smaps_rollup_operations;
 extern const struct file_operations proc_clear_refs_operations;
 extern const struct file_operations proc_pagemap_operations;
+extern const struct file_operations proc_page_idle_operations;
 
 extern unsigned long task_vsize(struct mm_struct *);
 extern unsigned long task_statm(struct mm_struct *,
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 4d2b860dbc3f..11ccc53da38e 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1642,6 +1642,63 @@ const struct file_operations proc_pagemap_operations = {
.open   = pagemap_open,
.release= pagemap_release,
 };
+
+#ifdef CONFIG_IDLE_PAGE_TRACKING
+static ssize_t proc_page_idle_read(struct file *file, char __user *buf,
+  size_t count, loff_t *ppos)
+{
+   int ret;
+   struct task_struct *tsk = get_proc_task(file_inode(file));
+
+   if (!tsk)
+   return -EINVAL;
+   ret = page_idle_proc_read(file, buf, count, ppos, tsk);
+   put_task_struct(tsk);
+   return ret;
+}
+
+static ssize_t proc_page_idle_write(struct file *file, const char __user *buf,
+size_t count, loff_t *ppos)
+{
+   int ret;
+   struct task_struct *tsk = get_proc_task(file_inode(file));
+
+   if (!tsk)
+   return -EINVAL;
+   ret = page_idle_proc_write(file, (char __user *)buf, count, ppos, tsk);
+   put_task_struct(tsk);
+   return ret;
+}
+
+static int proc_page_idle_open(struct inode *inode, struct file *file)
+{
+   struct mm_struct *mm;
+
+   mm = proc_mem_open(inode, 

Re: [PATCH v1 1/2] mm/page_idle: Add support for per-pid page_idle using virtual indexing

2019-07-22 Thread Andrew Morton
On Mon, 22 Jul 2019 17:32:04 -0400 "Joel Fernandes (Google)" 
 wrote:

> The page_idle tracking feature currently requires looking up the pagemap
> for a process followed by interacting with /sys/kernel/mm/page_idle.
> This is quite cumbersome and can be error-prone too. If between
> accessing the per-PID pagemap and the global page_idle bitmap, if
> something changes with the page then the information is not accurate.

Well, it's never going to be "accurate" - something could change one
nanosecond after userspace has read the data...

Presumably with this approach the data will be "more" accurate.  How
big a problem has this inaccuracy proven to be in real-world usage?

> More over looking up PFN from pagemap in Android devices is not
> supported by unprivileged process and requires SYS_ADMIN and gives 0 for
> the PFN.
> 
> This patch adds support to directly interact with page_idle tracking at
> the PID level by introducing a /proc//page_idle file. This
> eliminates the need for userspace to calculate the mapping of the page.
> It follows the exact same semantics as the global
> /sys/kernel/mm/page_idle, however it is easier to use for some usecases
> where looking up PFN is not needed and also does not require SYS_ADMIN.
> It ended up simplifying userspace code, solving the security issue
> mentioned and works quite well. SELinux does not need to be turned off
> since no pagemap look up is needed.
> 
> In Android, we are using this for the heap profiler (heapprofd) which
> profiles and pin points code paths which allocates and leaves memory
> idle for long periods of time.
> 
> Documentation material:
> The idle page tracking API for virtual address indexing using virtual page
> frame numbers (VFN) is located at /proc//page_idle. It is a bitmap
> that follows the same semantics as /sys/kernel/mm/page_idle/bitmap
> except that it uses virtual instead of physical frame numbers.
> 
> This idle page tracking API can be simpler to use than physical address
> indexing, since the pagemap for a process does not need to be looked up
> to mark or read a page's idle bit. It is also more accurate than
> physical address indexing since in physical address indexing, address
> space changes can occur between reading the pagemap and reading the
> bitmap. In virtual address indexing, the process's mmap_sem is held for
> the duration of the access.
> 
> ...
>
> --- a/mm/page_idle.c
> +++ b/mm/page_idle.c
> @@ -11,6 +11,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #define BITMAP_CHUNK_SIZEsizeof(u64)
>  #define BITMAP_CHUNK_BITS(BITMAP_CHUNK_SIZE * BITS_PER_BYTE)
> @@ -28,15 +29,12 @@
>   *
>   * This function tries to get a user memory page by pfn as described above.
>   */

Above comment needs updating or moving?

> -static struct page *page_idle_get_page(unsigned long pfn)
> +static struct page *page_idle_get_page(struct page *page_in)
>  {
>   struct page *page;
>   pg_data_t *pgdat;
>  
> - if (!pfn_valid(pfn))
> - return NULL;
> -
> - page = pfn_to_page(pfn);
> + page = page_in;
>   if (!page || !PageLRU(page) ||
>   !get_page_unless_zero(page))
>   return NULL;
>
> ...
>
> +static int page_idle_get_frames(loff_t pos, size_t count, struct mm_struct 
> *mm,
> + unsigned long *start, unsigned long *end)
> +{
> + unsigned long max_frame;
> +
> + /* If an mm is not given, assume we want physical frames */
> + max_frame = mm ? (mm->task_size >> PAGE_SHIFT) : max_pfn;
> +
> + if (pos % BITMAP_CHUNK_SIZE || count % BITMAP_CHUNK_SIZE)
> + return -EINVAL;
> +
> + *start = pos * BITS_PER_BYTE;
> + if (*start >= max_frame)
> + return -ENXIO;

Is said to mean "The system tried to use the device represented by a
file you specified, and it couldnt find the device.  This can mean that
the device file was installed incorrectly, or that the physical device
is missing or not correctly attached to the computer."

This doesn't seem appropriate in this usage and is hence possibly
misleading.  Someone whose application fails with ENXIO will be
scratching their heads.

> + *end = *start + count * BITS_PER_BYTE;
> + if (*end > max_frame)
> + *end = max_frame;
> + return 0;
> +}
> +
>
> ...
>
> +static void add_page_idle_list(struct page *page,
> +unsigned long addr, struct mm_walk *walk)
> +{
> + struct page *page_get;
> + struct page_node *pn;
> + int bit;
> + unsigned long frames;
> + struct page_idle_proc_priv *priv = walk->private;
> + u64 *chunk = (u64 *)priv->buffer;
> +
> + if (priv->write) {
> + /* Find whether this page was asked to be marked */
> + frames = (addr - priv->start_addr) >> PAGE_SHIFT;
> + bit = frames % BITMAP_CHUNK_BITS;
> + chunk = &chunk[frames / BITMAP_CHUNK_BITS];
> + if (((*chunk >> bit) & 1) == 0)
> +

[PATCH 2/2] kernel-doc: core-api: Include string.h into core-api

2019-07-22 Thread Joe Perches
core-api should show all the various string functions including the
newly added stracpy and stracpy_pad.

Miscellanea:

o Update the Returns: value for strscpy
o fix a defect with %NUL)

Signed-off-by: Joe Perches 
---
 Documentation/core-api/kernel-api.rst |  3 +++
 include/linux/string.h|  5 +++--
 lib/string.c  | 10 ++
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/Documentation/core-api/kernel-api.rst 
b/Documentation/core-api/kernel-api.rst
index 08af5caf036d..f77de49b1d51 100644
--- a/Documentation/core-api/kernel-api.rst
+++ b/Documentation/core-api/kernel-api.rst
@@ -42,6 +42,9 @@ String Manipulation
 .. kernel-doc:: lib/string.c
:export:
 
+.. kernel-doc:: include/linux/string.h
+   :internal:
+
 .. kernel-doc:: mm/util.c
:functions: kstrdup kstrdup_const kstrndup kmemdup kmemdup_nul memdup_user
vmemdup_user strndup_user memdup_user_nul
diff --git a/include/linux/string.h b/include/linux/string.h
index f80b0973f0e5..329188fffc11 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -515,8 +515,9 @@ static inline void memcpy_and_pad(void *dest, size_t 
dest_len,
  * But this can lead to bugs due to typos, or if prefix is a pointer
  * and not a constant. Instead use str_has_prefix().
  *
- * Returns: 0 if @str does not start with @prefix
- strlen(@prefix) if @str does start with @prefix
+ * Returns:
+ * * strlen(@prefix) if @str starts with @prefix
+ * * 0 if @str does not start with @prefix
  */
 static __always_inline size_t str_has_prefix(const char *str, const char 
*prefix)
 {
diff --git a/lib/string.c b/lib/string.c
index 461fb620f85f..53582b6dce2a 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -173,8 +173,9 @@ EXPORT_SYMBOL(strlcpy);
  * doesn't unnecessarily force the tail of the destination buffer to be
  * zeroed.  If zeroing is desired please use strscpy_pad().
  *
- * Return: The number of characters copied (not including the trailing
- * %NUL) or -E2BIG if the destination buffer wasn't big enough.
+ * Returns:
+ * * The number of characters copied (not including the trailing %NUL)
+ * * -E2BIG if count is 0.
  */
 ssize_t strscpy(char *dest, const char *src, size_t count)
 {
@@ -253,8 +254,9 @@ EXPORT_SYMBOL(strscpy);
  * For full explanation of why you may want to consider using the
  * 'strscpy' functions please see the function docstring for strscpy().
  *
- * Return: The number of characters copied (not including the trailing
- * %NUL) or -E2BIG if the destination buffer wasn't big enough.
+ * Returns:
+ * * The number of characters copied (not including the trailing %NUL)
+ * * -E2BIG if count is 0.
  */
 ssize_t strscpy_pad(char *dest, const char *src, size_t count)
 {
-- 
2.15.0



[PATCH 0/2] string: Add stracpy and stracpy_pad

2019-07-22 Thread Joe Perches
Add more string copy mechanisms to help avoid defects

Joe Perches (2):
  string: Add stracpy and stracpy_pad mechanisms
  kernel-doc: core-api: Include string.h into core-api

 Documentation/core-api/kernel-api.rst |  3 +++
 include/linux/string.h| 46 +--
 lib/string.c  | 10 +---
 3 files changed, 53 insertions(+), 6 deletions(-)

-- 
2.15.0



Re: [PATCH v2 0/2] Add CCPI2 PMU support

2019-07-22 Thread Ganapatrao Kulkarni
Hi Will,

Any further comments for this patch?

On Fri, Jul 5, 2019 at 2:43 PM Ganapatrao Kulkarni
 wrote:
>
> Add Cavium Coherent Processor Interconnect (CCPI2) PMU
> support in ThunderX2 Uncore driver.
>
> v2: Updated with review comments [1]
>
> [1] https://lkml.org/lkml/2019/6/14/965
>
> v1: initial patch
>
> Ganapatrao Kulkarni (2):
>   Documentation: perf: Update documentation for ThunderX2 PMU uncore
> driver
>   drivers/perf: Add CCPI2 PMU support in ThunderX2 UNCORE driver.
>
>  Documentation/perf/thunderx2-pmu.txt |  20 ++-
>  drivers/perf/thunderx2_pmu.c | 248 +++
>  2 files changed, 225 insertions(+), 43 deletions(-)
>
> --
> 2.17.1
>

Thanks,
Ganapat


[PATCH v3 01/12] fpga: dfl: fme: support 512bit data width PR

2019-07-22 Thread Wu Hao
In early partial reconfiguration private feature, it only
supports 32bit data width when writing data to hardware for
PR. 512bit data width PR support is an important optimization
for some specific solutions (e.g. XEON with FPGA integrated),
it allows driver to use AVX512 instruction to improve the
performance of partial reconfiguration. e.g. programming one
100MB bitstream image via this 512bit data width PR hardware
only takes ~300ms, but 32bit revision requires ~3s per test
result.

Please note now this optimization is only done on revision 2
of this PR private feature which is only used in integrated
solution that AVX512 is always supported. This revision 2
hardware doesn't support 32bit PR.

Signed-off-by: Ananda Ravuri 
Signed-off-by: Xu Yilun 
Signed-off-by: Wu Hao 
Acked-by: Alan Tull 
Signed-off-by: Moritz Fischer 
---
v2: remove DRV/MODULE_VERSION modifications
---
 drivers/fpga/dfl-fme-mgr.c | 110 ++---
 drivers/fpga/dfl-fme-pr.c  |  43 +++---
 drivers/fpga/dfl-fme.h |   2 +
 drivers/fpga/dfl.h |   5 +++
 4 files changed, 129 insertions(+), 31 deletions(-)

diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c
index b3f7eee..46e17f0 100644
--- a/drivers/fpga/dfl-fme-mgr.c
+++ b/drivers/fpga/dfl-fme-mgr.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "dfl.h"
 #include "dfl-fme-pr.h"
 
 /* FME Partial Reconfiguration Sub Feature Register Set */
@@ -30,6 +31,7 @@
 #define FME_PR_STS 0x10
 #define FME_PR_DATA0x18
 #define FME_PR_ERR 0x20
+#define FME_PR_512_DATA0x40 /* Data Register for 512bit 
datawidth PR */
 #define FME_PR_INTFC_ID_L  0xA8
 #define FME_PR_INTFC_ID_H  0xB0
 
@@ -67,8 +69,43 @@
 #define PR_WAIT_TIMEOUT   800
 #define PR_HOST_STATUS_IDLE0
 
+#if defined(CONFIG_X86) && defined(CONFIG_AS_AVX512)
+
+#include 
+#include 
+
+static inline int is_cpu_avx512_enabled(void)
+{
+   return cpu_feature_enabled(X86_FEATURE_AVX512F);
+}
+
+static inline void copy512(const void *src, void __iomem *dst)
+{
+   kernel_fpu_begin();
+
+   asm volatile("vmovdqu64 (%0), %%zmm0;"
+"vmovntdq %%zmm0, (%1);"
+:
+: "r"(src), "r"(dst)
+: "memory");
+
+   kernel_fpu_end();
+}
+#else
+static inline int is_cpu_avx512_enabled(void)
+{
+   return 0;
+}
+
+static inline void copy512(const void *src, void __iomem *dst)
+{
+   WARN_ON_ONCE(1);
+}
+#endif
+
 struct fme_mgr_priv {
void __iomem *ioaddr;
+   unsigned int pr_datawidth;
u64 pr_error;
 };
 
@@ -169,7 +206,7 @@ static int fme_mgr_write(struct fpga_manager *mgr,
struct fme_mgr_priv *priv = mgr->priv;
void __iomem *fme_pr = priv->ioaddr;
u64 pr_ctrl, pr_status, pr_data;
-   int delay = 0, pr_credit, i = 0;
+   int ret = 0, delay = 0, pr_credit;
 
dev_dbg(dev, "start request\n");
 
@@ -181,9 +218,9 @@ static int fme_mgr_write(struct fpga_manager *mgr,
 
/*
 * driver can push data to PR hardware using PR_DATA register once HW
-* has enough pr_credit (> 1), pr_credit reduces one for every 32bit
-* pr data write to PR_DATA register. If pr_credit <= 1, driver needs
-* to wait for enough pr_credit from hardware by polling.
+* has enough pr_credit (> 1), pr_credit reduces one for every pr data
+* width write to PR_DATA register. If pr_credit <= 1, driver needs to
+* wait for enough pr_credit from hardware by polling.
 */
pr_status = readq(fme_pr + FME_PR_STS);
pr_credit = FIELD_GET(FME_PR_STS_PR_CREDIT, pr_status);
@@ -192,7 +229,8 @@ static int fme_mgr_write(struct fpga_manager *mgr,
while (pr_credit <= 1) {
if (delay++ > PR_WAIT_TIMEOUT) {
dev_err(dev, "PR_CREDIT timeout\n");
-   return -ETIMEDOUT;
+   ret = -ETIMEDOUT;
+   goto done;
}
udelay(1);
 
@@ -200,21 +238,27 @@ static int fme_mgr_write(struct fpga_manager *mgr,
pr_credit = FIELD_GET(FME_PR_STS_PR_CREDIT, pr_status);
}
 
-   if (count < 4) {
-   dev_err(dev, "Invalid PR bitstream size\n");
-   return -EINVAL;
+   WARN_ON(count < priv->pr_datawidth);
+
+   switch (priv->pr_datawidth) {
+   case 4:
+   pr_data = FIELD_PREP(FME_PR_DATA_PR_DATA_RAW,
+*(u32 *)buf);
+   writeq(pr_data, fme_pr + FME_PR_DATA);
+   break;
+   case 64:
+   copy512(buf, fme_pr + FME_PR_512_DATA);
+   break;
+   default:
+   WA

[PATCH v3 06/12] fpga: dfl: add id_table for dfl private feature driver

2019-07-22 Thread Wu Hao
This patch adds id_table for each dfl private feature driver,
it allows to reuse same private feature driver to match and support
multiple dfl private features.

Signed-off-by: Xu Yilun 
Signed-off-by: Wu Hao 
Acked-by: Moritz Fischer 
Acked-by: Alan Tull 
Signed-off-by: Moritz Fischer 
---
v2: rebased, remove DRV/MODULE_VERSION modifications
---
 drivers/fpga/dfl-afu-main.c | 14 --
 drivers/fpga/dfl-fme-main.c | 11 ---
 drivers/fpga/dfl-fme-pr.c   |  7 ++-
 drivers/fpga/dfl-fme.h  |  3 ++-
 drivers/fpga/dfl.c  | 18 --
 drivers/fpga/dfl.h  | 21 +++--
 6 files changed, 59 insertions(+), 15 deletions(-)

diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c
index 9025314..fbd9553 100644
--- a/drivers/fpga/dfl-afu-main.c
+++ b/drivers/fpga/dfl-afu-main.c
@@ -435,6 +435,11 @@ static void port_hdr_uinit(struct platform_device *pdev,
return ret;
 }
 
+static const struct dfl_feature_id port_hdr_id_table[] = {
+   {.id = PORT_FEATURE_ID_HEADER,},
+   {0,}
+};
+
 static const struct dfl_feature_ops port_hdr_ops = {
.init = port_hdr_init,
.uinit = port_hdr_uinit,
@@ -496,6 +501,11 @@ static void port_afu_uinit(struct platform_device *pdev,
device_remove_groups(&pdev->dev, port_afu_groups);
 }
 
+static const struct dfl_feature_id port_afu_id_table[] = {
+   {.id = PORT_FEATURE_ID_AFU,},
+   {0,}
+};
+
 static const struct dfl_feature_ops port_afu_ops = {
.init = port_afu_init,
.uinit = port_afu_uinit,
@@ -503,11 +513,11 @@ static void port_afu_uinit(struct platform_device *pdev,
 
 static struct dfl_feature_driver port_feature_drvs[] = {
{
-   .id = PORT_FEATURE_ID_HEADER,
+   .id_table = port_hdr_id_table,
.ops = &port_hdr_ops,
},
{
-   .id = PORT_FEATURE_ID_AFU,
+   .id_table = port_afu_id_table,
.ops = &port_afu_ops,
},
{
diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c
index e61e0fe..e333f19 100644
--- a/drivers/fpga/dfl-fme-main.c
+++ b/drivers/fpga/dfl-fme-main.c
@@ -133,6 +133,11 @@ static long fme_hdr_ioctl(struct platform_device *pdev,
return -ENODEV;
 }
 
+static const struct dfl_feature_id fme_hdr_id_table[] = {
+   {.id = FME_FEATURE_ID_HEADER,},
+   {0,}
+};
+
 static const struct dfl_feature_ops fme_hdr_ops = {
.init = fme_hdr_init,
.uinit = fme_hdr_uinit,
@@ -141,12 +146,12 @@ static long fme_hdr_ioctl(struct platform_device *pdev,
 
 static struct dfl_feature_driver fme_feature_drvs[] = {
{
-   .id = FME_FEATURE_ID_HEADER,
+   .id_table = fme_hdr_id_table,
.ops = &fme_hdr_ops,
},
{
-   .id = FME_FEATURE_ID_PR_MGMT,
-   .ops = &pr_mgmt_ops,
+   .id_table = fme_pr_mgmt_id_table,
+   .ops = &fme_pr_mgmt_ops,
},
{
.ops = NULL,
diff --git a/drivers/fpga/dfl-fme-pr.c b/drivers/fpga/dfl-fme-pr.c
index cd94ba8..52f1745 100644
--- a/drivers/fpga/dfl-fme-pr.c
+++ b/drivers/fpga/dfl-fme-pr.c
@@ -483,7 +483,12 @@ static long fme_pr_ioctl(struct platform_device *pdev,
return ret;
 }
 
-const struct dfl_feature_ops pr_mgmt_ops = {
+const struct dfl_feature_id fme_pr_mgmt_id_table[] = {
+   {.id = FME_FEATURE_ID_PR_MGMT,},
+   {0}
+};
+
+const struct dfl_feature_ops fme_pr_mgmt_ops = {
.init = pr_mgmt_init,
.uinit = pr_mgmt_uinit,
.ioctl = fme_pr_ioctl,
diff --git a/drivers/fpga/dfl-fme.h b/drivers/fpga/dfl-fme.h
index de20755..7a021c4 100644
--- a/drivers/fpga/dfl-fme.h
+++ b/drivers/fpga/dfl-fme.h
@@ -35,6 +35,7 @@ struct dfl_fme {
struct dfl_feature_platform_data *pdata;
 };
 
-extern const struct dfl_feature_ops pr_mgmt_ops;
+extern const struct dfl_feature_ops fme_pr_mgmt_ops;
+extern const struct dfl_feature_id fme_pr_mgmt_id_table[];
 
 #endif /* __DFL_FME_H */
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index c3a8e1d..3eb67ab 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -281,6 +281,21 @@ static int dfl_feature_instance_init(struct 
platform_device *pdev,
return ret;
 }
 
+static bool dfl_feature_drv_match(struct dfl_feature *feature,
+ struct dfl_feature_driver *driver)
+{
+   const struct dfl_feature_id *ids = driver->id_table;
+
+   if (ids) {
+   while (ids->id) {
+   if (ids->id == feature->id)
+   return true;
+   ids++;
+   }
+   }
+   return false;
+}
+
 /**
  * dfl_fpga_dev_feature_init - init for sub features of dfl feature device
  * @pdev: feature device.
@@ -301,8 +316,7 @@ int dfl_fpga_dev_feature_init(struct platform_device *pdev,
 
while (drv->ops) {
dfl_fpga_dev_for_each_feature(pdata,

[PATCH v3 00/12] FPGA DFL updates

2019-07-22 Thread Wu Hao
Hi Greg

This is v3 patchset which adds more features to FPGA DFL. This patchset
is made on top of patch[1] and 5.3-rc1 tree. Documentation patch for DFL
is added back to this patchset

Main changes from v2:
  - update kernel version/date in sysfs doc (patch #4, #5, #8, #10, #11).
  - add back Documentation patch (patch #12).

Main changes from v1:
  - remove DRV/MODULE_VERSION modifications. (patch #1, #3, #4, #6)
  - remove argsz from new ioctls. (patch #2)
  - replace sysfs_create/remove_* with device_add/remove_* for sysfs entries.
(patch #5, #8, #11)

[1] [PATCH] fpga: dfl: use driver core functions, not sysfs ones.
https://lkml.org/lkml/2019/7/4/36

Wu Hao (12):
  fpga: dfl: fme: support 512bit data width PR
  fpga: dfl: fme: add DFL_FPGA_FME_PORT_RELEASE/ASSIGN ioctl support.
  fpga: dfl: pci: enable SRIOV support.
  fpga: dfl: afu: add AFU state related sysfs interfaces
  fpga: dfl: afu: add userclock sysfs interfaces.
  fpga: dfl: add id_table for dfl private feature driver
  fpga: dfl: afu: export __port_enable/disable function.
  fpga: dfl: afu: add error reporting support.
  fpga: dfl: afu: add STP (SignalTap) support
  fpga: dfl: fme: add capability sysfs interfaces
  fpga: dfl: fme: add global error reporting support
  Documentation: fpga: dfl: add descriptions for virtualization and new
interfaces.

 Documentation/ABI/testing/sysfs-platform-dfl-fme  |  98 ++
 Documentation/ABI/testing/sysfs-platform-dfl-port | 104 ++
 Documentation/fpga/dfl.rst| 105 ++
 drivers/fpga/Makefile |   3 +-
 drivers/fpga/dfl-afu-error.c  | 225 +
 drivers/fpga/dfl-afu-main.c   | 328 +-
 drivers/fpga/dfl-afu.h|   7 +
 drivers/fpga/dfl-fme-error.c  | 385 ++
 drivers/fpga/dfl-fme-main.c   |  93 +-
 drivers/fpga/dfl-fme-mgr.c| 110 ++-
 drivers/fpga/dfl-fme-pr.c |  50 ++-
 drivers/fpga/dfl-fme.h|   7 +-
 drivers/fpga/dfl-pci.c|  39 +++
 drivers/fpga/dfl.c| 166 +-
 drivers/fpga/dfl.h|  54 ++-
 include/uapi/linux/fpga-dfl.h |  19 ++
 16 files changed, 1722 insertions(+), 71 deletions(-)
 create mode 100644 drivers/fpga/dfl-afu-error.c
 create mode 100644 drivers/fpga/dfl-fme-error.c

-- 
1.8.3.1



[PATCH v3 05/12] fpga: dfl: afu: add userclock sysfs interfaces.

2019-07-22 Thread Wu Hao
This patch introduces userclock sysfs interfaces for AFU, user
could use these interfaces for clock setting to AFU.

Please note that, this is only working for port header feature
with revision 0, for later revisions, userclock setting is moved
to a separated private feature, so one revision sysfs interface
is exposed to userspace application for this purpose too.

Signed-off-by: Ananda Ravuri 
Signed-off-by: Russ Weight 
Signed-off-by: Xu Yilun 
Signed-off-by: Wu Hao 
Acked-by: Alan Tull 
Signed-off-by: Moritz Fischer 
---
v2: rebased, and switched to use device_add/remove_groups for sysfs
v3: update kernel version and date in sysfs doc
---
 Documentation/ABI/testing/sysfs-platform-dfl-port |  35 +++
 drivers/fpga/dfl-afu-main.c   | 114 +-
 drivers/fpga/dfl.h|   4 +
 3 files changed, 152 insertions(+), 1 deletion(-)

diff --git a/Documentation/ABI/testing/sysfs-platform-dfl-port 
b/Documentation/ABI/testing/sysfs-platform-dfl-port
index 5961fb2..f641807 100644
--- a/Documentation/ABI/testing/sysfs-platform-dfl-port
+++ b/Documentation/ABI/testing/sysfs-platform-dfl-port
@@ -44,3 +44,38 @@ Contact: Wu Hao 
 Description:   Read-write. Read and set AFU latency tolerance reporting value.
Set ltr to 1 if the AFU can tolerate latency >= 40us or set it
to 0 if it is latency sensitive.
+
+What:  /sys/bus/platform/devices/dfl-port.0/revision
+Date:  July 2019
+KernelVersion: 5.4
+Contact:   Wu Hao 
+Description:   Read-only. Read this file to get the revision of port header
+   feature.
+
+What:  /sys/bus/platform/devices/dfl-port.0/userclk_freqcmd
+Date:  July 2019
+KernelVersion: 5.4
+Contact:   Wu Hao 
+Description:   Write-only. User writes command to this interface to set
+   userclock to AFU.
+
+What:  /sys/bus/platform/devices/dfl-port.0/userclk_freqsts
+Date:  July 2019
+KernelVersion: 5.4
+Contact:   Wu Hao 
+Description:   Read-only. Read this file to get the status of issued command
+   to userclck_freqcmd.
+
+What:  /sys/bus/platform/devices/dfl-port.0/userclk_freqcntrcmd
+Date:  July 2019
+KernelVersion: 5.4
+Contact:   Wu Hao 
+Description:   Write-only. User writes command to this interface to set
+   userclock counter.
+
+What:  /sys/bus/platform/devices/dfl-port.0/userclk_freqcntrsts
+Date:  July 2019
+KernelVersion: 5.4
+Contact:   Wu Hao 
+Description:   Read-only. Read this file to get the status of issued command
+   to userclck_freqcntrcmd.
diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c
index cb3f73e..9025314 100644
--- a/drivers/fpga/dfl-afu-main.c
+++ b/drivers/fpga/dfl-afu-main.c
@@ -142,6 +142,17 @@ static int port_get_id(struct platform_device *pdev)
 static DEVICE_ATTR_RO(id);
 
 static ssize_t
+revision_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   void __iomem *base;
+
+   base = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_HEADER);
+
+   return sprintf(buf, "%x\n", dfl_feature_revision(base));
+}
+static DEVICE_ATTR_RO(revision);
+
+static ssize_t
 ltr_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
@@ -276,6 +287,7 @@ static int port_get_id(struct platform_device *pdev)
 
 static struct attribute *port_hdr_attrs[] = {
&dev_attr_id.attr,
+   &dev_attr_revision.attr,
&dev_attr_ltr.attr,
&dev_attr_ap1_event.attr,
&dev_attr_ap2_event.attr,
@@ -284,14 +296,113 @@ static int port_get_id(struct platform_device *pdev)
 };
 ATTRIBUTE_GROUPS(port_hdr);
 
+static ssize_t
+userclk_freqcmd_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+   struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
+   u64 userclk_freq_cmd;
+   void __iomem *base;
+
+   if (kstrtou64(buf, 0, &userclk_freq_cmd))
+   return -EINVAL;
+
+   base = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_HEADER);
+
+   mutex_lock(&pdata->lock);
+   writeq(userclk_freq_cmd, base + PORT_HDR_USRCLK_CMD0);
+   mutex_unlock(&pdata->lock);
+
+   return count;
+}
+static DEVICE_ATTR_WO(userclk_freqcmd);
+
+static ssize_t
+userclk_freqcntrcmd_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+   struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
+   u64 userclk_freqcntr_cmd;
+   void __iomem *base;
+
+   if (kstrtou64(buf, 0, &userclk_freqcntr_cmd))
+   return -EINVAL;
+
+   base = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_HEADER);
+
+   mutex_lock(&pdata->lock);
+   writeq(userclk_freqcntr_cmd, base + PORT_HDR_USRCLK_CMD1);

[PATCH v3 03/12] fpga: dfl: pci: enable SRIOV support.

2019-07-22 Thread Wu Hao
This patch enables the standard sriov support. It allows user to
enable SRIOV (and VFs), then user could pass through accelerators
(VFs) into virtual machine or use VFs directly in host.

Signed-off-by: Zhang Yi Z 
Signed-off-by: Xu Yilun 
Signed-off-by: Wu Hao 
Acked-by: Alan Tull 
Acked-by: Moritz Fischer 
Signed-off-by: Moritz Fischer 
---
v2: remove DRV/MODULE_VERSION modifications.
---
 drivers/fpga/dfl-pci.c | 39 +++
 drivers/fpga/dfl.c | 41 +
 drivers/fpga/dfl.h |  1 +
 3 files changed, 81 insertions(+)

diff --git a/drivers/fpga/dfl-pci.c b/drivers/fpga/dfl-pci.c
index 66b5720..0e65d81 100644
--- a/drivers/fpga/dfl-pci.c
+++ b/drivers/fpga/dfl-pci.c
@@ -223,8 +223,46 @@ int cci_pci_probe(struct pci_dev *pcidev, const struct 
pci_device_id *pcidevid)
return ret;
 }
 
+static int cci_pci_sriov_configure(struct pci_dev *pcidev, int num_vfs)
+{
+   struct cci_drvdata *drvdata = pci_get_drvdata(pcidev);
+   struct dfl_fpga_cdev *cdev = drvdata->cdev;
+   int ret = 0;
+
+   mutex_lock(&cdev->lock);
+
+   if (!num_vfs) {
+   /*
+* disable SRIOV and then put released ports back to default
+* PF access mode.
+*/
+   pci_disable_sriov(pcidev);
+
+   __dfl_fpga_cdev_config_port_vf(cdev, false);
+
+   } else if (cdev->released_port_num == num_vfs) {
+   /*
+* only enable SRIOV if cdev has matched released ports, put
+* released ports into VF access mode firstly.
+*/
+   __dfl_fpga_cdev_config_port_vf(cdev, true);
+
+   ret = pci_enable_sriov(pcidev, num_vfs);
+   if (ret)
+   __dfl_fpga_cdev_config_port_vf(cdev, false);
+   } else {
+   ret = -EINVAL;
+   }
+
+   mutex_unlock(&cdev->lock);
+   return ret;
+}
+
 static void cci_pci_remove(struct pci_dev *pcidev)
 {
+   if (dev_is_pf(&pcidev->dev))
+   cci_pci_sriov_configure(pcidev, 0);
+
cci_remove_feature_devs(pcidev);
pci_disable_pcie_error_reporting(pcidev);
 }
@@ -234,6 +272,7 @@ static void cci_pci_remove(struct pci_dev *pcidev)
.id_table = cci_pcie_id_tbl,
.probe = cci_pci_probe,
.remove = cci_pci_remove,
+   .sriov_configure = cci_pci_sriov_configure,
 };
 
 module_pci_driver(cci_pci_driver);
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index e04ed45..c3a8e1d 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -1112,6 +1112,47 @@ int dfl_fpga_cdev_config_port(struct dfl_fpga_cdev 
*cdev, int port_id,
 }
 EXPORT_SYMBOL_GPL(dfl_fpga_cdev_config_port);
 
+static void config_port_vf(struct device *fme_dev, int port_id, bool is_vf)
+{
+   void __iomem *base;
+   u64 v;
+
+   base = dfl_get_feature_ioaddr_by_id(fme_dev, FME_FEATURE_ID_HEADER);
+
+   v = readq(base + FME_HDR_PORT_OFST(port_id));
+
+   v &= ~FME_PORT_OFST_ACC_CTRL;
+   v |= FIELD_PREP(FME_PORT_OFST_ACC_CTRL,
+   is_vf ? FME_PORT_OFST_ACC_VF : FME_PORT_OFST_ACC_PF);
+
+   writeq(v, base + FME_HDR_PORT_OFST(port_id));
+}
+
+/**
+ * __dfl_fpga_cdev_config_port_vf - configure port to VF access mode
+ *
+ * @cdev: parent container device.
+ * @if_vf: true for VF access mode, and false for PF access mode
+ *
+ * Return: 0 on success, negative error code otherwise.
+ *
+ * This function is needed in sriov configuration routine. It could be used to
+ * configures the released ports access mode to VF or PF.
+ * The caller needs to hold lock for protection.
+ */
+void __dfl_fpga_cdev_config_port_vf(struct dfl_fpga_cdev *cdev, bool is_vf)
+{
+   struct dfl_feature_platform_data *pdata;
+
+   list_for_each_entry(pdata, &cdev->port_dev_list, node) {
+   if (device_is_registered(&pdata->dev->dev))
+   continue;
+
+   config_port_vf(cdev->fme_dev, pdata->id, is_vf);
+   }
+}
+EXPORT_SYMBOL_GPL(__dfl_fpga_cdev_config_port_vf);
+
 static int __init dfl_fpga_init(void)
 {
int ret;
diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h
index d700ee9..061ccd4 100644
--- a/drivers/fpga/dfl.h
+++ b/drivers/fpga/dfl.h
@@ -421,5 +421,6 @@ struct platform_device *
 
 int dfl_fpga_cdev_config_port(struct dfl_fpga_cdev *cdev,
  int port_id, bool release);
+void __dfl_fpga_cdev_config_port_vf(struct dfl_fpga_cdev *cdev, bool is_vf);
 
 #endif /* __FPGA_DFL_H */
-- 
1.8.3.1



[PATCH v3 10/12] fpga: dfl: fme: add capability sysfs interfaces

2019-07-22 Thread Wu Hao
This patch adds 3 read-only sysfs interfaces for FPGA Management Engine
(FME) block for capabilities including cache_size, fabric_version and
socket_id.

Signed-off-by: Luwei Kang 
Signed-off-by: Xu Yilun 
Signed-off-by: Wu Hao 
Acked-by: Alan Tull 
Signed-off-by: Moritz Fischer 
---
v2: rebased.
v3: update kernel version and date in sysfs doc
---
 Documentation/ABI/testing/sysfs-platform-dfl-fme | 23 
 drivers/fpga/dfl-fme-main.c  | 48 
 2 files changed, 71 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-platform-dfl-fme 
b/Documentation/ABI/testing/sysfs-platform-dfl-fme
index 8fa4feb..269e807 100644
--- a/Documentation/ABI/testing/sysfs-platform-dfl-fme
+++ b/Documentation/ABI/testing/sysfs-platform-dfl-fme
@@ -21,3 +21,26 @@ Contact: Wu Hao 
 Description:   Read-only. It returns Bitstream (static FPGA region) meta
data, which includes the synthesis date, seed and other
information of this static FPGA region.
+
+What:  /sys/bus/platform/devices/dfl-fme.0/cache_size
+Date:  July 2019
+KernelVersion:  5.4
+Contact:   Wu Hao 
+Description:   Read-only. It returns cache size of this FPGA device.
+
+What:  /sys/bus/platform/devices/dfl-fme.0/fabric_version
+Date:  July 2019
+KernelVersion:  5.4
+Contact:   Wu Hao 
+Description:   Read-only. It returns fabric version of this FPGA device.
+   Userspace applications need this information to select
+   best data channels per different fabric design.
+
+What:  /sys/bus/platform/devices/dfl-fme.0/socket_id
+Date:  July 2019
+KernelVersion:  5.4
+Contact:   Wu Hao 
+Description:   Read-only. It returns socket_id to indicate which socket
+   this FPGA belongs to, only valid for integrated solution.
+   User only needs this information, in case standard numa node
+   can't provide correct information.
diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c
index e333f19..c8703c4 100644
--- a/drivers/fpga/dfl-fme-main.c
+++ b/drivers/fpga/dfl-fme-main.c
@@ -73,10 +73,58 @@ static ssize_t bitstream_metadata_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(bitstream_metadata);
 
+static ssize_t cache_size_show(struct device *dev,
+  struct device_attribute *attr, char *buf)
+{
+   void __iomem *base;
+   u64 v;
+
+   base = dfl_get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER);
+
+   v = readq(base + FME_HDR_CAP);
+
+   return sprintf(buf, "%u\n",
+  (unsigned int)FIELD_GET(FME_CAP_CACHE_SIZE, v));
+}
+static DEVICE_ATTR_RO(cache_size);
+
+static ssize_t fabric_version_show(struct device *dev,
+  struct device_attribute *attr, char *buf)
+{
+   void __iomem *base;
+   u64 v;
+
+   base = dfl_get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER);
+
+   v = readq(base + FME_HDR_CAP);
+
+   return sprintf(buf, "%u\n",
+  (unsigned int)FIELD_GET(FME_CAP_FABRIC_VERID, v));
+}
+static DEVICE_ATTR_RO(fabric_version);
+
+static ssize_t socket_id_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+   void __iomem *base;
+   u64 v;
+
+   base = dfl_get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER);
+
+   v = readq(base + FME_HDR_CAP);
+
+   return sprintf(buf, "%u\n",
+  (unsigned int)FIELD_GET(FME_CAP_SOCKET_ID, v));
+}
+static DEVICE_ATTR_RO(socket_id);
+
 static struct attribute *fme_hdr_attrs[] = {
&dev_attr_ports_num.attr,
&dev_attr_bitstream_id.attr,
&dev_attr_bitstream_metadata.attr,
+   &dev_attr_cache_size.attr,
+   &dev_attr_fabric_version.attr,
+   &dev_attr_socket_id.attr,
NULL,
 };
 ATTRIBUTE_GROUPS(fme_hdr);
-- 
1.8.3.1



[PATCH v3 12/12] Documentation: fpga: dfl: add descriptions for virtualization and new interfaces.

2019-07-22 Thread Wu Hao
This patch adds virtualization support description for DFL based
FPGA devices (based on PCIe SRIOV), and introductions to new
interfaces added by new dfl private feature drivers.

[m...@kernel.org: Fixed up to make it work with new reStructuredText docs]
Signed-off-by: Xu Yilun 
Signed-off-by: Wu Hao 
Acked-by: Alan Tull 
Signed-off-by: Moritz Fischer 
---
 Documentation/fpga/dfl.rst | 105 +
 1 file changed, 105 insertions(+)

diff --git a/Documentation/fpga/dfl.rst b/Documentation/fpga/dfl.rst
index 2f125ab..6fa483f 100644
--- a/Documentation/fpga/dfl.rst
+++ b/Documentation/fpga/dfl.rst
@@ -87,6 +87,8 @@ The following functions are exposed through ioctls:
 - Get driver API version (DFL_FPGA_GET_API_VERSION)
 - Check for extensions (DFL_FPGA_CHECK_EXTENSION)
 - Program bitstream (DFL_FPGA_FME_PORT_PR)
+- Assign port to PF (DFL_FPGA_FME_PORT_ASSIGN)
+- Release port from PF (DFL_FPGA_FME_PORT_RELEASE)
 
 More functions are exposed through sysfs
 (/sys/class/fpga_region/regionX/dfl-fme.n/):
@@ -102,6 +104,10 @@ More functions are exposed through sysfs
  one FPGA device may have more than one port, this sysfs interface 
indicates
  how many ports the FPGA device has.
 
+ Global error reporting management (errors/)
+ error reporting sysfs interfaces allow user to read errors detected by the
+ hardware, and clear the logged errors.
+
 
 FIU - PORT
 ==
@@ -143,6 +149,10 @@ More functions are exposed through sysfs:
  Read Accelerator GUID (afu_id)
  afu_id indicates which PR bitstream is programmed to this AFU.
 
+ Error reporting (errors/)
+ error reporting sysfs interfaces allow user to read port/afu errors
+ detected by the hardware, and clear the logged errors.
+
 
 DFL Framework Overview
 ==
@@ -218,6 +228,101 @@ the compat_id exposed by the target FPGA region. This 
check is usually done by
 userspace before calling the reconfiguration IOCTL.
 
 
+FPGA virtualization - PCIe SRIOV
+
+This section describes the virtualization support on DFL based FPGA device to
+enable accessing an accelerator from applications running in a virtual machine
+(VM). This section only describes the PCIe based FPGA device with SRIOV 
support.
+
+Features supported by the particular FPGA device are exposed through Device
+Feature Lists, as illustrated below:
+
+::
+
++---+  +-+
+|  PF   |  | VF  |
++---+  +-+
+^^ ^  ^
+|| |  |
+  +-||-|--|---+
+  | || |  |   |
+  |  +-+ +---+ +---+  +---+   |
+  |  | FME | | Port0 | | Port1 |  | Port2 |   |
+  |  +-+ +---+ +---+  +---+   |
+  |  ^ ^  ^   |
+  |  | |  |   |
+  |  +---+ +--+   +---+   |
+  |  |  AFU  | |  AFU |   |  AFU  |   |
+  |  +---+ +--+   +---+   |
+  |   |
+  |DFL based FPGA PCIe Device |
+  +---+
+
+FME is always accessed through the physical function (PF).
+
+Ports (and related AFUs) are accessed via PF by default, but could be exposed
+through virtual function (VF) devices via PCIe SRIOV. Each VF only contains
+1 Port and 1 AFU for isolation. Users could assign individual VFs 
(accelerators)
+created via PCIe SRIOV interface, to virtual machines.
+
+The driver organization in virtualization case is illustrated below:
+::
+
++---++--++--+ |
+| FME   || FME  || FME  | |
+| FPGA  || FPGA || FPGA | |
+|Manager||Bridge||Region| |
++---++--++--+ |
++---+  ++ | ++
+|  FME  |  |  AFU   | | |  AFU   |
+| Module|  | Module | | | Module |
++---+  ++ | ++
+  +---+   |   +---+
+  | FPGA Container Device |   |   | FPGA Container Device |
+  |  (FPGA Base Region)   |   |   |  (FPGA Base Region)   |
+  +---+   |   +---+
++--+  | +--+
+| FPGA PCIE Module |  | Virtual | FPGA PCIE Module |
++--+   Host   | Machine +--+
+   -- | --
+ +---+

[PATCH v3 08/12] fpga: dfl: afu: add error reporting support.

2019-07-22 Thread Wu Hao
Error reporting is one important private feature, it reports error
detected on port and accelerated function unit (AFU). It introduces
several sysfs interfaces to allow userspace to check and clear
errors detected by hardware.

Signed-off-by: Xu Yilun 
Signed-off-by: Wu Hao 
Acked-by: Alan Tull 
Signed-off-by: Moritz Fischer 
---
v2: switch to device_add/remove_group for sysfs.
v3: update kernel version and date in sysfs doc
---
 Documentation/ABI/testing/sysfs-platform-dfl-port |  39 
 drivers/fpga/Makefile |   1 +
 drivers/fpga/dfl-afu-error.c  | 225 ++
 drivers/fpga/dfl-afu-main.c   |   4 +
 drivers/fpga/dfl-afu.h|   4 +
 5 files changed, 273 insertions(+)
 create mode 100644 drivers/fpga/dfl-afu-error.c

diff --git a/Documentation/ABI/testing/sysfs-platform-dfl-port 
b/Documentation/ABI/testing/sysfs-platform-dfl-port
index f641807..03740c2 100644
--- a/Documentation/ABI/testing/sysfs-platform-dfl-port
+++ b/Documentation/ABI/testing/sysfs-platform-dfl-port
@@ -79,3 +79,42 @@ KernelVersion:   5.4
 Contact:   Wu Hao 
 Description:   Read-only. Read this file to get the status of issued command
to userclck_freqcntrcmd.
+
+What:  /sys/bus/platform/devices/dfl-port.0/errors/revision
+Date:  July 2019
+KernelVersion: 5.4
+Contact:   Wu Hao 
+Description:   Read-only. Read this file to get the revision of this error
+   reporting private feature.
+
+What:  /sys/bus/platform/devices/dfl-port.0/errors/errors
+Date:  July 2019
+KernelVersion: 5.4
+Contact:   Wu Hao 
+Description:   Read-only. Read this file to get errors detected on port and
+   Accelerated Function Unit (AFU).
+
+What:  /sys/bus/platform/devices/dfl-port.0/errors/first_error
+Date:  July 2019
+KernelVersion: 5.4
+Contact:   Wu Hao 
+Description:   Read-only. Read this file to get the first error detected by
+   hardware.
+
+What:  /sys/bus/platform/devices/dfl-port.0/errors/first_malformed_req
+Date:  July 2019
+KernelVersion: 5.4
+Contact:   Wu Hao 
+Description:   Read-only. Read this file to get the first malformed request
+   captured by hardware.
+
+What:  /sys/bus/platform/devices/dfl-port.0/errors/clear
+Date:  July 2019
+KernelVersion: 5.4
+Contact:   Wu Hao 
+Description:   Write-only. Write error code to this file to clear errors.
+   Write fails with -EINVAL if input parsing fails or input error
+   code doesn't match.
+   Write fails with -EBUSY or -ETIMEDOUT if error can't be cleared
+   as hardware is in low power state (-EBUSY) or not responding
+   (-ETIMEDOUT).
diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile
index 312b937..7255891 100644
--- a/drivers/fpga/Makefile
+++ b/drivers/fpga/Makefile
@@ -41,6 +41,7 @@ obj-$(CONFIG_FPGA_DFL_AFU)+= dfl-afu.o
 
 dfl-fme-objs := dfl-fme-main.o dfl-fme-pr.o
 dfl-afu-objs := dfl-afu-main.o dfl-afu-region.o dfl-afu-dma-region.o
+dfl-afu-objs += dfl-afu-error.o
 
 # Drivers for FPGAs which implement DFL
 obj-$(CONFIG_FPGA_DFL_PCI) += dfl-pci.o
diff --git a/drivers/fpga/dfl-afu-error.c b/drivers/fpga/dfl-afu-error.c
new file mode 100644
index 000..9649da8
--- /dev/null
+++ b/drivers/fpga/dfl-afu-error.c
@@ -0,0 +1,225 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Driver for FPGA Accelerated Function Unit (AFU) Error Reporting
+ *
+ * Copyright 2019 Intel Corporation, Inc.
+ *
+ * Authors:
+ *   Wu Hao 
+ *   Xiao Guangrong 
+ *   Joseph Grecco 
+ *   Enno Luebbers 
+ *   Tim Whisonant 
+ *   Ananda Ravuri 
+ *   Mitchel Henry 
+ */
+
+#include 
+
+#include "dfl-afu.h"
+
+#define PORT_ERROR_MASK0x8
+#define PORT_ERROR 0x10
+#define PORT_FIRST_ERROR   0x18
+#define PORT_MALFORMED_REQ00x20
+#define PORT_MALFORMED_REQ10x28
+
+#define ERROR_MASK GENMASK_ULL(63, 0)
+
+/* mask or unmask port errors by the error mask register. */
+static void __port_err_mask(struct device *dev, bool mask)
+{
+   void __iomem *base;
+
+   base = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_ERROR);
+
+   writeq(mask ? ERROR_MASK : 0, base + PORT_ERROR_MASK);
+}
+
+/* clear port errors. */
+static int __port_err_clear(struct device *dev, u64 err)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   void __iomem *base_err, *base_hdr;
+   int ret;
+   u64 v;
+
+   base_err = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_ERROR);
+   base_hdr = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_HEADER);
+
+   /*
+* clear Port Errors
+*
+* - Check for AP6 State
+* - Halt Port by keeping Port in reset
+* - Set PORT Error mask to all 1 to mask errors
+* - Clear all errors
+* 

[PATCH v3 09/12] fpga: dfl: afu: add STP (SignalTap) support

2019-07-22 Thread Wu Hao
STP (SignalTap) is one of the private features under the port for
debugging. This patch adds private feature driver support for it
to allow userspace applications to mmap related mmio region and
provide STP service.

Signed-off-by: Xu Yilun 
Signed-off-by: Wu Hao 
Acked-by: Moritz Fischer 
Acked-by: Alan Tull 
Signed-off-by: Moritz Fischer 
---
 drivers/fpga/dfl-afu-main.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c
index 15dd4cb..395f96e 100644
--- a/drivers/fpga/dfl-afu-main.c
+++ b/drivers/fpga/dfl-afu-main.c
@@ -514,6 +514,36 @@ static void port_afu_uinit(struct platform_device *pdev,
.uinit = port_afu_uinit,
 };
 
+static int port_stp_init(struct platform_device *pdev,
+struct dfl_feature *feature)
+{
+   struct resource *res = &pdev->resource[feature->resource_index];
+
+   dev_dbg(&pdev->dev, "PORT STP Init.\n");
+
+   return afu_mmio_region_add(dev_get_platdata(&pdev->dev),
+  DFL_PORT_REGION_INDEX_STP,
+  resource_size(res), res->start,
+  DFL_PORT_REGION_MMAP | DFL_PORT_REGION_READ |
+  DFL_PORT_REGION_WRITE);
+}
+
+static void port_stp_uinit(struct platform_device *pdev,
+  struct dfl_feature *feature)
+{
+   dev_dbg(&pdev->dev, "PORT STP UInit.\n");
+}
+
+static const struct dfl_feature_id port_stp_id_table[] = {
+   {.id = PORT_FEATURE_ID_STP,},
+   {0,}
+};
+
+static const struct dfl_feature_ops port_stp_ops = {
+   .init = port_stp_init,
+   .uinit = port_stp_uinit,
+};
+
 static struct dfl_feature_driver port_feature_drvs[] = {
{
.id_table = port_hdr_id_table,
@@ -528,6 +558,10 @@ static void port_afu_uinit(struct platform_device *pdev,
.ops = &port_err_ops,
},
{
+   .id_table = port_stp_id_table,
+   .ops = &port_stp_ops,
+   },
+   {
.ops = NULL,
}
 };
-- 
1.8.3.1



[PATCH v3 07/12] fpga: dfl: afu: export __port_enable/disable function.

2019-07-22 Thread Wu Hao
As these two functions are used by other private features. e.g.
in error reporting private feature, it requires to check port status
and reset port for error clearing.

Signed-off-by: Xu Yilun 
Signed-off-by: Wu Hao 
Acked-by: Moritz Fischer 
Acked-by: Alan Tull 
Signed-off-by: Moritz Fischer 
---
v2: rebased.
---
 drivers/fpga/dfl-afu-main.c | 25 ++---
 drivers/fpga/dfl-afu.h  |  3 +++
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c
index fbd9553..22d294b 100644
--- a/drivers/fpga/dfl-afu-main.c
+++ b/drivers/fpga/dfl-afu-main.c
@@ -22,14 +22,16 @@
 #include "dfl-afu.h"
 
 /**
- * port_enable - enable a port
+ * __port_enable - enable a port
  * @pdev: port platform device.
  *
  * Enable Port by clear the port soft reset bit, which is set by default.
  * The AFU is unable to respond to any MMIO access while in reset.
- * port_enable function should only be used after port_disable function.
+ * __port_enable function should only be used after __port_disable function.
+ *
+ * The caller needs to hold lock for protection.
  */
-static void port_enable(struct platform_device *pdev)
+void __port_enable(struct platform_device *pdev)
 {
struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
void __iomem *base;
@@ -52,13 +54,14 @@ static void port_enable(struct platform_device *pdev)
 #define RST_POLL_TIMEOUT 1000 /* us */
 
 /**
- * port_disable - disable a port
+ * __port_disable - disable a port
  * @pdev: port platform device.
  *
- * Disable Port by setting the port soft reset bit, it puts the port into
- * reset.
+ * Disable Port by setting the port soft reset bit, it puts the port into 
reset.
+ *
+ * The caller needs to hold lock for protection.
  */
-static int port_disable(struct platform_device *pdev)
+int __port_disable(struct platform_device *pdev)
 {
struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
void __iomem *base;
@@ -104,9 +107,9 @@ static int __port_reset(struct platform_device *pdev)
 {
int ret;
 
-   ret = port_disable(pdev);
+   ret = __port_disable(pdev);
if (!ret)
-   port_enable(pdev);
+   __port_enable(pdev);
 
return ret;
 }
@@ -806,9 +809,9 @@ static int port_enable_set(struct platform_device *pdev, 
bool enable)
 
mutex_lock(&pdata->lock);
if (enable)
-   port_enable(pdev);
+   __port_enable(pdev);
else
-   ret = port_disable(pdev);
+   ret = __port_disable(pdev);
mutex_unlock(&pdata->lock);
 
return ret;
diff --git a/drivers/fpga/dfl-afu.h b/drivers/fpga/dfl-afu.h
index 0c7630a..35e60c5 100644
--- a/drivers/fpga/dfl-afu.h
+++ b/drivers/fpga/dfl-afu.h
@@ -79,6 +79,9 @@ struct dfl_afu {
struct dfl_feature_platform_data *pdata;
 };
 
+void __port_enable(struct platform_device *pdev);
+int __port_disable(struct platform_device *pdev);
+
 void afu_mmio_region_init(struct dfl_feature_platform_data *pdata);
 int afu_mmio_region_add(struct dfl_feature_platform_data *pdata,
u32 region_index, u64 region_size, u64 phys, u32 flags);
-- 
1.8.3.1



[PATCH v3 02/12] fpga: dfl: fme: add DFL_FPGA_FME_PORT_RELEASE/ASSIGN ioctl support.

2019-07-22 Thread Wu Hao
In order to support virtualization usage via PCIe SRIOV, this patch
adds two ioctls under FPGA Management Engine (FME) to release and
assign back the port device. In order to safely turn Port from PF
into VF and enable PCIe SRIOV, it requires user to invoke this
PORT_RELEASE ioctl to release port firstly to remove userspace
interfaces, and then configure the PF/VF access register in FME.
After disable SRIOV, it requires user to invoke this PORT_ASSIGN
ioctl to attach the port back to PF.

 Ioctl interfaces:
 * DFL_FPGA_FME_PORT_RELEASE
   Release platform device of given port, it deletes port platform
   device to remove related userspace interfaces on PF, then
   configures PF/VF access mode to VF.

 * DFL_FPGA_FME_PORT_ASSIGN
   Assign platform device of given port back to PF, it configures
   PF/VF access mode to PF, then adds port platform device back to
   re-enable related userspace interfaces on PF.

Signed-off-by: Zhang Yi Z 
Signed-off-by: Xu Yilun 
Signed-off-by: Wu Hao 
Acked-by: Alan Tull 
Acked-by: Moritz Fischer 
Signed-off-by: Moritz Fischer 
---
v2: remove argsz from ioctls.
---
 drivers/fpga/dfl-fme-main.c   |  30 
 drivers/fpga/dfl.c| 107 +-
 drivers/fpga/dfl.h|  10 
 include/uapi/linux/fpga-dfl.h |  19 
 4 files changed, 154 insertions(+), 12 deletions(-)

diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c
index 0be4635..e61e0fe 100644
--- a/drivers/fpga/dfl-fme-main.c
+++ b/drivers/fpga/dfl-fme-main.c
@@ -16,6 +16,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include "dfl.h"
@@ -104,9 +105,38 @@ static void fme_hdr_uinit(struct platform_device *pdev,
device_remove_groups(&pdev->dev, fme_hdr_groups);
 }
 
+static long fme_hdr_ioctl_config_port(struct dfl_feature_platform_data *pdata,
+ unsigned long arg, bool release)
+{
+   struct dfl_fpga_cdev *cdev = pdata->dfl_cdev;
+   int port_id;
+
+   if (get_user(port_id, (int __user *)arg))
+   return -EFAULT;
+
+   return dfl_fpga_cdev_config_port(cdev, port_id, release);
+}
+
+static long fme_hdr_ioctl(struct platform_device *pdev,
+ struct dfl_feature *feature,
+ unsigned int cmd, unsigned long arg)
+{
+   struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
+
+   switch (cmd) {
+   case DFL_FPGA_FME_PORT_RELEASE:
+   return fme_hdr_ioctl_config_port(pdata, arg, true);
+   case DFL_FPGA_FME_PORT_ASSIGN:
+   return fme_hdr_ioctl_config_port(pdata, arg, false);
+   }
+
+   return -ENODEV;
+}
+
 static const struct dfl_feature_ops fme_hdr_ops = {
.init = fme_hdr_init,
.uinit = fme_hdr_uinit,
+   .ioctl = fme_hdr_ioctl,
 };
 
 static struct dfl_feature_driver fme_feature_drvs[] = {
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index 4b66aaa..e04ed45 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -231,16 +231,20 @@ void dfl_fpga_port_ops_del(struct dfl_fpga_port_ops *ops)
  */
 int dfl_fpga_check_port_id(struct platform_device *pdev, void *pport_id)
 {
-   struct dfl_fpga_port_ops *port_ops = dfl_fpga_port_ops_get(pdev);
-   int port_id;
+   struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
+   struct dfl_fpga_port_ops *port_ops;
+
+   if (pdata->id != FEATURE_DEV_ID_UNUSED)
+   return pdata->id == *(int *)pport_id;
 
+   port_ops = dfl_fpga_port_ops_get(pdev);
if (!port_ops || !port_ops->get_id)
return 0;
 
-   port_id = port_ops->get_id(pdev);
+   pdata->id = port_ops->get_id(pdev);
dfl_fpga_port_ops_put(port_ops);
 
-   return port_id == *(int *)pport_id;
+   return pdata->id == *(int *)pport_id;
 }
 EXPORT_SYMBOL_GPL(dfl_fpga_check_port_id);
 
@@ -474,6 +478,7 @@ static int build_info_commit_dev(struct 
build_feature_devs_info *binfo)
pdata->dev = fdev;
pdata->num = binfo->feature_num;
pdata->dfl_cdev = binfo->cdev;
+   pdata->id = FEATURE_DEV_ID_UNUSED;
mutex_init(&pdata->lock);
lockdep_set_class_and_name(&pdata->lock, &dfl_pdata_keys[type],
   dfl_pdata_key_strings[type]);
@@ -973,25 +978,27 @@ void dfl_fpga_feature_devs_remove(struct dfl_fpga_cdev 
*cdev)
 {
struct dfl_feature_platform_data *pdata, *ptmp;
 
-   remove_feature_devs(cdev);
-
mutex_lock(&cdev->lock);
-   if (cdev->fme_dev) {
-   /* the fme should be unregistered. */
-   WARN_ON(device_is_registered(cdev->fme_dev));
+   if (cdev->fme_dev)
put_device(cdev->fme_dev);
-   }
 
list_for_each_entry_safe(pdata, ptmp, &cdev->port_dev_list, node) {
struct platform_device *port_dev = pdata->dev;
 
-   /* the port should be unregistered. */
-   WARN_ON(d

[PATCH v3 04/12] fpga: dfl: afu: add AFU state related sysfs interfaces

2019-07-22 Thread Wu Hao
This patch introduces more sysfs interfaces for Accelerated
Function Unit (AFU). These interfaces allow users to read
current AFU Power State (APx), read / clear AFU Power (APx)
events which are sticky to identify transient APx state,
and manage AFU's LTR (latency tolerance reporting).

Signed-off-by: Ananda Ravuri 
Signed-off-by: Xu Yilun 
Signed-off-by: Wu Hao 
Acked-by: Alan Tull 
Signed-off-by: Moritz Fischer 
---
v2: rebased, and remove DRV/MODULE_VERSION modifications
v3: update kernel version and date in sysfs doc
---
 Documentation/ABI/testing/sysfs-platform-dfl-port |  30 +
 drivers/fpga/dfl-afu-main.c   | 137 ++
 drivers/fpga/dfl.h|  11 ++
 3 files changed, 178 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-platform-dfl-port 
b/Documentation/ABI/testing/sysfs-platform-dfl-port
index 6a92dda..5961fb2 100644
--- a/Documentation/ABI/testing/sysfs-platform-dfl-port
+++ b/Documentation/ABI/testing/sysfs-platform-dfl-port
@@ -14,3 +14,33 @@ Description: Read-only. User can program different PR 
bitstreams to FPGA
Accelerator Function Unit (AFU) for different functions. It
returns uuid which could be used to identify which PR bitstream
is programmed in this AFU.
+
+What:  /sys/bus/platform/devices/dfl-port.0/power_state
+Date:  July 2019
+KernelVersion: 5.4
+Contact:   Wu Hao 
+Description:   Read-only. It reports the APx (AFU Power) state, different APx
+   means different throttling level. When reading this file, it
+   returns "0" - Normal / "1" - AP1 / "2" - AP2 / "6" - AP6.
+
+What:  /sys/bus/platform/devices/dfl-port.0/ap1_event
+Date:  July 2019
+KernelVersion: 5.4
+Contact:   Wu Hao 
+Description:   Read-write. Read or set 1 to clear AP1 (AFU Power State 1)
+   event. It's used to indicate transient AP1 state.
+
+What:  /sys/bus/platform/devices/dfl-port.0/ap2_event
+Date:  July 2019
+KernelVersion: 5.4
+Contact:   Wu Hao 
+Description:   Read-write. Read or set 1 to clear AP2 (AFU Power State 2)
+   event. It's used to indicate transient AP2 state.
+
+What:  /sys/bus/platform/devices/dfl-port.0/ltr
+Date:  July 2019
+KernelVersion: 5.4
+Contact:   Wu Hao 
+Description:   Read-write. Read and set AFU latency tolerance reporting value.
+   Set ltr to 1 if the AFU can tolerate latency >= 40us or set it
+   to 0 if it is latency sensitive.
diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c
index 68b4d08..cb3f73e 100644
--- a/drivers/fpga/dfl-afu-main.c
+++ b/drivers/fpga/dfl-afu-main.c
@@ -141,8 +141,145 @@ static int port_get_id(struct platform_device *pdev)
 }
 static DEVICE_ATTR_RO(id);
 
+static ssize_t
+ltr_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
+   void __iomem *base;
+   u64 v;
+
+   base = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_HEADER);
+
+   mutex_lock(&pdata->lock);
+   v = readq(base + PORT_HDR_CTRL);
+   mutex_unlock(&pdata->lock);
+
+   return sprintf(buf, "%x\n", (u8)FIELD_GET(PORT_CTRL_LATENCY, v));
+}
+
+static ssize_t
+ltr_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+   struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
+   void __iomem *base;
+   u8 ltr;
+   u64 v;
+
+   if (kstrtou8(buf, 0,  1)
+   return -EINVAL;
+
+   base = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_HEADER);
+
+   mutex_lock(&pdata->lock);
+   v = readq(base + PORT_HDR_CTRL);
+   v &= ~PORT_CTRL_LATENCY;
+   v |= FIELD_PREP(PORT_CTRL_LATENCY, ltr);
+   writeq(v, base + PORT_HDR_CTRL);
+   mutex_unlock(&pdata->lock);
+
+   return count;
+}
+static DEVICE_ATTR_RW(ltr);
+
+static ssize_t
+ap1_event_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
+   void __iomem *base;
+   u64 v;
+
+   base = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_HEADER);
+
+   mutex_lock(&pdata->lock);
+   v = readq(base + PORT_HDR_STS);
+   mutex_unlock(&pdata->lock);
+
+   return sprintf(buf, "%x\n", (u8)FIELD_GET(PORT_STS_AP1_EVT, v));
+}
+
+static ssize_t
+ap1_event_store(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
+   void __iomem *base;
+   u8 ap1_event;
+
+   if (kstrtou8(buf, 0, &ap1_event) || ap1_event != 1)
+   return -EINVAL;
+
+   base = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_HEADER);
+
+   mutex_lock(&pdata->lock);
+   writeq(PORT_S

[PATCH v3 11/12] fpga: dfl: fme: add global error reporting support

2019-07-22 Thread Wu Hao
This patch adds support for global error reporting for FPGA
Management Engine (FME), it introduces sysfs interfaces to
report different error detected by the hardware, and allow
user to clear errors or inject error for testing purpose.

Signed-off-by: Luwei Kang 
Signed-off-by: Ananda Ravuri 
Signed-off-by: Xu Yilun 
Signed-off-by: Wu Hao 
Acked-by: Alan Tull 
Signed-off-by: Moritz Fischer 
---
v2: switch to device_add/remove_groups for sysfs.
v3: update kernel version and date in sysfs doc
---
 Documentation/ABI/testing/sysfs-platform-dfl-fme |  75 +
 drivers/fpga/Makefile|   2 +-
 drivers/fpga/dfl-fme-error.c | 385 +++
 drivers/fpga/dfl-fme-main.c  |   4 +
 drivers/fpga/dfl-fme.h   |   2 +
 drivers/fpga/dfl.h   |   2 +
 6 files changed, 469 insertions(+), 1 deletion(-)
 create mode 100644 drivers/fpga/dfl-fme-error.c

diff --git a/Documentation/ABI/testing/sysfs-platform-dfl-fme 
b/Documentation/ABI/testing/sysfs-platform-dfl-fme
index 269e807..ad36b79 100644
--- a/Documentation/ABI/testing/sysfs-platform-dfl-fme
+++ b/Documentation/ABI/testing/sysfs-platform-dfl-fme
@@ -44,3 +44,78 @@ Description: Read-only. It returns socket_id to indicate 
which socket
this FPGA belongs to, only valid for integrated solution.
User only needs this information, in case standard numa node
can't provide correct information.
+
+What:  /sys/bus/platform/devices/dfl-fme.0/errors/revision
+Date:  July 2019
+KernelVersion:  5.4
+Contact:   Wu Hao 
+Description:   Read-only. Read this file to get the revision of this global
+   error reporting private feature.
+
+What:  /sys/bus/platform/devices/dfl-fme.0/errors/pcie0_errors
+Date:  July 2019
+KernelVersion:  5.4
+Contact:   Wu Hao 
+Description:   Read-Write. Read this file for errors detected on pcie0 link.
+   Write this file to clear errors logged in pcie0_errors. Write
+   fails with -EINVAL if input parsing fails or input error code
+   doesn't match.
+
+What:  /sys/bus/platform/devices/dfl-fme.0/errors/pcie1_errors
+Date:  July 2019
+KernelVersion:  5.4
+Contact:   Wu Hao 
+Description:   Read-Write. Read this file for errors detected on pcie1 link.
+   Write this file to clear errors logged in pcie1_errors. Write
+   fails with -EINVAL if input parsing fails or input error code
+   doesn't match.
+
+What:  /sys/bus/platform/devices/dfl-fme.0/errors/nonfatal_errors
+Date:  July 2019
+KernelVersion:  5.4
+Contact:   Wu Hao 
+Description:   Read-only. It returns non-fatal errors detected.
+
+What:  /sys/bus/platform/devices/dfl-fme.0/errors/catfatal_errors
+Date:  July 2019
+KernelVersion:  5.4
+Contact:   Wu Hao 
+Description:   Read-only. It returns catastrophic and fatal errors detected.
+
+What:  /sys/bus/platform/devices/dfl-fme.0/errors/inject_error
+Date:  July 2019
+KernelVersion:  5.4
+Contact:   Wu Hao 
+Description:   Read-Write. Read this file to check errors injected. Write this
+   file to inject errors for testing purpose. Write fails with
+   -EINVAL if input parsing fails or input inject error code isn't
+   supported.
+
+What:  /sys/bus/platform/devices/dfl-fme.0/errors/fme-errors/errors
+Date:  July 2019
+KernelVersion:  5.4
+Contact:   Wu Hao 
+Description:   Read-only. Read this file to get errors detected by hardware.
+
+What:  
/sys/bus/platform/devices/dfl-fme.0/errors/fme-errors/first_error
+Date:  July 2019
+KernelVersion:  5.4
+Contact:   Wu Hao 
+Description:   Read-only. Read this file to get the first error detected by
+   hardware.
+
+What:  /sys/bus/platform/devices/dfl-fme.0/errors/fme-errors/next_error
+Date:  July 2019
+KernelVersion:  5.4
+Contact:   Wu Hao 
+Description:   Read-only. Read this file to get the second error detected by
+   hardware.
+
+What:  /sys/bus/platform/devices/dfl-fme.0/errors/fme-errors/clear
+Date:  July 2019
+KernelVersion:  5.4
+Contact:   Wu Hao 
+Description:   Write-only. Write error code to this file to clear all errors
+   logged in errors, first_error and next_error. Write fails with
+   -EINVAL if input parsing fails or input error code doesn't
+   match.
diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile
index 7255891..4865b74 100644
--- a/drivers/fpga/Makefile
+++ b/drivers/fpga/Makefile
@@ -39,7 +39,7 @@ obj-$(CONFIG_FPGA_DFL_FME_BRIDGE) += dfl-fme-br.o
 obj-$(CONFIG_FPGA_DFL_FME_REGION)  += dfl-fme-region.o
 obj-$(CONFIG_FPGA_DFL_AFU) += dfl-afu.o
 
-dfl-fme-objs := dfl-fme-main.o dfl-fme-pr.o
+dfl-fme-objs := 

Re: [PATCH v1 1/2] mm/page_idle: Add support for per-pid page_idle using virtual indexing

2019-07-22 Thread Michal Hocko
[Cc linux-api - please always do CC this list when introducing a user
 visible API]

On Mon 22-07-19 17:32:04, Joel Fernandes (Google) wrote:
> The page_idle tracking feature currently requires looking up the pagemap
> for a process followed by interacting with /sys/kernel/mm/page_idle.
> This is quite cumbersome and can be error-prone too. If between
> accessing the per-PID pagemap and the global page_idle bitmap, if
> something changes with the page then the information is not accurate.
> More over looking up PFN from pagemap in Android devices is not
> supported by unprivileged process and requires SYS_ADMIN and gives 0 for
> the PFN.
> 
> This patch adds support to directly interact with page_idle tracking at
> the PID level by introducing a /proc//page_idle file. This
> eliminates the need for userspace to calculate the mapping of the page.
> It follows the exact same semantics as the global
> /sys/kernel/mm/page_idle, however it is easier to use for some usecases
> where looking up PFN is not needed and also does not require SYS_ADMIN.
> It ended up simplifying userspace code, solving the security issue
> mentioned and works quite well. SELinux does not need to be turned off
> since no pagemap look up is needed.
> 
> In Android, we are using this for the heap profiler (heapprofd) which
> profiles and pin points code paths which allocates and leaves memory
> idle for long periods of time.
> 
> Documentation material:
> The idle page tracking API for virtual address indexing using virtual page
> frame numbers (VFN) is located at /proc//page_idle. It is a bitmap
> that follows the same semantics as /sys/kernel/mm/page_idle/bitmap
> except that it uses virtual instead of physical frame numbers.
> 
> This idle page tracking API can be simpler to use than physical address
> indexing, since the pagemap for a process does not need to be looked up
> to mark or read a page's idle bit. It is also more accurate than
> physical address indexing since in physical address indexing, address
> space changes can occur between reading the pagemap and reading the
> bitmap. In virtual address indexing, the process's mmap_sem is held for
> the duration of the access.

I didn't get to read the actual code but the overall idea makes sense to
me. I can see this being useful for userspace memory management (along
with remote MADV_PAGEOUT, MADV_COLD).

Normally I would object that a cumbersome nature of the existing
interface can be hidden in a userspace but I do agree that rowhammer has
made this one close to unusable for anything but a privileged process.

I do not think you can make any argument about accuracy because
the information will never be accurate. Sure the race window is smaller
in principle but you can hardly say anything about how much or whether
at all.

Thanks.
-- 
Michal Hocko
SUSE Labs


Re: [PATCH v1 1/2] mm/page_idle: Add support for per-pid page_idle using virtual indexing

2019-07-22 Thread Minchan Kim
Hi Joel,

On Mon, Jul 22, 2019 at 05:32:04PM -0400, Joel Fernandes (Google) wrote:
> The page_idle tracking feature currently requires looking up the pagemap
> for a process followed by interacting with /sys/kernel/mm/page_idle.
> This is quite cumbersome and can be error-prone too. If between

cumbersome: That's the fair tradeoff between idle page tracking and
clear_refs because idle page tracking could check even though the page
is not mapped.

error-prone: What's the error?

> accessing the per-PID pagemap and the global page_idle bitmap, if
> something changes with the page then the information is not accurate.

What you mean with error is this timing issue?
Why do you need to be accurate? IOW, accurate is always good but what's
the scale of the accuracy?

> More over looking up PFN from pagemap in Android devices is not
> supported by unprivileged process and requires SYS_ADMIN and gives 0 for
> the PFN.
> 
> This patch adds support to directly interact with page_idle tracking at
> the PID level by introducing a /proc//page_idle file. This
> eliminates the need for userspace to calculate the mapping of the page.
> It follows the exact same semantics as the global
> /sys/kernel/mm/page_idle, however it is easier to use for some usecases
> where looking up PFN is not needed and also does not require SYS_ADMIN.

Ah, so the primary goal is to provide convinience interface and it would
help accurary, too. IOW, accuracy is not your main goal?

> It ended up simplifying userspace code, solving the security issue
> mentioned and works quite well. SELinux does not need to be turned off
> since no pagemap look up is needed.

I'm not sure how it is painful to check it via pagemap for your goal
but not sure it's a good idea to create new ABI for just convinience.
I think that's library we have.

> 
> In Android, we are using this for the heap profiler (heapprofd) which
> profiles and pin points code paths which allocates and leaves memory
> idle for long periods of time.

So the goal is to detect idle pages with idle memory tracking?
It couldn't work well because such idle pages could finally swap out and
lose every flags of the page descriptor which is working mechanism of
idle page tracking. It should have named "workingset page tracking",
not "idle page tracking".

> 
> Documentation material:
> The idle page tracking API for virtual address indexing using virtual page
> frame numbers (VFN) is located at /proc//page_idle. It is a bitmap
> that follows the same semantics as /sys/kernel/mm/page_idle/bitmap
> except that it uses virtual instead of physical frame numbers.
> 
> This idle page tracking API can be simpler to use than physical address
> indexing, since the pagemap for a process does not need to be looked up
> to mark or read a page's idle bit. It is also more accurate than
> physical address indexing since in physical address indexing, address
> space changes can occur between reading the pagemap and reading the
> bitmap. In virtual address indexing, the process's mmap_sem is held for
> the duration of the access.
> 
> Cc: vdavydov@gmail.com
> Cc: Brendan Gregg 
> Cc: kernel-t...@android.com
> Signed-off-by: Joel Fernandes (Google) 
> 
> ---
> Internal review -> v1:
> Fixes from Suren.
> Corrections to change log, docs (Florian, Sandeep)
> 
>  fs/proc/base.c|   3 +
>  fs/proc/internal.h|   1 +
>  fs/proc/task_mmu.c|  57 +++
>  include/linux/page_idle.h |   4 +
>  mm/page_idle.c| 305 +-
>  5 files changed, 330 insertions(+), 40 deletions(-)
> 
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index 77eb628ecc7f..a58dd74606e9 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -3021,6 +3021,9 @@ static const struct pid_entry tgid_base_stuff[] = {
>   REG("smaps",  S_IRUGO, proc_pid_smaps_operations),
>   REG("smaps_rollup", S_IRUGO, proc_pid_smaps_rollup_operations),
>   REG("pagemap",S_IRUSR, proc_pagemap_operations),
> +#ifdef CONFIG_IDLE_PAGE_TRACKING
> + REG("page_idle", S_IRUSR|S_IWUSR, proc_page_idle_operations),
> +#endif
>  #endif
>  #ifdef CONFIG_SECURITY
>   DIR("attr",   S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, 
> proc_attr_dir_operations),
> diff --git a/fs/proc/internal.h b/fs/proc/internal.h
> index cd0c8d5ce9a1..bc9371880c63 100644
> --- a/fs/proc/internal.h
> +++ b/fs/proc/internal.h
> @@ -293,6 +293,7 @@ extern const struct file_operations 
> proc_pid_smaps_operations;
>  extern const struct file_operations proc_pid_smaps_rollup_operations;
>  extern const struct file_operations proc_clear_refs_operations;
>  extern const struct file_operations proc_pagemap_operations;
> +extern const struct file_operations proc_page_idle_operations;
>  
>  extern unsigned long task_vsize(struct mm_struct *);
>  extern unsigned long task_statm(struct mm_struct *,
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index 4d2b860dbc3f..11ccc53da38e 100644
> --- a/fs/proc/ta

[PATCH V2 10/10] Documentation: cpufreq: Update policy notifier documentation

2019-07-22 Thread Viresh Kumar
Update documentation with the recent policy notifier updates.

Signed-off-by: Viresh Kumar 
---
 Documentation/cpu-freq/core.txt | 16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/Documentation/cpu-freq/core.txt b/Documentation/cpu-freq/core.txt
index 55193e680250..ed577d9c154b 100644
--- a/Documentation/cpu-freq/core.txt
+++ b/Documentation/cpu-freq/core.txt
@@ -57,19 +57,11 @@ transition notifiers.
 2.1 CPUFreq policy notifiers
 
 
-These are notified when a new policy is intended to be set. Each
-CPUFreq policy notifier is called twice for a policy transition:
+These are notified when a new policy is created or removed.
 
-1.) During CPUFREQ_ADJUST all CPUFreq notifiers may change the limit if
-they see a need for this - may it be thermal considerations or
-hardware limitations.
-
-2.) And during CPUFREQ_NOTIFY all notifiers are informed of the new policy
-   - if two hardware drivers failed to agree on a new policy before this
-   stage, the incompatible hardware shall be shut down, and the user
-   informed of this.
-
-The phase is specified in the second argument to the notifier.
+The phase is specified in the second argument to the notifier.  The phase is
+CPUFREQ_CREATE_POLICY when the policy is first created and it is
+CPUFREQ_REMOVE_POLICY when the policy is removed.
 
 The third argument, a void *pointer, points to a struct cpufreq_policy
 consisting of several values, including min, max (the lower and upper
-- 
2.21.0.rc0.269.g1a574e7a288b