[PATCH 2/2] drm/panel: tv101wum: Add STARRY 2081101QFH032011-53G

2021-02-13 Thread Zhengqiao Xia
Add STARRY 2081101QFH032011-53G 10.1" WUXGA TFT LCD panel as a
part of tv101wum-n16.

Signed-off-by: Zhengqiao Xia 
---
 .../gpu/drm/panel/panel-boe-tv101wum-nl6.c| 132 ++
 1 file changed, 132 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c 
b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
index db9d0b86d542..904cf1559dbe 100644
--- a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
+++ b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
@@ -426,6 +426,108 @@ static const struct panel_init_cmd 
auo_b101uan08_3_init_cmd[] = {
{},
 };
 
+static const struct panel_init_cmd starry_qfh032011_53g_init_cmd[] = {
+   _INIT_DCS_CMD(0xB0, 0x05),
+   _INIT_DCS_CMD(0xC0, 0x04),
+   _INIT_DCS_CMD(0xC2, 0x03),
+   _INIT_DCS_CMD(0xD9, 0x04),
+   _INIT_DCS_CMD(0xDB, 0x03),
+   _INIT_DCS_CMD(0xB0, 0x01),
+   _INIT_DCS_CMD(0xC3, 0x4F),
+   _INIT_DCS_CMD(0xC4, 0x40),
+   _INIT_DCS_CMD(0xC5, 0x40),
+   _INIT_DCS_CMD(0xC6, 0x40),
+   _INIT_DCS_CMD(0xC7, 0x40),
+   _INIT_DCS_CMD(0xC8, 0x4D),
+   _INIT_DCS_CMD(0xC9, 0x52),
+   _INIT_DCS_CMD(0xCA, 0x51),
+   _INIT_DCS_CMD(0xCD, 0x5D),
+   _INIT_DCS_CMD(0xCE, 0x5B),
+   _INIT_DCS_CMD(0xCF, 0x4B),
+   _INIT_DCS_CMD(0xD0, 0x49),
+   _INIT_DCS_CMD(0xD1, 0x47),
+   _INIT_DCS_CMD(0xD2, 0x45),
+   _INIT_DCS_CMD(0xD3, 0x41),
+   _INIT_DCS_CMD(0xD7, 0x50),
+   _INIT_DCS_CMD(0xD8, 0x40),
+   _INIT_DCS_CMD(0xD9, 0x40),
+   _INIT_DCS_CMD(0xDA, 0x40),
+   _INIT_DCS_CMD(0xDB, 0x40),
+   _INIT_DCS_CMD(0xDC, 0x4E),
+   _INIT_DCS_CMD(0xDD, 0x52),
+   _INIT_DCS_CMD(0xDE, 0x51),
+   _INIT_DCS_CMD(0xE1, 0x5E),
+   _INIT_DCS_CMD(0xE2, 0x5C),
+   _INIT_DCS_CMD(0xE3, 0x4C),
+   _INIT_DCS_CMD(0xE4, 0x4A),
+   _INIT_DCS_CMD(0xE5, 0x48),
+   _INIT_DCS_CMD(0xE6, 0x46),
+   _INIT_DCS_CMD(0xE7, 0x42),
+   _INIT_DCS_CMD(0xB0, 0x03),
+   _INIT_DCS_CMD(0xBE, 0x03),
+   _INIT_DCS_CMD(0xCC, 0x44),
+   _INIT_DCS_CMD(0xC8, 0x07),
+   _INIT_DCS_CMD(0xC9, 0x05),
+   _INIT_DCS_CMD(0xCA, 0x42),
+   _INIT_DCS_CMD(0xCD, 0x3E),
+   _INIT_DCS_CMD(0xCF, 0x60),
+   _INIT_DCS_CMD(0xD2, 0x04),
+   _INIT_DCS_CMD(0xD3, 0x04),
+   _INIT_DCS_CMD(0xD4, 0x01),
+   _INIT_DCS_CMD(0xD5, 0x00),
+   _INIT_DCS_CMD(0xD6, 0x03),
+   _INIT_DCS_CMD(0xD7, 0x04),
+   _INIT_DCS_CMD(0xD9, 0x01),
+   _INIT_DCS_CMD(0xDB, 0x01),
+   _INIT_DCS_CMD(0xE4, 0xF0),
+   _INIT_DCS_CMD(0xE5, 0x0A),
+   _INIT_DCS_CMD(0xB0, 0x00),
+   _INIT_DCS_CMD(0xCC, 0x08),
+   _INIT_DCS_CMD(0xC2, 0x08),
+   _INIT_DCS_CMD(0xC4, 0x10),
+   _INIT_DCS_CMD(0xB0, 0x02),
+   _INIT_DCS_CMD(0xC0, 0x00),
+   _INIT_DCS_CMD(0xC1, 0x0A),
+   _INIT_DCS_CMD(0xC2, 0x20),
+   _INIT_DCS_CMD(0xC3, 0x24),
+   _INIT_DCS_CMD(0xC4, 0x23),
+   _INIT_DCS_CMD(0xC5, 0x29),
+   _INIT_DCS_CMD(0xC6, 0x23),
+   _INIT_DCS_CMD(0xC7, 0x1C),
+   _INIT_DCS_CMD(0xC8, 0x19),
+   _INIT_DCS_CMD(0xC9, 0x17),
+   _INIT_DCS_CMD(0xCA, 0x17),
+   _INIT_DCS_CMD(0xCB, 0x18),
+   _INIT_DCS_CMD(0xCC, 0x1A),
+   _INIT_DCS_CMD(0xCD, 0x1E),
+   _INIT_DCS_CMD(0xCE, 0x20),
+   _INIT_DCS_CMD(0xCF, 0x23),
+   _INIT_DCS_CMD(0xD0, 0x07),
+   _INIT_DCS_CMD(0xD1, 0x00),
+   _INIT_DCS_CMD(0xD2, 0x00),
+   _INIT_DCS_CMD(0xD3, 0x0A),
+   _INIT_DCS_CMD(0xD4, 0x13),
+   _INIT_DCS_CMD(0xD5, 0x1C),
+   _INIT_DCS_CMD(0xD6, 0x1A),
+   _INIT_DCS_CMD(0xD7, 0x13),
+   _INIT_DCS_CMD(0xD8, 0x17),
+   _INIT_DCS_CMD(0xD9, 0x1C),
+   _INIT_DCS_CMD(0xDA, 0x19),
+   _INIT_DCS_CMD(0xDB, 0x17),
+   _INIT_DCS_CMD(0xDC, 0x17),
+   _INIT_DCS_CMD(0xDD, 0x18),
+   _INIT_DCS_CMD(0xDE, 0x1A),
+   _INIT_DCS_CMD(0xDF, 0x1E),
+   _INIT_DCS_CMD(0xE0, 0x20),
+   _INIT_DCS_CMD(0xE1, 0x23),
+   _INIT_DCS_CMD(0xE2, 0x07),
+   _INIT_DCS_CMD(0X11),
+   _INIT_DELAY_CMD(120),
+   _INIT_DCS_CMD(0X29),
+   _INIT_DELAY_CMD(80),
+   {},
+};
+
 static inline struct boe_panel *to_boe_panel(struct drm_panel *panel)
 {
return container_of(panel, struct boe_panel, base);
@@ -613,6 +715,33 @@ static const struct panel_desc boe_tv101wum_nl6_desc = {
.discharge_on_disable = false,
 };
 
+static const struct drm_display_mode starry_qfh032011_53g_default_mode = {
+   .clock = 165731,
+   .hdisplay = 1200,
+   .hsync_start = 1200 + 100,
+   .hsync_end = 1200 + 100 + 10,
+   .htotal = 1200 + 100 + 10 + 100,
+   .vdisplay = 1920,
+   .vsync_start = 1920 + 14,
+   .vsync_end = 1920 + 14 + 10,
+   .vtotal = 1920 + 14 + 10 + 15,
+};
+
+static const struct panel_desc starry_qfh032011_53g_desc = {
+   .modes = &starry_qfh032011_53g_default_mode,
+   .bpc = 8,
+   .size = {
+   .width_mm = 135,
+   .height_mm = 216,
+   },
+   .lanes = 4,
+   .format = MIPI

Re: [PATCH] proc: Convert S_ permission uses to octal

2021-02-13 Thread Alexey Dobriyan
On Fri, Feb 12, 2021 at 04:01:48PM -0600, Eric W. Biederman wrote:
> Joe Perches  writes:
> 
> > Convert S_ permissions to the more readable octal.

> Something like that should be able to address the readability while
> still using symbolic constants.

Macros are easy. I've sent a patch long time ago which does essentially

#define rwxrwxrwx 0777
...

But then kernel will start using something nobode else does.

This whole issue is like sizeof(*ptr) vs sizeof(sizeof(struct S)).
No preferred way overall with ever vigilant checkpatch.pl guarding
kernel 24/7. :-)


include/linux/compiler_types.h:319:38: error: call to '__compiletime_assert_223' declared with attribute error: BUILD_BUG_ON failed: FIX_KMAP_SLOTS > PTRS_PER_PTE

2021-02-13 Thread kernel test robot
Hi Thomas,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   dcc0b49040c70ad827a7f3d58a21b01fdb14e749
commit: 39cac191ff37939544af80d5d2af6b870fd94c9b arc/mm/highmem: Use generic 
kmap atomic implementation
date:   3 months ago
config: arc-randconfig-r006-20210213 (attached as .config)
compiler: arc-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=39cac191ff37939544af80d5d2af6b870fd94c9b
git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 39cac191ff37939544af80d5d2af6b870fd94c9b
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   In file included from :
   arch/arc/mm/highmem.c: In function 'kmap_init':
>> include/linux/compiler_types.h:319:38: error: call to 
>> '__compiletime_assert_223' declared with attribute error: BUILD_BUG_ON 
>> failed: FIX_KMAP_SLOTS > PTRS_PER_PTE
 319 |  _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
 |  ^
   include/linux/compiler_types.h:300:4: note: in definition of macro 
'__compiletime_assert'
 300 |prefix ## suffix();\
 |^~
   include/linux/compiler_types.h:319:2: note: in expansion of macro 
'_compiletime_assert'
 319 |  _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
 |  ^~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 
'compiletime_assert'
  39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
 | ^~
   include/linux/build_bug.h:50:2: note: in expansion of macro 
'BUILD_BUG_ON_MSG'
  50 |  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
 |  ^~~~
   arch/arc/mm/highmem.c:69:2: note: in expansion of macro 'BUILD_BUG_ON'
  69 |  BUILD_BUG_ON(FIX_KMAP_SLOTS > PTRS_PER_PTE);
 |  ^~~~


vim +/__compiletime_assert_223 +319 include/linux/compiler_types.h

eb5c2d4b45e3d2 Will Deacon 2020-07-21  305  
eb5c2d4b45e3d2 Will Deacon 2020-07-21  306  #define 
_compiletime_assert(condition, msg, prefix, suffix) \
eb5c2d4b45e3d2 Will Deacon 2020-07-21  307  __compiletime_assert(condition, 
msg, prefix, suffix)
eb5c2d4b45e3d2 Will Deacon 2020-07-21  308  
eb5c2d4b45e3d2 Will Deacon 2020-07-21  309  /**
eb5c2d4b45e3d2 Will Deacon 2020-07-21  310   * compiletime_assert - break build 
and emit msg if condition is false
eb5c2d4b45e3d2 Will Deacon 2020-07-21  311   * @condition: a compile-time 
constant condition to check
eb5c2d4b45e3d2 Will Deacon 2020-07-21  312   * @msg:   a message to emit if 
condition is false
eb5c2d4b45e3d2 Will Deacon 2020-07-21  313   *
eb5c2d4b45e3d2 Will Deacon 2020-07-21  314   * In tradition of POSIX assert, 
this macro will break the build if the
eb5c2d4b45e3d2 Will Deacon 2020-07-21  315   * supplied condition is *false*, 
emitting the supplied error message if the
eb5c2d4b45e3d2 Will Deacon 2020-07-21  316   * compiler has support to do so.
eb5c2d4b45e3d2 Will Deacon 2020-07-21  317   */
eb5c2d4b45e3d2 Will Deacon 2020-07-21  318  #define 
compiletime_assert(condition, msg) \
eb5c2d4b45e3d2 Will Deacon 2020-07-21 @319  _compiletime_assert(condition, 
msg, __compiletime_assert_, __COUNTER__)
eb5c2d4b45e3d2 Will Deacon 2020-07-21  320  

:: The code at line 319 was first introduced by commit
:: eb5c2d4b45e3d2d5d052ea6b8f1463976b1020d5 compiler.h: Move 
compiletime_assert() macros into compiler_types.h

:: TO: Will Deacon 
:: CC: Will Deacon 

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


[tip:x86/entry 14/14] kernel/softirq.o: warning: objtool: do_softirq()+0xdb: return with modified stack frame

2021-02-13 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/entry
head:   72f40a2823d6e16229ab58b898c6f22044e5222f
commit: 72f40a2823d6e16229ab58b898c6f22044e5222f [14/14] x86/softirq/64: Inline 
do_softirq_own_stack()
config: x86_64-randconfig-a012-20201005 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
# 
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=72f40a2823d6e16229ab58b898c6f22044e5222f
git remote add tip 
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
git fetch --no-tags tip x86/entry
git checkout 72f40a2823d6e16229ab58b898c6f22044e5222f
# save the attached .config to linux build tree
make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> kernel/softirq.o: warning: objtool: do_softirq()+0xdb: return with modified 
>> stack frame

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


Re: [PATCH v2] misc: fastrpc: restrict user apps from sending kernel RPC messages

2021-02-13 Thread Greg Kroah-Hartman
On Fri, Feb 12, 2021 at 10:26:58PM +0300, Dmitry Baryshkov wrote:
> Verify that user applications are not using the kernel RPC message
> handle to restrict them from directly attaching to guest OS on the
> remote subsystem. This is a port of CVE-2019-2308 fix.

A port of the fix of what to what?

Is this to go only into a stable tree (if so what ones and what is the
id in Linus's tree), or is it to go into Linus's tree like normal (if so
how can this be a port)?

thanks,

greg k-h


Re: [PATCH v3 2/2] serial: 8250: Add new 8250-core based Broadcom STB driver

2021-02-13 Thread Greg Kroah-Hartman
On Fri, Feb 12, 2021 at 12:47:02PM -0800, Florian Fainelli wrote:
> 
> 
> On 2/12/2021 11:57 AM, Al Cooper wrote:
> > Add a UART driver for the new Broadcom 8250 based STB UART. The new
> > UART is backward compatible with the standard 8250, but has some
> > additional features. The new features include a high accuracy baud
> > rate clock system and DMA support.
> > 
> > The driver will use the new optional BAUD MUX clock to select the best
> > one of the four master clocks (81MHz, 108MHz, 64MHz and 48MHz) to feed
> > the baud rate selection logic for any requested baud rate.  This allows
> > for more accurate BAUD rates when high speed baud rates are selected.
> > 
> > The driver will use the new UART DMA hardware if the UART DMA registers
> > are specified in Device Tree "reg" property.
> > 
> > The driver also sets the UPSTAT_AUTOCTS flag when hardware flow control
> > is enabled. This flag is needed for UARTs that don't assert a CTS
> > changed interrupt when CTS changes and AFE (Hardware Flow Control) is
> > enabled.
> > 
> > The driver also contains a workaround for a bug in the Synopsis 8250
> > core. The problem is that at high baud rates, the RX partial FIFO
> > timeout interrupt can occur but there is no RX data (DR not set in
> > the LSR register). In this case the driver will not read the Receive
> > Buffer Register, which clears the interrupt, and the system will get
> > continuous UART interrupts until the next RX character arrives. The
> > fix originally suggested by Synopsis was to read the Receive Buffer
> > Register and discard the character when the DR bit in the LSR was
> > not set, to clear the interrupt. The problem was that occasionally
> > a character would arrive just after the DR bit check and a valid
> > character would be discarded. The fix that was added will clear
> > receive interrupts to stop the interrupt, deassert RTS to insure
> > that no new data can arrive, wait for 1.5 character times for the
> > sender to react to RTS and then check for data and either do a dummy
> > read or a valid read. Sysfs error counters were also added and were
> > used to help create test software that would cause the error condition.
> > The counters can be found at:
> > /sys/devices/platform/rdb/*serial/rx_bad_timeout_late_char
> > /sys/devices/platform/rdb/*serial/rx_bad_timeout_no_char
> > 
> > Signed-off-by: Al Cooper 
> > ---
> >  MAINTAINERS|8 +
> >  drivers/tty/serial/8250/8250_bcm7271.c | 1099 
> >  drivers/tty/serial/8250/Kconfig|   11 +
> >  drivers/tty/serial/8250/Makefile   |1 +
> >  drivers/tty/serial/8250/bcm7271_uart.h |  158 
> >  5 files changed, 1277 insertions(+)
> >  create mode 100644 drivers/tty/serial/8250/8250_bcm7271.c
> >  create mode 100644 drivers/tty/serial/8250/bcm7271_uart.h
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 64c7169db617..bb6ad2fc4376 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -3582,6 +3582,14 @@ S:   Supported
> >  F: Documentation/devicetree/bindings/i2c/brcm,brcmstb-i2c.yaml
> >  F: drivers/i2c/busses/i2c-brcmstb.c
> >  
> > +BROADCOM BRCMSTB UART DRIVER
> > +M: Al Cooper 
> > +L: linux-...@vger.kernel.org
> 
> This should probably be linux-serial, copy pasted from the USB entry
> down below presumably.

Yes, it should not be linux-usb, and that explains why these
serial-driver patches were cc:ed to that list :(

thanks,

greg k-h


Re: [PATCH net-next v2] misc: Add Renesas Synchronization Management Unit (SMU) support

2021-02-13 Thread Greg KH
On Fri, Feb 12, 2021 at 07:06:17PM +, Min Li wrote:
> > 
> > On Fri, Feb 12, 2021 at 03:44:52PM +, Min Li wrote:
> > > > >
> > > > > -set combomode
> > > > > -get dpll's state
> > > > > -get dpll's ffo
> > > > >
> > > > > This driver must work with Renesas MFD driver to access SMU
> > > > > through I2C/SPI.
> > > > >
> > > > > Changes since v1:
> > > > > -Provide more background for purpose of the change.
> > > > > -Provide compat_ioctl support
> > > > > -Fix ioctl cmd definition
> > > >
> > > > This "changes" list goes below the --- line.
> > > >
> > >
> > > Sorry, is this a problem that you are requesting me to address? I am bit
> > confused...
> > 
> > Yes, please place that list of changes below the --- line in your patch.
> > The documentation says to do this, right?
> > 
> Hi Greg
> 
> Do you mean this "---" like below? How can I do that? Sorry I was never asked 
> to do that from other reviewer.

Yes, that line.

The documentation should tell you how to do that, as per my patch bot:

- This looks like a new version of a previously submitted patch, but you
  did not list below the --- line any changes from the previous version.
  Please read the section entitled "The canonical patch format" in the
  kernel file, Documentation/SubmittingPatches for what needs to be done
  here to properly describe this.

thanks,

greg k-h


arch/sh/kernel/cpu/sh2a/clock-sh7206.c:26:44: sparse: sparse: incorrect type in argument 1 (different base types)

2021-02-13 Thread kernel test robot
Hi Luc,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   dcc0b49040c70ad827a7f3d58a21b01fdb14e749
commit: e5fc436f06eef54ef512ea55a9db8eb9f2e76959 sparse: use static inline for 
__chk_{user,io}_ptr()
date:   6 months ago
config: sh-randconfig-s031-20210213 (attached as .config)
compiler: sh4-linux-gcc (GCC) 9.3.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-215-g0fb77bb6-dirty
# 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e5fc436f06eef54ef512ea55a9db8eb9f2e76959
git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout e5fc436f06eef54ef512ea55a9db8eb9f2e76959
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=sh 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


"sparse warnings: (new ones prefixed by >>)"
>> arch/sh/kernel/cpu/sh2a/clock-sh7206.c:26:44: sparse: sparse: incorrect type 
>> in argument 1 (different base types) @@ expected void const volatile 
>> [noderef] __iomem *ptr @@ got unsigned int @@
   arch/sh/kernel/cpu/sh2a/clock-sh7206.c:26:44: sparse: expected void 
const volatile [noderef] __iomem *ptr
   arch/sh/kernel/cpu/sh2a/clock-sh7206.c:26:44: sparse: got unsigned int
   arch/sh/kernel/cpu/sh2a/clock-sh7206.c:35:20: sparse: sparse: incorrect type 
in argument 1 (different base types) @@ expected void const volatile 
[noderef] __iomem *ptr @@ got unsigned int @@
   arch/sh/kernel/cpu/sh2a/clock-sh7206.c:35:20: sparse: expected void 
const volatile [noderef] __iomem *ptr
   arch/sh/kernel/cpu/sh2a/clock-sh7206.c:35:20: sparse: got unsigned int
   arch/sh/kernel/cpu/sh2a/clock-sh7206.c:45:46: sparse: sparse: incorrect type 
in argument 1 (different base types) @@ expected void const volatile 
[noderef] __iomem *ptr @@ got unsigned int @@
   arch/sh/kernel/cpu/sh2a/clock-sh7206.c:45:46: sparse: expected void 
const volatile [noderef] __iomem *ptr
   arch/sh/kernel/cpu/sh2a/clock-sh7206.c:45:46: sparse: got unsigned int
   arch/sh/kernel/cpu/sh2a/clock-sh7206.c:54:20: sparse: sparse: incorrect type 
in argument 1 (different base types) @@ expected void const volatile 
[noderef] __iomem *ptr @@ got unsigned int @@
   arch/sh/kernel/cpu/sh2a/clock-sh7206.c:54:20: sparse: expected void 
const volatile [noderef] __iomem *ptr
   arch/sh/kernel/cpu/sh2a/clock-sh7206.c:54:20: sparse: got unsigned int
--
   fs/cifs/cifs_debug.c:770:14: sparse: sparse: incorrect type in initializer 
(different address spaces) @@ expected char const *__gu_addr @@ got 
char const [noderef] __user *buffer @@
   fs/cifs/cifs_debug.c:770:14: sparse: expected char const *__gu_addr
   fs/cifs/cifs_debug.c:770:14: sparse: got char const [noderef] __user 
*buffer
>> fs/cifs/cifs_debug.c:770:14: sparse: sparse: incorrect type in argument 1 
>> (different address spaces) @@ expected void const volatile [noderef] 
>> __user *ptr @@ got char const *__gu_addr @@
   fs/cifs/cifs_debug.c:770:14: sparse: expected void const volatile 
[noderef] __user *ptr
   fs/cifs/cifs_debug.c:770:14: sparse: got char const *__gu_addr
--
   fs/cifs/ioctl.c:214:29: sparse: sparse: incorrect type in initializer 
(different address spaces) @@ expected int const *__gu_addr @@ got int 
[noderef] __user * @@
   fs/cifs/ioctl.c:214:29: sparse: expected int const *__gu_addr
   fs/cifs/ioctl.c:214:29: sparse: got int [noderef] __user *
>> fs/cifs/ioctl.c:214:29: sparse: sparse: incorrect type in argument 1 
>> (different address spaces) @@ expected void const volatile [noderef] 
>> __user *ptr @@ got int const *__gu_addr @@
   fs/cifs/ioctl.c:214:29: sparse: expected void const volatile [noderef] 
__user *ptr
   fs/cifs/ioctl.c:214:29: sparse: got int const *__gu_addr
--
   fs/cifs/dfs_cache.c:195:14: sparse: sparse: incorrect type in initializer 
(different address spaces) @@ expected char const *__gu_addr @@ got 
char const [noderef] __user *buffer @@
   fs/cifs/dfs_cache.c:195:14: sparse: expected char const *__gu_addr
   fs/cifs/dfs_cache.c:195:14: sparse: got char const [noderef] __user 
*buffer
>> fs/cifs/dfs_cache.c:195:14: sparse: sparse: incorrect type in argument 1 
>> (different address spaces) @@ expected void const volatile [noderef] 
>> __user *ptr @@ got char const *__gu_addr @@
   fs/cifs/dfs_cache.c:195:14: sparse: expec

Re: objtool segfault in 5.10 kernels with binutils-2.36.1

2021-02-13 Thread Greg KH
On Fri, Feb 12, 2021 at 05:51:45PM -0600, Josh Poimboeuf wrote:
> On Thu, Feb 11, 2021 at 05:16:56PM +, Ken Moffat wrote:
> > Hi,
> > 
> > in 5.10 kernels up to and including 5.10.15 when trying to build the
> > kernel for an x86_64 skylake using binutils-2.36.1, gcc-10.2 and
> > glibic-2.33 I get a segfault in objtool if the orc unwinder is
> > enabled.
> > 
> > This has already been fixed in 5.11 by ''objtool: Fix seg fault with
> > Clang non-section symbols'
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/patch/?id=44f6a7c0755d8dd453c70557e11687bb080a6f21
> > 
> > So can this be added to 5.10 stable, please ?
> > 
> > Please CC me as I am no-longer subscribed.
> 
> Hi Ken,
> 
> I agree that needs to be backported (and my bad for not marking it as
> stable to begin with).
> 
> Greg, this also came up in another thread, are you pulling that one in,
> or do you want me to send it to stable list?

I will pull it in after the next release happens in a few hours, thanks.

greg k-h


Re: [PATCH] nvme-tcp: Check if request has started before processing it

2021-02-13 Thread Hannes Reinecke

On 2/12/21 7:17 PM, Daniel Wagner wrote:

blk_mq_tag_to_rq() will always return a request if the command_id is
in the valid range. Check if the request has been started. If we
blindly process the request we might double complete a request which
can be fatal.

Signed-off-by: Daniel Wagner 
---

This patch is against nvme-5.12.

There is one blk_mq_tag_to_rq() in nvme_tcp_recv_ddgst() which I
didn't update as I am not sure if it's also needed.

I guess it is; this patch is essentially a protection against invalid 
frames, and as such affects all places.


Cheers,

Hannes
--
Dr. Hannes ReineckeKernel Storage Architect
h...@suse.de  +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer


Re: [PATCH] nvme-tcp: Check if request has started before processing it

2021-02-13 Thread Hannes Reinecke

On 2/12/21 10:49 PM, Sagi Grimberg wrote:



blk_mq_tag_to_rq() will always return a request if the command_id is
in the valid range. Check if the request has been started. If we
blindly process the request we might double complete a request which
can be fatal.


How did you get to this one? did the controller send a completion for
a completed/bogus request?


If that is the case, then that must mean it's possible the driver could
have started the command id just before the bogus completion check. Data
iorruption, right?


Yes, which is why I don't think this check is very useful..


I actually view that as a valid protection against spoofed frames.
Without it it's easy to crash the machine by injecting fake completions 
with random command ids.


Cheers,

Hannes
--
Dr. Hannes ReineckeKernel Storage Architect
h...@suse.de  +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer


Re: [PATCH] ARM: dts: sun8i: h3: orangepi-plus: Fix Ethernet PHY mode

2021-02-13 Thread Jernej Škrabec
Hi!

Let me first explain that it was oversight on my side not noticing initials in 
your SoB tag. But since the issue was raised by Maxime, I didn't follow up.

Dne sobota, 13. februar 2021 ob 07:51:32 CET je B.R. Oake napisal(a):
> On Wed Feb 10 at 16:01:18 CET 2021, Maxime Ripard wrote:
> > Unfortunately we can't take this patch as is, this needs to be your real
> > name, see:
> > https://www.kernel.org/doc/html/latest/process/submitting-patches.html#de
> > veloper-s-certificate-of-origin-1-1
> Dear Maxime,
> 
> Thank you very much for considering my contribution and for all your
> work on supporting sunxi-based hardware; I appreciate it.
> 
> Thank you for referring me to the Developer's Certificate of Origin, but
> I had already read it before submitting (I had to do so in order to know
> what I was saying by "Signed-off-by:") and I do certify what it says.
> 
> Looking through recent entries in the commit log of the mainline kernel,
> I see several patches from authors such as:
> 
>   H.J. Lu 
>   B K Karthik 
>   JC Kuo 
>   EJ Hsu 
>   LH Lin 
>   KP Singh 
>   Karthik B S 
>   Shreyas NC 
>   Vandana BN 
> 
> so I believe names of this form are in fact acceptable, even if the
> style might seem a little old-fashioned to some.

Speaking generally, not only for this case, prior art arguments rarely hold, 
because:
- it might be oversight,
- it might be a bad practice, which should not be followed in new 
contributions,
- different maintainers have different point of view on same thing,
- maintainer wants to adapt new practice or steer subsystem in new direction

> 
> I would like to add that I have met many people with names such as C.J.,
> A A, TC, MG, etc. That is what everybody calls them and it would be
> natural for them to sign themselves that way. Some of them might want to
> contribute to Linux some day, and I think it would be a great shame and
> a loss to all of us if they were discouraged from doing so by reading
> our conversation in the archives and concluding that any contribution
> from them, however small, would be summarily refused simply because of
> their name. Please could you ensure that does not happen?

The link you posted says following:
"using your real name (sorry, no pseudonyms or anonymous contributions.)"

I believe that real name means no initials, no matter what people are 
accustomed to. From my point of view, CJ is pseudonym derived from real name.

This is not the first time that fix of SoB tag was requested, you can find such 
requests in ML archives.

Best regards,
Jernej

> 
> Thank you again for your consideration.
> 
> Yours sincerely,
> B.R. Oake.






Re: MIPS noncoherent DMA cleanups v2

2021-02-13 Thread Thomas Bogendoerfer
On Wed, Feb 10, 2021 at 10:56:35AM +0100, Christoph Hellwig wrote:
> Hi Thomas,
> 
> this series cleans up some of the mips (maybe) noncoherent support.
> It also remove the need for the special  header only
> provided by mips.
> 
> Changes since v1:
>  - fix a bisection issue due to a missing brace
>  - simplify the parameter parsing given that it happens after
>plat_mem_init

series applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.[ RFC1925, 2.3 ]


Re: [PATCH 2/2] MIPS: Simplify EVA cache handling

2021-02-13 Thread Thomas Bogendoerfer
On Wed, Feb 10, 2021 at 05:16:14PM +0100, Thomas Bogendoerfer wrote:
> protected_cache_op is only used for flushing user addresses, so
> we only need to define protected_cache_op different in EVA mode and
> be done with it.
> 
> Signed-off-by: Thomas Bogendoerfer 
> ---
>  arch/mips/include/asm/r4kcache.h | 67 ++--
>  1 file changed, 11 insertions(+), 56 deletions(-)

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.[ RFC1925, 2.3 ]


Re: [PATCH 1/2] Revert "MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes"

2021-02-13 Thread Thomas Bogendoerfer
On Wed, Feb 10, 2021 at 05:16:13PM +0100, Thomas Bogendoerfer wrote:
> This reverts commit 6ebda44f366478d1eea180d93154e7d97b591f50.
> 
> All icache flushes in this code paths are done via flush_icache_range(),
> which only uses normal cache instruction. And this is the correct thing
> for EVA mode, too. So no need to do set_fs(KERNEL_DS) here.
> 
> Signed-off-by: Thomas Bogendoerfer 
> ---
>  arch/mips/kernel/ftrace.c |  4 
>  arch/mips/kernel/kgdb.c   | 18 +-
>  2 files changed, 1 insertion(+), 21 deletions(-)

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.[ RFC1925, 2.3 ]


Re: [PATCH v2 RESEND] MIPS: Add basic support for ptrace single step

2021-02-13 Thread Thomas Bogendoerfer
On Sat, Feb 13, 2021 at 02:20:46AM +0800, Tiezhu Yang wrote:
> From: Tiezhu Yang 
> 
> In the current code, arch_has_single_step() is not defined on MIPS,
> that means MIPS does not support instruction single-step for user mode.
> 
> Delve is a debugger for the Go programming language, the ptrace syscall
> PtraceSingleStep() failed [1] on MIPS and then the single step function
> can not work well, we can see that PtraceSingleStep() definition returns
> ptrace(PTRACE_SINGLESTEP) [2].
> 
> So it is necessary to support ptrace single step on MIPS.
> 
> At the beginning, we try to use the Debug Single Step exception on the
> Loongson 3A4000 platform, but it has no effect when set CP0_DEBUG SSt
> bit, this is because CP0_DEBUG NoSSt bit is 1 which indicates no
> single-step feature available [3], so this way which is dependent on the
> hardware is almost impossible.
> 
> With further research, we find out there exists a common way used with
> break instruction in arch/alpha/kernel/ptrace.c, it is workable.
> 
> For the above analysis, define arch_has_single_step(), add the common
> function user_enable_single_step() and user_disable_single_step(), set
> flag TIF_SINGLESTEP for child process, use break instruction to set
> breakpoint.
> 
> We can use the following testcase to test it:
> tools/testing/selftests/breakpoints/step_after_suspend_test.c
> 
>  $ make -C tools/testing/selftests TARGETS=breakpoints
>  $ cd tools/testing/selftests/breakpoints
> 
> Without this patch:
> 
>  $ ./step_after_suspend_test -n
>  TAP version 13
>  1..4
>  # ptrace(PTRACE_SINGLESTEP) not supported on this architecture: Input/output 
> error
>  ok 1 # SKIP CPU 0
>  # ptrace(PTRACE_SINGLESTEP) not supported on this architecture: Input/output 
> error
>  ok 2 # SKIP CPU 1
>  # ptrace(PTRACE_SINGLESTEP) not supported on this architecture: Input/output 
> error
>  ok 3 # SKIP CPU 2
>  # ptrace(PTRACE_SINGLESTEP) not supported on this architecture: Input/output 
> error
>  ok 4 # SKIP CPU 3
>  # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:4 error:0
> 
> With this patch:
> 
>  $ ./step_after_suspend_test -n
>  TAP version 13
>  1..4
>  ok 1 CPU 0
>  ok 2 CPU 1
>  ok 3 CPU 2
>  ok 4 CPU 3
>  # Totals: pass:4 fail:0 xfail:0 xpass:0 skip:0 error:0
> 
> [1] 
> https://github.com/go-delve/delve/blob/master/pkg/proc/native/threads_linux.go#L50
> [2] 
> https://github.com/go-delve/delve/blob/master/vendor/golang.org/x/sys/unix/syscall_linux.go#L1573
> [3] http://www.t-es-t.hu/download/mips/md00047f.pdf
> 
> Reported-by: Guoqi Chen 
> Signed-off-by: Xingxing Su 
> Signed-off-by: Tiezhu Yang 
> Reported-by: kernel test robot 
> ---
> 
> RESEND due to send to mail list failed, sorry for that.
> 
> v2: make union mips_instruction mips_insn = { 0 };
> to fix uninitialized build warning used with clang
> reported by kernel test robot.
> 
>  arch/mips/include/asm/ptrace.h  |   2 +
>  arch/mips/include/asm/thread_info.h |   5 ++
>  arch/mips/kernel/ptrace.c   | 108 
> 
>  arch/mips/kernel/signal.c   |   2 +-
>  4 files changed, 116 insertions(+), 1 deletion(-)

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.[ RFC1925, 2.3 ]


[PATCH v2] mtd: spinand: add support for Foresee FS35ND01G-S1Y2

2021-02-13 Thread Daniel Palmer
Add support for the Foresee FS35ND01G-S1Y2 manufactured by Longsys.

Signed-off-by: Daniel Palmer 

Link: 
https://datasheet.lcsc.com/szlcsc/2008121142_FORESEE-FS35ND01G-S1Y2QWFI000_C719495.pdf
---
 drivers/mtd/nand/spi/Makefile  |  2 +-
 drivers/mtd/nand/spi/core.c|  1 +
 drivers/mtd/nand/spi/longsys.c | 86 ++
 include/linux/mtd/spinand.h|  1 +
 4 files changed, 89 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/nand/spi/longsys.c

diff --git a/drivers/mtd/nand/spi/Makefile b/drivers/mtd/nand/spi/Makefile
index 9662b9c1d5a9..1d6819022e43 100644
--- a/drivers/mtd/nand/spi/Makefile
+++ b/drivers/mtd/nand/spi/Makefile
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
-spinand-objs := core.o gigadevice.o macronix.o micron.o paragon.o toshiba.o 
winbond.o
+spinand-objs := core.o gigadevice.o longsys.o macronix.o micron.o paragon.o 
toshiba.o winbond.o
 obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 61d932c1b718..8c36f0f6b1c9 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -864,6 +864,7 @@ static const struct nand_ops spinand_ops = {
 
 static const struct spinand_manufacturer *spinand_manufacturers[] = {
&gigadevice_spinand_manufacturer,
+   &longsys_spinand_manufacturer,
¯onix_spinand_manufacturer,
µn_spinand_manufacturer,
¶gon_spinand_manufacturer,
diff --git a/drivers/mtd/nand/spi/longsys.c b/drivers/mtd/nand/spi/longsys.c
new file mode 100644
index ..418bd5a1f20d
--- /dev/null
+++ b/drivers/mtd/nand/spi/longsys.c
@@ -0,0 +1,86 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2020 Daniel Palmer 
+ *
+ */
+
+#include 
+#include 
+#include 
+
+#define SPINAND_MFR_LONGSYS0xCD
+
+static SPINAND_OP_VARIANTS(read_cache_variants,
+   SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+
+static SPINAND_OP_VARIANTS(write_cache_variants,
+   SPINAND_PROG_LOAD(true, 0, NULL, 0));
+
+static SPINAND_OP_VARIANTS(update_cache_variants,
+   SPINAND_PROG_LOAD(false, 0, NULL, 0));
+
+static int fs35nd01g_s1y2_ooblayout_ecc(struct mtd_info *mtd, int section,
+   struct mtd_oob_region *region)
+{
+   if (section > 3)
+   return -ERANGE;
+
+   /* ECC is not user accessible */
+   region->offset = 0;
+   region->length = 0;
+
+   return 0;
+}
+
+static int fs35nd01g_s1y2_ooblayout_free(struct mtd_info *mtd, int section,
+   struct mtd_oob_region *region)
+{
+   if (section > 3)
+   return -ERANGE;
+
+   /*
+* No ECC data is stored in the accessible OOB so the full 16 bytes
+* of each spare region is available to the user. Apparently also
+* covered by the internal ECC.
+*/
+   if (section) {
+   region->offset = 16 * section;
+   region->length = 16;
+   } else {
+   /* First byte in spare0 area is used for bad block marker */
+   region->offset = 1;
+   region->length = 15;
+   }
+
+   return 0;
+}
+
+static const struct mtd_ooblayout_ops fs35nd01g_s1y2_ooblayout = {
+   .ecc = fs35nd01g_s1y2_ooblayout_ecc,
+   .free = fs35nd01g_s1y2_ooblayout_free,
+};
+
+static const struct spinand_info longsys_spinand_table[] = {
+   SPINAND_INFO("FS35ND01G-S1Y2",
+SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xEA, 0x11),
+NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
+NAND_ECCREQ(4, 512),
+SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+ &write_cache_variants,
+ &update_cache_variants),
+SPINAND_HAS_QE_BIT,
+SPINAND_ECCINFO(&fs35nd01g_s1y2_ooblayout,
+NULL)),
+};
+
+static const struct spinand_manufacturer_ops longsys_spinand_manuf_ops = {
+};
+
+const struct spinand_manufacturer longsys_spinand_manufacturer = {
+   .id = SPINAND_MFR_LONGSYS,
+   .name = "Longsys",
+   .chips = longsys_spinand_table,
+   .nchips = ARRAY_SIZE(longsys_spinand_table),
+   .ops = &longsys_spinand_manuf_ops,
+};
diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
index 6bb92f26833e..8651e63a2f8a 100644
--- a/include/linux/mtd/spinand.h
+++ b/include/linux/mtd/spinand.h
@@ -239,6 +239,7 @@ struct spinand_manufacturer {
 
 /* SPI NAND manufacturers */
 extern const struct spinand_manufacturer gigadevice_spinand_manufacturer;
+extern const struct spinand_manufacturer longsys_spinand_manufacturer;
 extern const struct spinand_manufacturer macronix_spinand_manufacturer;
 extern const struct spinand_manufacturer micro

Re: [PATCH mvebu v2 00/10] Armada 37xx: Fix cpufreq changing base CPU speed to 800 MHz from 1000 MHz

2021-02-13 Thread Pali Rohár
On Thursday 11 February 2021 16:41:13 nnet wrote:
> On Thu, Feb 11, 2021, at 3:44 PM, Pali Rohár wrote:
> > On Thursday 11 February 2021 12:22:52 nnet wrote:
> > > On Thu, Feb 11, 2021, at 11:55 AM, Pali Rohár wrote:
> > > > On Wednesday 10 February 2021 11:08:59 nnet wrote:
> > > > > On Wed, Feb 10, 2021, at 10:03 AM, Pali Rohár wrote:
> > > > > > > > Hello! Could you please enable userspace governor during kernel
> > > > > > > > compilation?
> > > > > > > > 
> > > > > > > > CONFIG_CPU_FREQ_GOV_USERSPACE=y
> > > > > > > > 
> > > > > > > > It can be activated via command:
> > > > > > > > 
> > > > > > > > echo userspace > 
> > > > > > > > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
> > > > > > > > 
> > > > > > > > After that you can "force" CPU frequency to specific value, 
> > > > > > > > e.g.:
> > > > > > > > 
> > > > > > > > echo 100 > 
> > > > > > > > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed
> > > > > > > > 
> > > > > > > > I need to know which switch (from --> to freq) cause this 
> > > > > > > > system hang.
> > > > > > > > 
> > > > > > > > This patch series (via MIN_VOLT_MV_FOR_L0_L1_1GHZ) is fixing 
> > > > > > > > only
> > > > > > > > switching from 500 MHz to 1000 MHz on 1 GHz variant. As only 
> > > > > > > > this switch
> > > > > > > > is causing issue.
> > > > > > > > 
> > > > > > > > I have used following simple bash script to check that 
> > > > > > > > switching between
> > > > > > > > 500 MHz and 1 GHz is stable:
> > > > > > > > 
> > > > > > > > while true; do
> > > > > > > > echo 100 > 
> > > > > > > > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed;
> > > > > > > > echo 50 > 
> > > > > > > > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed;
> > > > > > > > echo 100 > 
> > > > > > > > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed;
> > > > > > > > echo 50 > 
> > > > > > > > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed;
> > > > > > > > done
> > > > > > > 
> > > > > > > echo userspace | tee 
> > > > > > > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
> > > > > > > while true; do
> > > > > > >   echo 120 | tee 
> > > > > > > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed;
> > > > > > >   echo 60 | tee 
> > > > > > > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed;
> > > > > > > done
> > > > > > > 
> > > > > > > >> +#define MIN_VOLT_MV_FOR_L0_L1_1GHZ 1108
> > > > > > > 
> > > > > > > With 1108 I get a freeze within a minute. The last output to 
> > > > > > > stdout is 60.
> > > > > > > 
> > > > > > > With 1120 it takes a few minutes.
> > > > > > > 
> > > > > > > With any of 1225, 1155, 1132 the device doesn't freeze over the 
> > > > > > > full 5 minute load test.
> > > > > > > 
> > > > > > > I'm using ondemand now with the above at 1132 without issue so 
> > > > > > > far.
> > > > > > 
> > > > > > Great, thank you for testing!
> > > > > > 
> > > > > > Can you check if switching between any two lower frequencies 20
> > > > > > 30 60 is stable?
> > > > > 
> > > > > This is stable using 1132 mV for MIN_VOLT_MV_FOR_L0_L1_1GHZ:
> > > > > 
> > > > > while true; do
> > > > >   # down
> > > > >   echo 120 | tee 
> > > > > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed;
> > > > ...
> > > > 
> > > > Hello!
> > > > 
> > > > Could you please re-run test without tee, in form as I have shown above?
> > > > UART is slow and printing something to console adds delay which decrease
> > > > probability that real issue is triggered as this is timing issue.
> > > 
> > > The test was done over SSH.
> > 
> > Ok! But it is still better to not print any results as it adds unwanted
> > delay between frequency switching.
> > 
> > > > Also please do tests just between two frequencies in loop as I observed
> > > > that switching between more decreased probability to hit issue.
> > > 
> > > > > > > echo userspace | tee 
> > > > > > > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
> > > > > > > while true; do
> > > > > > >   echo 120 | tee 
> > > > > > > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed;
> > > > > > >   echo 60 | tee 
> > > > > > > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed;
> > > > > > > done
> > > 
> > > The first test ^ switched between 600 MHz and 1.2 GHz.
> > > 
> > > > The real issue for 1 GHz variant of A3720 is only when doing switch from
> > > > 500 MHz to 1 GHz. So could you try to do some tests also without
> > > > changing MIN_VOLT_MV_FOR_L0_L1_1GHZ and switching just between non-1.2
> > > > frequencies (to verify that on 1.2 GHz variant it is also from 600 MHz
> > > > to 1.2 GHz)?
> > > 
> > > With 1108 mV and switching between 600 MHz and 1.2GHz, I always saw a 
> > > freeze within a minute.
> > 
> > I mean to try switching with 1.108 V between 200 MHz and 300 MHz or
> > between 300 MHz and 600 MHz. To check that issue is really only with
> > switch 

Re: general protection fault in tomoyo_socket_sendmsg_permission

2021-02-13 Thread Tetsuo Handa
Greg, will you queue 
https://lkml.kernel.org/r/20210205135707.4574-1-penguin-ker...@i-love.sakura.ne.jp
 (which can
close a report which is wasting syzbot's resource with 5300+ crashes) for 5.12 
? The change shown below will be
too large to test before merge window for 5.12 opens. 

The patch for fixing "general protection fault in 
tomoyo_socket_sendmsg_permission" will kill kthread_get_run().
Closing frequently crashing bug now is the better.

On 2021/02/11 22:40, Tetsuo Handa wrote:
> I guess that we need to serialize attach operation and reset/detach 
> operations, for
> it seems there is a race window that might result in "general protection 
> fault in
> tomoyo_socket_sendmsg_permission". Details follows...

Here is untested diff that is expected to be complete.

(1) Handle kthread_create() failure (which avoids "KASAN: null-ptr-deref Write 
in vhci_shutdown_connection")
by grouping socket lookup, SOCK_STREAM check and kthread_get_run() into 
usbip_prepare_threads() function.

(2) Serialize usbip_sockfd_store(), detach_store(), attach_store(), 
usbip_sockfd_store() and
ud->eh_ops.shutdown()/ud->eh_ops.reset()/ud->eh_ops.unusable() operations 
using usbip_store_mutex mutex
(which avoids "general protection fault in 
tomoyo_socket_sendmsg_permission").

(3) Don't reset ud->tcp_socket to NULL in vhci_device_reset(). Since 
tx_thread/rx_thread depends on
ud->tcp_socket != NULL whereas tcp_socket and tx_thread/rx_thread are 
assigned at the same time,
it is never safe to reset only ud->tcp_socket from ud->eh_ops.reset(). And 
actually nobody is
calling ud->eh_ops.reset() without ud->eh_ops.shutdown().

(4) usbip_sockfd_store() must perform {sdev,udc}->ud.status != 
SDEV_ST_AVAILABLE && {sdev,udc}->ud.status = SDEV_ST_USED
exclusively, or multiple tx_thread/rx_thread can be created when 
concurrently called. Although (2) will already
serialize this action, (1) will make it possible to perform within one 
spinlock section.

 drivers/usb/usbip/stub_dev.c | 56 ++--
 drivers/usb/usbip/usbip_common.c | 55 +++
 drivers/usb/usbip/usbip_common.h | 13 
 drivers/usb/usbip/usbip_event.c  |  9 +
 drivers/usb/usbip/vhci_hcd.c |  7 +---
 drivers/usb/usbip/vhci_sysfs.c   | 50 
 drivers/usb/usbip/vudc_sysfs.c   | 50 
 7 files changed, 175 insertions(+), 65 deletions(-)

diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
index 2305d425e6c9..522d58826049 100644
--- a/drivers/usb/usbip/stub_dev.c
+++ b/drivers/usb/usbip/stub_dev.c
@@ -39,12 +39,11 @@ static DEVICE_ATTR_RO(usbip_status);
  * is used to transfer usbip requests by kernel threads. -1 is a magic number
  * by which usbip connection is finished.
  */
-static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute 
*attr,
-   const char *buf, size_t count)
+static ssize_t __usbip_sockfd_store(struct device *dev, struct 
device_attribute *attr,
+   const char *buf, size_t count)
 {
struct stub_device *sdev = dev_get_drvdata(dev);
int sockfd = 0;
-   struct socket *socket;
int rv;
 
if (!sdev) {
@@ -57,7 +56,12 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct 
device_attribute *a
return -EINVAL;
 
if (sockfd != -1) {
-   int err;
+   struct usbip_thread_info uti;
+   int err = usbip_prepare_threads(&uti, &sdev->ud, sockfd,
+   stub_tx_loop, "stub_tx", 
stub_rx_loop, "stub_rx");
+
+   if (err)
+   return err;
 
dev_info(dev, "stub up\n");
 
@@ -65,44 +69,46 @@ static ssize_t usbip_sockfd_store(struct device *dev, 
struct device_attribute *a
 
if (sdev->ud.status != SDEV_ST_AVAILABLE) {
dev_err(dev, "not ready\n");
-   goto err;
+   spin_unlock_irq(&sdev->ud.lock);
+   usbip_unprepare_threads(&uti);
+   return -EINVAL;
}
 
-   socket = sockfd_lookup(sockfd, &err);
-   if (!socket)
-   goto err;
-
-   sdev->ud.tcp_socket = socket;
+   sdev->ud.tcp_socket = uti.tcp_socket;
sdev->ud.sockfd = sockfd;
-
-   spin_unlock_irq(&sdev->ud.lock);
-
-   sdev->ud.tcp_rx = kthread_get_run(stub_rx_loop, &sdev->ud,
- "stub_rx");
-   sdev->ud.tcp_tx = kthread_get_run(stub_tx_loop, &sdev->ud,
- "stub_tx");
-
-   spin_lock_irq(&sdev->ud.lock);
+   sdev->ud.tcp_rx = uti.tcp_rx;
+   sdev->ud.tcp_tx = uti.tcp_tx;
sdev->ud.status = SDEV_ST_USE

Re: general protection fault in tomoyo_socket_sendmsg_permission

2021-02-13 Thread Greg Kroah-Hartman
On Sat, Feb 13, 2021 at 07:02:22PM +0900, Tetsuo Handa wrote:
> Greg, will you queue 
> https://lkml.kernel.org/r/20210205135707.4574-1-penguin-ker...@i-love.sakura.ne.jp
>  (which can
> close a report which is wasting syzbot's resource with 5300+ crashes) for 
> 5.12 ? The change shown below will be
> too large to test before merge window for 5.12 opens. 
> 
> The patch for fixing "general protection fault in 
> tomoyo_socket_sendmsg_permission" will kill kthread_get_run().
> Closing frequently crashing bug now is the better.
> 
> On 2021/02/11 22:40, Tetsuo Handa wrote:
> > I guess that we need to serialize attach operation and reset/detach 
> > operations, for
> > it seems there is a race window that might result in "general protection 
> > fault in
> > tomoyo_socket_sendmsg_permission". Details follows...
> 
> Here is untested diff that is expected to be complete.

Please work and test this and get it merged in a normal manner, there is
no "rush" here at all.  Submit it properly and all will be fine.

thanks,

greg k-h


Re: general protection fault in tomoyo_socket_sendmsg_permission

2021-02-13 Thread Greg Kroah-Hartman
On Sat, Feb 13, 2021 at 07:02:22PM +0900, Tetsuo Handa wrote:
> Greg, will you queue 
> https://lkml.kernel.org/r/20210205135707.4574-1-penguin-ker...@i-love.sakura.ne.jp
>  (which can
> close a report which is wasting syzbot's resource with 5300+ crashes) for 
> 5.12 ? The change shown below will be
> too large to test before merge window for 5.12 opens. 
> 
> The patch for fixing "general protection fault in 
> tomoyo_socket_sendmsg_permission" will kill kthread_get_run().
> Closing frequently crashing bug now is the better.
> 
> On 2021/02/11 22:40, Tetsuo Handa wrote:
> > I guess that we need to serialize attach operation and reset/detach 
> > operations, for
> > it seems there is a race window that might result in "general protection 
> > fault in
> > tomoyo_socket_sendmsg_permission". Details follows...
> 
> Here is untested diff that is expected to be complete.
> 
> (1) Handle kthread_create() failure (which avoids "KASAN: null-ptr-deref 
> Write in vhci_shutdown_connection")
> by grouping socket lookup, SOCK_STREAM check and kthread_get_run() into 
> usbip_prepare_threads() function.
> 
> (2) Serialize usbip_sockfd_store(), detach_store(), attach_store(), 
> usbip_sockfd_store() and
> ud->eh_ops.shutdown()/ud->eh_ops.reset()/ud->eh_ops.unusable() operations 
> using usbip_store_mutex mutex
> (which avoids "general protection fault in 
> tomoyo_socket_sendmsg_permission").
> 
> (3) Don't reset ud->tcp_socket to NULL in vhci_device_reset(). Since 
> tx_thread/rx_thread depends on
> ud->tcp_socket != NULL whereas tcp_socket and tx_thread/rx_thread are 
> assigned at the same time,
> it is never safe to reset only ud->tcp_socket from ud->eh_ops.reset(). 
> And actually nobody is
> calling ud->eh_ops.reset() without ud->eh_ops.shutdown().
> 
> (4) usbip_sockfd_store() must perform {sdev,udc}->ud.status != 
> SDEV_ST_AVAILABLE && {sdev,udc}->ud.status = SDEV_ST_USED
> exclusively, or multiple tx_thread/rx_thread can be created when 
> concurrently called. Although (2) will already
> serialize this action, (1) will make it possible to perform within one 
> spinlock section.

Shouldn't this be 4 different patches?

thanks,

greg k-h


[PATCH 1/4] ASoC: mmp-sspa: drop unneeded snd_soc_dai_set_drvdata

2021-02-13 Thread Julia Lawall
snd_soc_dai_set_drvdata is not needed when the set data comes from
snd_soc_dai_get_drvdata or dev_get_drvdata.  The problem was fixed
usingthe following semantic patch: (http://coccinelle.lip6.fr/)

// 
@@
expression x,y,e;
@@
x = dev_get_drvdata(y->dev)
... when != x = e
-   snd_soc_dai_set_drvdata(y,x);

@@
expression x,y,e;
@@
x = snd_soc_dai_get_drvdata(y)
... when != x = e
-   snd_soc_dai_set_drvdata(y,x);
// 

Signed-off-by: Julia Lawall 

---
 sound/soc/pxa/mmp-sspa.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c
index 4803972ee655..7e39210a0b38 100644
--- a/sound/soc/pxa/mmp-sspa.c
+++ b/sound/soc/pxa/mmp-sspa.c
@@ -330,7 +330,6 @@ static int mmp_sspa_probe(struct snd_soc_dai *dai)
&sspa->playback_dma_data,
&sspa->capture_dma_data);
 
-   snd_soc_dai_set_drvdata(dai, sspa);
return 0;
 }
 



[PATCH 0/4] drop unneeded snd_soc_dai_set_drvdata

2021-02-13 Thread Julia Lawall
snd_soc_dai_set_drvdata is not needed when the set data comes from
snd_soc_dai_get_drvdata or dev_get_drvdata.  

---

 sound/soc/fsl/fsl_micfil.c  |2 --
 sound/soc/fsl/fsl_sai.c |2 --
 sound/soc/fsl/fsl_xcvr.c|1 -
 sound/soc/mxs/mxs-saif.c|   10 --
 sound/soc/pxa/mmp-sspa.c|1 -
 sound/soc/sunxi/sun4i-i2s.c |2 --
 6 files changed, 18 deletions(-)


[PATCH 2/4] ASoC: mxs-saif: drop unneeded snd_soc_dai_set_drvdata

2021-02-13 Thread Julia Lawall
snd_soc_dai_set_drvdata is not needed when the set data comes from
snd_soc_dai_get_drvdata or dev_get_drvdata.  The problem was fixed
usingthe following semantic patch: (http://coccinelle.lip6.fr/)

// 
@@
expression x,y,e;
@@
x = dev_get_drvdata(y->dev)
... when != x = e
-   snd_soc_dai_set_drvdata(y,x);

@@
expression x,y,e;
@@
x = snd_soc_dai_get_drvdata(y)
... when != x = e
-   snd_soc_dai_set_drvdata(y,x);
// 

In this case, the whole probe function then does nothing, so drop it.

Signed-off-by: Julia Lawall 

---
 sound/soc/mxs/mxs-saif.c |   10 --
 1 file changed, 10 deletions(-)

diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
index 07f8cf9980e3..6a2d24d48964 100644
--- a/sound/soc/mxs/mxs-saif.c
+++ b/sound/soc/mxs/mxs-saif.c
@@ -642,18 +642,8 @@ static const struct snd_soc_dai_ops mxs_saif_dai_ops = {
.set_fmt = mxs_saif_set_dai_fmt,
 };
 
-static int mxs_saif_dai_probe(struct snd_soc_dai *dai)
-{
-   struct mxs_saif *saif = dev_get_drvdata(dai->dev);
-
-   snd_soc_dai_set_drvdata(dai, saif);
-
-   return 0;
-}
-
 static struct snd_soc_dai_driver mxs_saif_dai = {
.name = "mxs-saif",
-   .probe = mxs_saif_dai_probe,
.playback = {
.channels_min = 2,
.channels_max = 2,



Re: [PATCH RFC 5/6] btrfs: sysfs: Add directory for read policies

2021-02-13 Thread Greg KH
On Tue, Feb 09, 2021 at 09:30:39PM +0100, Michal Rostecki wrote:
> From: Michal Rostecki 
> 
> Before this change, raid1 read policy could be selected by using the
> /sys/fs/btrfs/[fsid]/read_policy file.
> 
> Change it to /sys/fs/btrfs/[fsid]/read_policies/policy.
> 
> The motivation behing creating the read_policies directory is that the
> next changes and new read policies are going to intruduce settings
> specific to read policies.

No Documentation/ABI/ update for this change?



[PATCH 3/4] ASoC: sun4i-i2s: drop unneeded snd_soc_dai_set_drvdata

2021-02-13 Thread Julia Lawall
snd_soc_dai_set_drvdata is not needed when the set data comes from
snd_soc_dai_get_drvdata or dev_get_drvdata.  The problem was fixed
usingthe following semantic patch: (http://coccinelle.lip6.fr/)

// 
@@
expression x,y,e;
@@
x = dev_get_drvdata(y->dev)
... when != x = e
-   snd_soc_dai_set_drvdata(y,x);

@@
expression x,y,e;
@@
x = snd_soc_dai_get_drvdata(y)
... when != x = e
-   snd_soc_dai_set_drvdata(y,x);
// 

Signed-off-by: Julia Lawall 

---
 sound/soc/sunxi/sun4i-i2s.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 78506c3811dc..c57feae3396e 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -1079,8 +1079,6 @@ static int sun4i_i2s_dai_probe(struct snd_soc_dai *dai)
  &i2s->playback_dma_data,
  &i2s->capture_dma_data);
 
-   snd_soc_dai_set_drvdata(dai, i2s);
-
return 0;
 }
 



[PATCH 4/4] ASoC: fsl: drop unneeded snd_soc_dai_set_drvdata

2021-02-13 Thread Julia Lawall
snd_soc_dai_set_drvdata is not needed when the set data comes from
snd_soc_dai_get_drvdata or dev_get_drvdata.  The problem was fixed
usingthe following semantic patch: (http://coccinelle.lip6.fr/)

// 
@@
expression x,y,e;
@@
x = dev_get_drvdata(y->dev)
... when != x = e
-   snd_soc_dai_set_drvdata(y,x);

@@
expression x,y,e;
@@
x = snd_soc_dai_get_drvdata(y)
... when != x = e
-   snd_soc_dai_set_drvdata(y,x);
// 

Signed-off-by: Julia Lawall 

---
 sound/soc/fsl/fsl_micfil.c |2 --
 sound/soc/fsl/fsl_sai.c|2 --
 sound/soc/fsl/fsl_xcvr.c   |1 -
 3 files changed, 5 deletions(-)

diff --git a/sound/soc/fsl/fsl_micfil.c b/sound/soc/fsl/fsl_micfil.c
index 8aedf6590b28..fd21017fa2bd 100644
--- a/sound/soc/fsl/fsl_micfil.c
+++ b/sound/soc/fsl/fsl_micfil.c
@@ -423,8 +423,6 @@ static int fsl_micfil_dai_probe(struct snd_soc_dai *cpu_dai)
return ret;
}
 
-   snd_soc_dai_set_drvdata(cpu_dai, micfil);
-
return 0;
 }
 
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index 5e65b456d3e2..8876d0ed37d9 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -727,8 +727,6 @@ static int fsl_sai_dai_probe(struct snd_soc_dai *cpu_dai)
snd_soc_dai_init_dma_data(cpu_dai, &sai->dma_params_tx,
&sai->dma_params_rx);
 
-   snd_soc_dai_set_drvdata(cpu_dai, sai);
-
return 0;
 }
 
diff --git a/sound/soc/fsl/fsl_xcvr.c b/sound/soc/fsl/fsl_xcvr.c
index dd228b421e2c..8a3bde718697 100644
--- a/sound/soc/fsl/fsl_xcvr.c
+++ b/sound/soc/fsl/fsl_xcvr.c
@@ -869,7 +869,6 @@ static int fsl_xcvr_dai_probe(struct snd_soc_dai *dai)
struct fsl_xcvr *xcvr = snd_soc_dai_get_drvdata(dai);
 
snd_soc_dai_init_dma_data(dai, &xcvr->dma_prms_tx, &xcvr->dma_prms_rx);
-   snd_soc_dai_set_drvdata(dai, xcvr);
 
snd_soc_add_dai_controls(dai, &fsl_xcvr_mode_kctl, 1);
snd_soc_add_dai_controls(dai, &fsl_xcvr_arc_mode_kctl, 1);



Re: [RFC PATCH 09/12] drivers: base: reintroduce find_bus()

2021-02-13 Thread Greg KH
On Mon, Feb 08, 2021 at 11:22:00PM +0100, Enrico Weigelt, metux IT consult 
wrote:
> ---
>  drivers/base/bus.c | 14 ++
>  include/linux/device/bus.h |  2 ++
>  2 files changed, 12 insertions(+), 4 deletions(-)

Um, no.


Re: [PATCH net-next v2 1/3] net: phy: broadcom: Avoid forward for bcm54xx_config_clock_delay()

2021-02-13 Thread Vladimir Oltean
On Fri, Feb 12, 2021 at 07:46:30PM -0800, Florian Fainelli wrote:
> Avoid a forward declaration by moving the callers of
> bcm54xx_config_clock_delay() below its body.
> 
> Signed-off-by: Florian Fainelli 
> ---

Reviewed-by: Vladimir Oltean 


Re: [PATCH net-next v2 2/3] net: phy: broadcom: Remove unused flags

2021-02-13 Thread Vladimir Oltean
On Fri, Feb 12, 2021 at 07:46:31PM -0800, Florian Fainelli wrote:
> We have a number of unused flags defined today and since we are scarce
> on space and may need to introduce new flags in the future remove and
> shift every existing flag down into a contiguous assignment.
> PHY_BCM_FLAGS_MODE_1000BX was only used internally for the BCM54616S
> PHY, so we allocate a driver private structure instead to store that
> flag instead of canibalizing one from phydev->dev_flags for that
> purpose.
> 
> Signed-off-by: Florian Fainelli 
> ---

So you want to remove the IBND dev_flags separately, okay.

Reviewed-by: Vladimir Oltean 


possible deadlock in evict

2021-02-13 Thread syzbot
Hello,

syzbot found the following issue on:

HEAD commit:c6d8570e Merge tag 'io_uring-5.11-2021-02-12' of git://git..
git tree:   upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=123a4be2d0
kernel config:  https://syzkaller.appspot.com/x/.config?x=bec717fd4ac4bf03
dashboard link: https://syzkaller.appspot.com/bug?extid=1b2c6989ec12e467d65c

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+1b2c6989ec12e467d...@syzkaller.appspotmail.com

==
WARNING: possible circular locking dependency detected
5.11.0-rc7-syzkaller #0 Not tainted
--
kswapd0/2232 is trying to acquire lock:
88801f552650 (sb_internal){.+.+}-{0:0}, at: evict+0x2ed/0x6b0 fs/inode.c:577

but task is already holding lock:
8be89240 (fs_reclaim){+.+.}-{0:0}, at: __fs_reclaim_acquire+0x0/0x30 
mm/page_alloc.c:5195

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (fs_reclaim){+.+.}-{0:0}:
   __fs_reclaim_acquire mm/page_alloc.c:4326 [inline]
   fs_reclaim_acquire+0x117/0x150 mm/page_alloc.c:4340
   might_alloc include/linux/sched/mm.h:193 [inline]
   slab_pre_alloc_hook mm/slab.h:493 [inline]
   slab_alloc_node mm/slab.c:3221 [inline]
   kmem_cache_alloc_node_trace+0x48/0x520 mm/slab.c:3596
   __do_kmalloc_node mm/slab.c:3618 [inline]
   __kmalloc_node+0x38/0x60 mm/slab.c:3626
   kmalloc_node include/linux/slab.h:575 [inline]
   kvmalloc_node+0x61/0xf0 mm/util.c:587
   kvmalloc include/linux/mm.h:781 [inline]
   ext4_xattr_inode_cache_find fs/ext4/xattr.c:1465 [inline]
   ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1508 [inline]
   ext4_xattr_set_entry+0x1ce6/0x3780 fs/ext4/xattr.c:1649
   ext4_xattr_ibody_set+0x78/0x2b0 fs/ext4/xattr.c:2224
   ext4_xattr_set_handle+0x8f4/0x13e0 fs/ext4/xattr.c:2380
   ext4_xattr_set+0x13a/0x340 fs/ext4/xattr.c:2493
   __vfs_setxattr+0x10e/0x170 fs/xattr.c:177
   __vfs_setxattr_noperm+0x11a/0x4c0 fs/xattr.c:208
   __vfs_setxattr_locked+0x1bf/0x250 fs/xattr.c:266
   vfs_setxattr+0x135/0x320 fs/xattr.c:291
   setxattr+0x1ff/0x290 fs/xattr.c:553
   path_setxattr+0x170/0x190 fs/xattr.c:572
   __do_sys_setxattr fs/xattr.c:587 [inline]
   __se_sys_setxattr fs/xattr.c:583 [inline]
   __x64_sys_setxattr+0xc0/0x160 fs/xattr.c:583
   do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
   entry_SYSCALL_64_after_hwframe+0x44/0xa9

-> #2 (&ei->xattr_sem){}-{3:3}:
   down_write+0x8d/0x150 kernel/locking/rwsem.c:1406
   ext4_write_lock_xattr fs/ext4/xattr.h:142 [inline]
   ext4_xattr_set_handle+0x15c/0x13e0 fs/ext4/xattr.c:2308
   ext4_initxattrs+0xb5/0x120 fs/ext4/xattr_security.c:43
   security_inode_init_security+0x1c4/0x370 security/security.c:1054
   __ext4_new_inode+0x3963/0x5570 fs/ext4/ialloc.c:1317
   ext4_create+0x2c3/0x4c0 fs/ext4/namei.c:2613
   lookup_open.isra.0+0xf85/0x1350 fs/namei.c:3106
   open_last_lookups fs/namei.c:3180 [inline]
   path_openat+0x96d/0x2730 fs/namei.c:3368
   do_filp_open+0x17e/0x3c0 fs/namei.c:3398
   do_sys_openat2+0x16d/0x420 fs/open.c:1172
   do_sys_open fs/open.c:1188 [inline]
   __do_sys_open fs/open.c:1196 [inline]
   __se_sys_open fs/open.c:1192 [inline]
   __x64_sys_open+0x119/0x1c0 fs/open.c:1192
   do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
   entry_SYSCALL_64_after_hwframe+0x44/0xa9

-> #1 (jbd2_handle){}-{0:0}:
   start_this_handle+0xfb4/0x1380 fs/jbd2/transaction.c:446
   jbd2__journal_start+0x399/0x930 fs/jbd2/transaction.c:503
   __ext4_journal_start_sb+0x227/0x4a0 fs/ext4/ext4_jbd2.c:105
   ext4_sample_last_mounted fs/ext4/file.c:804 [inline]
   ext4_file_open+0x613/0xb40 fs/ext4/file.c:832
   do_dentry_open+0x4b9/0x11b0 fs/open.c:817
   do_open fs/namei.c:3254 [inline]
   path_openat+0x1b9a/0x2730 fs/namei.c:3371
   do_filp_open+0x17e/0x3c0 fs/namei.c:3398
   do_sys_openat2+0x16d/0x420 fs/open.c:1172
   do_sys_open fs/open.c:1188 [inline]
   __do_sys_open fs/open.c:1196 [inline]
   __se_sys_open fs/open.c:1192 [inline]
   __x64_sys_open+0x119/0x1c0 fs/open.c:1192
   do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
   entry_SYSCALL_64_after_hwframe+0x44/0xa9

-> #0 (sb_internal){.+.+}-{0:0}:
   check_prev_add kernel/locking/lockdep.c:2868 [inline]
   check_prevs_add kernel/locking/lockdep.c:2993 [inline]
   validate_chain kernel/locking/lockdep.c:3608 [inline]
   __lock_acquire+0x2b26/0x54f0 kernel/locking/lockdep.c:4832
   lock_acquire kernel/locking/lockdep.c:5442 [inline]
   lock_acquire+0x1a8/0x720 kernel/locking/lockdep.c:5407
   percpu_down_read include/linux/percpu-rwsem.h

Re: [PATCH net-next v2 3/3] net: phy: broadcom: Allow BCM54210E to configure APD

2021-02-13 Thread Vladimir Oltean
On Fri, Feb 12, 2021 at 07:46:32PM -0800, Florian Fainelli wrote:
> BCM54210E/BCM50212E has been verified to work correctly with the
> auto-power down configuration done by bcm54xx_adjust_rxrefclk(), add it
> to the list of PHYs working.
> 
> While we are at it, provide an appropriate name for the bit we are
> changing which disables the RXC and TXC during auto-power down when
> there is no energy on the cable.
> 
> Signed-off-by: Florian Fainelli 
> ---

Reviewed-by: Vladimir Oltean 

>  drivers/net/phy/broadcom.c | 8 +---
>  include/linux/brcmphy.h| 2 +-
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
> index 3ce266ab521b..91fbd26c809e 100644
> --- a/drivers/net/phy/broadcom.c
> +++ b/drivers/net/phy/broadcom.c
> @@ -193,6 +193,7 @@ static void bcm54xx_adjust_rxrefclk(struct phy_device 
> *phydev)
>   if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM57780 &&
>   BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610 &&
>   BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610M &&
> + BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54210E &&
>   BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54810 &&
>   BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54811)
>   return;
> @@ -227,9 +228,10 @@ static void bcm54xx_adjust_rxrefclk(struct phy_device 
> *phydev)
>   val |= BCM54XX_SHD_SCR3_DLLAPD_DIS;
>  
>   if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) {
> - if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810 ||
> - BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54811)
> - val |= BCM54810_SHD_SCR3_TRDDAPD;
> + if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54210E ||
> + BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810 ||
> + BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54210E)
> + val |= BCM54XX_SHD_SCR3_RXCTXC_DIS;
>   else
>   val |= BCM54XX_SHD_SCR3_TRDDAPD;
>   }
> diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
> index 844dcfe789a2..16597d3fa011 100644
> --- a/include/linux/brcmphy.h
> +++ b/include/linux/brcmphy.h
> @@ -193,6 +193,7 @@
>  #define  BCM54XX_SHD_SCR3_DEF_CLK125 0x0001
>  #define  BCM54XX_SHD_SCR3_DLLAPD_DIS 0x0002
>  #define  BCM54XX_SHD_SCR3_TRDDAPD0x0004
> +#define  BCM54XX_SHD_SCR3_RXCTXC_DIS 0x0100

Curiously enough, my BCM5464R datasheet does say:

The TXC and RXC outputs can be disabled during auto-power down by setting the 
“1000BASE-T/100BASE-TX/10BASE-T
Spare Control 3 Register (Address 1Ch, Shadow Value 00101),” bit 8 =1.

but when I go to the definition of the register, bit 8 is hidden. Odd.

How can I ensure that the auto power down feature is doing something?

>  
>  /* 01010: Auto Power-Down */
>  #define BCM54XX_SHD_APD  0x0a
> @@ -253,7 +254,6 @@
>  #define BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN  (1 << 0)
>  #define BCM54810_SHD_CLK_CTL 0x3
>  #define BCM54810_SHD_CLK_CTL_GTXCLK_EN   (1 << 9)
> -#define BCM54810_SHD_SCR3_TRDDAPD0x0100
>  
>  /* BCM54612E Registers */
>  #define BCM54612E_EXP_SPARE0 (MII_BCM54XX_EXP_SEL_ETC + 0x34)
> -- 
> 2.25.1
> 


[PULL REQUEST] i2c for v5.11

2021-02-13 Thread Wolfram Sang
Linus,

here is one more I2C driver bugfix. Please pull.

Thanks,

   Wolfram


The following changes since commit 92bf22614b21a2706f4993b278017e437f7785b3:

  Linux 5.11-rc7 (2021-02-07 13:57:38 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-current

for you to fetch changes up to 3d6a3d3a2a7a3a60a824e7c04e95fd50dec57812:

  i2c: stm32f7: fix configuration of the digital filter (2021-02-12 11:36:40 
+0100)


Alain Volmat (1):
  i2c: stm32f7: fix configuration of the digital filter

 drivers/i2c/busses/i2c-stm32f7.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)


signature.asc
Description: PGP signature


Re: [PATCH v2 1/1] riscv/kasan: add KASAN_VMALLOC support

2021-02-13 Thread Alex Ghiti

Hi Nylon, Palmer,

Le 2/8/21 à 1:28 AM, Alex Ghiti a écrit :

Hi Nylon,

Le 1/22/21 à 10:56 PM, Palmer Dabbelt a écrit :

On Fri, 15 Jan 2021 21:58:35 PST (-0800), nyl...@andestech.com wrote:

It references to x86/s390 architecture.
>> So, it doesn't map the early shadow page to cover VMALLOC space.

Prepopulate top level page table for the range that would otherwise be
empty.

lower levels are filled dynamically upon memory allocation while
booting.


I think we can improve the changelog a bit here with something like that:

"KASAN vmalloc space used to be mapped using kasan early shadow page. 
KASAN_VMALLOC requires the top-level of the kernel page table to be 
properly populated, lower levels being filled dynamically upon memory 
allocation at runtime."




Signed-off-by: Nylon Chen 
Signed-off-by: Nick Hu 
---
 arch/riscv/Kconfig |  1 +
 arch/riscv/mm/kasan_init.c | 57 +-
 2 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 81b76d44725d..15a2c8088bbe 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -57,6 +57,7 @@ config RISCV
 select HAVE_ARCH_JUMP_LABEL
 select HAVE_ARCH_JUMP_LABEL_RELATIVE
 select HAVE_ARCH_KASAN if MMU && 64BIT
+    select HAVE_ARCH_KASAN_VMALLOC if MMU && 64BIT
 select HAVE_ARCH_KGDB
 select HAVE_ARCH_KGDB_QXFER_PKT
 select HAVE_ARCH_MMAP_RND_BITS if MMU
diff --git a/arch/riscv/mm/kasan_init.c b/arch/riscv/mm/kasan_init.c
index 12ddd1f6bf70..4b9149f963d3 100644
--- a/arch/riscv/mm/kasan_init.c
+++ b/arch/riscv/mm/kasan_init.c
@@ -9,6 +9,19 @@
 #include 
 #include 
 #include 
+#include 
+
+static __init void *early_alloc(size_t size, int node)
+{
+    void *ptr = memblock_alloc_try_nid(size, size,
+    __pa(MAX_DMA_ADDRESS), MEMBLOCK_ALLOC_ACCESSIBLE, node);
+
+    if (!ptr)
+    panic("%pS: Failed to allocate %zu bytes align=%zx nid=%d 
from=%llx\n",

+    __func__, size, size, node, (u64)__pa(MAX_DMA_ADDRESS));
+
+    return ptr;
+}

 extern pgd_t early_pg_dir[PTRS_PER_PGD];
 asmlinkage void __init kasan_early_init(void)
@@ -83,6 +96,40 @@ static void __init populate(void *start, void *end)
 memset(start, 0, end - start);
 }

+void __init kasan_shallow_populate(void *start, void *end)
+{
+    unsigned long vaddr = (unsigned long)start & PAGE_MASK;
+    unsigned long vend = PAGE_ALIGN((unsigned long)end);
+    unsigned long pfn;
+    int index;
+    void *p;
+    pud_t *pud_dir, *pud_k;
+    pgd_t *pgd_dir, *pgd_k;
+    p4d_t *p4d_dir, *p4d_k;
+
+    while (vaddr < vend) {
+    index = pgd_index(vaddr);
+    pfn = csr_read(CSR_SATP) & SATP_PPN;


At this point in the boot process, we know that we use swapper_pg_dir so 
no need to read SATP.



+    pgd_dir = (pgd_t *)pfn_to_virt(pfn) + index;


Here, this pgd_dir assignment is overwritten 2 lines below, so no need 
for it.



+    pgd_k = init_mm.pgd + index;
+    pgd_dir = pgd_offset_k(vaddr);


pgd_offset_k(vaddr) = init_mm.pgd + pgd_index(vaddr) so pgd_k == pgd_dir.


+    set_pgd(pgd_dir, *pgd_k);
+
+    p4d_dir = p4d_offset(pgd_dir, vaddr);
+    p4d_k  = p4d_offset(pgd_k, vaddr);
+
+    vaddr = (vaddr + PUD_SIZE) & PUD_MASK;


Why do you increase vaddr *before* populating the first one ? And 
pud_addr_end does that properly: it returns the next pud address if it 
does not go beyond end address to map.



+    pud_dir = pud_offset(p4d_dir, vaddr);
+    pud_k = pud_offset(p4d_k, vaddr);
+
+    if (pud_present(*pud_dir)) {
+    p = early_alloc(PAGE_SIZE, NUMA_NO_NODE);
+    pud_populate(&init_mm, pud_dir, p);


init_mm is not needed here.


+    }
+    vaddr += PAGE_SIZE;


Why do you need to add PAGE_SIZE ? vaddr already points to the next pud.

It seems like this patch tries to populate userspace page table whereas 
at this point in the boot process, only swapper_pg_dir is used or am I 
missing something ?


Thanks,

Alex


I implemented this morning a version that fixes all the comments I made 
earlier. I was able to insert test_kasan_module on both sv39 and sv48 
without any modification: set_pgd "goes through" all the unused page 
table levels, whereas p*d_populate are noop for unused levels.


If you have any comment, do not hesitate.

diff --git a/arch/riscv/mm/kasan_init.c b/arch/riscv/mm/kasan_init.c 

index adbf94b7e68a..d643b222167c 100644 

--- a/arch/riscv/mm/kasan_init.c 

+++ b/arch/riscv/mm/kasan_init.c 

@@ -195,6 +195,31 @@ static void __init kasan_populate(void *start, void 
*end)
memset(start, KASAN_SHADOW_INIT, end - start); 

 } 




+void __init kasan_shallow_populate_pgd(unsigned long vaddr, unsigned 
long end)
+{ 

+   unsigned long next; 

+   void *p; 

+   pgd_t *pgd_k = pgd_offset_k(vaddr); 

+ 

+   do { 

+   next = pgd_addr_end(vaddr, end); 

+   if (pgd_page_vaddr(*pgd_k) == (unsigned 
long)lm_alias(kasan_early_shadow_pgd_nex

Re: [PATCH] coresight: etm4x: Add ETM PIDs for Cortex-A55 and Cortex-A78

2021-02-13 Thread Mike Leach
Hi Sai,

This patch does not apply to coresight/next - possibly because the PID
for A55 has been added in an earlier patch ( [b8336ad947e19 ]
coresight: etm4x: add AMBA id for Cortex-A55 and Cortex-A75).

Regards

Mike



On Fri, 12 Feb 2021 at 17:23, Sai Prakash Ranjan
 wrote:
>
> Add ETM PIDs for Cortex-A55 and Cortex-A78 to the list of
> supported ETMs.
>
> Signed-off-by: Sai Prakash Ranjan 
> ---
>  drivers/hwtracing/coresight/coresight-etm4x-core.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c 
> b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> index b20b6ff17cf6..193233792ab5 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> @@ -1713,7 +1713,9 @@ static const struct amba_id etm4_ids[] = {
> CS_AMBA_ID(0x000bb95a), /* Cortex-A72 */
> CS_AMBA_ID(0x000bb959), /* Cortex-A73 */
> CS_AMBA_UCI_ID(0x000bb9da, uci_id_etm4),/* Cortex-A35 */
> +   CS_AMBA_UCI_ID(0x000bbd05, uci_id_etm4),/* Cortex-A55 */
> CS_AMBA_UCI_ID(0x000bbd0c, uci_id_etm4),/* Neoverse N1 */
> +   CS_AMBA_UCI_ID(0x000bbd41, uci_id_etm4),/* Cortex-A78 */
> CS_AMBA_UCI_ID(0x000f0205, uci_id_etm4),/* Qualcomm Kryo */
> CS_AMBA_UCI_ID(0x000f0211, uci_id_etm4),/* Qualcomm Kryo */
> CS_AMBA_UCI_ID(0x000bb802, uci_id_etm4),/* Qualcomm Kryo 385 
> Cortex-A55 */
>
> base-commit: 1efbcec2ef8c037f1e801c76e4b9434ee2400be7
> --
> QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
> of Code Aurora Forum, hosted by The Linux Foundation
>


--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK


Re: possible deadlock in start_this_handle (2)

2021-02-13 Thread Dmitry Vyukov
On Fri, Feb 12, 2021 at 4:43 PM Michal Hocko  wrote:
>
> On Fri 12-02-21 21:58:15, Tetsuo Handa wrote:
> > On 2021/02/12 21:30, Michal Hocko wrote:
> > > On Fri 12-02-21 12:22:07, Matthew Wilcox wrote:
> > >> On Fri, Feb 12, 2021 at 08:18:11PM +0900, Tetsuo Handa wrote:
> > >>> On 2021/02/12 1:41, Michal Hocko wrote:
> >  But I suspect we have drifted away from the original issue. I thought
> >  that a simple check would help us narrow down this particular case and
> >  somebody messing up from the IRQ context didn't sound like a completely
> >  off.
> > 
> > >>>
> > >>>  From my experience at 
> > >>> https://lkml.kernel.org/r/201409192053.ihj35462.jlomosoffvt...@i-love.sakura.ne.jp
> > >>>  ,
> > >>> I think we can replace direct PF_* manipulation with macros which do 
> > >>> not receive "struct task_struct *" argument.
> > >>> Since TASK_PFA_TEST()/TASK_PFA_SET()/TASK_PFA_CLEAR() are for 
> > >>> manipulating PFA_* flags on a remote thread, we can
> > >>> define similar ones for manipulating PF_* flags on current thread. 
> > >>> Then, auditing dangerous users becomes easier.
> > >>
> > >> No, nobody is manipulating another task's GFP flags.
> > >
> > > Agreed. And nobody should be manipulating PF flags on remote tasks
> > > either.
> > >
> >
> > No. You are misunderstanding. The bug report above is an example of
> > manipulating PF flags on remote tasks.
>
> The bug report you are referring to is ancient. And the cpuset code
> doesn't touch task->flags for a long time. I haven't checked exactly but
> it is years since regular and atomic flags have been separated unless I
> misremember.
>
> > You say "nobody should", but the reality is "there indeed was". There
> > might be unnoticed others. The point of this proposal is to make it
> > possible to "find such unnoticed users who are manipulating PF flags
> > on remote tasks".
>
> I am really confused what you are proposing here TBH and referring to an
> ancient bug doesn't really help. task->flags are _explicitly_ documented
> to be only used for _current_. Is it possible that somebody writes a
> buggy code? Sure, should we build a whole infrastructure around that to
> catch such a broken code? I am not really sure. One bug 6 years ago
> doesn't sound like a good reason for that.

Another similar one was just reported:

https://syzkaller.appspot.com/bug?extid=1b2c6989ec12e467d65c

WARNING: possible circular locking dependency detected
5.11.0-rc7-syzkaller #0 Not tainted
--
kswapd0/2232 is trying to acquire lock:
88801f552650 (sb_internal){.+.+}-{0:0}, at: evict+0x2ed/0x6b0 fs/inode.c:577

but task is already holding lock:
8be89240 (fs_reclaim){+.+.}-{0:0}, at:
__fs_reclaim_acquire+0x0/0x30 mm/page_alloc.c:5195

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-> #3 (fs_reclaim){+.+.}-{0:0}:
   __fs_reclaim_acquire mm/page_alloc.c:4326 [inline]
   fs_reclaim_acquire+0x117/0x150 mm/page_alloc.c:4340
   might_alloc include/linux/sched/mm.h:193 [inline]
   slab_pre_alloc_hook mm/slab.h:493 [inline]
   slab_alloc_node mm/slab.c:3221 [inline]
   kmem_cache_alloc_node_trace+0x48/0x520 mm/slab.c:3596
   __do_kmalloc_node mm/slab.c:3618 [inline]
   __kmalloc_node+0x38/0x60 mm/slab.c:3626
   kmalloc_node include/linux/slab.h:575 [inline]
   kvmalloc_node+0x61/0xf0 mm/util.c:587
   kvmalloc include/linux/mm.h:781 [inline]
   ext4_xattr_inode_cache_find fs/ext4/xattr.c:1465 [inline]
   ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1508 [inline]
   ext4_xattr_set_entry+0x1ce6/0x3780 fs/ext4/xattr.c:1649
   ext4_xattr_ibody_set+0x78/0x2b0 fs/ext4/xattr.c:2224
   ext4_xattr_set_handle+0x8f4/0x13e0 fs/ext4/xattr.c:2380
   ext4_xattr_set+0x13a/0x340 fs/ext4/xattr.c:2493
   __vfs_setxattr+0x10e/0x170 fs/xattr.c:177
   __vfs_setxattr_noperm+0x11a/0x4c0 fs/xattr.c:208
   __vfs_setxattr_locked+0x1bf/0x250 fs/xattr.c:266
   vfs_setxattr+0x135/0x320 fs/xattr.c:291
   setxattr+0x1ff/0x290 fs/xattr.c:553
   path_setxattr+0x170/0x190 fs/xattr.c:572
   __do_sys_setxattr fs/xattr.c:587 [inline]
   __se_sys_setxattr fs/xattr.c:583 [inline]
   __x64_sys_setxattr+0xc0/0x160 fs/xattr.c:583
   do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46


Re: [PATCH v2] ARM: kprobes: rewrite test-[arm|thumb].c in UAL

2021-02-13 Thread Ard Biesheuvel
On Fri, 29 Jan 2021 at 00:30, Ard Biesheuvel  wrote:
>
> On Thu, 28 Jan 2021 at 23:28, Arnd Bergmann  wrote:
> >
> > On Thu, Jan 28, 2021 at 10:03 PM Ard Biesheuvel  wrote:
> > > On Thu, 28 Jan 2021 at 20:34, Nick Desaulniers  
> > > wrote:
> > > > @@ -468,15 +468,15 @@ void kprobe_thumb32_test_cases(void)
> > > >
> > > > TEST_UNSUPPORTED("strexbr0, r1, [r2]")
> > > > TEST_UNSUPPORTED("strexhr0, r1, [r2]")
> > > > -   TEST_UNSUPPORTED("strexdr0, r1, [r2]")
> > > > +   TEST_UNSUPPORTED("strexdr0, r1, r2, [r2]")
> > > > TEST_UNSUPPORTED("ldrexbr0, [r1]")
> > > > TEST_UNSUPPORTED("ldrexhr0, [r1]")
> > > > -   TEST_UNSUPPORTED("ldrexdr0, [r1]")
> > > > +   TEST_UNSUPPORTED("ldrexdr0, r1, [r1]")
> > > >
> > > > TEST_GROUP("Data-processing (shifted register) and (modified 
> > > > immediate)")
> > > >
> > > >  #define _DATA_PROCESSING32_DNM(op,s,val)   
> > > > \
> > > > -   TEST_RR(op s".w r0,  r",1, VAL1,", r",2, val, "")   
> > > > \
> > > > +   TEST_RR(op s"   r0,  r",1, VAL1,", r",2, val, "")   
> > > > \
> > >
> > > What is wrong with these .w suffixes? Shouldn't the assembler accept
> > > these even on instructions that only exist in a wide encoding?
> >
> > I don't know if that is a bug in the integrated assembler or
> > intentional behavior, but it may be easier to just change the
> > kernel than the compiler in this case, as it also makes it work
> > for older versions.
> >
> > FWIW, I needed a related change in a couple of other files:
> >
>
> For fully specified test cases, I suppose removing the .w is fine. But
> for the macros below, it really isn't: it depends on the actual
> register assignment whether narrow encodings exist or not, and in that
> case, we definitely want the wide one. The fact that instantiating the
> macro in a different way can only produce wide encodings in the first
> place should really not trigger an error.
>
> Things like this can break the Thumb2 build very subtly, so if the
> integrated assembler is not up to that, we should simply disable it
> for Thumb2 builds.
>

As mentioned in issue #1271, my observation here is not entirely accurate.

In the general case, macros that take register names as inputs can
produce narrow or wide opcodes depending on which exact registers are
being used (narrow opcodes mostly only support registers r0-r7)

However, in this particular case, all the ldr/str instructions are
either the pre-indexed or the post-indexed variants, for which only a
wide encoding exists, and so omitting the .w suffix is safe here.

However, if we apply the change below, can we please document this in
a comment, i.e., that encoding T4 is used for LDR/STR, and so the
result is guaranteed to be wide in spite of the missing suffix?



> > diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
> > index 6acdfde56849..3ced01d9afe4 100644
> > --- a/arch/arm/lib/copy_from_user.S
> > +++ b/arch/arm/lib/copy_from_user.S
> > @@ -60,7 +60,7 @@
> >  #define LDR1W_SHIFT 0
> >
> >   .macro ldr1w ptr reg abort
> > - USERL(\abort, W(ldr) \reg, [\ptr], #4)
> > + USERL(\abort, ldr \reg, [\ptr], #4)
> >   .endm
> >
> >   .macro ldr4w ptr reg1 reg2 reg3 reg4 abort
> > @@ -80,7 +80,7 @@
> >  #define STR1W_SHIFT 0
> >
> >   .macro str1w ptr reg abort
> > - W(str) \reg, [\ptr], #4
> > + str \reg, [\ptr], #4
> >   .endm
> >
> >   .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
> > diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
> > index 485fa3cffdbe..a6a96f814720 100644
> > --- a/arch/arm/lib/copy_to_user.S
> > +++ b/arch/arm/lib/copy_to_user.S
> > @@ -34,7 +34,7 @@
> >  #define LDR1W_SHIFT 0
> >
> >   .macro ldr1w ptr reg abort
> > - W(ldr) \reg, [\ptr], #4
> > + ldr \reg, [\ptr], #4
> >   .endm
> >
> >   .macro ldr4w ptr reg1 reg2 reg3 reg4 abort
> > @@ -77,7 +77,7 @@
> >  #define STR1W_SHIFT 0
> >
> >   .macro str1w ptr reg abort
> > - USERL(\abort, W(str) \reg, [\ptr], #4)
> > + USERL(\abort, str \reg, [\ptr], #4)
> >   .endm
> >
> >   .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
> > diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
> > index e4caf48c089f..7b980a1a4227 100644
> > --- a/arch/arm/lib/memcpy.S
> > +++ b/arch/arm/lib/memcpy.S
> > @@ -15,7 +15,7 @@
> >  #define STR1W_SHIFT 0
> >
> >   .macro ldr1w ptr reg abort
> > - W(ldr) \reg, [\ptr], #4
> > + ldr \reg, [\ptr], #4
> >   .endm
> >
> >   .macro ldr4w ptr reg1 reg2 reg3 reg4 abort
> > @@ -31,7 +31,7 @@
> >   .endm
> >
> >   .macro str1w ptr reg abort
> > - W(str) \reg, [\ptr], #4
> > + str \reg, [\ptr], #4
> >   .endm
> >
> >   .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
> > diff --git a/arch/arm/lib/memmove.S b/arch/arm/lib/memmove.S
> > index 6fecc12a1f51..35c5c06b7588 100644
> > --- a/arch/arm/lib/memmove.S
> > +++ b

Re: [PATCH 0/6] Support second Image Signal Processor on rk3399

2021-02-13 Thread Sebastian Fricke

Hey Heiko,

On 11.02.2021 15:42, Heiko Stübner wrote:

Hi Sebastian,

Am Donnerstag, 11. Februar 2021, 06:25:15 CET schrieb Sebastian Fricke:

Hey Heiko,

On 10.02.2021 12:15, Heiko Stübner wrote:
>Hi Sebastian,
>
>Am Freitag, 5. Februar 2021, 15:55:56 CET schrieb Heiko Stübner:
>> Hi Sebastian,
>>
>> I did some tests myself today as well and can confirm your
>> hdmi related finding - at least when plugged in on boot.
>>
>> I tried some combinations of camera vs. hdmi and it seems
>> really only when hdmi is plugged in on boot
>
>as you can see in v2, it should work now even with hdmi
>connected on boot. My patch ignored the grf-clock when
>doing the grf-based init.
>
>All clocks are on during boot and I guess the hdmi-driver
>did disable it after its probe. The phy_power_on functions
>did handle it correctly already, so it was only happening
>with hdmi connected on boot.

Thank you very much for solving that problem, I've tested the scenarios
described below and it works like a charm. (With your V2)
>
>
>Btw. do you plan on submitting your ov13850 driver
>soonish?

Actually, I have posted the patch already see here:
https://patchwork.kernel.org/project/linux-media/patch/20210130182313.32903-2-sebastian.fri...@posteo.net/


very cool to see


I currently review the requested changes and questions and will soon
post a second version, but I expect quite some time until it is actually
merged.


could you Cc me on future versions?


Sure will do :)




Thanks
Heiko


Sebastian


Greetings,
Sebastian

>
>
>>
>> (1)
>> - boot
>> - camera
>> --> works
>>
>> (2)
>> - boot
>> - camera
>> - hdmi plugged in
>> - hdmi works
>> - camera
>> --> works
>>
>> (3)
>> - hdmi plugged in
>> - boot
>> - hdmi works
>> - camera
>> --> camera doesn't work
>>
>> (4)
>> - boot
>> - hdmi plugged in
>> - hdmi works
>> - camera
>> -> camera works
>>
>>
>> With a bit of brute-force [0] it seems the camera also works again even
>> with hdmi connected on boot. So conclusion would be that some clock
>> is misbehaving.
>>
>> Now we'll "only" need to find out which one that is.
>>
>>
>> Heiko
>>
>>
>> [0]
>> Don't disable any clock gates
>>
>> diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c
>> index 070dc47e95a1..8daf1fc3388c 100644
>> --- a/drivers/clk/clk-gate.c
>> +++ b/drivers/clk/clk-gate.c
>> @@ -61,6 +61,9 @@ static void clk_gate_endisable(struct clk_hw *hw, int 
enable)
>>
>> set ^= enable;
>>
>> +if (!enable)
>> +return;
>> +
>> if (gate->lock)
>> spin_lock_irqsave(gate->lock, flags);
>> else
>>
>>
>>
>> Am Freitag, 5. Februar 2021, 09:15:47 CET schrieb Heiko Stübner:
>> > Hi Sebastian,
>> >
>> > Am Freitag, 5. Februar 2021, 07:43:35 CET schrieb Sebastian Fricke:
>> > > On 03.02.2021 20:54, Heiko Stübner wrote:
>> > > >Am Mittwoch, 3. Februar 2021, 19:14:22 CET schrieb Sebastian Fricke:
>> > > >> I have tested your patch set on my nanoPC-T4, here is a complete log
>> > > >> with:
>> > > >> - relevant kernel log entries
>> > > >> - system information
>> > > >> - media ctl output
>> > > >> - sysfs entry information
>> > > >>
>> > > >> https://paste.debian.net/1183874/
>> > > >>
>> > > >> Additionally, to your patchset I have applied the following patches:
>> > > >> 
https://github.com/initBasti/Linux_kernel_media_tree_fork/commits/dual_cam_setup
>> > > >>
>> > > >> And just to not cause confusion the `media_dev` entries come from this
>> > > >> unmerged series:
>> > > >> https://patchwork.kernel.org/project/linux-media/list/?series=426269
>> > > >>
>> > > >> I have actually been able to stream with both of my cameras at the 
same
>> > > >> time using the libcamera cam command.
>> > > >> I would like to thank you a lot for making this possible.
>> > > >
>> > > >Thanks for testing a dual camera setup. On my board I could only test
>> > > >the second ISP. And really glad it works for you tool :-) .
>> > > >
>> > > >Out of curiosity, do you also see that green tint in the images the 
cameras
>> > > >produce?
>> > >
>> > > Yes, I do. Actually, I currently have two forms of a green tint, on my
>> > > OV13850 everything is quite dark and greenish, which is caused by the
>> > > missing 3A algorithms. On my OV4689, I have big patches of the image
>> > > with bright green color and flickering, I investigated if this is
>> > > connected to the 2nd ISP instance, but that doesn't seem to be the case
>> > > as I have the same results when I switch the CSI ports of the cameras.
>> > >
>> > > I have found another issue, while testing I discovered following
>> > > issue:
>> > > When I start the system with an HDMI monitor connected, then the camera
>> > > on the 2nd port doesn't work. This is probably because the RX/TX is
>> > > reserved as a TX.
>> > > But it made me wonder because if the system has an RX, a TX, and
>> > > an RX/TX, why isn't the pure TX used by the monitor and the
>> > > cameras take RX and RX/TX?
>> > > Or do you think that this is maybe a malfunction of this patch?
>> >
>> > I 

Re: [PATCH] coresight: etm4x: Add ETM PIDs for Cortex-A55 and Cortex-A78

2021-02-13 Thread Sai Prakash Ranjan

Hi Mike,

On 2021-02-13 16:24, Mike Leach wrote:

Hi Sai,

This patch does not apply to coresight/next - possibly because the PID
for A55 has been added in an earlier patch ( [b8336ad947e19 ]
coresight: etm4x: add AMBA id for Cortex-A55 and Cortex-A75).



Apologies, my remote was still pointing to linaro coresight repo,
https://git.linaro.org/kernel/coresight.git, I have now updated
the remote to a proper kernel.org coresight repo and will post
the updated patchset.

Thanks,
Sai





On Fri, 12 Feb 2021 at 17:23, Sai Prakash Ranjan
 wrote:


Add ETM PIDs for Cortex-A55 and Cortex-A78 to the list of
supported ETMs.

Signed-off-by: Sai Prakash Ranjan 
---
 drivers/hwtracing/coresight/coresight-etm4x-core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c 
b/drivers/hwtracing/coresight/coresight-etm4x-core.c

index b20b6ff17cf6..193233792ab5 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
@@ -1713,7 +1713,9 @@ static const struct amba_id etm4_ids[] = {
CS_AMBA_ID(0x000bb95a), /* Cortex-A72 */
CS_AMBA_ID(0x000bb959), /* Cortex-A73 */
CS_AMBA_UCI_ID(0x000bb9da, uci_id_etm4),/* Cortex-A35 */
+   CS_AMBA_UCI_ID(0x000bbd05, uci_id_etm4),/* Cortex-A55 */
CS_AMBA_UCI_ID(0x000bbd0c, uci_id_etm4),/* Neoverse N1 */
+   CS_AMBA_UCI_ID(0x000bbd41, uci_id_etm4),/* Cortex-A78 */
CS_AMBA_UCI_ID(0x000f0205, uci_id_etm4),/* Qualcomm Kryo */
CS_AMBA_UCI_ID(0x000f0211, uci_id_etm4),/* Qualcomm Kryo */
CS_AMBA_UCI_ID(0x000bb802, uci_id_etm4),/* Qualcomm Kryo 385 
Cortex-A55 */


base-commit: 1efbcec2ef8c037f1e801c76e4b9434ee2400be7
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a 
member

of Code Aurora Forum, hosted by The Linux Foundation




--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK


--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a 
member

of Code Aurora Forum, hosted by The Linux Foundation


RE: [PATCH V10 01/10] dt-bindings: remoteproc: convert imx rproc bindings to json-schema

2021-02-13 Thread Peng Fan
> Subject: Re: [PATCH V10 01/10] dt-bindings: remoteproc: convert imx rproc
> bindings to json-schema
> 
> On Mon, Feb 08, 2021 at 04:56:02PM +0800, peng@oss.nxp.com wrote:
> > From: Peng Fan 
> >
> > Convert the imx rproc binding to DT schema format using json-schema.
> >
> > Signed-off-by: Peng Fan 
> > ---
> >  .../bindings/remoteproc/fsl,imx-rproc.yaml| 59
> +++
> >  .../bindings/remoteproc/imx-rproc.txt | 33 ---
> >  2 files changed, 59 insertions(+), 33 deletions(-)  create mode
> > 100644 Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
> >  delete mode 100644
> > Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
> >
> > diff --git
> > a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
> > b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
> > new file mode 100644
> > index ..5e906fa6a39d
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
> > @@ -0,0 +1,59 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2
> > +---
> > +$id:
> "https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevice
> tree.org%2Fschemas%2Fremoteproc%2Ffsl%2Cimx-rproc.yaml%23&dat
> a=04%7C01%7Cpeng.fan%40nxp.com%7Cd1b06ffd889240a45f8308d8cdea93
> 40%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6374857546682
> 06133%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2l
> uMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=jTnFLISLpjJN
> vV4euhlqUvnj9YMk9YoDZWoxQi97kdc%3D&reserved=0"
> > +$schema:
> "https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevice
> tree.org%2Fmeta-schemas%2Fcore.yaml%23&data=04%7C01%7Cpeng.f
> an%40nxp.com%7Cd1b06ffd889240a45f8308d8cdea9340%7C686ea1d3bc2b
> 4c6fa92cd99c5c301635%7C0%7C0%7C637485754668206133%7CUnknown
> %7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1ha
> WwiLCJXVCI6Mn0%3D%7C1000&sdata=98u0FLfvAhOiYoT7Vvbqg6yW5
> wVEmLVrhLvCz83VRiM%3D&reserved=0"
> > +
> > +title: NXP iMX6SX/iMX7D Co-Processor Bindings
> > +
> > +description:
> > +  This binding provides support for ARM Cortex M4 Co-processor found on
> some NXP iMX SoCs.
> > +
> > +maintainers:
> > +  - Peng Fan 
> > +
> > +properties:
> > +  compatible:
> > +enum:
> > +  - fsl,imx7d-cm4
> > +  - fsl,imx6sx-cm4
> > +
> > +  clocks:
> > +maxItems: 1
> > +
> > +  syscon:
> > +$ref: /schemas/types.yaml#/definitions/phandle
> > +description:
> > +  Phandle to syscon block which provide access to System Reset
> > + Controller
> > +
> > +  memory-region:
> > +description:
> > +  If present, a phandle for a reserved memory area that used for
> vdev buffer,
> > +  resource table, vring region and others used by remote processor.
> 
> You need to define what each one is as a schema. How does the driver know
> which one is the vring region for example? Minimally, it's:
> 
> items:
>   - description: ...
>   - description: ...
>   - description: ...
> 
> But if what's present is variable, then it gets more complicated. If the OS 
> side
> doesn't need to know what each region is, then you can do just:
> 
> minItems: N
> maxItems: M

I'll use minItems: 1, no maxItems.

Thanks,
Peng.

> 
> Rob
> 
> 
> 
> > +
> > +required:
> > +  - compatible
> > +  - clocks
> > +  - syscon
> > +
> > +additionalProperties: false
> > +
> > +examples:
> > +  - |
> > +#include 
> > +m4_reserved_sysmem1: cm4@8000 {
> > +  reg = <0x8000 0x8>;
> > +};
> > +
> > +m4_reserved_sysmem2: cm4@8100 {
> > +  reg = <0x8100 0x8>;
> > +};
> > +
> > +imx7d-cm4 {
> > +  compatible   = "fsl,imx7d-cm4";
> > +  memory-region= <&m4_reserved_sysmem1>,
> <&m4_reserved_sysmem2>;
> > +  syscon   = <&src>;
> > +  clocks   = <&clks IMX7D_ARM_M4_ROOT_CLK>;
> > +};
> > +
> > +...
> > diff --git
> > a/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
> > b/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
> > deleted file mode 100644
> > index fbcefd965dc4..
> > --- a/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
> > +++ /dev/null
> > @@ -1,33 +0,0 @@
> > -NXP iMX6SX/iMX7D Co-Processor Bindings
> > -
> > -
> > -This binding provides support for ARM Cortex M4 Co-processor found on
> > some -NXP iMX SoCs.
> > -
> > -Required properties:
> > -- compatible   Should be one of:
> > -   "fsl,imx7d-cm4"
> > -   "fsl,imx6sx-cm4"
> > -- clocks   Clock for co-processor (See: 
> > ../clock/clock-bindings.txt)
> > -- syscon   Phandle to syscon block which provide access to
> > -   System Reset Controller
> > -
> > -Optional properties:
> > -- memory-regionlist of phandels to the reserved memory regions.
> > -   (See: ../reserved-memory/reserved-memory.txt)
> > -
> >

Re: [PATCH] pinctrl: Support pin that does not support configuration option

2021-02-13 Thread Michael Nazzareno Trimarchi
Hi Fabio

On Fri, Feb 12, 2021 at 9:31 AM Michael Nazzareno Trimarchi
 wrote:
>
> Hi
>
> On Fri, Feb 12, 2021 at 9:26 AM Linus Walleij  
> wrote:
> >
> > On Mon, Feb 1, 2021 at 12:54 PM Michael Nazzareno Trimarchi
> >  wrote:
> > > On Mon, Feb 1, 2021 at 12:47 PM Fabio Estevam  wrote:
> > > >
> > > > Hi Michael,
> > > >
> > > > On Sat, Jan 30, 2021 at 5:21 AM Michael Trimarchi
> > > >  wrote:
> > > > >
> > > > > Some of the iMX25 pins have not an associated configuration register 
> > > > > so
> > > > > when they are configured the standard way through the device tree the
> > > > > kernel complains with:
> > > > >
> > > > > imx25-pinctrl 43fac000.iomuxc: Pin(MX25_PAD_EXT_ARMCLK) does not 
> > > > > support
> > > > > config function
> > > >
> > > > Could you please share your device tree that causes this warning?
> > > >
> > > > Shouldn't you pass 0x8000 in the devicetree for this pad then?
> > > >
> > > > 0x8000 means that the kernel should not touch the PAD_CTL register
> > > > and use the default configuration from the bootloader/POR.
> > >
> > > arch/arm/boot/dts/imx25-lisa.dts:
> > > MX25_PAD_EXT_ARMCLK__GPIO_3_15  0x8000
> > >
> > > The problem that exists pad that can be muxed but not configured
> >
> > Did you reach any conclusion on this?
> >
> > I need Fabio's consent to apply the patch, but it seems maybe the
> > DTS should be changed instead?
> >
>
> Let me re-check with the latest linux code. I did not find any change
> there. It's on my side
> now

Looking at the code (I will ask to check on real hw) seems that
conf_reg is -1 when there is no conf_reg.
the pinmux core set_state just calls the pin_config_set and one pin
can have the mux supported and the config
not supported. And imx25 has several of them that are only muxed.
Seems that this NO_CTL_PAD is something
that is nxp

 clk_osc_audio: clk-osc-audio {
compatible = "gpio-gate-clock";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_clk26mhz_osc>;
clocks = <&clksis>;
#clock-cells = <0>;
enable-gpios = <&gpio3 15 GPIO_ACTIVE_LOW>;
};

this is my use case
 pinctrl_clk26mhz_osc: clk26mhzosc {
fsl,pins = <
MX25_PAD_EXT_ARMCLK__GPIO_3_15  0x8000
>;
};

Michael




>
> Michael
>
> > Yours,
> > Linus Walleij
>
>
>
> --
> Michael Nazzareno Trimarchi
> Amarula Solutions BV
> COO Co-Founder
> Cruquiuskade 47 Amsterdam 1018 AM NL
> T. +31(0)851119172
> M. +39(0)3479132170
> [`as] https://www.amarulasolutions.com



-- 
Michael Nazzareno Trimarchi
Amarula Solutions BV
COO Co-Founder
Cruquiuskade 47 Amsterdam 1018 AM NL
T. +31(0)851119172
M. +39(0)3479132170
[`as] https://www.amarulasolutions.com


Re: [PATCH v2] mm/vmalloc: randomize vmalloc() allocations

2021-02-13 Thread Topi Miettinen

Hello,

Is there a chance of getting this reviewed and maybe even merged, please?

-Topi

On 12.12.2020 19.56, Topi Miettinen wrote:

Memory mappings inside kernel allocated with vmalloc() are in
predictable order and packed tightly toward the low addresses. With
new kernel boot parameter 'randomize_vmalloc=1', the entire area is
used randomly to make the allocations less predictable and harder to
guess for attackers. Also module and BPF code locations get randomized
(within their dedicated and rather small area though) and if
CONFIG_VMAP_STACK is enabled, also kernel thread stack locations.

On 32 bit systems this may cause problems due to increased VM
fragmentation if the address space gets crowded.

On all systems, it will reduce performance and increase memory and
cache usage due to less efficient use of page tables and inability to
merge adjacent VMAs with compatible attributes. On x86_64 with 5 level
page tables, in the worst case, additional page table entries of up to
4 pages are created for each mapping, so with small mappings there's
considerable penalty.

Without randomize_vmalloc=1:
$ cat /proc/vmallocinfo
0xc900-0xc90020008192 acpi_os_map_iomem+0x29e/0x2c0 
phys=0x3ffe1000 ioremap
0xc9002000-0xc9005000   12288 acpi_os_map_iomem+0x29e/0x2c0 
phys=0x3ffe ioremap
0xc9005000-0xc90070008192 hpet_enable+0x36/0x4a9 
phys=0xfed0 ioremap
0xc9007000-0xc90090008192 gen_pool_add_owner+0x49/0x130 
pages=1 vmalloc
0xc9009000-0xc900b0008192 gen_pool_add_owner+0x49/0x130 
pages=1 vmalloc
0xc900b000-0xc900d0008192 gen_pool_add_owner+0x49/0x130 
pages=1 vmalloc
0xc900d000-0xc900f0008192 gen_pool_add_owner+0x49/0x130 
pages=1 vmalloc
0xc9011000-0xc9015000   16384 n_tty_open+0x16/0xe0 pages=3 
vmalloc
0xc93de000-0xc93e8192 acpi_os_map_iomem+0x29e/0x2c0 
phys=0xfed0 ioremap
0xc93e-0xc93e20008192 memremap+0x1a1/0x280 
phys=0x000f5000 ioremap
0xc93e2000-0xc93f3000   69632 pcpu_create_chunk+0x80/0x2c0 
pages=16 vmalloc
0xc93f3000-0xc9405000   73728 pcpu_create_chunk+0xb7/0x2c0 
pages=17 vmalloc
0xc9405000-0xc940a000   20480 pcpu_create_chunk+0xed/0x2c0 
pages=4 vmalloc
0xe8c0-0xe8e0 2097152 pcpu_get_vm_areas+0x0/0x1a40 
vmalloc

With randomize_vmalloc=1, the allocations are randomized:
$ cat /proc/vmallocinfo
0xca3a36442000-0xca3a36447000   20480 pcpu_create_chunk+0xed/0x2c0 
pages=4 vmalloc
0xca63034d6000-0xca63034d9000   12288 acpi_os_map_iomem+0x29e/0x2c0 
phys=0x3ffe ioremap
0xcce23d32e000-0xcce23d338192 memremap+0x1a1/0x280 
phys=0x000f5000 ioremap
0xcfb9f0e22000-0xcfb9f0e240008192 hpet_enable+0x36/0x4a9 
phys=0xfed0 ioremap
0xd1df23e9e000-0xd1df23eb   73728 pcpu_create_chunk+0xb7/0x2c0 
pages=17 vmalloc
0xd690c299-0xd690c29920008192 acpi_os_map_iomem+0x29e/0x2c0 
phys=0x3ffe1000 ioremap
0xd8460c718000-0xd8460c71c000   16384 n_tty_open+0x16/0xe0 pages=3 
vmalloc
0xd89aba709000-0xd89aba70b0008192 gen_pool_add_owner+0x49/0x130 
pages=1 vmalloc
0xe0ca3f2ed000-0xe0ca3f2ef0008192 acpi_os_map_iomem+0x29e/0x2c0 
phys=0xfed0 ioremap
0xe3ba44802000-0xe3ba448040008192 gen_pool_add_owner+0x49/0x130 
pages=1 vmalloc
0xe4524b2a2000-0xe4524b2a40008192 gen_pool_add_owner+0x49/0x130 
pages=1 vmalloc
0xe61372b2e000-0xe61372b38192 gen_pool_add_owner+0x49/0x130 
pages=1 vmalloc
0xe704d2f7c000-0xe704d2f8d000   69632 pcpu_create_chunk+0x80/0x2c0 
pages=16 vmalloc
0xe8c0-0xe8e0 2097152 pcpu_get_vm_areas+0x0/0x1a40 
vmalloc

With CONFIG_VMAP_STACK, also kernel thread stacks are placed in
vmalloc area and therefore they also get randomized (only one example
line from /proc/vmallocinfo shown for brevity):

unrandomized:
0xc9018000-0xc9021000   36864 kernel_clone+0xf9/0x560 pages=8 
vmalloc

randomized:
0xcb57611a8000-0xcb57611b1000   36864 kernel_clone+0xf9/0x560 pages=8 
vmalloc

CC: Andrew Morton 
CC: Andy Lutomirski 
CC: Jann Horn 
CC: Kees Cook 
CC: Linux API 
CC: Matthew Wilcox 
CC: Mike Rapoport 
Signed-off-by: Topi Miettinen 
---
v2: retry allocation from other end of vmalloc space in case of
failure (Matthew Wilcox), improve commit message and documentation
---
  .../admin-guide/kernel-parameters.txt | 23 +++
  mm/vmalloc.c  | 29 +--
  2 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 44fde25bb221..9386b1b40a27 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ 

Re: [PATCH 2/2] rcu-tasks: add RCU-tasks self tests

2021-02-13 Thread Uladzislau Rezki
On Fri, Feb 12, 2021 at 04:43:28PM -0800, Paul E. McKenney wrote:
> On Fri, Feb 12, 2021 at 04:37:09PM -0800, Paul E. McKenney wrote:
> > On Fri, Feb 12, 2021 at 03:48:51PM -0800, Paul E. McKenney wrote:
> > > On Fri, Feb 12, 2021 at 10:12:07PM +0100, Uladzislau Rezki wrote:
> > > > On Fri, Feb 12, 2021 at 08:20:59PM +0100, Sebastian Andrzej Siewior 
> > > > wrote:
> > > > > On 2020-12-09 21:27:32 [+0100], Uladzislau Rezki (Sony) wrote:
> > > > > > Add self tests for checking of RCU-tasks API functionality.
> > > > > > It covers:
> > > > > > - wait API functions;
> > > > > > - invoking/completion call_rcu_tasks*().
> > > > > > 
> > > > > > Self-tests are run when CONFIG_PROVE_RCU kernel parameter is set.
> > > > > 
> > > > > I just bisected to this commit. By booting with `threadirqs' I end up
> > > > > with:
> > > > > [0.176533] Running RCU-tasks wait API self tests
> > > > > 
> > > > > No stall warning or so.
> > > > > It boots again with:
> > > > > 
> > > > > diff --git a/init/main.c b/init/main.c
> > > > > --- a/init/main.c
> > > > > +++ b/init/main.c
> > > > > @@ -1489,6 +1489,7 @@ void __init console_on_rootfs(void)
> > > > >   fput(file);
> > > > >  }
> > > > >  
> > > > > +void rcu_tasks_initiate_self_tests(void);
> > > > >  static noinline void __init kernel_init_freeable(void)
> > > > >  {
> > > > >   /*
> > > > > @@ -1514,6 +1515,7 @@ static noinline void __init 
> > > > > kernel_init_freeable(void)
> > > > >  
> > > > >   rcu_init_tasks_generic();
> > > > >   do_pre_smp_initcalls();
> > > > > + rcu_tasks_initiate_self_tests();
> > > > >   lockup_detector_init();
> > > > >  
> > > > >   smp_init();
> > > > > diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
> > > > > --- a/kernel/rcu/tasks.h
> > > > > +++ b/kernel/rcu/tasks.h
> > > > > @@ -1266,7 +1266,7 @@ static void test_rcu_tasks_callback(struct 
> > > > > rcu_head *rhp)
> > > > >   rttd->notrun = true;
> > > > >  }
> > > > >  
> > > > > -static void rcu_tasks_initiate_self_tests(void)
> > > > > +void rcu_tasks_initiate_self_tests(void)
> > > > >  {
> > > > >   pr_info("Running RCU-tasks wait API self tests\n");
> > > > >  #ifdef CONFIG_TASKS_RCU
> > > > > @@ -1322,7 +1322,6 @@ void __init rcu_init_tasks_generic(void)
> > > > >  #endif
> > > > >  
> > > > >   // Run the self-tests.
> > > > > - rcu_tasks_initiate_self_tests();
> > > > >  }
> > > > >  
> > > > >  #else /* #ifdef CONFIG_TASKS_RCU_GENERIC */
> > > > > 
> > > > > > Signed-off-by: Uladzislau Rezki (Sony) 
> > > 
> > > Apologies for the hassle!  My testing clearly missed this combination
> > > of CONFIG_PROVE_RCU=y and threadirqs=1.  :-(
> > > 
> > > But at least I can easily reproduce this hang as follows:
> > > 
> > > tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 2 
> > > --configs "TREE03" --kconfig "CONFIG_DEBUG_LOCK_ALLOC=y 
> > > CONFIG_PROVE_LOCKING=y" --bootargs "threadirqs=1" --trust-make
> > > 
> > > Sadly, I cannot take your patch because that simply papers over the
> > > fact that early boot use of synchronize_rcu_tasks() is broken in this
> > > particular configuration, which will likely eventually bite others now
> > > that init_kprobes() has been moved earlier in boot:
> > > 
> > > 1b04fa990026 ("rcu-tasks: Move RCU-tasks initialization to before 
> > > early_initcall()")
> > > Link: https://lore.kernel.org/rcu/87eekfh80a@dja-thinkpad.axtens.net/
> > > Fixes: 36dadef23fcc ("kprobes: Init kprobes in early_initcall")
> > > 
> > > > > Sebastian
> > > > >
> > > > We should be able to use call_rcu_tasks() in the *initcall() callbacks.
> > > > The problem is that, ksoftirqd threads are not spawned by the time when
> > > > an rcu_init_tasks_generic() is invoked:
> > > > 
> > > > diff --git a/init/main.c b/init/main.c
> > > > index c68d784376ca..e6106bb12b2d 100644
> > > > --- a/init/main.c
> > > > +++ b/init/main.c
> > > > @@ -954,7 +954,6 @@ asmlinkage __visible void __init 
> > > > __no_sanitize_address start_kernel(void)
> > > > rcu_init_nohz();
> > > > init_timers();
> > > > hrtimers_init();
> > > > -   softirq_init();
> > > > timekeeping_init();
> > > >  
> > > > /*
> > > > @@ -1512,6 +1511,7 @@ static noinline void __init 
> > > > kernel_init_freeable(void)
> > > >  
> > > > init_mm_internals();
> > > >  
> > > > +   softirq_init();
> > > > rcu_init_tasks_generic();
> > > > do_pre_smp_initcalls();
> > > > lockup_detector_init();
> > > > diff --git a/kernel/softirq.c b/kernel/softirq.c
> > > > index 9d71046ea247..cafa55c496d0 100644
> > > > --- a/kernel/softirq.c
> > > > +++ b/kernel/softirq.c
> > > > @@ -630,6 +630,7 @@ void __init softirq_init(void)
> > > > &per_cpu(tasklet_hi_vec, cpu).head;
> > > > }
> > > >  
> > > > +   spawn_ksoftirqd();
> > > 
> > > We need a forward reference to allow this to build, but with that added,
> > > my test case passes.  Good show!
> > >

[PATCH v4 0/5] perf cs-etm: Fix pid tracing with VHE

2021-02-13 Thread Leo Yan
This patch set is to follow up the patch series "coresight: etm-perf:
Fix pid tracing with VHE" [1].

Since the kernel and documentation patches have been picked up by
Mathieu Poirier and will go through the char-misc-next branch [2] to the
mainline kernel; the rest patches are for the perf tool, so combine
these patches into this patch set.

The patch set can be cleanly applied on perf/core branch with:

  commit 6db59d357e8e ("perf arm64/s390: Fix printf conversion specifier for IP 
addresses")

And this patch set has been verified on Arm Juno-r2 board.

Changes from v3:
* Added Reviewed-by tags (Mathieu/Mike/Suzuki);
* Changed to use the existed macros for option bits in patch 02/05
  (Mathieu).


[1] https://lore.kernel.org/patchwork/cover/1376776/
[2] 
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/log/?h=char-misc-next


Leo Yan (2):
  tools headers UAPI: Update tools' copy of linux/coresight-pmu.h
  perf cs-etm: Add helper cs_etm__get_pid_fmt()

Suzuki K Poulose (3):
  perf cs-etm: Fix bitmap for option
  perf cs-etm: Support PID tracing in config
  perf cs-etm: Detect pid in VMID for kernel running at EL2

 tools/include/linux/coresight-pmu.h   | 20 --
 tools/perf/arch/arm/util/cs-etm.c | 69 ++-
 .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 38 --
 tools/perf/util/cs-etm.c  | 42 +++
 tools/perf/util/cs-etm.h  |  1 +
 5 files changed, 145 insertions(+), 25 deletions(-)

-- 
2.25.1



[PATCH v4 3/5] perf cs-etm: Support PID tracing in config

2021-02-13 Thread Leo Yan
From: Suzuki K Poulose 

If the kernel is running at EL2, the pid of a task is exposed via VMID
instead of the CONTEXTID.  Add support for this in the perf tool.

This patch respects user setting if user has specified any configs
from "contextid", "contextid1" or "contextid2"; otherwise, it
dynamically sets config based on PMU format "contextid".

Cc: Mike Leach 
Cc: Mathieu Poirier 
Cc: Al Grant 
Signed-off-by: Suzuki K Poulose 
Co-developed-by: Leo Yan 
Signed-off-by: Leo Yan 
Reviewed-by: Mike Leach 
Reviewed-by: Mathieu Poirier 
---
 tools/include/linux/coresight-pmu.h |  3 ++
 tools/perf/arch/arm/util/cs-etm.c   | 61 +++--
 2 files changed, 52 insertions(+), 12 deletions(-)

diff --git a/tools/include/linux/coresight-pmu.h 
b/tools/include/linux/coresight-pmu.h
index 5dc47cfdcf07..4ac5c081af93 100644
--- a/tools/include/linux/coresight-pmu.h
+++ b/tools/include/linux/coresight-pmu.h
@@ -20,14 +20,17 @@
  */
 #define ETM_OPT_CYCACC 12
 #define ETM_OPT_CTXTID 14
+#define ETM_OPT_CTXTID215
 #define ETM_OPT_TS 28
 #define ETM_OPT_RETSTK 29
 
 /* ETMv4 CONFIGR programming bits for the ETM OPTs */
 #define ETM4_CFG_BIT_CYCACC4
 #define ETM4_CFG_BIT_CTXTID6
+#define ETM4_CFG_BIT_VMID  7
 #define ETM4_CFG_BIT_TS11
 #define ETM4_CFG_BIT_RETSTK12
+#define ETM4_CFG_BIT_VMID_OPT  15
 
 static inline int coresight_get_trace_id(int cpu)
 {
diff --git a/tools/perf/arch/arm/util/cs-etm.c 
b/tools/perf/arch/arm/util/cs-etm.c
index ad8421e8b651..08c329d6b2a5 100644
--- a/tools/perf/arch/arm/util/cs-etm.c
+++ b/tools/perf/arch/arm/util/cs-etm.c
@@ -67,6 +67,7 @@ static int cs_etm_set_context_id(struct auxtrace_record *itr,
char path[PATH_MAX];
int err = -EINVAL;
u32 val;
+   u64 contextid;
 
ptr = container_of(itr, struct cs_etm_recording, itr);
cs_etm_pmu = ptr->cs_etm_pmu;
@@ -86,25 +87,59 @@ static int cs_etm_set_context_id(struct auxtrace_record 
*itr,
goto out;
}
 
+   /* User has configured for PID tracing, respects it. */
+   contextid = evsel->core.attr.config &
+   (BIT(ETM_OPT_CTXTID) | BIT(ETM_OPT_CTXTID2));
+
/*
-* TRCIDR2.CIDSIZE, bit [9-5], indicates whether contextID tracing
-* is supported:
-*  0b0 Context ID tracing is not supported.
-*  0b00100 Maximum of 32-bit Context ID size.
-*  All other values are reserved.
+* If user doesn't configure the contextid format, parse PMU format and
+* enable PID tracing according to the "contextid" format bits:
+*
+*   If bit ETM_OPT_CTXTID is set, trace CONTEXTIDR_EL1;
+*   If bit ETM_OPT_CTXTID2 is set, trace CONTEXTIDR_EL2.
 */
-   val = BMVAL(val, 5, 9);
-   if (!val || val != 0x4) {
-   err = -EINVAL;
-   goto out;
+   if (!contextid)
+   contextid = perf_pmu__format_bits(&cs_etm_pmu->format,
+ "contextid");
+
+   if (contextid & BIT(ETM_OPT_CTXTID)) {
+   /*
+* TRCIDR2.CIDSIZE, bit [9-5], indicates whether contextID
+* tracing is supported:
+*  0b0 Context ID tracing is not supported.
+*  0b00100 Maximum of 32-bit Context ID size.
+*  All other values are reserved.
+*/
+   val = BMVAL(val, 5, 9);
+   if (!val || val != 0x4) {
+   pr_err("%s: CONTEXTIDR_EL1 isn't supported\n",
+  CORESIGHT_ETM_PMU_NAME);
+   err = -EINVAL;
+   goto out;
+   }
+   }
+
+   if (contextid & BIT(ETM_OPT_CTXTID2)) {
+   /*
+* TRCIDR2.VMIDOPT[30:29] != 0 and
+* TRCIDR2.VMIDSIZE[14:10] == 0b00100 (32bit virtual contextid)
+* We can't support CONTEXTIDR in VMID if the size of the
+* virtual context id is < 32bit.
+* Any value of VMIDSIZE >= 4 (i.e, > 32bit) is fine for us.
+*/
+   if (!BMVAL(val, 29, 30) || BMVAL(val, 10, 14) < 4) {
+   pr_err("%s: CONTEXTIDR_EL2 isn't supported\n",
+  CORESIGHT_ETM_PMU_NAME);
+   err = -EINVAL;
+   goto out;
+   }
}
 
/* All good, let the kernel know */
-   evsel->core.attr.config |= (1 << ETM_OPT_CTXTID);
+   evsel->core.attr.config |= contextid;
err = 0;
 
 out:
-
return err;
 }
 
@@ -485,7 +520,9 @@ static u64 cs_etmv4_get_config(struct auxtrace_record *itr)
config |= BIT(ETM4_CFG_BIT_TS);
if (config_opts & BIT(ETM_OPT_RETSTK))
config |= BIT(ETM4_CFG_BIT_RETSTK);
-
+   if (config_opts & BIT(ETM_OPT_CTXTID2))
+   

[PATCH v4 1/5] tools headers UAPI: Update tools' copy of linux/coresight-pmu.h

2021-02-13 Thread Leo Yan
To get the changes in the commit:

  "coresight: etm-perf: Clarify comment on perf options".

Signed-off-by: Leo Yan 
Reviewed-by: Suzuki K Poulose 
Reviewed-by: Mathieu Poirier 
---
 tools/include/linux/coresight-pmu.h | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/tools/include/linux/coresight-pmu.h 
b/tools/include/linux/coresight-pmu.h
index b0e35eec6499..5dc47cfdcf07 100644
--- a/tools/include/linux/coresight-pmu.h
+++ b/tools/include/linux/coresight-pmu.h
@@ -10,11 +10,18 @@
 #define CORESIGHT_ETM_PMU_NAME "cs_etm"
 #define CORESIGHT_ETM_PMU_SEED  0x10
 
-/* ETMv3.5/PTM's ETMCR config bit */
-#define ETM_OPT_CYCACC  12
-#define ETM_OPT_CTXTID 14
-#define ETM_OPT_TS  28
-#define ETM_OPT_RETSTK 29
+/*
+ * Below are the definition of bit offsets for perf option, and works as
+ * arbitrary values for all ETM versions.
+ *
+ * Most of them are orignally from ETMv3.5/PTM's ETMCR config, therefore,
+ * ETMv3.5/PTM doesn't define ETMCR config bits with prefix "ETM3_" and
+ * directly use below macros as config bits.
+ */
+#define ETM_OPT_CYCACC 12
+#define ETM_OPT_CTXTID 14
+#define ETM_OPT_TS 28
+#define ETM_OPT_RETSTK 29
 
 /* ETMv4 CONFIGR programming bits for the ETM OPTs */
 #define ETM4_CFG_BIT_CYCACC4
-- 
2.25.1



[PATCH v4 2/5] perf cs-etm: Fix bitmap for option

2021-02-13 Thread Leo Yan
From: Suzuki K Poulose 

When set option with macros ETM_OPT_CTXTID and ETM_OPT_TS, it wrongly
takes these two values (14 and 28 prespectively) as bit masks, but
actually both are the offset for bits.  But this doesn't lead to
further failure due to the AND logic operation will be always true for
ETM_OPT_CTXTID / ETM_OPT_TS.

This patch uses the BIT() macro for option bits, thus it can request the
correct bitmaps for "contextid" and "timestamp" when calling
cs_etm_set_option().

Signed-off-by: Suzuki K Poulose 
[Extract the change as a separate patch for easier review]
Signed-off-by: Leo Yan 
Reviewed-by: Mike Leach 
Reviewed-by: Mathieu Poirier 
---
 tools/perf/arch/arm/util/cs-etm.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/arch/arm/util/cs-etm.c 
b/tools/perf/arch/arm/util/cs-etm.c
index bd446aba64f7..ad8421e8b651 100644
--- a/tools/perf/arch/arm/util/cs-etm.c
+++ b/tools/perf/arch/arm/util/cs-etm.c
@@ -169,17 +169,17 @@ static int cs_etm_set_option(struct auxtrace_record *itr,
!cpu_map__has(online_cpus, i))
continue;
 
-   if (option & ETM_OPT_CTXTID) {
+   if (option & BIT(ETM_OPT_CTXTID)) {
err = cs_etm_set_context_id(itr, evsel, i);
if (err)
goto out;
}
-   if (option & ETM_OPT_TS) {
+   if (option & BIT(ETM_OPT_TS)) {
err = cs_etm_set_timestamp(itr, evsel, i);
if (err)
goto out;
}
-   if (option & ~(ETM_OPT_CTXTID | ETM_OPT_TS))
+   if (option & ~(BIT(ETM_OPT_CTXTID) | BIT(ETM_OPT_TS)))
/* Nothing else is currently supported */
goto out;
}
@@ -406,7 +406,7 @@ static int cs_etm_recording_options(struct auxtrace_record 
*itr,
evsel__set_sample_bit(cs_etm_evsel, CPU);
 
err = cs_etm_set_option(itr, cs_etm_evsel,
-   ETM_OPT_CTXTID | ETM_OPT_TS);
+   BIT(ETM_OPT_CTXTID) | BIT(ETM_OPT_TS));
if (err)
goto out;
}
-- 
2.25.1



[PATCH v4 5/5] perf cs-etm: Detect pid in VMID for kernel running at EL2

2021-02-13 Thread Leo Yan
From: Suzuki K Poulose 

The PID of the task could be traced as VMID when the kernel is running
at EL2.  Teach the decoder to look for VMID when the CONTEXTIDR (Arm32)
or CONTEXTIDR_EL1 (Arm64) is invalid but we have a valid VMID.

Cc: Mike Leach 
Cc: Mathieu Poirier 
Cc: Al Grant 
Signed-off-by: Suzuki K Poulose 
Co-developed-by: Leo Yan 
Signed-off-by: Leo Yan 
Reviewed-by: Mathieu Poirier 
---
 .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 38 +--
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c 
b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
index 3f4bc4050477..4052c9ce6e2f 100644
--- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
+++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
@@ -6,6 +6,7 @@
  * Author: Mathieu Poirier 
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -491,13 +492,42 @@ cs_etm_decoder__set_tid(struct cs_etm_queue *etmq,
const ocsd_generic_trace_elem *elem,
const uint8_t trace_chan_id)
 {
-   pid_t tid;
+   pid_t tid = -1;
+   static u64 pid_fmt;
+   int ret;
 
-   /* Ignore PE_CONTEXT packets that don't have a valid contextID */
-   if (!elem->context.ctxt_id_valid)
+   /*
+* As all the ETMs run at the same exception level, the system should
+* have the same PID format crossing CPUs.  So cache the PID format
+* and reuse it for sequential decoding.
+*/
+   if (!pid_fmt) {
+   ret = cs_etm__get_pid_fmt(trace_chan_id, &pid_fmt);
+   if (ret)
+   return OCSD_RESP_FATAL_SYS_ERR;
+   }
+
+   /*
+* Process the PE_CONTEXT packets if we have a valid contextID or VMID.
+* If the kernel is running at EL2, the PID is traced in CONTEXTIDR_EL2
+* as VMID, Bit ETM_OPT_CTXTID2 is set in this case.
+*/
+   switch (pid_fmt) {
+   case BIT(ETM_OPT_CTXTID):
+   if (elem->context.ctxt_id_valid)
+   tid = elem->context.context_id;
+   break;
+   case BIT(ETM_OPT_CTXTID2):
+   if (elem->context.vmid_valid)
+   tid = elem->context.vmid;
+   break;
+   default:
+   break;
+   }
+
+   if (tid == -1)
return OCSD_RESP_CONT;
 
-   tid =  elem->context.context_id;
if (cs_etm__etmq_set_tid(etmq, tid, trace_chan_id))
return OCSD_RESP_FATAL_SYS_ERR;
 
-- 
2.25.1



[PATCH v4 4/5] perf cs-etm: Add helper cs_etm__get_pid_fmt()

2021-02-13 Thread Leo Yan
This patch adds helper function cs_etm__get_pid_fmt(), by passing
parameter "traceID", it returns the PID format.

Signed-off-by: Leo Yan 
Reviewed-by: Mathieu Poirier 
Reviewed-by: Suzuki K Poulose 
---
 tools/perf/util/cs-etm.c | 42 
 tools/perf/util/cs-etm.h |  1 +
 2 files changed, 43 insertions(+)

diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index a2a369e2fbb6..b9c1d329a7f1 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -156,6 +157,47 @@ int cs_etm__get_cpu(u8 trace_chan_id, int *cpu)
return 0;
 }
 
+/*
+ * The returned PID format is presented by two bits:
+ *
+ *   Bit ETM_OPT_CTXTID: CONTEXTIDR or CONTEXTIDR_EL1 is traced;
+ *   Bit ETM_OPT_CTXTID2: CONTEXTIDR_EL2 is traced.
+ *
+ * It's possible that the two bits ETM_OPT_CTXTID and ETM_OPT_CTXTID2
+ * are enabled at the same time when the session runs on an EL2 kernel.
+ * This means the CONTEXTIDR_EL1 and CONTEXTIDR_EL2 both will be
+ * recorded in the trace data, the tool will selectively use
+ * CONTEXTIDR_EL2 as PID.
+ */
+int cs_etm__get_pid_fmt(u8 trace_chan_id, u64 *pid_fmt)
+{
+   struct int_node *inode;
+   u64 *metadata, val;
+
+   inode = intlist__find(traceid_list, trace_chan_id);
+   if (!inode)
+   return -EINVAL;
+
+   metadata = inode->priv;
+
+   if (metadata[CS_ETM_MAGIC] == __perf_cs_etmv3_magic) {
+   val = metadata[CS_ETM_ETMCR];
+   /* CONTEXTIDR is traced */
+   if (val & BIT(ETM_OPT_CTXTID))
+   *pid_fmt = BIT(ETM_OPT_CTXTID);
+   } else {
+   val = metadata[CS_ETMV4_TRCCONFIGR];
+   /* CONTEXTIDR_EL2 is traced */
+   if (val & (BIT(ETM4_CFG_BIT_VMID) | BIT(ETM4_CFG_BIT_VMID_OPT)))
+   *pid_fmt = BIT(ETM_OPT_CTXTID2);
+   /* CONTEXTIDR_EL1 is traced */
+   else if (val & BIT(ETM4_CFG_BIT_CTXTID))
+   *pid_fmt = BIT(ETM_OPT_CTXTID);
+   }
+
+   return 0;
+}
+
 void cs_etm__etmq_set_traceid_queue_timestamp(struct cs_etm_queue *etmq,
  u8 trace_chan_id)
 {
diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h
index 4ad925d6d799..7cc3bba0017d 100644
--- a/tools/perf/util/cs-etm.h
+++ b/tools/perf/util/cs-etm.h
@@ -173,6 +173,7 @@ struct cs_etm_packet_queue {
 int cs_etm__process_auxtrace_info(union perf_event *event,
  struct perf_session *session);
 int cs_etm__get_cpu(u8 trace_chan_id, int *cpu);
+int cs_etm__get_pid_fmt(u8 trace_chan_id, u64 *pid_fmt);
 int cs_etm__etmq_set_tid(struct cs_etm_queue *etmq,
 pid_t tid, u8 trace_chan_id);
 bool cs_etm__etmq_is_timeless(struct cs_etm_queue *etmq);
-- 
2.25.1



[PATCHv2] coresight: etm4x: Add ETM PID for Cortex-A78

2021-02-13 Thread Sai Prakash Ranjan
Add ETM PID for Cortex-A78 to the list of supported ETMs.

Signed-off-by: Sai Prakash Ranjan 
---

Changes in v2:
 * Rebased on top of coresight/next from kernel.org coresight repo.

---
 drivers/hwtracing/coresight/coresight-etm4x-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c 
b/drivers/hwtracing/coresight/coresight-etm4x-core.c
index 15016f757828..a5b13a7779c3 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
@@ -1951,6 +1951,7 @@ static const struct amba_id etm4_ids[] = {
CS_AMBA_UCI_ID(0x000bbd05, uci_id_etm4),/* Cortex-A55 */
CS_AMBA_UCI_ID(0x000bbd0a, uci_id_etm4),/* Cortex-A75 */
CS_AMBA_UCI_ID(0x000bbd0c, uci_id_etm4),/* Neoverse N1 */
+   CS_AMBA_UCI_ID(0x000bbd41, uci_id_etm4),/* Cortex-A78 */
CS_AMBA_UCI_ID(0x000f0205, uci_id_etm4),/* Qualcomm Kryo */
CS_AMBA_UCI_ID(0x000f0211, uci_id_etm4),/* Qualcomm Kryo */
CS_AMBA_UCI_ID(0x000bb802, uci_id_etm4),/* Qualcomm Kryo 385 Cortex-A55 
*/

base-commit: 06c18e28c402ecfb842df8e22a19a097c35ffca9
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



Re: [PATCH v5 net-next 09/11] skbuff: allow to optionally use NAPI cache from __alloc_skb()

2021-02-13 Thread Alexander Lobakin
From: Alexander Duyck 
Date: Thu, 11 Feb 2021 19:18:45 -0800

> On Thu, Feb 11, 2021 at 11:00 AM Alexander Lobakin  wrote:
> >
> > Reuse the old and forgotten SKB_ALLOC_NAPI to add an option to get
> > an skbuff_head from the NAPI cache instead of inplace allocation
> > inside __alloc_skb().
> > This implies that the function is called from softirq or BH-off
> > context, not for allocating a clone or from a distant node.
> >
> > Signed-off-by: Alexander Lobakin 
> > ---
> >  net/core/skbuff.c | 13 +
> >  1 file changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> > index 9e1a8ded4acc..a0b457ae87c2 100644
> > --- a/net/core/skbuff.c
> > +++ b/net/core/skbuff.c
> > @@ -397,15 +397,20 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t 
> > gfp_mask,
> > struct sk_buff *skb;
> > u8 *data;
> > bool pfmemalloc;
> > +   bool clone;
> >
> > -   cache = (flags & SKB_ALLOC_FCLONE)
> > -   ? skbuff_fclone_cache : skbuff_head_cache;
> > +   clone = !!(flags & SKB_ALLOC_FCLONE);
> 
> The boolean conversion here is probably unnecessary. I would make
> clone an int like flags and work with that. I suspect the compiler is
> doing it already, but it is better to be explicit.
> 
> > +   cache = clone ? skbuff_fclone_cache : skbuff_head_cache;
> >
> > if (sk_memalloc_socks() && (flags & SKB_ALLOC_RX))
> > gfp_mask |= __GFP_MEMALLOC;
> >
> > /* Get the HEAD */
> > -   skb = kmem_cache_alloc_node(cache, gfp_mask & ~__GFP_DMA, node);
> > +   if ((flags & SKB_ALLOC_NAPI) && !clone &&
> 
> Rather than having to do two checks you could just check for
> SKB_ALLOC_NAPI and SKB_ALLOC_FCLONE in a single check. You could just
> do something like:
> if ((flags & (SKB_ALLOC_FCLONE | SKB_ALLOC_NAPI) == SKB_ALLOC_NAPI)
> 
> That way you can avoid the extra conditional jumps and can start
> computing the flags value sooner.

I thought about combined check for two flags yesterday, so yeah, that
probably should be better than the current version.

> > +   likely(node == NUMA_NO_NODE || node == numa_mem_id()))
> > +   skb = napi_skb_cache_get();
> > +   else
> > +   skb = kmem_cache_alloc_node(cache, gfp_mask & ~GFP_DMA, 
> > node);
> > if (unlikely(!skb))
> > return NULL;
> > prefetchw(skb);
> > @@ -436,7 +441,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t 
> > gfp_mask,
> > __build_skb_around(skb, data, 0);
> > skb->pfmemalloc = pfmemalloc;
> >
> > -   if (flags & SKB_ALLOC_FCLONE) {
> > +   if (clone) {
> > struct sk_buff_fclones *fclones;
> >
> > fclones = container_of(skb, struct sk_buff_fclones, skb1);
> > --
> > 2.30.1

Thanks,
Al



Re: [PATCH v2] mm/vmalloc: randomize vmalloc() allocations

2021-02-13 Thread Uladzislau Rezki
> Hello,
> 
> Is there a chance of getting this reviewed and maybe even merged, please?
> 
> -Topi
> 
I can review it and help with it. But before that i would like to
clarify if such "randomization" is something that you can not leave?

For example on 32bit system vmalloc space is limited, such randomization
can slow down it, also it will lead to failing of allocations much more,
thus it will require repeating with different offset.

Second. There is a space or region for modules. Using various offsets
can waste of that memory, thus can lead to failing of module loading.

On the other side there is a per-cpu allocator. Interfering with it
also will increase a rate of failing.

--
Vlad Rezki

> > Memory mappings inside kernel allocated with vmalloc() are in
> > predictable order and packed tightly toward the low addresses. With
> > new kernel boot parameter 'randomize_vmalloc=1', the entire area is
> > used randomly to make the allocations less predictable and harder to
> > guess for attackers. Also module and BPF code locations get randomized
> > (within their dedicated and rather small area though) and if
> > CONFIG_VMAP_STACK is enabled, also kernel thread stack locations.
> > 
> > On 32 bit systems this may cause problems due to increased VM
> > fragmentation if the address space gets crowded.
> > 
> > On all systems, it will reduce performance and increase memory and
> > cache usage due to less efficient use of page tables and inability to
> > merge adjacent VMAs with compatible attributes. On x86_64 with 5 level
> > page tables, in the worst case, additional page table entries of up to
> > 4 pages are created for each mapping, so with small mappings there's
> > considerable penalty.
> > 
> > Without randomize_vmalloc=1:
> > $ cat /proc/vmallocinfo
> > 0xc900-0xc90020008192 acpi_os_map_iomem+0x29e/0x2c0 
> > phys=0x3ffe1000 ioremap
> > 0xc9002000-0xc9005000   12288 acpi_os_map_iomem+0x29e/0x2c0 
> > phys=0x3ffe ioremap
> > 0xc9005000-0xc90070008192 hpet_enable+0x36/0x4a9 
> > phys=0xfed0 ioremap
> > 0xc9007000-0xc90090008192 gen_pool_add_owner+0x49/0x130 
> > pages=1 vmalloc
> > 0xc9009000-0xc900b0008192 gen_pool_add_owner+0x49/0x130 
> > pages=1 vmalloc
> > 0xc900b000-0xc900d0008192 gen_pool_add_owner+0x49/0x130 
> > pages=1 vmalloc
> > 0xc900d000-0xc900f0008192 gen_pool_add_owner+0x49/0x130 
> > pages=1 vmalloc
> > 0xc9011000-0xc9015000   16384 n_tty_open+0x16/0xe0 pages=3 
> > vmalloc
> > 0xc93de000-0xc93e8192 acpi_os_map_iomem+0x29e/0x2c0 
> > phys=0xfed0 ioremap
> > 0xc93e-0xc93e20008192 memremap+0x1a1/0x280 
> > phys=0x000f5000 ioremap
> > 0xc93e2000-0xc93f3000   69632 pcpu_create_chunk+0x80/0x2c0 
> > pages=16 vmalloc
> > 0xc93f3000-0xc9405000   73728 pcpu_create_chunk+0xb7/0x2c0 
> > pages=17 vmalloc
> > 0xc9405000-0xc940a000   20480 pcpu_create_chunk+0xed/0x2c0 
> > pages=4 vmalloc
> > 0xe8c0-0xe8e0 2097152 pcpu_get_vm_areas+0x0/0x1a40 
> > vmalloc
> > 
> > With randomize_vmalloc=1, the allocations are randomized:
> > $ cat /proc/vmallocinfo
> > 0xca3a36442000-0xca3a36447000   20480 pcpu_create_chunk+0xed/0x2c0 
> > pages=4 vmalloc
> > 0xca63034d6000-0xca63034d9000   12288 acpi_os_map_iomem+0x29e/0x2c0 
> > phys=0x3ffe ioremap
> > 0xcce23d32e000-0xcce23d338192 memremap+0x1a1/0x280 
> > phys=0x000f5000 ioremap
> > 0xcfb9f0e22000-0xcfb9f0e240008192 hpet_enable+0x36/0x4a9 
> > phys=0xfed0 ioremap
> > 0xd1df23e9e000-0xd1df23eb   73728 pcpu_create_chunk+0xb7/0x2c0 
> > pages=17 vmalloc
> > 0xd690c299-0xd690c29920008192 acpi_os_map_iomem+0x29e/0x2c0 
> > phys=0x3ffe1000 ioremap
> > 0xd8460c718000-0xd8460c71c000   16384 n_tty_open+0x16/0xe0 pages=3 
> > vmalloc
> > 0xd89aba709000-0xd89aba70b0008192 gen_pool_add_owner+0x49/0x130 
> > pages=1 vmalloc
> > 0xe0ca3f2ed000-0xe0ca3f2ef0008192 acpi_os_map_iomem+0x29e/0x2c0 
> > phys=0xfed0 ioremap
> > 0xe3ba44802000-0xe3ba448040008192 gen_pool_add_owner+0x49/0x130 
> > pages=1 vmalloc
> > 0xe4524b2a2000-0xe4524b2a40008192 gen_pool_add_owner+0x49/0x130 
> > pages=1 vmalloc
> > 0xe61372b2e000-0xe61372b38192 gen_pool_add_owner+0x49/0x130 
> > pages=1 vmalloc
> > 0xe704d2f7c000-0xe704d2f8d000   69632 pcpu_create_chunk+0x80/0x2c0 
> > pages=16 vmalloc
> > 0xe8c0-0xe8e0 2097152 pcpu_get_vm_areas+0x0/0x1a40 
> > vmalloc
> > 
> > With CONFIG_VMAP_STACK, also kernel thread stacks are placed in
> > vmalloc area and therefore they also get randomized (only one example
> > line from /proc/vmallocinfo shown for brevity):
> >

[RFC PATCH 0/7] Add managed version of delayed work init

2021-02-13 Thread Matti Vaittinen
It's not rare that device drivers need delayed work.
It's not rare that this work needs driver's data.

Often this means that driver must ensure the work is not queued when
driver exits. Usually this is done by ensuring new work is not added and
then calling cancel_delayed_work_sync() at remove(). In many cases this
may also require cleanup at probe error path - which is easy to forget.

It might be helpful for (a) few drivers if there was a work init
function which would ensure cancel_delayed_work_sync() is called at
driver exit. So this series implements one on top of devm and replaces
the obvious cases where only thing remove call-back in a driver does is
cancelling the work. There might be other cases where we could switch
more than just work cancellation to use managed version and thus get rid
of remove.

Main reson why this is RFC is that I had hard time deciding where this
function should be introduced. It's not nice to include all device stuff
in workqueue - because many workqueue users are not interested in
devices. In same way, not all of the devices are interested in WQs.
OTOH, adding own file just for this sounds like an overkill.

This time I decided that it is more correct that devices use WQs than
that WQs use devices. Hence the function is introduced in
include/linux/device.h and drivers/base/devres.c

--

Matti Vaittinen (7):
  drivers: base: Add resource managed version of delayed work init
  extconn: Clean-up few drivers by using managed work init
  hwmon: raspberry-pi: Clean-up few drivers by using managed work init
  platform/x86: gpd pocket fan: Clean-up by using managed work init
  power: supply: Clean-up few drivers by using managed work init
  regulator: qcom_spmi-regulator: Clean-up by using managed work init
  watchdog: retu_wdt: Clean-up by using managed work init

 drivers/base/devres.c| 33 
 drivers/extcon/extcon-gpio.c | 14 ++---
 drivers/extcon/extcon-intel-int3496.c| 15 ++---
 drivers/extcon/extcon-palmas.c   | 16 +++---
 drivers/extcon/extcon-qcom-spmi-misc.c   | 16 +++---
 drivers/hwmon/raspberrypi-hwmon.c| 16 +++---
 drivers/platform/x86/gpd-pocket-fan.c| 16 +++---
 drivers/power/supply/axp20x_usb_power.c  | 15 +++--
 drivers/power/supply/bq24735-charger.c   | 17 +++---
 drivers/power/supply/ltc2941-battery-gauge.c | 19 ---
 drivers/power/supply/sbs-battery.c   | 15 +++--
 drivers/regulator/qcom_spmi-regulator.c  | 33 +---
 drivers/watchdog/retu_wdt.c  | 21 +++--
 include/linux/device.h   |  5 +++
 14 files changed, 95 insertions(+), 156 deletions(-)


base-commit: 92bf22614b21a2706f4993b278017e437f7785b3
-- 
2.25.4


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 


[RFC PATCH 1/7] drivers: base: Add resource managed version of delayed work init

2021-02-13 Thread Matti Vaittinen
A few drivers which need a delayed work-queue must cancel work at exit.
Some of those implement remove solely for this purpose. Help drivers
to avoid unnecessary remove and error-branch implementation by adding
managed verision of delayed work initialization

Signed-off-by: Matti Vaittinen 
---
 drivers/base/devres.c  | 33 +
 include/linux/device.h |  5 +
 2 files changed, 38 insertions(+)

diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index fb9d5289a620..2879595bb5a4 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -1231,3 +1231,36 @@ void devm_free_percpu(struct device *dev, void __percpu 
*pdata)
   (void *)pdata));
 }
 EXPORT_SYMBOL_GPL(devm_free_percpu);
+
+static void dev_delayed_work_drop(struct device *dev, void *res)
+{
+   cancel_delayed_work_sync(*(struct delayed_work **)res);
+}
+
+/**
+ * devm_delayed_work_autocancel - Resource-managed work allocation
+ * @dev: Device which lifetime work is bound to
+ * @pdata: work to be cancelled when device exits
+ *
+ * Initialize work which is automatically cancelled when device exits.
+ * A few drivers need delayed work which must be cancelled before driver
+ * is unload to avoid accessing removed resources.
+ * devm_delayed_work_autocancel() can be used to omit the explicit
+ * cancelleation when driver is unload.
+ */
+int devm_delayed_work_autocancel(struct device *dev, struct delayed_work *w,
+void (*worker)(struct work_struct *work))
+{
+   struct delayed_work **ptr;
+
+   ptr = devres_alloc(dev_delayed_work_drop, sizeof(*ptr), GFP_KERNEL);
+   if (!ptr)
+   return -ENOMEM;
+
+   INIT_DELAYED_WORK(w, worker);
+   *ptr = w;
+   devres_add(dev, ptr);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(devm_delayed_work_autocancel);
diff --git a/include/linux/device.h b/include/linux/device.h
index 1779f90eeb4c..192456198de7 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -249,6 +250,10 @@ void __iomem *devm_of_iomap(struct device *dev,
struct device_node *node, int index,
resource_size_t *size);
 
+/* delayed work which is cancelled when driver exits */
+int devm_delayed_work_autocancel(struct device *dev, struct delayed_work *w,
+void (*worker)(struct work_struct *work));
+
 /* allows to add/remove a custom action to devres stack */
 int devm_add_action(struct device *dev, void (*action)(void *), void *data);
 void devm_remove_action(struct device *dev, void (*action)(void *), void 
*data);
-- 
2.25.4


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 


[PATCH] tty: serial: Add earlycon driver for Tegra Combined UART

2021-02-13 Thread Mikko Perttunen
Add an earlycon driver for platforms with TCU, namely Tegra194.
The driver is compatible with boot parameters passed by NVIDIA
boot chains.

Signed-off-by: Mikko Perttunen 
---
 drivers/tty/serial/Kconfig  | 12 +
 drivers/tty/serial/Makefile |  1 +
 drivers/tty/serial/tegra-tcu-earlycon.c | 72 +
 3 files changed, 85 insertions(+)
 create mode 100644 drivers/tty/serial/tegra-tcu-earlycon.c

diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 34a2899e69c0..d941785e3f46 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -331,6 +331,18 @@ config SERIAL_TEGRA_TCU_CONSOLE
 
  If unsure, say Y.
 
+config SERIAL_TEGRA_TCU_EARLYCON
+   bool "Earlycon on NVIDIA Tegra Combined UART"
+   depends on ARCH_TEGRA || COMPILE_TEST
+   select SERIAL_EARLYCON
+   select SERIAL_CORE_CONSOLE
+   default y if SERIAL_TEGRA_TCU_CONSOLE
+   help
+ If you say Y here, TCU output will be supported during the earlycon
+ phase of the boot.
+
+ If unsure, say Y.
+
 config SERIAL_MAX3100
tristate "MAX3100 support"
depends on SPI
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index b85d53f9e9ff..408144326fed 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -72,6 +72,7 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o
 obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o
 obj-$(CONFIG_SERIAL_TEGRA) += serial-tegra.o
 obj-$(CONFIG_SERIAL_TEGRA_TCU) += tegra-tcu.o
+obj-$(CONFIG_SERIAL_TEGRA_TCU_EARLYCON) += tegra-tcu-earlycon.o
 obj-$(CONFIG_SERIAL_AR933X)   += ar933x_uart.o
 obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o
 obj-$(CONFIG_SERIAL_ARC)   += arc_uart.o
diff --git a/drivers/tty/serial/tegra-tcu-earlycon.c 
b/drivers/tty/serial/tegra-tcu-earlycon.c
new file mode 100644
index ..9decfbced0a7
--- /dev/null
+++ b/drivers/tty/serial/tegra-tcu-earlycon.c
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017-2021, NVIDIA CORPORATION.  All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+
+#define NUM_BYTES_FIELD_BIT24
+#define FLUSH_BIT  26
+#define INTR_TRIGGER_BIT   31
+
+static u32 update_and_send_mbox(u8 __iomem *addr, u32 mbox_val, char c)
+{
+   int bytes = bytes = (mbox_val >> NUM_BYTES_FIELD_BIT) & 0x3;
+
+   mbox_val |= BIT(INTR_TRIGGER_BIT);
+   mbox_val |= c << (bytes * 8);
+   bytes++;
+   mbox_val = (mbox_val & ~(3 << NUM_BYTES_FIELD_BIT)) |
+   (bytes << NUM_BYTES_FIELD_BIT);
+
+   if (bytes == 3) {
+   /* Send current packet to SPE */
+   while (readl(addr) & BIT(INTR_TRIGGER_BIT))
+   cpu_relax();
+   writel(mbox_val, addr);
+   mbox_val = BIT(INTR_TRIGGER_BIT);
+   }
+
+   return mbox_val;
+}
+
+/*
+ * This function splits the string to be printed (const char *s) into multiple
+ * packets. Each packet contains a max of 3 characters. Packets are sent to the
+ * SPE-based combined UART server for printing. Communication with SPE is done
+ * through mailbox registers which can generate interrupts for SPE.
+ */
+static void early_tcu_write(struct console *console, const char *s, unsigned 
int count)
+{
+   struct earlycon_device *device = console->data;
+   u8 __iomem *addr = device->port.membase;
+   u32 mbox_val = BIT(INTR_TRIGGER_BIT);
+   unsigned int i;
+
+   /* Loop for processing each 3 char packet */
+   for (i = 0; i < count; i++) {
+   if (s[i] == '\n')
+   mbox_val = update_and_send_mbox(addr, mbox_val, '\r');
+   mbox_val = update_and_send_mbox(addr, mbox_val, s[i]);
+   }
+
+   if ((mbox_val >> NUM_BYTES_FIELD_BIT) & 0x3) {
+   while (readl(addr) & BIT(INTR_TRIGGER_BIT))
+   cpu_relax();
+   writel(mbox_val, addr);
+   }
+}
+
+int __init early_tegra_combined_uart_setup(struct earlycon_device *device, 
const char *options)
+{
+   if (!(device->port.membase))
+   return -ENODEV;
+
+   device->con->write = early_tcu_write;
+
+   return 0;
+}
+
+EARLYCON_DECLARE(tegra_comb_uart, early_tegra_combined_uart_setup);
-- 
2.30.0



[RFC PATCH 2/7] extconn: Clean-up few drivers by using managed work init

2021-02-13 Thread Matti Vaittinen
Few drivers implement remove call-back only for ensuring a delayed
work gets cancelled prior driver removal. Clean-up these by switching
to use devm_delayed_work_autocancel() instead.

This change is compile-tested only. All testing is appreciated.

Signed-off-by: Matti Vaittinen 
---
 drivers/extcon/extcon-gpio.c   | 14 +++---
 drivers/extcon/extcon-intel-int3496.c  | 15 +++
 drivers/extcon/extcon-palmas.c | 16 +---
 drivers/extcon/extcon-qcom-spmi-misc.c | 16 +---
 4 files changed, 16 insertions(+), 45 deletions(-)

diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
index c211222f5d0c..7a45610e6c59 100644
--- a/drivers/extcon/extcon-gpio.c
+++ b/drivers/extcon/extcon-gpio.c
@@ -112,7 +112,9 @@ static int gpio_extcon_probe(struct platform_device *pdev)
if (ret < 0)
return ret;
 
-   INIT_DELAYED_WORK(&data->work, gpio_extcon_work);
+   ret = devm_delayed_work_autocancel(dev, &data->work, gpio_extcon_work);
+   if (ret)
+   return ret;
 
/*
 * Request the interrupt of gpio to detect whether external connector
@@ -131,15 +133,6 @@ static int gpio_extcon_probe(struct platform_device *pdev)
return 0;
 }
 
-static int gpio_extcon_remove(struct platform_device *pdev)
-{
-   struct gpio_extcon_data *data = platform_get_drvdata(pdev);
-
-   cancel_delayed_work_sync(&data->work);
-
-   return 0;
-}
-
 #ifdef CONFIG_PM_SLEEP
 static int gpio_extcon_resume(struct device *dev)
 {
@@ -158,7 +151,6 @@ static SIMPLE_DEV_PM_OPS(gpio_extcon_pm_ops, NULL, 
gpio_extcon_resume);
 
 static struct platform_driver gpio_extcon_driver = {
.probe  = gpio_extcon_probe,
-   .remove = gpio_extcon_remove,
.driver = {
.name   = "extcon-gpio",
.pm = &gpio_extcon_pm_ops,
diff --git a/drivers/extcon/extcon-intel-int3496.c 
b/drivers/extcon/extcon-intel-int3496.c
index 80c9abcc3f97..508a63dae3b4 100644
--- a/drivers/extcon/extcon-intel-int3496.c
+++ b/drivers/extcon/extcon-intel-int3496.c
@@ -101,7 +101,9 @@ static int int3496_probe(struct platform_device *pdev)
return -ENOMEM;
 
data->dev = dev;
-   INIT_DELAYED_WORK(&data->work, int3496_do_usb_id);
+   ret = devm_delayed_work_autocancel(dev, &data->work, int3496_do_usb_id);
+   if (ret)
+   return ret;
 
data->gpio_usb_id = devm_gpiod_get(dev, "id", GPIOD_IN);
if (IS_ERR(data->gpio_usb_id)) {
@@ -155,16 +157,6 @@ static int int3496_probe(struct platform_device *pdev)
return 0;
 }
 
-static int int3496_remove(struct platform_device *pdev)
-{
-   struct int3496_data *data = platform_get_drvdata(pdev);
-
-   devm_free_irq(&pdev->dev, data->usb_id_irq, data);
-   cancel_delayed_work_sync(&data->work);
-
-   return 0;
-}
-
 static const struct acpi_device_id int3496_acpi_match[] = {
{ "INT3496" },
{ }
@@ -177,7 +169,6 @@ static struct platform_driver int3496_driver = {
.acpi_match_table = int3496_acpi_match,
},
.probe = int3496_probe,
-   .remove = int3496_remove,
 };
 
 module_platform_driver(int3496_driver);
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index a2852bcc5f0d..1c48094bcf68 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -237,7 +237,11 @@ static int palmas_usb_probe(struct platform_device *pdev)
palmas_usb->sw_debounce_jiffies = 
msecs_to_jiffies(debounce);
}
 
-   INIT_DELAYED_WORK(&palmas_usb->wq_detectid, palmas_gpio_id_detect);
+   status = devm_delayed_work_autocancel(&pdev->dev,
+ &palmas_usb->wq_detectid,
+ palmas_gpio_id_detect);
+   if (status)
+   return status;
 
palmas->usb = palmas_usb;
palmas_usb->palmas = palmas;
@@ -359,15 +363,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
return 0;
 }
 
-static int palmas_usb_remove(struct platform_device *pdev)
-{
-   struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
-
-   cancel_delayed_work_sync(&palmas_usb->wq_detectid);
-
-   return 0;
-}
-
 #ifdef CONFIG_PM_SLEEP
 static int palmas_usb_suspend(struct device *dev)
 {
@@ -422,7 +417,6 @@ static const struct of_device_id of_palmas_match_tbl[] = {
 
 static struct platform_driver palmas_usb_driver = {
.probe = palmas_usb_probe,
-   .remove = palmas_usb_remove,
.driver = {
.name = "palmas-usb",
.of_match_table = of_palmas_match_tbl,
diff --git a/drivers/extcon/extcon-qcom-spmi-misc.c 
b/drivers/extcon/extcon-qcom-spmi-misc.c
index 6b836ae62176..82a7498951d2 100644
--- a/drivers/extcon/extcon-qcom-spmi-misc.c
+++ b/drivers/extcon/extcon-qcom-spmi-misc.c
@@ -80,7 +80,11 @@ static i

[RFC PATCH 3/7] hwmon: raspberry-pi: Clean-up few drivers by using managed work init

2021-02-13 Thread Matti Vaittinen
Few drivers implement remove call-back only for ensuring a delayed
work gets cancelled prior driver removal. Clean-up these by switching
to use devm_delayed_work_autocancel() instead.

This change is compile-tested only. All testing is appreciated.

Signed-off-by: Matti Vaittinen 
---
 drivers/hwmon/raspberrypi-hwmon.c | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/hwmon/raspberrypi-hwmon.c 
b/drivers/hwmon/raspberrypi-hwmon.c
index d3a64a35f7a9..acfa674932bc 100644
--- a/drivers/hwmon/raspberrypi-hwmon.c
+++ b/drivers/hwmon/raspberrypi-hwmon.c
@@ -106,6 +106,7 @@ static int rpi_hwmon_probe(struct platform_device *pdev)
 {
struct device *dev = &pdev->dev;
struct rpi_hwmon_data *data;
+   int ret;
 
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
@@ -119,7 +120,10 @@ static int rpi_hwmon_probe(struct platform_device *pdev)
   &rpi_chip_info,
   NULL);
 
-   INIT_DELAYED_WORK(&data->get_values_poll_work, get_values_poll);
+   ret = devm_delayed_work_autocancel(dev, &data->get_values_poll_work,
+  get_values_poll);
+   if (ret)
+   return ret;
platform_set_drvdata(pdev, data);
 
if (!PTR_ERR_OR_ZERO(data->hwmon_dev))
@@ -128,18 +132,8 @@ static int rpi_hwmon_probe(struct platform_device *pdev)
return PTR_ERR_OR_ZERO(data->hwmon_dev);
 }
 
-static int rpi_hwmon_remove(struct platform_device *pdev)
-{
-   struct rpi_hwmon_data *data = platform_get_drvdata(pdev);
-
-   cancel_delayed_work_sync(&data->get_values_poll_work);
-
-   return 0;
-}
-
 static struct platform_driver rpi_hwmon_driver = {
.probe = rpi_hwmon_probe,
-   .remove = rpi_hwmon_remove,
.driver = {
.name = "raspberrypi-hwmon",
},
-- 
2.25.4


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 


[PATCH]: staging: hikey9xx: Fix alignment of function parameters

2021-02-13 Thread Mukul Mehar
This patch fixes the following checkpatch.pl check:

CHECK: Alignment should match open parenthesis

Signed-off-by: Mukul Mehar 
---
 drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c 
b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
index 9c5e113e1a81..4ebcfea9f3bf 100644
--- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
+++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
@@ -177,7 +177,7 @@ static void hi6421_spmi_pmic_irq_init(struct 
hi6421_spmi_pmic *ddata)
 
for (i = 0; i < HISI_IRQ_ARRAY; i++)
regmap_write(ddata->regmap, SOC_PMIC_IRQ_MASK_0_ADDR + i,
-   HISI_MASK);
+HISI_MASK);
 
for (i = 0; i < HISI_IRQ_ARRAY; i++) {
regmap_read(ddata->regmap, SOC_PMIC_IRQ0_ADDR + i, &pending);
@@ -235,7 +235,7 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev)
return -ENOMEM;
 
ddata->domain = irq_domain_add_simple(np, HISI_IRQ_NUM, 0,
-&hi6421_spmi_domain_ops, ddata);
+ &hi6421_spmi_domain_ops, ddata);
if (!ddata->domain) {
dev_err(dev, "Failed to create IRQ domain\n");
return -ENODEV;
-- 
2.25.1



[RFC PATCH 4/7] platform/x86: gpd pocket fan: Clean-up by using managed work init

2021-02-13 Thread Matti Vaittinen
Few drivers implement remove call-back only for ensuring a delayed
work gets cancelled prior driver removal. Clean-up these by switching
to use devm_delayed_work_autocancel() instead.

This change is compile-tested only. All testing is appreciated.

Signed-off-by: Matti Vaittinen 
---
 drivers/platform/x86/gpd-pocket-fan.c | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/platform/x86/gpd-pocket-fan.c 
b/drivers/platform/x86/gpd-pocket-fan.c
index 5b516e4c2bfb..271ab902f046 100644
--- a/drivers/platform/x86/gpd-pocket-fan.c
+++ b/drivers/platform/x86/gpd-pocket-fan.c
@@ -124,7 +124,7 @@ static void gpd_pocket_fan_force_update(struct 
gpd_pocket_fan_data *fan)
 static int gpd_pocket_fan_probe(struct platform_device *pdev)
 {
struct gpd_pocket_fan_data *fan;
-   int i;
+   int i, ret;
 
for (i = 0; i < ARRAY_SIZE(temp_limits); i++) {
if (temp_limits[i] < 2 || temp_limits[i] > 9) {
@@ -152,7 +152,10 @@ static int gpd_pocket_fan_probe(struct platform_device 
*pdev)
return -ENOMEM;
 
fan->dev = &pdev->dev;
-   INIT_DELAYED_WORK(&fan->work, gpd_pocket_fan_worker);
+   ret = devm_delayed_work_autocancel(&pdev->dev, &fan->work,
+  gpd_pocket_fan_worker);
+   if (ret)
+   return ret;
 
/* Note this returns a "weak" reference which we don't need to free */
fan->dts0 = thermal_zone_get_zone_by_name("soc_dts0");
@@ -177,14 +180,6 @@ static int gpd_pocket_fan_probe(struct platform_device 
*pdev)
return 0;
 }
 
-static int gpd_pocket_fan_remove(struct platform_device *pdev)
-{
-   struct gpd_pocket_fan_data *fan = platform_get_drvdata(pdev);
-
-   cancel_delayed_work_sync(&fan->work);
-   return 0;
-}
-
 #ifdef CONFIG_PM_SLEEP
 static int gpd_pocket_fan_suspend(struct device *dev)
 {
@@ -215,7 +210,6 @@ MODULE_DEVICE_TABLE(acpi, gpd_pocket_fan_acpi_match);
 
 static struct platform_driver gpd_pocket_fan_driver = {
.probe  = gpd_pocket_fan_probe,
-   .remove = gpd_pocket_fan_remove,
.driver = {
.name   = "gpd_pocket_fan",
.acpi_match_table   = gpd_pocket_fan_acpi_match,
-- 
2.25.4


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 


[RFC PATCH 5/7] power: supply: Clean-up few drivers by using managed work init

2021-02-13 Thread Matti Vaittinen
Few drivers implement remove call-back only for ensuring a delayed
work gets cancelled prior driver removal. Clean-up these by switching
to use devm_delayed_work_autocancel() instead.

This change is compile-tested only. All testing is appreciated.

Signed-off-by: Matti Vaittinen 
---
 drivers/power/supply/axp20x_usb_power.c  | 15 ---
 drivers/power/supply/bq24735-charger.c   | 17 +
 drivers/power/supply/ltc2941-battery-gauge.c | 19 ++-
 drivers/power/supply/sbs-battery.c   | 15 ---
 4 files changed, 19 insertions(+), 47 deletions(-)

diff --git a/drivers/power/supply/axp20x_usb_power.c 
b/drivers/power/supply/axp20x_usb_power.c
index 70b28b699a80..149119601da3 100644
--- a/drivers/power/supply/axp20x_usb_power.c
+++ b/drivers/power/supply/axp20x_usb_power.c
@@ -645,22 +645,16 @@ static int axp20x_usb_power_probe(struct platform_device 
*pdev)
}
}
 
-   INIT_DELAYED_WORK(&power->vbus_detect, axp20x_usb_power_poll_vbus);
+   ret = devm_delayed_work_autocancel(&pdev->dev, &power->vbus_detect,
+  axp20x_usb_power_poll_vbus);
+   if (ret)
+   return ret;
if (axp20x_usb_vbus_needs_polling(power))
queue_delayed_work(system_power_efficient_wq, 
&power->vbus_detect, 0);
 
return 0;
 }
 
-static int axp20x_usb_power_remove(struct platform_device *pdev)
-{
-   struct axp20x_usb_power *power = platform_get_drvdata(pdev);
-
-   cancel_delayed_work_sync(&power->vbus_detect);
-
-   return 0;
-}
-
 static const struct of_device_id axp20x_usb_power_match[] = {
{
.compatible = "x-powers,axp202-usb-power-supply",
@@ -680,7 +674,6 @@ MODULE_DEVICE_TABLE(of, axp20x_usb_power_match);
 
 static struct platform_driver axp20x_usb_power_driver = {
.probe = axp20x_usb_power_probe,
-   .remove = axp20x_usb_power_remove,
.driver = {
.name   = DRVNAME,
.of_match_table = axp20x_usb_power_match,
diff --git a/drivers/power/supply/bq24735-charger.c 
b/drivers/power/supply/bq24735-charger.c
index ab2f4bf8f603..eb23a5665664 100644
--- a/drivers/power/supply/bq24735-charger.c
+++ b/drivers/power/supply/bq24735-charger.c
@@ -473,7 +473,11 @@ static int bq24735_charger_probe(struct i2c_client *client,
if (!charger->poll_interval)
return 0;
 
-   INIT_DELAYED_WORK(&charger->poll, bq24735_poll);
+   ret = devm_delayed_work_autocancel(&client->dev, &charger->poll,
+  bq24735_poll);
+   if (ret)
+   return ret;
+
schedule_delayed_work(&charger->poll,
  msecs_to_jiffies(charger->poll_interval));
}
@@ -481,16 +485,6 @@ static int bq24735_charger_probe(struct i2c_client *client,
return 0;
 }
 
-static int bq24735_charger_remove(struct i2c_client *client)
-{
-   struct bq24735 *charger = i2c_get_clientdata(client);
-
-   if (charger->poll_interval)
-   cancel_delayed_work_sync(&charger->poll);
-
-   return 0;
-}
-
 static const struct i2c_device_id bq24735_charger_id[] = {
{ "bq24735-charger", 0 },
{}
@@ -509,7 +503,6 @@ static struct i2c_driver bq24735_charger_driver = {
.of_match_table = bq24735_match_ids,
},
.probe = bq24735_charger_probe,
-   .remove = bq24735_charger_remove,
.id_table = bq24735_charger_id,
 };
 
diff --git a/drivers/power/supply/ltc2941-battery-gauge.c 
b/drivers/power/supply/ltc2941-battery-gauge.c
index 10cd617516ec..7eaa0f6115dc 100644
--- a/drivers/power/supply/ltc2941-battery-gauge.c
+++ b/drivers/power/supply/ltc2941-battery-gauge.c
@@ -445,15 +445,6 @@ static enum power_supply_property ltc294x_properties[] = {
POWER_SUPPLY_PROP_CURRENT_NOW,
 };
 
-static int ltc294x_i2c_remove(struct i2c_client *client)
-{
-   struct ltc294x_info *info = i2c_get_clientdata(client);
-
-   cancel_delayed_work_sync(&info->work);
-   power_supply_unregister(info->supply);
-   return 0;
-}
-
 static int ltc294x_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
 {
@@ -547,7 +538,10 @@ static int ltc294x_i2c_probe(struct i2c_client *client,
 
psy_cfg.drv_data = info;
 
-   INIT_DELAYED_WORK(&info->work, ltc294x_work);
+   ret = devm_delayed_work_autocancel(&client->dev, &info->work,
+  ltc294x_work);
+   if (ret)
+   return ret;
 
ret = ltc294x_reset(info, prescaler_exp);
if (ret < 0) {
@@ -555,8 +549,8 @@ static int ltc294x_i2c_probe(struct i2c_client *client,
return ret;
}
 
-   info->supply = power_supply_register(&client->dev, &info->supply_desc,
-&psy_cfg);
+   

[RFC PATCH 6/7] regulator: qcom_spmi-regulator: Clean-up by using managed work init

2021-02-13 Thread Matti Vaittinen
Few drivers implement remove call-back only for ensuring a delayed
work gets cancelled prior driver removal. Clean-up these by switching
to use devm_delayed_work_autocancel() instead.

This change is compile-tested only. All testing is appreciated.

Signed-off-by: Matti Vaittinen 
---
 drivers/regulator/qcom_spmi-regulator.c | 33 ++---
 1 file changed, 7 insertions(+), 26 deletions(-)

diff --git a/drivers/regulator/qcom_spmi-regulator.c 
b/drivers/regulator/qcom_spmi-regulator.c
index e62e1d72d943..68aefffc235f 100644
--- a/drivers/regulator/qcom_spmi-regulator.c
+++ b/drivers/regulator/qcom_spmi-regulator.c
@@ -1842,7 +1842,10 @@ static int spmi_regulator_of_parse(struct device_node 
*node,
return ret;
}
 
-   INIT_DELAYED_WORK(&vreg->ocp_work, spmi_regulator_vs_ocp_work);
+   ret = devm_delayed_work_autocancel(dev, &vreg->ocp_work,
+  spmi_regulator_vs_ocp_work);
+   if (ret)
+   return ret;
}
 
return 0;
@@ -2157,10 +2160,8 @@ static int qcom_spmi_regulator_probe(struct 
platform_device *pdev)
vreg->regmap = regmap;
if (reg->ocp) {
vreg->ocp_irq = platform_get_irq_byname(pdev, reg->ocp);
-   if (vreg->ocp_irq < 0) {
-   ret = vreg->ocp_irq;
-   goto err;
-   }
+   if (vreg->ocp_irq < 0)
+   return vreg->ocp_irq;
}
vreg->desc.id = -1;
vreg->desc.owner = THIS_MODULE;
@@ -2203,8 +2204,7 @@ static int qcom_spmi_regulator_probe(struct 
platform_device *pdev)
rdev = devm_regulator_register(dev, &vreg->desc, &config);
if (IS_ERR(rdev)) {
dev_err(dev, "failed to register %s\n", name);
-   ret = PTR_ERR(rdev);
-   goto err;
+   return PTR_ERR(rdev);
}
 
INIT_LIST_HEAD(&vreg->node);
@@ -2212,24 +2212,6 @@ static int qcom_spmi_regulator_probe(struct 
platform_device *pdev)
}
 
return 0;
-
-err:
-   list_for_each_entry(vreg, vreg_list, node)
-   if (vreg->ocp_irq)
-   cancel_delayed_work_sync(&vreg->ocp_work);
-   return ret;
-}
-
-static int qcom_spmi_regulator_remove(struct platform_device *pdev)
-{
-   struct spmi_regulator *vreg;
-   struct list_head *vreg_list = platform_get_drvdata(pdev);
-
-   list_for_each_entry(vreg, vreg_list, node)
-   if (vreg->ocp_irq)
-   cancel_delayed_work_sync(&vreg->ocp_work);
-
-   return 0;
 }
 
 static struct platform_driver qcom_spmi_regulator_driver = {
@@ -2238,7 +2220,6 @@ static struct platform_driver qcom_spmi_regulator_driver 
= {
.of_match_table = qcom_spmi_regulator_match,
},
.probe  = qcom_spmi_regulator_probe,
-   .remove = qcom_spmi_regulator_remove,
 };
 module_platform_driver(qcom_spmi_regulator_driver);
 
-- 
2.25.4


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 


Re: [RFC PATCH 3/7] hwmon: raspberry-pi: Clean-up few drivers by using managed work init

2021-02-13 Thread Greg Kroah-Hartman
On Sat, Feb 13, 2021 at 02:07:02PM +0200, Matti Vaittinen wrote:
> Few drivers implement remove call-back only for ensuring a delayed
> work gets cancelled prior driver removal. Clean-up these by switching
> to use devm_delayed_work_autocancel() instead.
> 
> This change is compile-tested only. All testing is appreciated.
> 
> Signed-off-by: Matti Vaittinen 
> ---
>  drivers/hwmon/raspberrypi-hwmon.c | 16 +---
>  1 file changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/hwmon/raspberrypi-hwmon.c 
> b/drivers/hwmon/raspberrypi-hwmon.c
> index d3a64a35f7a9..acfa674932bc 100644
> --- a/drivers/hwmon/raspberrypi-hwmon.c
> +++ b/drivers/hwmon/raspberrypi-hwmon.c
> @@ -106,6 +106,7 @@ static int rpi_hwmon_probe(struct platform_device *pdev)
>  {
>   struct device *dev = &pdev->dev;
>   struct rpi_hwmon_data *data;
> + int ret;
>  
>   data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
>   if (!data)
> @@ -119,7 +120,10 @@ static int rpi_hwmon_probe(struct platform_device *pdev)
>  &rpi_chip_info,
>  NULL);
>  
> - INIT_DELAYED_WORK(&data->get_values_poll_work, get_values_poll);
> + ret = devm_delayed_work_autocancel(dev, &data->get_values_poll_work,
> +get_values_poll);
> + if (ret)
> + return ret;
>   platform_set_drvdata(pdev, data);
>  
>   if (!PTR_ERR_OR_ZERO(data->hwmon_dev))
> @@ -128,18 +132,8 @@ static int rpi_hwmon_probe(struct platform_device *pdev)
>   return PTR_ERR_OR_ZERO(data->hwmon_dev);
>  }
>  
> -static int rpi_hwmon_remove(struct platform_device *pdev)
> -{
> - struct rpi_hwmon_data *data = platform_get_drvdata(pdev);
> -
> - cancel_delayed_work_sync(&data->get_values_poll_work);
> -
> - return 0;
> -}
> -
>  static struct platform_driver rpi_hwmon_driver = {
>   .probe = rpi_hwmon_probe,
> - .remove = rpi_hwmon_remove,
>   .driver = {
>   .name = "raspberrypi-hwmon",
>   },

So if I manually unbind the driver from the device, and then unload the
driver, what happens?

thanks,

greg k-h


Re: [RFC PATCH 1/7] drivers: base: Add resource managed version of delayed work init

2021-02-13 Thread Greg Kroah-Hartman
On Sat, Feb 13, 2021 at 01:58:44PM +0200, Matti Vaittinen wrote:
> A few drivers which need a delayed work-queue must cancel work at exit.
> Some of those implement remove solely for this purpose. Help drivers
> to avoid unnecessary remove and error-branch implementation by adding
> managed verision of delayed work initialization
> 
> Signed-off-by: Matti Vaittinen 

That's not a good idea.  As this would kick in when the device is
removed from the system, not when it is unbound from the driver, right?

> ---
>  drivers/base/devres.c  | 33 +
>  include/linux/device.h |  5 +
>  2 files changed, 38 insertions(+)
> 
> diff --git a/drivers/base/devres.c b/drivers/base/devres.c
> index fb9d5289a620..2879595bb5a4 100644
> --- a/drivers/base/devres.c
> +++ b/drivers/base/devres.c
> @@ -1231,3 +1231,36 @@ void devm_free_percpu(struct device *dev, void 
> __percpu *pdata)
>  (void *)pdata));
>  }
>  EXPORT_SYMBOL_GPL(devm_free_percpu);
> +
> +static void dev_delayed_work_drop(struct device *dev, void *res)
> +{
> + cancel_delayed_work_sync(*(struct delayed_work **)res);
> +}
> +
> +/**
> + * devm_delayed_work_autocancel - Resource-managed work allocation
> + * @dev: Device which lifetime work is bound to
> + * @pdata: work to be cancelled when device exits
> + *
> + * Initialize work which is automatically cancelled when device exits.

There is no such thing in the driver model as "when device exits".
Please use the proper terminology as I do not understand what you think
this is doing here...

> + * A few drivers need delayed work which must be cancelled before driver
> + * is unload to avoid accessing removed resources.
> + * devm_delayed_work_autocancel() can be used to omit the explicit
> + * cancelleation when driver is unload.
> + */
> +int devm_delayed_work_autocancel(struct device *dev, struct delayed_work *w,
> +  void (*worker)(struct work_struct *work))
> +{
> + struct delayed_work **ptr;
> +
> + ptr = devres_alloc(dev_delayed_work_drop, sizeof(*ptr), GFP_KERNEL);
> + if (!ptr)
> + return -ENOMEM;
> +
> + INIT_DELAYED_WORK(w, worker);
> + *ptr = w;
> + devres_add(dev, ptr);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(devm_delayed_work_autocancel);
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 1779f90eeb4c..192456198de7 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -249,6 +250,10 @@ void __iomem *devm_of_iomap(struct device *dev,
>   struct device_node *node, int index,
>   resource_size_t *size);
>  
> +/* delayed work which is cancelled when driver exits */

Not when the "driver exits".

There is two different lifespans here (well 3).  Code and data*2.  Don't
confuse them as that will just cause lots of problems.

The move toward more and more "devm" functions is not the way to go as
they just more and more make things easier to get wrong.

APIs should be impossible to get wrong, this one is going to be almost
impossible to get right.

thanks,

greg k-h


Re: [RFC PATCH 5/7] power: supply: Clean-up few drivers by using managed work init

2021-02-13 Thread Greg Kroah-Hartman
On Sat, Feb 13, 2021 at 02:12:41PM +0200, Matti Vaittinen wrote:
> Few drivers implement remove call-back only for ensuring a delayed
> work gets cancelled prior driver removal. Clean-up these by switching
> to use devm_delayed_work_autocancel() instead.
> 
> This change is compile-tested only. All testing is appreciated.

These will all break as I mentioned before...



[RFC PATCH 7/7] watchdog: retu_wdt: Clean-up by using managed work init

2021-02-13 Thread Matti Vaittinen
Few drivers implement remove call-back only for ensuring a delayed
work gets cancelled prior driver removal. Clean-up these by switching
to use devm_delayed_work_autocancel() instead.

This change is compile-tested only. All testing is appreciated.

Signed-off-by: Matti Vaittinen 
---
 drivers/watchdog/retu_wdt.c | 21 +
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/watchdog/retu_wdt.c b/drivers/watchdog/retu_wdt.c
index 258dfcf9cbda..3b65bdaf54b4 100644
--- a/drivers/watchdog/retu_wdt.c
+++ b/drivers/watchdog/retu_wdt.c
@@ -127,9 +127,12 @@ static int retu_wdt_probe(struct platform_device *pdev)
wdev->rdev  = rdev;
wdev->dev   = &pdev->dev;
 
-   INIT_DELAYED_WORK(&wdev->ping_work, retu_wdt_ping_work);
+   ret = devm_delayed_work_autocancel(&pdev->dev, &wdev->ping_work,
+  retu_wdt_ping_work);
+   if (ret)
+   return ret;
 
-   ret = watchdog_register_device(retu_wdt);
+   ret = devm_watchdog_register_device(&pdev->dev, retu_wdt);
if (ret < 0)
return ret;
 
@@ -138,25 +141,11 @@ static int retu_wdt_probe(struct platform_device *pdev)
else
retu_wdt_ping_enable(wdev);
 
-   platform_set_drvdata(pdev, retu_wdt);
-
-   return 0;
-}
-
-static int retu_wdt_remove(struct platform_device *pdev)
-{
-   struct watchdog_device *wdog = platform_get_drvdata(pdev);
-   struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog);
-
-   watchdog_unregister_device(wdog);
-   cancel_delayed_work_sync(&wdev->ping_work);
-
return 0;
 }
 
 static struct platform_driver retu_wdt_driver = {
.probe  = retu_wdt_probe,
-   .remove = retu_wdt_remove,
.driver = {
.name   = "retu-wdt",
},
-- 
2.25.4


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 


[PATCH v2 0/3] Fixes & a new supplementary feature to SPRD mailbox driver

2021-02-13 Thread Orson Zhai
Fix a real problem fot SPRD's mailbox driver in patch 1/3.
Add supplementary inbox support for newly added sc9863a in patch 3/3 and
change dt bindings yaml accordingly in patch 2/3.

Changes Log:
V2:
- Change patches order. (Yaml go to the head of dirver)
- Remove unnecessary initializing refcnt to zero. 
- Add fix of possible crash caused by NULL of chan->cl. (Actually move from
  changes to sprd-mailbox.c of patch v1)
- Remove unnecessary "inline" for do_inbox_isr().
- Fix yaml errors from Rob's robot checking.
- Add sc9863a compatible string for real supplementary inbox usage. (sc9860
  is not supported by supp-inbox)
- Add more details to supp-inbox in commit messages.

Orson Zhai (3):
  mailbox: sprd: Introduce refcnt when clients requests/free channels
  dt-bindings: mailbox: Add interrupt-names to SPRD mailbox
  mailbox: sprd: Add supplementary inbox support

 .../bindings/mailbox/sprd-mailbox.yaml|  18 ++-
 drivers/mailbox/sprd-mailbox.c| 135 +-
 2 files changed, 117 insertions(+), 36 deletions(-)

-- 
2.17.1



[PATCH v2 1/3] mailbox: sprd: Introduce refcnt when clients requests/free channels

2021-02-13 Thread Orson Zhai
From: Orson Zhai 

Unisoc mailbox has no way to be enabled/disabled for any single channel.
They can only be set to startup or shutdown as a whole device at same time.

Add a variable to count references to avoid mailbox FIFO being reset
unexpectedly when clients are requesting or freeing channels.

Also add a lock to dismiss possible conflicts from register r/w in
different startup or shutdown threads. And fix the crash problem when early
interrupts come from channel which has not been requested by client yet.

Fixes: ca27fc26cd22 ("mailbox: sprd: Add Spreadtrum mailbox driver")
Signed-off-by: Orson Zhai 
---
 drivers/mailbox/sprd-mailbox.c | 43 +++---
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/drivers/mailbox/sprd-mailbox.c b/drivers/mailbox/sprd-mailbox.c
index f6fab24ae8a9..920de7b9dce1 100644
--- a/drivers/mailbox/sprd-mailbox.c
+++ b/drivers/mailbox/sprd-mailbox.c
@@ -60,6 +60,8 @@ struct sprd_mbox_priv {
struct clk  *clk;
u32 outbox_fifo_depth;
 
+   struct mutexlock;
+   u32 refcnt;
struct mbox_chanchan[SPRD_MBOX_CHAN_MAX];
 };
 
@@ -115,7 +117,11 @@ static irqreturn_t sprd_mbox_outbox_isr(int irq, void 
*data)
id = readl(priv->outbox_base + SPRD_MBOX_ID);
 
chan = &priv->chan[id];
-   mbox_chan_received_data(chan, (void *)msg);
+   if (chan->cl)
+   mbox_chan_received_data(chan, (void *)msg);
+   else
+   dev_warn_ratelimited(priv->dev,
+   "message's been dropped at ch[%d]\n", id);
 
/* Trigger to update outbox FIFO pointer */
writel(0x1, priv->outbox_base + SPRD_MBOX_TRIGGER);
@@ -215,18 +221,22 @@ static int sprd_mbox_startup(struct mbox_chan *chan)
struct sprd_mbox_priv *priv = to_sprd_mbox_priv(chan->mbox);
u32 val;
 
-   /* Select outbox FIFO mode and reset the outbox FIFO status */
-   writel(0x0, priv->outbox_base + SPRD_MBOX_FIFO_RST);
+   mutex_lock(&priv->lock);
+   if (priv->refcnt++ == 0) {
+   /* Select outbox FIFO mode and reset the outbox FIFO status */
+   writel(0x0, priv->outbox_base + SPRD_MBOX_FIFO_RST);
 
-   /* Enable inbox FIFO overflow and delivery interrupt */
-   val = readl(priv->inbox_base + SPRD_MBOX_IRQ_MSK);
-   val &= ~(SPRD_INBOX_FIFO_OVERFLOW_IRQ | SPRD_INBOX_FIFO_DELIVER_IRQ);
-   writel(val, priv->inbox_base + SPRD_MBOX_IRQ_MSK);
+   /* Enable inbox FIFO overflow and delivery interrupt */
+   val = readl(priv->inbox_base + SPRD_MBOX_IRQ_MSK);
+   val &= ~(SPRD_INBOX_FIFO_OVERFLOW_IRQ | 
SPRD_INBOX_FIFO_DELIVER_IRQ);
+   writel(val, priv->inbox_base + SPRD_MBOX_IRQ_MSK);
 
-   /* Enable outbox FIFO not empty interrupt */
-   val = readl(priv->outbox_base + SPRD_MBOX_IRQ_MSK);
-   val &= ~SPRD_OUTBOX_FIFO_NOT_EMPTY_IRQ;
-   writel(val, priv->outbox_base + SPRD_MBOX_IRQ_MSK);
+   /* Enable outbox FIFO not empty interrupt */
+   val = readl(priv->outbox_base + SPRD_MBOX_IRQ_MSK);
+   val &= ~SPRD_OUTBOX_FIFO_NOT_EMPTY_IRQ;
+   writel(val, priv->outbox_base + SPRD_MBOX_IRQ_MSK);
+   }
+   mutex_unlock(&priv->lock);
 
return 0;
 }
@@ -235,9 +245,13 @@ static void sprd_mbox_shutdown(struct mbox_chan *chan)
 {
struct sprd_mbox_priv *priv = to_sprd_mbox_priv(chan->mbox);
 
-   /* Disable inbox & outbox interrupt */
-   writel(SPRD_INBOX_FIFO_IRQ_MASK, priv->inbox_base + SPRD_MBOX_IRQ_MSK);
-   writel(SPRD_OUTBOX_FIFO_IRQ_MASK, priv->outbox_base + 
SPRD_MBOX_IRQ_MSK);
+   mutex_lock(&priv->lock);
+   if (--priv->refcnt == 0) {
+   /* Disable inbox & outbox interrupt */
+   writel(SPRD_INBOX_FIFO_IRQ_MASK, priv->inbox_base + 
SPRD_MBOX_IRQ_MSK);
+   writel(SPRD_OUTBOX_FIFO_IRQ_MASK, priv->outbox_base + 
SPRD_MBOX_IRQ_MSK);
+   }
+   mutex_unlock(&priv->lock);
 }
 
 static const struct mbox_chan_ops sprd_mbox_ops = {
@@ -266,6 +280,7 @@ static int sprd_mbox_probe(struct platform_device *pdev)
return -ENOMEM;
 
priv->dev = dev;
+   mutex_init(&priv->lock);
 
/*
 * The Spreadtrum mailbox uses an inbox to send messages to the target
-- 
2.17.1



[PATCH v2 2/3] dt-bindings: mailbox: Add interrupt-names to SPRD mailbox

2021-02-13 Thread Orson Zhai
From: Orson Zhai 

We add an optional supp-outbox interrupt support to SPRD mailbox driver
with newly added sc9863a support and change to configure interrupts with
names in device tree files.

Signed-off-by: Orson Zhai 
---
 .../bindings/mailbox/sprd-mailbox.yaml | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/mailbox/sprd-mailbox.yaml 
b/Documentation/devicetree/bindings/mailbox/sprd-mailbox.yaml
index 26a5cca3f838..67736450ee93 100644
--- a/Documentation/devicetree/bindings/mailbox/sprd-mailbox.yaml
+++ b/Documentation/devicetree/bindings/mailbox/sprd-mailbox.yaml
@@ -15,6 +15,7 @@ properties:
   compatible:
 enum:
   - sprd,sc9860-mailbox
+  - sprd,sc9863a-mailbox
 
   reg:
 items:
@@ -22,9 +23,18 @@ properties:
   - description: outbox registers' base address
 
   interrupts:
-items:
-  - description: inbox interrupt
-  - description: outbox interrupt
+minItems: 2
+maxItems: 3
+
+  interrupt-names:
+oneOf:
+  - items:
+  - const: inbox
+  - const: outbox
+  - items:
+  - const: inbox
+  - const: outbox
+  - const: supp-outbox
 
   clocks:
 maxItems: 1
@@ -40,6 +50,7 @@ required:
   - compatible
   - reg
   - interrupts
+  - interrupt-names
   - "#mbox-cells"
   - clocks
   - clock-names
@@ -56,5 +67,6 @@ examples:
   clock-names = "enable";
   clocks = <&aon_gate 53>;
   interrupts = , ;
+  interrupt-names = "inbox", "outbox";
 };
 ...
-- 
2.17.1



[PATCH v2 3/3] mailbox: sprd: Add supplementary inbox support

2021-02-13 Thread Orson Zhai
From: Orson Zhai 

Some sensors connected to Unisoc mailbox will send data very frequently.
This makes channel 0 very busy and the messages from other remote cores
not able to be handled as soon as possible.

It's a trick (un-documented) from Unisoc ASIC designers to resolve this
special requirement that an inbox assigned to one of the remote cores
before was modified to be exposed to host cpu core.

Then from host side, a supplementary inbox is added for transferring mass
but not emergency messages from the remote cores, such as step counting
sensor, with an independent FIFO and interrupt which is as same as channel
0. Meanwihle, inbox part of this channel is still kept for original remote
core to use.

Signed-off-by: Orson Zhai 
---
 drivers/mailbox/sprd-mailbox.c | 88 +++---
 1 file changed, 71 insertions(+), 17 deletions(-)

diff --git a/drivers/mailbox/sprd-mailbox.c b/drivers/mailbox/sprd-mailbox.c
index 920de7b9dce1..7abd6c6d655d 100644
--- a/drivers/mailbox/sprd-mailbox.c
+++ b/drivers/mailbox/sprd-mailbox.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -50,13 +51,17 @@
 #define SPRD_OUTBOX_FIFO_NOT_EMPTY_IRQ BIT(0)
 #define SPRD_OUTBOX_FIFO_IRQ_MASK  GENMASK(4, 0)
 
+#define SPRD_OUTBOX_BASE_SPAN  0x1000
 #define SPRD_MBOX_CHAN_MAX 8
+#define SPRD_SUPP_INBOX_ID_SC9863A 7
 
 struct sprd_mbox_priv {
struct mbox_controller  mbox;
struct device   *dev;
void __iomem*inbox_base;
void __iomem*outbox_base;
+   /*  Base register address for supplementary outbox */
+   void __iomem*supp_base;
struct clk  *clk;
u32 outbox_fifo_depth;
 
@@ -96,14 +101,13 @@ static u32 sprd_mbox_get_fifo_len(struct sprd_mbox_priv 
*priv, u32 fifo_sts)
return fifo_len;
 }
 
-static irqreturn_t sprd_mbox_outbox_isr(int irq, void *data)
+static irqreturn_t do_outbox_isr(void __iomem *base, struct sprd_mbox_priv 
*priv)
 {
-   struct sprd_mbox_priv *priv = data;
struct mbox_chan *chan;
u32 fifo_sts, fifo_len, msg[2];
int i, id;
 
-   fifo_sts = readl(priv->outbox_base + SPRD_MBOX_FIFO_STS);
+   fifo_sts = readl(base + SPRD_MBOX_FIFO_STS);
 
fifo_len = sprd_mbox_get_fifo_len(priv, fifo_sts);
if (!fifo_len) {
@@ -112,9 +116,9 @@ static irqreturn_t sprd_mbox_outbox_isr(int irq, void *data)
}
 
for (i = 0; i < fifo_len; i++) {
-   msg[0] = readl(priv->outbox_base + SPRD_MBOX_MSG_LOW);
-   msg[1] = readl(priv->outbox_base + SPRD_MBOX_MSG_HIGH);
-   id = readl(priv->outbox_base + SPRD_MBOX_ID);
+   msg[0] = readl(base + SPRD_MBOX_MSG_LOW);
+   msg[1] = readl(base + SPRD_MBOX_MSG_HIGH);
+   id = readl(base + SPRD_MBOX_ID);
 
chan = &priv->chan[id];
if (chan->cl)
@@ -124,15 +128,29 @@ static irqreturn_t sprd_mbox_outbox_isr(int irq, void 
*data)
"message's been dropped at ch[%d]\n", id);
 
/* Trigger to update outbox FIFO pointer */
-   writel(0x1, priv->outbox_base + SPRD_MBOX_TRIGGER);
+   writel(0x1, base + SPRD_MBOX_TRIGGER);
}
 
/* Clear irq status after reading all message. */
-   writel(SPRD_MBOX_IRQ_CLR, priv->outbox_base + SPRD_MBOX_IRQ_STS);
+   writel(SPRD_MBOX_IRQ_CLR, base + SPRD_MBOX_IRQ_STS);
 
return IRQ_HANDLED;
 }
 
+static irqreturn_t sprd_mbox_outbox_isr(int irq, void *data)
+{
+   struct sprd_mbox_priv *priv = data;
+
+   return do_outbox_isr(priv->outbox_base, priv);
+}
+
+static irqreturn_t sprd_mbox_supp_isr(int irq, void *data)
+{
+   struct sprd_mbox_priv *priv = data;
+
+   return do_outbox_isr(priv->supp_base, priv);
+}
+
 static irqreturn_t sprd_mbox_inbox_isr(int irq, void *data)
 {
struct sprd_mbox_priv *priv = data;
@@ -235,6 +253,14 @@ static int sprd_mbox_startup(struct mbox_chan *chan)
val = readl(priv->outbox_base + SPRD_MBOX_IRQ_MSK);
val &= ~SPRD_OUTBOX_FIFO_NOT_EMPTY_IRQ;
writel(val, priv->outbox_base + SPRD_MBOX_IRQ_MSK);
+
+   /* Enable supplementary outbox as the fundamental one */
+   if (priv->supp_base) {
+   writel(0x0, priv->supp_base + SPRD_MBOX_FIFO_RST);
+   val = readl(priv->supp_base + SPRD_MBOX_IRQ_MSK);
+   val &= ~SPRD_OUTBOX_FIFO_NOT_EMPTY_IRQ;
+   writel(val, priv->supp_base + SPRD_MBOX_IRQ_MSK);
+   }
}
mutex_unlock(&priv->lock);
 
@@ -250,6 +276,10 @@ static void sprd_mbox_shutdown(struct mbox_chan *chan)
/* Disable inbox & outbox interrupt */
writel(SPRD_INBOX_FIFO_IRQ_MASK, priv->inbox_base + 
SPRD_

Re: [RFC PATCH 1/7] drivers: base: Add resource managed version of delayed work init

2021-02-13 Thread Vaittinen, Matti

On Sat, 2021-02-13 at 13:16 +0100, Greg Kroah-Hartman wrote:
> On Sat, Feb 13, 2021 at 01:58:44PM +0200, Matti Vaittinen wrote:
> > A few drivers which need a delayed work-queue must cancel work at
> > exit.
> > Some of those implement remove solely for this purpose. Help
> > drivers
> > to avoid unnecessary remove and error-branch implementation by
> > adding
> > managed verision of delayed work initialization
> > 
> > Signed-off-by: Matti Vaittinen 
> 
> That's not a good idea.  As this would kick in when the device is
> removed from the system, not when it is unbound from the driver,
> right?
> 
> > ---
> >  drivers/base/devres.c  | 33 +
> >  include/linux/device.h |  5 +
> >  2 files changed, 38 insertions(+)
> > 
> > diff --git a/drivers/base/devres.c b/drivers/base/devres.c
> > index fb9d5289a620..2879595bb5a4 100644
> > --- a/drivers/base/devres.c
> > +++ b/drivers/base/devres.c
> > @@ -1231,3 +1231,36 @@ void devm_free_percpu(struct device *dev,
> > void __percpu *pdata)
> >(void *)pdata));
> >  }
> >  EXPORT_SYMBOL_GPL(devm_free_percpu);
> > +
> > +static void dev_delayed_work_drop(struct device *dev, void *res)
> > +{
> > +   cancel_delayed_work_sync(*(struct delayed_work **)res);
> > +}
> > +
> > +/**
> > + * devm_delayed_work_autocancel - Resource-managed work allocation
> > + * @dev: Device which lifetime work is bound to
> > + * @pdata: work to be cancelled when device exits
> > + *
> > + * Initialize work which is automatically cancelled when device
> > exits.
> 
> There is no such thing in the driver model as "when device exits".
> Please use the proper terminology as I do not understand what you
> think
> this is doing here...
> 
> > + * A few drivers need delayed work which must be cancelled before
> > driver
> > + * is unload to avoid accessing removed resources.
> > + * devm_delayed_work_autocancel() can be used to omit the explicit
> > + * cancelleation when driver is unload.
> > + */
> > +int devm_delayed_work_autocancel(struct device *dev, struct
> > delayed_work *w,
> > +void (*worker)(struct work_struct
> > *work))
> > +{
> > +   struct delayed_work **ptr;
> > +
> > +   ptr = devres_alloc(dev_delayed_work_drop, sizeof(*ptr),
> > GFP_KERNEL);
> > +   if (!ptr)
> > +   return -ENOMEM;
> > +
> > +   INIT_DELAYED_WORK(w, worker);
> > +   *ptr = w;
> > +   devres_add(dev, ptr);
> > +
> > +   return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(devm_delayed_work_autocancel);
> > diff --git a/include/linux/device.h b/include/linux/device.h
> > index 1779f90eeb4c..192456198de7 100644
> > --- a/include/linux/device.h
> > +++ b/include/linux/device.h
> > @@ -27,6 +27,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -249,6 +250,10 @@ void __iomem *devm_of_iomap(struct device
> > *dev,
> > struct device_node *node, int index,
> > resource_size_t *size);
> >  
> > +/* delayed work which is cancelled when driver exits */
> 
> Not when the "driver exits".
> 
> There is two different lifespans here (well 3).  Code and
> data*2.  Don't
> confuse them as that will just cause lots of problems.
> 
> The move toward more and more "devm" functions is not the way to go
> as
> they just more and more make things easier to get wrong.
> 
> APIs should be impossible to get wrong, this one is going to be
> almost
> impossible to get right.

Thanks for prompt reply. I guess I must've misunderstood some of this
concept. Frankly to say, I don't understand how the devm based irq
management works and this does not. Maybe I'd better study this further
then.

Best Regards
Matti Vaittinen


[tip:locking/core] BUILD SUCCESS 3765d01bab73bdb920ef711203978f02cd26e4da

2021-02-13 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git 
locking/core
branch HEAD: 3765d01bab73bdb920ef711203978f02cd26e4da  Merge branch 
'for-mingo-lkmm' of 
git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu into 
locking/core

elapsed time: 723m

configs tested: 152
configs skipped: 2

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
arm  moxart_defconfig
armspear6xx_defconfig
openrisc simple_smp_defconfig
arm shannon_defconfig
arm davinci_all_defconfig
arcvdk_hs38_defconfig
shsh7763rdp_defconfig
c6xevmc6474_defconfig
sh  rts7751r2d1_defconfig
m68kq40_defconfig
armlart_defconfig
armpleb_defconfig
arm   milbeaut_m10v_defconfig
h8300alldefconfig
openrisc alldefconfig
sh   se7712_defconfig
h8300   defconfig
shhp6xx_defconfig
arm  simpad_defconfig
powerpc mpc8315_rdb_defconfig
arm  pxa3xx_defconfig
sh   se7206_defconfig
sh ap325rxa_defconfig
powerpc   eiger_defconfig
xtensa  cadence_csp_defconfig
powerpc linkstation_defconfig
mips   jazz_defconfig
powerpc mpc832x_mds_defconfig
mips   capcella_defconfig
arm   netwinder_defconfig
powerpc64   defconfig
arc  alldefconfig
microblaze  mmu_defconfig
powerpc mpc834x_mds_defconfig
mipsnlm_xlp_defconfig
powerpcfsp2_defconfig
powerpc  ppc64e_defconfig
mips   ci20_defconfig
powerpc   bluestone_defconfig
sh  rsk7203_defconfig
powerpcgamecube_defconfig
mips  ath79_defconfig
powerpc64alldefconfig
nds32   defconfig
powerpc mpc5200_defconfig
armclps711x_defconfig
arcnsim_700_defconfig
powerpc  pmac32_defconfig
powerpcicon_defconfig
arm rpc_defconfig
arm lpc32xx_defconfig
arm  badge4_defconfig
mips  maltaaprp_defconfig
xtensa virt_defconfig
mips bigsur_defconfig
sparc   defconfig
armmagician_defconfig
mipse55_defconfig
parisc  defconfig
pariscgeneric-32bit_defconfig
ia64 allmodconfig
ia64defconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nios2   defconfig
arc  allyesconfig
nds32 allnoconfig
c6x  allyesconfig
nios2allyesconfig
cskydefconfig
alpha   defconfig
alphaallyesconfig
xtensa   allyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
s390 allyesconfig
s390 allmodconfig
parisc   allyesconfig
s390defconfig
i386 allyesconfig
sparcallyesconfig
i386   tinyconfig
i386defconfig
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc  allmodconfig
powerpc   allnoconfig
x86_64   randconfig-a006-20210209
x86_64   randconfig-a001-20210209
x86_64   randconfig-a005-20210209

[tip:x86/entry] BUILD SUCCESS a3251c1a36f595046bea03935ebe37a1e1f1f1d7

2021-02-13 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git 
x86/entry
branch HEAD: a3251c1a36f595046bea03935ebe37a1e1f1f1d7  Merge branch 
'x86/paravirt' into x86/entry

elapsed time: 722m

configs tested: 146
configs skipped: 2

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
arm  moxart_defconfig
armspear6xx_defconfig
openrisc simple_smp_defconfig
arm shannon_defconfig
arm davinci_all_defconfig
arcvdk_hs38_defconfig
shsh7763rdp_defconfig
c6xevmc6474_defconfig
sh  rts7751r2d1_defconfig
m68kq40_defconfig
armlart_defconfig
armpleb_defconfig
arm   milbeaut_m10v_defconfig
h8300alldefconfig
openrisc alldefconfig
sh   se7712_defconfig
h8300   defconfig
shhp6xx_defconfig
arm  simpad_defconfig
powerpc mpc8315_rdb_defconfig
arm  pxa3xx_defconfig
sh   se7206_defconfig
sh ap325rxa_defconfig
powerpc   eiger_defconfig
xtensa  cadence_csp_defconfig
powerpc linkstation_defconfig
mips   jazz_defconfig
powerpc mpc832x_mds_defconfig
mips   capcella_defconfig
arm   netwinder_defconfig
powerpcfsp2_defconfig
powerpc  ppc64e_defconfig
mips   ci20_defconfig
powerpc   bluestone_defconfig
sh  rsk7203_defconfig
powerpcgamecube_defconfig
mips  ath79_defconfig
powerpc64alldefconfig
nds32   defconfig
powerpc mpc5200_defconfig
armclps711x_defconfig
arcnsim_700_defconfig
powerpc  pmac32_defconfig
powerpcicon_defconfig
arm rpc_defconfig
arm lpc32xx_defconfig
arm  badge4_defconfig
mips  maltaaprp_defconfig
parisc  defconfig
pariscgeneric-32bit_defconfig
openriscdefconfig
powerpc  ppc6xx_defconfig
powerpc mpc83xx_defconfig
ia64 allmodconfig
ia64defconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nios2   defconfig
arc  allyesconfig
nds32 allnoconfig
c6x  allyesconfig
nios2allyesconfig
cskydefconfig
alpha   defconfig
alphaallyesconfig
xtensa   allyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
s390 allyesconfig
s390 allmodconfig
parisc   allyesconfig
s390defconfig
i386 allyesconfig
sparcallyesconfig
sparc   defconfig
i386   tinyconfig
i386defconfig
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc  allmodconfig
powerpc   allnoconfig
x86_64   randconfig-a006-20210209
x86_64   randconfig-a001-20210209
x86_64   randconfig-a005-20210209
x86_64   randconfig-a004-20210209
x86_64   randconfig-a002-20210209
x86_64   randconfig-a003-20210209
x86_64   randconfig-a003-20210212
x86_64   randconfig-a002-20210212
x86_64   randconfig-a004-20210212
x86_64   randconfig-a001-20210212
x86_64   randconfi

[tip:core/rcu] BUILD SUCCESS 2b392cb11c0db645ba81a08b6a2e96c56ec1fc64

2021-02-13 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git 
core/rcu
branch HEAD: 2b392cb11c0db645ba81a08b6a2e96c56ec1fc64  Merge branch 
'for-mingo-nolibc' of 
git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu into core/rcu

elapsed time: 723m

configs tested: 149
configs skipped: 2

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
arm shannon_defconfig
arm davinci_all_defconfig
arcvdk_hs38_defconfig
shsh7763rdp_defconfig
c6xevmc6474_defconfig
sh  rts7751r2d1_defconfig
m68kq40_defconfig
armlart_defconfig
armpleb_defconfig
arm   milbeaut_m10v_defconfig
h8300alldefconfig
openrisc alldefconfig
sh   se7712_defconfig
h8300   defconfig
shhp6xx_defconfig
arm  simpad_defconfig
powerpc mpc8315_rdb_defconfig
arm   netwinder_defconfig
armmagician_defconfig
arc  alldefconfig
mipsnlm_xlp_defconfig
arm  pxa3xx_defconfig
sh   se7206_defconfig
sh ap325rxa_defconfig
powerpc   eiger_defconfig
xtensa  cadence_csp_defconfig
powerpc linkstation_defconfig
mips   jazz_defconfig
powerpc mpc832x_mds_defconfig
mips   capcella_defconfig
arm cm_x300_defconfig
xtensa virt_defconfig
mips tb0219_defconfig
c6xevmc6678_defconfig
powerpc  walnut_defconfig
arcnsim_700_defconfig
powerpc   bluestone_defconfig
sh  rsk7203_defconfig
powerpcgamecube_defconfig
mips  ath79_defconfig
powerpc64alldefconfig
nds32   defconfig
powerpc mpc5200_defconfig
armclps711x_defconfig
powerpc  pmac32_defconfig
openrisc simple_smp_defconfig
powerpcicon_defconfig
arm rpc_defconfig
arm lpc32xx_defconfig
arm  badge4_defconfig
mips  maltaaprp_defconfig
pariscgeneric-32bit_defconfig
parisc  defconfig
openriscdefconfig
powerpc  ppc6xx_defconfig
powerpc mpc83xx_defconfig
ia64 allmodconfig
ia64defconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nios2   defconfig
arc  allyesconfig
nds32 allnoconfig
c6x  allyesconfig
nios2allyesconfig
cskydefconfig
alpha   defconfig
alphaallyesconfig
xtensa   allyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
s390 allyesconfig
s390 allmodconfig
parisc   allyesconfig
s390defconfig
i386 allyesconfig
sparcallyesconfig
sparc   defconfig
i386   tinyconfig
i386defconfig
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc  allmodconfig
powerpc   allnoconfig
x86_64   randconfig-a003-20210212
x86_64   randconfig-a002-20210212
x86_64   randconfig-a004-20210212
x86_64   randconfig-a001-20210212
x86_64   randconfig-a005-20210212
x86_64   randconfig-a006-20210212
i386  

[tip:auto-latest] BUILD SUCCESS f1b61f7b4fb971f281978fb905507e9ac9b2d973

2021-02-13 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git 
auto-latest
branch HEAD: f1b61f7b4fb971f281978fb905507e9ac9b2d973  Merge branch 'core/mm'

elapsed time: 724m

configs tested: 131
configs skipped: 2

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
sh  rts7751r2d1_defconfig
m68kq40_defconfig
armlart_defconfig
armpleb_defconfig
arm   milbeaut_m10v_defconfig
h8300alldefconfig
openrisc alldefconfig
sh   se7712_defconfig
h8300   defconfig
shhp6xx_defconfig
arm  simpad_defconfig
powerpc mpc8315_rdb_defconfig
powerpc akebono_defconfig
arm   mainstone_defconfig
sh ap325rxa_defconfig
powerpc mpc8313_rdb_defconfig
powerpc ksi8560_defconfig
powerpc64   defconfig
arc  alldefconfig
microblaze  mmu_defconfig
powerpc mpc834x_mds_defconfig
mipsnlm_xlp_defconfig
powerpc   bluestone_defconfig
sh  rsk7203_defconfig
powerpcgamecube_defconfig
mips  ath79_defconfig
powerpc64alldefconfig
powerpc mpc5200_defconfig
openrisc  or1klitex_defconfig
arm   cns3420vb_defconfig
arm   h5000_defconfig
armclps711x_defconfig
arcnsim_700_defconfig
powerpc  pmac32_defconfig
openrisc simple_smp_defconfig
powerpcicon_defconfig
mips   jazz_defconfig
arm rpc_defconfig
arm lpc32xx_defconfig
arm  badge4_defconfig
mips  maltaaprp_defconfig
xtensa virt_defconfig
mips bigsur_defconfig
sparc   defconfig
armmagician_defconfig
mipse55_defconfig
powerpc ps3_defconfig
arm   imx_v4_v5_defconfig
m68k  atari_defconfig
riscv  rv32_defconfig
ia64 allmodconfig
ia64defconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nios2   defconfig
arc  allyesconfig
nds32 allnoconfig
c6x  allyesconfig
nds32   defconfig
nios2allyesconfig
cskydefconfig
alpha   defconfig
alphaallyesconfig
xtensa   allyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
parisc  defconfig
s390 allyesconfig
s390 allmodconfig
parisc   allyesconfig
s390defconfig
i386 allyesconfig
sparcallyesconfig
i386   tinyconfig
i386defconfig
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc  allmodconfig
powerpc   allnoconfig
i386 randconfig-a001-20210209
i386 randconfig-a005-20210209
i386 randconfig-a003-20210209
i386 randconfig-a002-20210209
i386 randconfig-a006-20210209
i386 randconfig-a004-20210209
x86_64   randconfig-a003-20210210
x86_64   randconfig-a002-20210210
x86_64   randconfig-a001-20210210
x86_64   randconfig-a004-20210210
x86_64   randconfig-a005-20210210
x86_64   randconfig-a006-20210210
i386 randconfig-a016-20210209
i38

Re: [GIT PULL tip/core/rcu] RCU, LKMM, and KCSAN commits for v5.12

2021-02-13 Thread Willy Tarreau
Hi Paul,

On Fri, Feb 12, 2021 at 07:07:05AM -0800, Paul E. McKenney wrote:
> Thank you, Ingo!  In the future, I will group nolibc with RCU.  But there
> has to be something other than RCU that needs it.  I will take a look. ;-)

All my kernels boot using a "preinit" that is built with nolibc and
integrated into the initramfs. Historically it used to just create /dev
entries and mount the rootfs, nowadays it's used to untar modules and
finish the boot so that I can have a clean separation between a kernel
image and a rootfs. It even allows to perform some minimal debugging as
it includes a minimalistic shell. Do you think something like this could
be of any use in your development sessions ? If so I can discuss this
with you in a separate thread so as not to annoy everyone. Just let me
know :-)

Cheers,
Willy


INFO: task hung in misc_open (4)

2021-02-13 Thread syzbot
Hello,

syzbot found the following issue on:

HEAD commit:e0756cfc Merge tag 'trace-v5.11-rc7' of git://git.kernel.o..
git tree:   upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=147e449cd0
kernel config:  https://syzkaller.appspot.com/x/.config?x=1106b4b91e8dfab8
dashboard link: https://syzkaller.appspot.com/bug?extid=358c9ab4c93da7b7238c
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=163e1dacd0
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13af25e4d0

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+358c9ab4c93da7b72...@syzkaller.appspotmail.com

INFO: task syz-executor487:8574 blocked for more than 143 seconds.
  Not tainted 5.11.0-rc7-syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz-executor487 state:D stack:28112 pid: 8574 ppid:  8479 flags:0x0004
Call Trace:
 context_switch kernel/sched/core.c:4327 [inline]
 __schedule+0x90c/0x21a0 kernel/sched/core.c:5078
 schedule+0xcf/0x270 kernel/sched/core.c:5157
 schedule_preempt_disabled+0xf/0x20 kernel/sched/core.c:5216
 __mutex_lock_common kernel/locking/mutex.c:1033 [inline]
 __mutex_lock+0x81a/0x1110 kernel/locking/mutex.c:1103
 misc_open+0x55/0x4a0 drivers/char/misc.c:107
 chrdev_open+0x266/0x770 fs/char_dev.c:414
 do_dentry_open+0x4b9/0x11b0 fs/open.c:817
 do_open fs/namei.c:3254 [inline]
 path_openat+0x1b9a/0x2730 fs/namei.c:3371
 do_filp_open+0x17e/0x3c0 fs/namei.c:3398
 do_sys_openat2+0x16d/0x420 fs/open.c:1172
 do_sys_open fs/open.c:1188 [inline]
 __do_sys_openat fs/open.c:1204 [inline]
 __se_sys_openat fs/open.c:1199 [inline]
 __x64_sys_openat+0x13f/0x1f0 fs/open.c:1199
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x4031a7
RSP: 002b:7ffd77c5adc0 EFLAGS: 0246 ORIG_RAX: 0101
RAX: ffda RBX: 2440 RCX: 004031a7
RDX: 0002 RSI: 0048803b RDI: ff9c
RBP: 0048803b R08:  R09: 
R10:  R11: 0246 R12: 0002
R13: 7ffd77c5ceec R14: 0076 R15: 7ffd77c5cef0
INFO: task syz-executor487:8631 blocked for more than 143 seconds.
  Not tainted 5.11.0-rc7-syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz-executor487 state:D stack:27912 pid: 8631 ppid:  8480 flags:0x0004
Call Trace:
 context_switch kernel/sched/core.c:4327 [inline]
 __schedule+0x90c/0x21a0 kernel/sched/core.c:5078
 schedule+0xcf/0x270 kernel/sched/core.c:5157
 schedule_preempt_disabled+0xf/0x20 kernel/sched/core.c:5216
 __mutex_lock_common kernel/locking/mutex.c:1033 [inline]
 __mutex_lock+0x81a/0x1110 kernel/locking/mutex.c:1103
 misc_open+0x55/0x4a0 drivers/char/misc.c:107
 chrdev_open+0x266/0x770 fs/char_dev.c:414
 do_dentry_open+0x4b9/0x11b0 fs/open.c:817
 do_open fs/namei.c:3254 [inline]
 path_openat+0x1b9a/0x2730 fs/namei.c:3371
 do_filp_open+0x17e/0x3c0 fs/namei.c:3398
 do_sys_openat2+0x16d/0x420 fs/open.c:1172
 do_sys_open fs/open.c:1188 [inline]
 __do_sys_openat fs/open.c:1204 [inline]
 __se_sys_openat fs/open.c:1199 [inline]
 __x64_sys_openat+0x13f/0x1f0 fs/open.c:1199
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x4031a7
RSP: 002b:7ffd77c5adc0 EFLAGS: 0246 ORIG_RAX: 0101
RAX: ffda RBX: 2440 RCX: 004031a7
RDX: 0002 RSI: 0048803b RDI: ff9c
RBP: 0048803b R08:  R09: 
R10:  R11: 0246 R12: 0002
R13: 7ffd77c5ceec R14: 0076 R15: 7ffd77c5cef0
INFO: task syz-executor487:8634 blocked for more than 143 seconds.
  Not tainted 5.11.0-rc7-syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz-executor487 state:D stack:28160 pid: 8634 ppid:  8475 flags:0x0004
Call Trace:
 context_switch kernel/sched/core.c:4327 [inline]
 __schedule+0x90c/0x21a0 kernel/sched/core.c:5078
 schedule+0xcf/0x270 kernel/sched/core.c:5157
 schedule_preempt_disabled+0xf/0x20 kernel/sched/core.c:5216
 __mutex_lock_common kernel/locking/mutex.c:1033 [inline]
 __mutex_lock+0x81a/0x1110 kernel/locking/mutex.c:1103
 misc_open+0x55/0x4a0 drivers/char/misc.c:107
 chrdev_open+0x266/0x770 fs/char_dev.c:414
 do_dentry_open+0x4b9/0x11b0 fs/open.c:817
 do_open fs/namei.c:3254 [inline]
 path_openat+0x1b9a/0x2730 fs/namei.c:3371
 do_filp_open+0x17e/0x3c0 fs/namei.c:3398
 do_sys_openat2+0x16d/0x420 fs/open.c:1172
 do_sys_open fs/open.c:1188 [inline]
 __do_sys_openat fs/open.c:1204 [inline]
 __se_sys_openat fs/open.c:1199 [inline]
 __x64_sys_openat+0x13f/0x1f0 fs/open.c:1199
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x4031a7
RSP: 002b:7ffd77c5adc0 EFLAG

Re: [RFC PATCH 1/7] drivers: base: Add resource managed version of delayed work init

2021-02-13 Thread gre...@linuxfoundation.org
On Sat, Feb 13, 2021 at 12:26:59PM +, Vaittinen, Matti wrote:
> 
> On Sat, 2021-02-13 at 13:16 +0100, Greg Kroah-Hartman wrote:
> > On Sat, Feb 13, 2021 at 01:58:44PM +0200, Matti Vaittinen wrote:
> > > A few drivers which need a delayed work-queue must cancel work at
> > > exit.
> > > Some of those implement remove solely for this purpose. Help
> > > drivers
> > > to avoid unnecessary remove and error-branch implementation by
> > > adding
> > > managed verision of delayed work initialization
> > > 
> > > Signed-off-by: Matti Vaittinen 
> > 
> > That's not a good idea.  As this would kick in when the device is
> > removed from the system, not when it is unbound from the driver,
> > right?
> > 
> > > ---
> > >  drivers/base/devres.c  | 33 +
> > >  include/linux/device.h |  5 +
> > >  2 files changed, 38 insertions(+)
> > > 
> > > diff --git a/drivers/base/devres.c b/drivers/base/devres.c
> > > index fb9d5289a620..2879595bb5a4 100644
> > > --- a/drivers/base/devres.c
> > > +++ b/drivers/base/devres.c
> > > @@ -1231,3 +1231,36 @@ void devm_free_percpu(struct device *dev,
> > > void __percpu *pdata)
> > >  (void *)pdata));
> > >  }
> > >  EXPORT_SYMBOL_GPL(devm_free_percpu);
> > > +
> > > +static void dev_delayed_work_drop(struct device *dev, void *res)
> > > +{
> > > + cancel_delayed_work_sync(*(struct delayed_work **)res);
> > > +}
> > > +
> > > +/**
> > > + * devm_delayed_work_autocancel - Resource-managed work allocation
> > > + * @dev: Device which lifetime work is bound to
> > > + * @pdata: work to be cancelled when device exits
> > > + *
> > > + * Initialize work which is automatically cancelled when device
> > > exits.
> > 
> > There is no such thing in the driver model as "when device exits".
> > Please use the proper terminology as I do not understand what you
> > think
> > this is doing here...
> > 
> > > + * A few drivers need delayed work which must be cancelled before
> > > driver
> > > + * is unload to avoid accessing removed resources.
> > > + * devm_delayed_work_autocancel() can be used to omit the explicit
> > > + * cancelleation when driver is unload.
> > > + */
> > > +int devm_delayed_work_autocancel(struct device *dev, struct
> > > delayed_work *w,
> > > +  void (*worker)(struct work_struct
> > > *work))
> > > +{
> > > + struct delayed_work **ptr;
> > > +
> > > + ptr = devres_alloc(dev_delayed_work_drop, sizeof(*ptr),
> > > GFP_KERNEL);
> > > + if (!ptr)
> > > + return -ENOMEM;
> > > +
> > > + INIT_DELAYED_WORK(w, worker);
> > > + *ptr = w;
> > > + devres_add(dev, ptr);
> > > +
> > > + return 0;
> > > +}
> > > +EXPORT_SYMBOL_GPL(devm_delayed_work_autocancel);
> > > diff --git a/include/linux/device.h b/include/linux/device.h
> > > index 1779f90eeb4c..192456198de7 100644
> > > --- a/include/linux/device.h
> > > +++ b/include/linux/device.h
> > > @@ -27,6 +27,7 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > @@ -249,6 +250,10 @@ void __iomem *devm_of_iomap(struct device
> > > *dev,
> > >   struct device_node *node, int index,
> > >   resource_size_t *size);
> > >  
> > > +/* delayed work which is cancelled when driver exits */
> > 
> > Not when the "driver exits".
> > 
> > There is two different lifespans here (well 3).  Code and
> > data*2.  Don't
> > confuse them as that will just cause lots of problems.
> > 
> > The move toward more and more "devm" functions is not the way to go
> > as
> > they just more and more make things easier to get wrong.
> > 
> > APIs should be impossible to get wrong, this one is going to be
> > almost
> > impossible to get right.
> 
> Thanks for prompt reply. I guess I must've misunderstood some of this
> concept. Frankly to say, I don't understand how the devm based irq
> management works and this does not. Maybe I'd better study this further
> then.

The devm based irq management works horribly and should not be used at
all.  That is the main offender in the "an api that is impossible to use
correctly" category.

Honestly, I think it should just be removed as there is almost no real
need for it that I can determine, other than to cause bugs.

thanks,

greg k-h


Re: [PATCH v1] clang_tools:gen_compile_commands: Change the default source directory

2021-02-13 Thread Masahiro Yamada
On Fri, Feb 12, 2021 at 8:20 PM Stephen Zhang  wrote:
>
> Masahiro Yamada  于2021年2月11日周四 下午10:16写道:
> > Please stop.
> >
> >
> > Commit 6ca4c6d25949117dc5b4845612e290b6d89e70a8
> > removed the tools/ support.
> >
> >
> > There exist two build systems in the Linux source tree.
> > Kbuild covers the entire tree except tools/.
> > The tools/ directory adopts a different build system.
> >
> > It is a pity that the tools/ directory
> > went in a wrong direction, and people
> > try to fix problems in a wrong layer.
> >
> >
> > You are not the first person to send to
> > tweak obj/source trees of this script.
> >
> > You can not do this correctly
> > without terribly messing up the code.
> >
> > Please do not try to support tools/.
> >
> >
> >
> > --
> > Best Regards
> > Masahiro Yamada
>
> Thanks for the suggestion.But what we try to support is scripts/
> instead of tools/. 'tools/' here is to help explaining the problem.
> Or am I just misunderstanding your words?



You took 'tools/perf' as an example,
so I just thought you were trying to fix the tools/.



I can get scripts/ entries without any problem.

If you do O= build, you can pass that directory
to the -d option of gen_compile_commands.py

  -d DIRECTORY, --directory DIRECTORY
specify the output directory used for the
kernel build (defaults to the working
directory)


This is the steps I tested.


masahiro@oscar:~/ref/linux$ make O=build  defconfig all -j24
  [ snip ]
masahiro@oscar:~/ref/linux$
./scripts/clang-tools/gen_compile_commands.py  -d build
masahiro@oscar:~/ref/linux$ grep '"file":' compile_commands.json |
grep scripts/ | head -n5
"file": "/home/masahiro/ref/linux/scripts/mod/empty.c"
"file": "/home/masahiro/ref/linux/scripts/mod/sumversion.c"
"file": "/home/masahiro/ref/linux/scripts/mod/file2alias.c"
"file": "/home/masahiro/ref/linux/scripts/mod/modpost.c"
"file": "/home/masahiro/ref/linux/build/scripts/kconfig/parser.tab.c"








-- 
Best Regards
Masahiro Yamada


[RFC][PATCH] sched: Fix affine_move_task()

2021-02-13 Thread Peter Zijlstra


When affine_move_task(p) is called on a running task @p, which is not
otherwise already changing affinity, we'll first set
p->migration_pending and then do:

 stop_one_cpu(cpu_of_rq(rq), migration_cpu_stop, &arg);

This then gets us to migration_cpu_stop() running on the CPU that was
previously running our victim task @p.

If we find that our task is no longer on that runqueue (this can
happen because of a concurrent migration due to load-balance etc.),
then we'll end up at the:

} else if (dest_cpu < 1 || pending) {

branch. Which we'll take because we set pending earlier. Here we first
check if the task @p has already satisfied the affinity constraints,
if so we bail early [A]. Otherwise we'll reissue migration_cpu_stop()
onto the CPU that is now hosting our task @p:

stop_one_cpu_nowait(cpu_of(rq), migration_cpu_stop,
&pending->arg, &pending->stop_work);

Except, we've never initialized pending->arg, which will be all 0s.

This then results in running migration_cpu_stop() on the next CPU with
arg->p == NULL, which gives the by now obvious result of fireworks.

The cure is to change affine_move_task() to always use pending->arg,
furthermore we can use the exact same pattern as the
SCA_MIGRATE_ENABLE case, since we'll block on the pending->done
completion anyway, no point in adding yet another completion in
stop_one_cpu().

This then gives a clear distinction between the two
migration_cpu_stop() use cases:

  - sched_exec() / migrate_task_to() : arg->pending == NULL
  - affine_move_task() : arg->pending != NULL;

And we can have it ignore p->migration_pending when !arg->pending. Any
stop work from sched_exec() / migrate_task_to() is in addition to stop
works from affine_move_task(), which will be sufficient to issue the
completion.


NOTES:

 - I've not been able to reproduce this crash on any of my machines
   without first removing the early termination condition [A] above.
   Doing this is a functional NOP but obviously widens up the window.

 - With the check [A] removed I can consistently hit the NULL deref
   and the below patch reliably cures it.

 - The original reporter says that this patch cures the NULL deref
   but results in another problem, which I've not yet been able to
   make sense of and obviously have failed at reproduction as well :/

Fixes: 6d337eab041d ("sched: Fix migrate_disable() vs set_cpus_allowed_ptr()")
Signed-off-by: Peter Zijlstra (Intel) 
---
 kernel/sched/core.c |   39 ---
 1 file changed, 28 insertions(+), 11 deletions(-)

--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1924,6 +1924,24 @@ static int migration_cpu_stop(void *data
rq_lock(rq, &rf);
 
pending = p->migration_pending;
+   if (pending && !arg->pending) {
+   /*
+* This happens from sched_exec() and migrate_task_to(),
+* neither of them care about pending and just want a task to
+* maybe move about.
+*
+* Even if there is a pending, we can ignore it, since
+* affine_move_task() will have it's own stop_work's in flight
+* which will manage the completion.
+*
+* Notably, pending doesn't need to match arg->pending. This can
+* happen when tripple concurrent affine_move_task() first sets
+* pending, then clears pending and eventually sets another
+* pending.
+*/
+   pending = NULL;
+   }
+
/*
 * If task_rq(p) != rq, it cannot be migrated here, because we're
 * holding rq->lock, if p->on_rq == 0 it cannot get enqueued because
@@ -2196,10 +2214,6 @@ static int affine_move_task(struct rq *r
int dest_cpu, unsigned int flags)
 {
struct set_affinity_pending my_pending = { }, *pending = NULL;
-   struct migration_arg arg = {
-   .task = p,
-   .dest_cpu = dest_cpu,
-   };
bool complete = false;
 
/* Can the task run on the task's current CPU? If so, we're done */
@@ -2237,6 +2251,12 @@ static int affine_move_task(struct rq *r
/* Install the request */
refcount_set(&my_pending.refs, 1);
init_completion(&my_pending.done);
+   my_pending.arg = (struct migration_arg) {
+   .task = p,
+   .dest_cpu = -1,
+   .pending = &my_pending,
+   };
+
p->migration_pending = &my_pending;
} else {
pending = p->migration_pending;
@@ -2267,12 +2287,6 @@ static int affine_move_task(struct rq *r
p->migration_flags &= ~MDF_PUSH;
task_rq_unlock(rq, p, rf);
 
-   pending->arg = (struct migration

Re: [PATCH v5 1/2] pinctrl: use to octal permissions for debugfs files

2021-02-13 Thread Andy Shevchenko
On Sat, Feb 13, 2021 at 12:30 AM Drew Fustini  wrote:
>
> Switch over pinctrl debugfs files to use octal permissions as they are
> preferred over symbolic permissions. Refer to commit f90774e1fd27
> ("checkpatch: look for symbolic permissions and suggest octal instead").
>
> Note: S_IFREG flag is added to the mode by __debugfs_create_file()
> in fs/debugfs/inode.c

I guess it also needs Suggested-by: Joe (IIRC he proposed to convert the rest).
Nevertheless,
Reviewed-by: Andy Shevchenko 
Thanks!


> Suggested-by: Andy Shevchenko 
> Signed-off-by: Drew Fustini 
> ---
>  drivers/pinctrl/core.c| 12 ++--
>  drivers/pinctrl/pinconf.c |  4 ++--
>  drivers/pinctrl/pinmux.c  |  4 ++--
>  3 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
> index 3663d87f51a0..07458742bc0f 100644
> --- a/drivers/pinctrl/core.c
> +++ b/drivers/pinctrl/core.c
> @@ -1888,11 +1888,11 @@ static void pinctrl_init_device_debugfs(struct 
> pinctrl_dev *pctldev)
> dev_name(pctldev->dev));
> return;
> }
> -   debugfs_create_file("pins", S_IFREG | S_IRUGO,
> +   debugfs_create_file("pins", 0444,
> device_root, pctldev, &pinctrl_pins_fops);
> -   debugfs_create_file("pingroups", S_IFREG | S_IRUGO,
> +   debugfs_create_file("pingroups", 0444,
> device_root, pctldev, &pinctrl_groups_fops);
> -   debugfs_create_file("gpio-ranges", S_IFREG | S_IRUGO,
> +   debugfs_create_file("gpio-ranges", 0444,
> device_root, pctldev, &pinctrl_gpioranges_fops);
> if (pctldev->desc->pmxops)
> pinmux_init_device_debugfs(device_root, pctldev);
> @@ -1914,11 +1914,11 @@ static void pinctrl_init_debugfs(void)
> return;
> }
>
> -   debugfs_create_file("pinctrl-devices", S_IFREG | S_IRUGO,
> +   debugfs_create_file("pinctrl-devices", 0444,
> debugfs_root, NULL, &pinctrl_devices_fops);
> -   debugfs_create_file("pinctrl-maps", S_IFREG | S_IRUGO,
> +   debugfs_create_file("pinctrl-maps", 0444,
> debugfs_root, NULL, &pinctrl_maps_fops);
> -   debugfs_create_file("pinctrl-handles", S_IFREG | S_IRUGO,
> +   debugfs_create_file("pinctrl-handles", 0444,
> debugfs_root, NULL, &pinctrl_fops);
>  }
>
> diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
> index 02c075cc010b..d9d54065472e 100644
> --- a/drivers/pinctrl/pinconf.c
> +++ b/drivers/pinctrl/pinconf.c
> @@ -370,9 +370,9 @@ DEFINE_SHOW_ATTRIBUTE(pinconf_groups);
>  void pinconf_init_device_debugfs(struct dentry *devroot,
>  struct pinctrl_dev *pctldev)
>  {
> -   debugfs_create_file("pinconf-pins", S_IFREG | S_IRUGO,
> +   debugfs_create_file("pinconf-pins", 0444,
> devroot, pctldev, &pinconf_pins_fops);
> -   debugfs_create_file("pinconf-groups", S_IFREG | S_IRUGO,
> +   debugfs_create_file("pinconf-groups", 0444,
> devroot, pctldev, &pinconf_groups_fops);
>  }
>
> diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
> index bab888fe3f8e..c651b2db0925 100644
> --- a/drivers/pinctrl/pinmux.c
> +++ b/drivers/pinctrl/pinmux.c
> @@ -676,9 +676,9 @@ DEFINE_SHOW_ATTRIBUTE(pinmux_pins);
>  void pinmux_init_device_debugfs(struct dentry *devroot,
>  struct pinctrl_dev *pctldev)
>  {
> -   debugfs_create_file("pinmux-functions", S_IFREG | S_IRUGO,
> +   debugfs_create_file("pinmux-functions", 0444,
> devroot, pctldev, &pinmux_functions_fops);
> -   debugfs_create_file("pinmux-pins", S_IFREG | S_IRUGO,
> +   debugfs_create_file("pinmux-pins", 0444,
> devroot, pctldev, &pinmux_pins_fops);
>  }
>
> --
> 2.25.1
>


-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 5.10 00/54] 5.10.16-rc1 review

2021-02-13 Thread Greg Kroah-Hartman
On Fri, Feb 12, 2021 at 08:54:01PM +0100, Pavel Machek wrote:
> Hi!
> 
> > This is the start of the stable review cycle for the 5.10.16 release.
> > There are 54 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> 
> CIP testing did not find any problems here:
> 
> https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-5.10.y
> 
> Tested-by: Pavel Machek (CIP) 

Thanks for testing some and letting me know.

greg k-h


Re: [PATCH 5.10 00/54] 5.10.16-rc1 review

2021-02-13 Thread Greg Kroah-Hartman
On Fri, Feb 12, 2021 at 11:21:26AM -0800, Florian Fainelli wrote:
> 
> 
> On 2/11/2021 7:01 AM, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 5.10.16 release.
> > There are 54 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> > 
> > Responses should be made by Sat, 13 Feb 2021 15:01:39 +.
> > Anything received after that time might be too late.
> > 
> > The whole patch series can be found in one patch at:
> > 
> > https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.16-rc1.gz
> > or in the git tree and branch at:
> > 
> > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> > linux-5.10.y
> > and the diffstat can be found below.
> > 
> > thanks,
> > 
> > greg k-h
> 
> Tested-by: Florian Fainelli 
> 
> On ARCH_BRCMSTB, 32-bit and 64-bit ARM, thanks!

Thanks for testing.

greg k-h


Re: [PATCH 5.10 00/54] 5.10.16-rc1 review

2021-02-13 Thread Greg Kroah-Hartman
On Fri, Feb 12, 2021 at 10:08:25AM -0800, Guenter Roeck wrote:
> On Thu, Feb 11, 2021 at 04:01:44PM +0100, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 5.10.16 release.
> > There are 54 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> > 
> > Responses should be made by Sat, 13 Feb 2021 15:01:39 +.
> > Anything received after that time might be too late.
> > 
> 
> Build results:
>   total: 154 pass: 154 fail: 0
> Qemu test results:
>   total: 427 pass: 427 fail: 0
> 
> Tested-by: Guenter Roeck 

Great, thanks for testing.

greg k-h


Re: [PATCH 5.10 00/54] 5.10.16-rc1 review

2021-02-13 Thread Greg Kroah-Hartman
On Fri, Feb 12, 2021 at 09:17:13AM -0700, Shuah Khan wrote:
> On 2/11/21 8:01 AM, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 5.10.16 release.
> > There are 54 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> > 
> > Responses should be made by Sat, 13 Feb 2021 15:01:39 +.
> > Anything received after that time might be too late.
> > 
> > The whole patch series can be found in one patch at:
> > 
> > https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.16-rc1.gz
> > or in the git tree and branch at:
> > 
> > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> > linux-5.10.y
> > and the diffstat can be found below.
> > 
> > thanks,
> > 
> > greg k-h
> > 
> 
> Compiled and booted on my test system. No dmesg regressions.
> 
> Tested-by: Shuah Khan 
> 
> Note: gdm doesn't start and no response to keyboard and mouse.
> 
> I can ssh in and use the system. I am going debug and update you.
> 5.4.98-rc1 and 4.9.176-rc1 are fine and no such issues.

Did you ever track this down?

thanks,

greg k-h


Re: [PATCH 5.10 00/54] 5.10.16-rc1 review

2021-02-13 Thread Greg Kroah-Hartman
On Fri, Feb 12, 2021 at 09:20:05PM -0600, Ross Schmidt wrote:
> On Thu, Feb 11, 2021 at 04:01:44PM +0100, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 5.10.16 release.
> > There are 54 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> >
> 
> Compiled and booted with no regressions on x86_64.
> 
> Tested-by: Ross Schmidt 
> 

Thanks for testing them all and letting me know.

greg k-h


Re: [PATCH 5.10 00/54] 5.10.16-rc1 review

2021-02-13 Thread Greg Kroah-Hartman
On Fri, Feb 12, 2021 at 08:46:36AM +0530, Naresh Kamboju wrote:
> On Thu, 11 Feb 2021 at 20:35, Greg Kroah-Hartman
>  wrote:
> >
> > This is the start of the stable review cycle for the 5.10.16 release.
> > There are 54 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> >
> > Responses should be made by Sat, 13 Feb 2021 15:01:39 +.
> > Anything received after that time might be too late.
> >
> > The whole patch series can be found in one patch at:
> > 
> > https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.16-rc1.gz
> > or in the git tree and branch at:
> > 
> > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> > linux-5.10.y
> > and the diffstat can be found below.
> >
> > thanks,
> >
> > greg k-h
> 
> Results from Linaro’s test farm.
> No regressions on arm64, arm, x86_64, and i386.
> 
> Tested-by: Linux Kernel Functional Testing 

Thanks for testing them all and letting me know.

greg k-h


Re: [tip: objtool/urgent] objtool: Fix seg fault with Clang non-section symbols

2021-02-13 Thread Greg Kroah-Hartman
On Thu, Feb 11, 2021 at 09:32:03PM +0800, Xi Ruoyao wrote:
> Hi all,
> 
> The latest GNU assembler (binutils-2.36.1) is removing unused section symbols
> like Clang [1].  So linux-5.10.15 can't be built with binutils-2.36.1 now.  It
> has been reported as https://bugzilla.kernel.org/show_bug.cgi?id=211693.
> 
> I can confirm this commit fixes the issue.  It should be cherry-picked into
> stable branches, so the following stable releases will be able to built with
> latest GNU toolchain.
> 
> [1]: https://sourceware.org/pipermail/binutils/2020-December/114671.html
> 
> At last, happy new lunar year guys :).
> 
> On 2020-12-16 13:49 +, tip-bot2 for Josh Poimboeuf wrote:
> > The following commit has been merged into the objtool/urgent branch of tip:
> > 
> > Commit-ID: 44f6a7c0755d8dd453c70557e11687bb080a6f21

Now queued up for 5.10.y.

If people want it in older kernels, please provide a working backport.

thanks,

greg k-h


[GIT PULL] idmapped mounts for v5.12

2021-02-13 Thread Christian Brauner
Hi Linus,

/* Summary */
This patch series introduces idmapped mounts which has been in the making for
some time. Simply put, different mounts can expose the same file or directory
with different ownership. This initial implementation comes with ports for fat,
ext4 and with Christoph's port for xfs with more filesystems being actively
worked on by independent people and maintainers.

Idmapping mounts handle a wide range of long standing use-cases.
Here are just a few:
- Idmapped mounts make it possible to easily share files between multiple users
  or multiple machines especially in complex scenarios. For example, idmapped
  mounts will be used in the implementation of portable home directories in
  systemd-homed.service(8) where they allow users to move their home directory
  to an external storage device and use it on multiple computers where they are
  assigned different uids and gids. This effectively makes it possible to
  assign random uids and gids at login time.
- It is possible to share files from the host with unprivileged containers
  without having to change ownership permanently through chown(2).
- It is possible to idmap a container's rootfs and without having to mangle
  every file. For example, Chromebooks use it to share the user's Download
  folder with their unprivileged containers in their Linux subsystem.
- It is possible to share files between containers with non-overlapping
  idmappings.
- Filesystem that lack a proper concept of ownership such as fat can use
  idmapped mounts to implement discretionary access (DAC) permission checking.
- They allow users to efficiently changing ownership on a per-mount basis
  without having to (recursively) chown(2) all files. In contrast to chown
  (2) changing ownership of large sets of files is instantenous with idmapped
  mounts. This is especially useful when ownership of a whole root filesystem
  of a virtual machine or container is changed. With idmapped mounts a single
  syscall mount_setattr syscall will be sufficient to change the ownership of
  all files.
- Idmapped mounts always take the current ownership into account as idmappings
  specify what a given uid or gid is supposed to be mapped to. This contrasts
  with the chown(2) syscall which cannot by itself take the current ownership
  of the files it changes into account. It simply changes the ownership to the
  specified uid and gid. This is especially problematic when recursively
  chown(2)ing a large set of files which is commong with the aforementioned
  portable home directory and container and vm scenario.
- Idmapped mounts allow to change ownership locally, restricting it to
  specific mounts, and temporarily as the ownership changes only apply as long
  as the mount exists.

Several userspace projects have either already put up patches and pull-requests
for this feature or will do so should you decide to pull this:
- systemd: In a wide variety of scenarios but especially right away in their
  implementation of portable home directories.
  https://systemd.io/HOME_DIRECTORY/
- container runtimes: containerd, runC, LXD:To share data between host and
  unprivileged containers, unprivileged and privileged containers, etc.
  The pull request for idmapped mounts support in containerd, the default
  Kubernetes runtime is already up for quite a while now:
  https://github.com/containerd/containerd/pull/4734
- The virtio-fs developers and several users have expressed interest in using
  this feature with virtual machines once virtio-fs is ported.
- ChromeOS: Sharing host-directories with unprivileged containers.
I've tightly synced with all those projects and all of those listed here have
also expressed their need/desire for this feature on the mailing list.
For more info on how people use this there's a bunch of talks about this too.
Here's just two recent ones:
https://www.cncf.io/wp-content/uploads/2020/12/Rootless-Containers-in-Gitpod.pdf
https://fosdem.org/2021/schedule/event/containers_idmap/

This series comes with an extensive xfstests suite covering both ext4 and xfs
https://git.kernel.org/brauner/xfstests-dev/h/idmapped_mounts
It covers truncation, creation, opening, xattrs, vfscaps, setid execution,
setgid inheritance and more both with idmapped and non-idmapped mounts.
It already helped to discover an unrelated xfs setgid inheritance bug which has
since been fixed in mainline. It will be sent for inclusion with the xfstests
project should you decide to merge this. 

In order to support per-mount idmappings vfsmounts are marked with user
namespaces. The idmapping of the user namespace will be used to map the
ids of vfs objects when they are accessed through that mount. By default
all vfsmounts are marked with the initial user namespace. The initial
user namespace is used to indicate that a mount is not idmapped. All
operations behave as before and this is verified in the testsuite.

Based on prior discussions we want to attach the whole user namespace
and not just a dedicated

[GIT PULL] Btrfs fix for 5.11-rc8

2021-02-13 Thread David Sterba
Hi,

a regression fix caused by a refactoring in 5.11. A corrupted superblock
wouldn't be detected by checksum verification due to wrongly placed
initialization of the checksum length, thus making memcmp always work.

I've verified it manually and ran other test suites before sending this.
Please pull, thanks.


The following changes since commit 9ad6d91f056b99dbe59a262810cb342519ea8d39:

  btrfs: fix log replay failure due to race with space cache rebuild 
(2021-01-25 18:44:53 +0100)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-5.11-rc7-tag

for you to fetch changes up to 83c68bbcb6ac2dbbcaf12e2281a29a9f73b97d0f:

  btrfs: initialize fs_info::csum_size earlier in open_ctree (2021-02-12 
14:48:24 +0100)


Su Yue (1):
  btrfs: initialize fs_info::csum_size earlier in open_ctree

 fs/btrfs/disk-io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


[PATCH RFC v3 1/3] checkpatch: add verbose mode

2021-02-13 Thread Dwaipayan Ray
Add a new verbose mode to checkpatch.pl to emit additional verbose
test descriptions. The verbose mode is optional and can be enabled
by the flag -v or --verbose.

The test descriptions are parsed from the checkpatch documentation
file at `Documentation/dev-tools/checkpatch.rst`. The test
descriptions in the docs are kept in a fixed format using rst field
lists, an example of which is as follows:

:LINE_SPACING:
  Vertical space is wasted given the limited number of lines an
  editor window can display when multiple blank lines are used.

:MISSING_SIGN_OFF:
  The patch is missing a Signed-off-by line.  A signed-off-by
  line should be added according to Developer's certificate of
  Origin.
  ref: `Documentation/process/submitting-patches.rst`

The verbose descriptions are not shown when the --terse option
is enabled.

Signed-off-by: Dwaipayan Ray 
---
 scripts/checkpatch.pl | 55 ++-
 1 file changed, 54 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 9a549b009d2f..062545e68405 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -23,6 +23,8 @@ my $V = '0.32';
 use Getopt::Long qw(:config no_auto_abbrev);
 
 my $quiet = 0;
+my $verbose = 0;
+my %verbose_messages = ();
 my $tree = 1;
 my $chk_signoff = 1;
 my $chk_patch = 1;
@@ -61,6 +63,7 @@ my $spelling_file = "$D/spelling.txt";
 my $codespell = 0;
 my $codespellfile = "/usr/share/codespell/dictionary.txt";
 my $conststructsfile = "$D/const_structs.checkpatch";
+my $docsfile = "$D/../Documentation/dev-tools/checkpatch.rst";
 my $typedefsfile;
 my $color = "auto";
 my $allow_c99_comments = 1; # Can be overridden by --ignore 
C99_COMMENT_TOLERANCE
@@ -78,6 +81,7 @@ Version: $V
 
 Options:
   -q, --quietquiet
+  -v, --verbose  verbose mode
   --no-tree  run without a kernel tree
   --no-signoff   do not check for 'Signed-off-by' line
   --patchtreat FILE as patchfile (default)
@@ -198,6 +202,46 @@ if (-f $conf) {
unshift(@ARGV, @conf_args) if @conf_args;
 }
 
+sub load_docs {
+   open(my $docs, '<', "$docsfile")
+   or warn "$P: Can't read the documentation file $docsfile $!\n";
+
+   my $type = '';
+   my $desc = '';
+   my $in_desc = 0;
+
+   while (<$docs>) {
+   chomp;
+   my $line = $_;
+   $line =~ s/\s+$//;
+
+   if ($line =~ /^\:(.+)\:$/) {
+   if ($desc ne '') {
+   $verbose_messages{$type} = trim($desc);
+   }
+   $type = $1;
+   $desc = '';
+   $in_desc = 1;
+   } elsif ($in_desc) {
+   if ($line =~ /^(?:\s{2,}|$)/) {
+   $line =~ s/^\s{2}//;
+   $desc .= $line;
+   $desc .= "\n";
+   } else {
+   $verbose_messages{$type} = trim($desc);
+   $type = '';
+   $desc = '';
+   $in_desc = 0;
+   }
+   }
+   }
+
+   if ($desc ne '') {
+   $verbose_messages{$type} = trim($desc);
+   }
+   close($docs);
+}
+
 # Perl's Getopt::Long allows options to take optional arguments after a space.
 # Prevent --color by itself from consuming other arguments
 foreach (@ARGV) {
@@ -208,6 +252,7 @@ foreach (@ARGV) {
 
 GetOptions(
'q|quiet+'  => \$quiet,
+   'v|verbose!'=> \$verbose,
'tree!' => \$tree,
'signoff!'  => \$chk_signoff,
'patch!'=> \$chk_patch,
@@ -249,6 +294,8 @@ help(0) if ($help);
 
 list_types(0) if ($list_types);
 
+load_docs() if ($verbose && !$terse);
+
 $fix = 1 if ($fix_inplace);
 $check_orig = $check;
 
@@ -2209,7 +2256,13 @@ sub report {
splice(@lines, 1, 1);
$output = join("\n", @lines);
}
-   $output = (split('\n', $output))[0] . "\n" if ($terse);
+
+   if ($terse) {
+   $output = (split('\n', $output))[0] . "\n";
+   } elsif ($verbose &&
+exists $verbose_messages{$type}) {
+   $output .= $verbose_messages{$type} . "\n\n";
+   }
 
push(our @report, $output);
 
-- 
2.30.0



[PATCH RFC v3 0/3] checkpatch: add verbose mode

2021-02-13 Thread Dwaipayan Ray
Add a new verbose mode to checkpatch. The verbose test 
descriptions are read from the checkpatch documentation
file at `Documentation/dev-tools/checkpatch.rst`.

The verbose mode is optional and can be enabled by the
flag -v or --verbose.

The documentation file is only parsed by checkpatch.pl
if the verbose mode is enabled. The verbose mode is also
suppressed when the --terse option is specified.

Changes in v3:
- Simplify documentation file parsing in checkpatch
- Document a total of 33 message types for checkpatch

Changes in v2:
- Use .rst Field Lists to specify the type descriptions.
- Add a few more type descriptions to documentation.


Dwaipayan Ray (3):
  checkpatch: add verbose mode
  docs: add documentation for checkpatch
  docs: add documentation for checkpatch

 Documentation/dev-tools/checkpatch.rst | 494 +
 Documentation/dev-tools/index.rst  |   1 +
 scripts/checkpatch.pl  |  55 ++-
 3 files changed, 549 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/dev-tools/checkpatch.rst

-- 
2.30.0



[PATCH] staging:wlan-ng: use memdup_user instead of kmalloc/copy_from_user

2021-02-13 Thread Ivan Safonov
memdup_user() is shorter and safer equivalent
of kmalloc/copy_from_user pair.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/wlan-ng/p80211netdev.c | 28 --
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/wlan-ng/p80211netdev.c 
b/drivers/staging/wlan-ng/p80211netdev.c
index a15abb2c8f54..6f9666dc0277 100644
--- a/drivers/staging/wlan-ng/p80211netdev.c
+++ b/drivers/staging/wlan-ng/p80211netdev.c
@@ -569,24 +569,22 @@ static int p80211knetdev_do_ioctl(struct net_device *dev,
goto bail;
}
 
-   /* Allocate a buf of size req->len */
-   msgbuf = kmalloc(req->len, GFP_KERNEL);
-   if (msgbuf) {
-   if (copy_from_user(msgbuf, (void __user *)req->data, req->len))
-   result = -EFAULT;
-   else
-   result = p80211req_dorequest(wlandev, msgbuf);
+   msgbuf = memdup_user(req->data, req->len);
+   if (IS_ERR(msgbuf)) {
+   result = PTR_ERR(msgbuf);
+   goto bail;
+   }
 
-   if (result == 0) {
-   if (copy_to_user
-   ((void __user *)req->data, msgbuf, req->len)) {
-   result = -EFAULT;
-   }
+   result = p80211req_dorequest(wlandev, msgbuf);
+
+   if (result == 0) {
+   if (copy_to_user
+   ((void __user *)req->data, msgbuf, req->len)) {
+   result = -EFAULT;
}
-   kfree(msgbuf);
-   } else {
-   result = -ENOMEM;
}
+   kfree(msgbuf);
+
 bail:
/* If allocate,copyfrom or copyto fails, return errno */
return result;
-- 
2.26.2



[PATCH RFC v3 2/3] docs: add documentation for checkpatch

2021-02-13 Thread Dwaipayan Ray
Add documentation for kernel script checkpatch.pl.
This documentation is also parsed by checkpatch to
enable a verbose mode.

The message types in checkpatch are documented with rst
field lists. A total of 33 checkpatch type descriptions
are added.

Signed-off-by: Dwaipayan Ray 
---
 Documentation/dev-tools/checkpatch.rst | 494 +
 1 file changed, 494 insertions(+)
 create mode 100644 Documentation/dev-tools/checkpatch.rst

diff --git a/Documentation/dev-tools/checkpatch.rst 
b/Documentation/dev-tools/checkpatch.rst
new file mode 100644
index ..8e6ff1e27353
--- /dev/null
+++ b/Documentation/dev-tools/checkpatch.rst
@@ -0,0 +1,494 @@
+.. SPDX-License-Identifier: GPL-2.0-only
+
+==
+Checkpatch
+==
+
+This document describes the kernel script checkpatch.pl.
+
+.. Table of Contents
+
+   === 1 Introduction
+   === 2 Options
+   === 3 Message Levels
+   === 4 Type Descriptions
+
+1 Introduction
+--
+
+Checkpatch (scripts/checkpatch.pl) is a perl script which checks for trivial 
style
+violations in patches and optionally corrects them.  Checkpatch can also be 
run on
+file contexts and without the kernel tree.
+
+Checkpatch is not always right. Your judgement takes precedence over checkpatch
+messages.  If your code looks better with the violations, then its probably
+best left alone.
+
+
+2 Options
+-
+
+This section will describe the options checkpatch can be run with.
+
+Usage::
+
+  ./scripts/checkpatch.pl [OPTION]... [FILE]...
+
+Available options:
+
+ - -q,  --quiet
+
+   Enable quiet mode.
+
+ - -v,  --verbose
+   Enable verbose mode.  Additional verbose test descriptions are output
+   so as to provide information on why that particular message is shown.
+
+ - --no-tree
+
+   Run checkpatch without the kernel tree.
+
+ - --no-signoff
+
+   Disable the 'Signed-off-by' line check.  The sign-off is a simple line at
+   the end of the explanation for the patch, which certifies that you wrote it
+   or otherwise have the right to pass it on as an open-source patch.
+
+   Example::
+
+Signed-off-by: Random J Developer 
+
+   Setting this flag effectively stops a message for a missing signed-off-by 
line
+   in a patch context.
+
+ - --patch
+
+   Treat FILE as a patch.  This is the default option and need not be
+   explicitly specified.
+
+ - --emacs
+
+   Set output to emacs compile window format.  This allows emacs users to jump
+   from the error in the compile window directly to the offending line in the 
patch.
+
+ - --terse
+
+   Output only one line per report.
+
+ - --showfile
+
+   Show the diffed file position instead of the input file position.
+
+ - -g,  --git
+
+   Treat FILE as a single commit or a git revision range.
+
+   Single commit with:
+
+   - 
+   - ^
+   - ~n
+
+   Multiple commits with:
+
+   - ..
+   - ...
+   - -
+
+ - -f,  --file
+
+   Treat FILE as a regular source file.  This option must be used when running
+   checkpatch on source files in the kernel.
+
+ - --subjective,  --strict
+
+   Enable stricter tests in checkpatch.  By default the tests emitted as CHECK
+   do not activate by default.  Use this flag to activate the CHECK tests.
+
+ - --list-types
+
+   Every message emitted by checkpatch has an associated TYPE.  Add this flag 
to
+   display all the types in checkpatch.
+
+   Note that when this flag is active, checkpatch does not read the input 
FILE, and
+   no message is emitted.  Only a list of types in checkpatch is output.
+
+ - --types TYPE(,TYPE2...)
+
+   Only display messages with the given types.
+
+   Example::
+
+ ./scripts/checkpatch.pl mypatch.patch --types 
EMAIL_SUBJECT,NO_AUTHOR_SIGN_OFF
+
+ - --ignore TYPE(,TYPE2...)
+
+   Checkpatch will not emit messages for the specified types.
+
+   Example::
+
+ ./scripts/checkpatch.pl mypatch.patch --ignore 
EMAIL_SUBJECT,NO_AUTHOR_SIGN_OFF
+
+ - --show-types
+
+   By default checkpatch doesn't display the type associated with the messages.
+   Set this flag to show the message type in the output.
+
+ - --max-line-length=n
+
+   Set the max line length (default 100).  If a line exceeds the specified 
length,
+   a LONG_LINE message is emitted.
+
+
+   The message level is different for patch and file contexts.  For patches, a 
WARNING is
+   emitted.  While a milder CHECK is emitted for files.  So for file contexts, 
the --strict
+   flag must also be enabled.
+
+ - --min-conf-desc-length=n
+
+   Set the Kconfig entry minimum description length, if shorter, warn.
+
+ - --tab-size=n
+
+   Set the number of spaces for tab (default 8).
+
+ - --root=PATH
+
+   PATH to the kernel tree root.
+
+   This option must be specified when invoking checkpatch from outside
+   the kernel root.
+
+ - --no-summary
+
+   Suppress the per file summary.
+
+ - --mailback
+
+   Only produce a report in case of Warnings or Errors.  Milder Checks are
+   excluded from this.
+
+ - --summary-file
+
+   Include the filename in summary.

[PATCH] staging:r8188eu: use IEEE80211_FCTL_* kernel definitions

2021-02-13 Thread Ivan Safonov
_TO_DS_, _FROM_DS_, _MORE_FRAG_, _RETRY_, _PWRMGT_, _MORE_DATA_,
_PRIVACY_, _ORDER_ definitions are duplicate IEEE80211_FCTL_*
kernel definitions.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/include/wifi.h | 51 ++--
 1 file changed, 21 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/rtl8188eu/include/wifi.h 
b/drivers/staging/rtl8188eu/include/wifi.h
index d0380f7f1bab..1b9006879a11 100644
--- a/drivers/staging/rtl8188eu/include/wifi.h
+++ b/drivers/staging/rtl8188eu/include/wifi.h
@@ -88,73 +88,64 @@ enum WIFI_REG_DOMAIN {
DOMAIN_MAX
 };
 
-#define _TO_DS_BIT(8)
-#define _FROM_DS_  BIT(9)
-#define _MORE_FRAG_BIT(10)
-#define _RETRY_BIT(11)
-#define _PWRMGT_   BIT(12)
-#define _MORE_DATA_BIT(13)
-#define _PRIVACY_  BIT(14)
-#define _ORDER_BIT(15)
-
 #define SetToDs(pbuf)  \
-   *(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_)
+   *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS)
 
-#define GetToDs(pbuf)  (((*(__le16 *)(pbuf)) & cpu_to_le16(_TO_DS_)) != 0)
+#define GetToDs(pbuf)  (((*(__le16 *)(pbuf)) & 
cpu_to_le16(IEEE80211_FCTL_TODS)) != 0)
 
 #define ClearToDs(pbuf)\
-   *(__le16 *)(pbuf) &= (~cpu_to_le16(_TO_DS_))
+   *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_TODS))
 
 #define SetFrDs(pbuf)  \
-   *(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_)
+   *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS)
 
-#define GetFrDs(pbuf)  (((*(__le16 *)(pbuf)) & cpu_to_le16(_FROM_DS_)) != 0)
+#define GetFrDs(pbuf)  (((*(__le16 *)(pbuf)) & 
cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0)
 
 #define ClearFrDs(pbuf)\
-   *(__le16 *)(pbuf) &= (~cpu_to_le16(_FROM_DS_))
+   *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_FROMDS))
 
 #define get_tofr_ds(pframe)((GetToDs(pframe) << 1) | GetFrDs(pframe))
 
 #define SetMFrag(pbuf) \
-   *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_)
+   *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)
 
-#define GetMFrag(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_FRAG_)) != 0)
+#define GetMFrag(pbuf) (((*(__le16 *)(pbuf)) & 
cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0)
 
 #define ClearMFrag(pbuf)   \
-   *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_))
+   *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREFRAGS))
 
 #define SetRetry(pbuf) \
-   *(__le16 *)(pbuf) |= cpu_to_le16(_RETRY_)
+   *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_RETRY)
 
-#define GetRetry(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_RETRY_)) != 0)
+#define GetRetry(pbuf) (((*(__le16 *)(pbuf)) & 
cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0)
 
 #define ClearRetry(pbuf)   \
-   *(__le16 *)(pbuf) &= (~cpu_to_le16(_RETRY_))
+   *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_RETRY))
 
 #define SetPwrMgt(pbuf)\
-   *(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_)
+   *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PM)
 
-#define GetPwrMgt(pbuf)(((*(__le16 *)(pbuf)) & cpu_to_le16(_PWRMGT_)) 
!= 0)
+#define GetPwrMgt(pbuf)(((*(__le16 *)(pbuf)) & 
cpu_to_le16(IEEE80211_FCTL_PM)) != 0)
 
 #define ClearPwrMgt(pbuf)  \
-   *(__le16 *)(pbuf) &= (~cpu_to_le16(_PWRMGT_))
+   *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_PM))
 
 #define SetMData(pbuf) \
-   *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_)
+   *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREDATA)
 
-#define GetMData(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_DATA_)) != 0)
+#define GetMData(pbuf) (((*(__le16 *)(pbuf)) & 
cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0)
 
 #define ClearMData(pbuf)   \
-   *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_))
+   *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREDATA))
 
 #define SetPrivacy(pbuf)   \
-   *(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_)
+   *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PROTECTED)
 
 #define GetPrivacy(pbuf)   \
-   (((*(__le16 *)(pbuf)) & cpu_to_le16(_PRIVACY_)) != 0)
+   (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0)
 
 #define GetOrder(pbuf) \
-   (((*(__le16 *)(pbuf)) & cpu_to_le16(_ORDER_)) != 0)
+   (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0)
 
 #define GetFrameType(pbuf) \
(le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(3) | BIT(2)))
-- 
2.26.2



[PATCH RFC v3 3/3] docs: add documentation for checkpatch

2021-02-13 Thread Dwaipayan Ray
Link the checkpatch documentation to the dev-tools index
for sphinx.

Signed-off-by: Dwaipayan Ray 
---
 Documentation/dev-tools/index.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/dev-tools/index.rst 
b/Documentation/dev-tools/index.rst
index 1b1cf4f5c9d9..43d28998118b 100644
--- a/Documentation/dev-tools/index.rst
+++ b/Documentation/dev-tools/index.rst
@@ -14,6 +14,7 @@ whole; patches welcome!
 .. toctree::
:maxdepth: 2
 
+   checkpatch
coccinelle
sparse
kcov
-- 
2.30.0



Linux 4.19.176

2021-02-13 Thread Greg Kroah-Hartman
I'm announcing the release of the 4.19.176 kernel.

All users of the 4.19 kernel series must upgrade.

The updated 4.19.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git 
linux-4.19.y
and can be browsed at the normal kernel.org git web browser:

https://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary

thanks,

greg k-h



 Makefile |2 
 arch/x86/kvm/svm.c   |   18 +--
 block/blk-mq.c   |7 -
 block/elevator.c |   14 --
 block/genhd.c|   10 +
 drivers/crypto/chelsio/chtls/chtls_cm.c  |7 -
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c |3 
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c |3 
 drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c |   11 +
 drivers/net/wireless/intel/iwlwifi/pcie/tx.c |5 
 drivers/regulator/core.c |   84 ++-
 drivers/remoteproc/qcom_q6v5_pil.c   |   11 +
 fs/fs-writeback.c|2 
 fs/nfs/pnfs.c|8 +
 fs/squashfs/export.c |   41 +--
 fs/squashfs/id.c |   40 +--
 fs/squashfs/squashfs_fs_sb.h |1 
 fs/squashfs/super.c  |6 -
 fs/squashfs/xattr.h  |   10 +
 fs/squashfs/xattr_id.c   |   66 ++-
 include/linux/backing-dev.h  |   10 +
 include/linux/kprobes.h  |2 
 include/linux/string.h   |4 
 include/linux/sunrpc/xdr.h   |3 
 include/trace/events/writeback.h |   35 +++---
 init/init_task.c |3 
 kernel/kprobes.c |   34 --
 kernel/trace/ftrace.c|2 
 kernel/trace/trace_kprobe.c  |4 
 lib/string.c |   47 +++-
 mm/backing-dev.c |1 
 net/key/af_key.c |6 -
 net/sunrpc/auth_gss/auth_gss.c   |   30 -
 net/sunrpc/auth_gss/auth_gss_internal.h  |   45 
 net/sunrpc/auth_gss/gss_krb5_mech.c  |   31 -
 35 files changed, 410 insertions(+), 196 deletions(-)

Cong Wang (1):
  af_key: relax availability checks for skb size calculation

Dave Wysochanski (2):
  SUNRPC: Move simple_get_bytes and simple_get_netobj into private header
  SUNRPC: Handle 0 length opaque XDR object data properly

David Collins (1):
  regulator: core: avoid regulator_resolve_supply() race condition

Douglas Anderson (1):
  regulator: core: Clean enabling always-on regulators + their supplies

Emmanuel Grumbach (1):
  iwlwifi: pcie: add a NULL check in iwl_pcie_txq_unmap

Greg Kroah-Hartman (1):
  Linux 4.19.176

Johannes Berg (3):
  iwlwifi: mvm: take mutex for calling iwl_mvm_get_sync_time()
  iwlwifi: pcie: fix context info memory leak
  iwlwifi: mvm: guard against device removal in reprobe

Mark Brown (1):
  regulator: Fix lockdep warning resolving supplies

Masami Hiramatsu (1):
  tracing/kprobe: Fix to support kretprobe events on unloaded modules

Ming Lei (2):
  block: don't hold q->sysfs_lock in elevator_init_mq
  blk-mq: don't hold q->sysfs_lock in blk_mq_map_swqueue

Olliver Schinagl (1):
  regulator: core: enable power when setting up constraints

Pan Bian (1):
  chtls: Fix potential resource leak

Peter Gonda (1):
  Fix unsynchronized access to sev members through svm_register_enc_region

Phillip Lougher (3):
  squashfs: add more sanity checks in id lookup
  squashfs: add more sanity checks in inode lookup
  squashfs: add more sanity checks in xattr id lookup

Qian Cai (1):
  include/trace/events/writeback.h: fix -Wstringop-truncation warnings

Sibi Sankar (2):
  remoteproc: qcom_q6v5_mss: Validate modem blob firmware size before load
  remoteproc: qcom_q6v5_mss: Validate MBA firmware size before load

Steven Rostedt (VMware) (1):
  fgraph: Initialize tracing_graph_pause at task creation

Theodore Ts'o (1):
  memcg: fix a crash in wb_workfn when a device disappears

Tobin C. Harding (1):
  lib/string: Add strscpy_pad() function

Trond Myklebust (1):
  pNFS/NFSv4: Try to return invalid layout in pnfs_layout_process()

zhengbin (1):
  block: fix 

Linux 5.4.98

2021-02-13 Thread Greg Kroah-Hartman
I'm announcing the release of the 5.4.98 kernel.

All users of the 5.4 kernel series must upgrade.

The updated 5.4.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git 
linux-5.4.y
and can be browsed at the normal kernel.org git web browser:

https://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary

thanks,

greg k-h



 Makefile |2 
 arch/x86/kvm/svm.c   |   18 ++--
 block/blk-cgroup.c   |   18 ++--
 drivers/crypto/chelsio/chtls/chtls_cm.c  |7 -
 drivers/i2c/busses/i2c-mt65xx.c  |   19 +++-
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c |3 
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c|3 
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c |7 +
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c |6 +
 drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c |   11 ++
 drivers/net/wireless/intel/iwlwifi/pcie/tx.c |5 +
 drivers/regulator/core.c |   44 +++---
 fs/nfs/pnfs.c|8 +
 fs/squashfs/export.c |   41 +++--
 fs/squashfs/id.c |   40 +++--
 fs/squashfs/squashfs_fs_sb.h |1 
 fs/squashfs/super.c  |6 -
 fs/squashfs/xattr.h  |   10 ++
 fs/squashfs/xattr_id.c   |   66 ---
 include/linux/kprobes.h  |2 
 include/linux/sunrpc/xdr.h   |3 
 kernel/bpf/verifier.c|   28 ++
 kernel/kprobes.c |   34 +--
 kernel/trace/trace_kprobe.c  |   10 +-
 net/key/af_key.c |6 -
 net/mac80211/spectmgmt.c |   10 +-
 net/sunrpc/auth_gss/auth_gss.c   |   30 --
 net/sunrpc/auth_gss/auth_gss_internal.h  |   45 ++
 net/sunrpc/auth_gss/gss_krb5_mech.c  |   31 ---
 sound/soc/codecs/ak4458.c|   22 +
 sound/soc/intel/skylake/skl-topology.c   |2 
 31 files changed, 363 insertions(+), 175 deletions(-)

Baolin Wang (1):
  blk-cgroup: Use cond_resched() when destroy blkgs

Cong Wang (1):
  af_key: relax availability checks for skb size calculation

Daniel Borkmann (1):
  bpf: Fix 32 bit src register truncation on div/mod

Dave Wysochanski (2):
  SUNRPC: Move simple_get_bytes and simple_get_netobj into private header
  SUNRPC: Handle 0 length opaque XDR object data properly

David Collins (1):
  regulator: core: avoid regulator_resolve_supply() race condition

Eliot Blennerhassett (1):
  ASoC: ak4458: correct reset polarity

Emmanuel Grumbach (1):
  iwlwifi: pcie: add a NULL check in iwl_pcie_txq_unmap

Greg Kroah-Hartman (1):
  Linux 5.4.98

Gregory Greenman (1):
  iwlwifi: mvm: invalidate IDs of internal stations at mvm start

Johannes Berg (3):
  iwlwifi: mvm: take mutex for calling iwl_mvm_get_sync_time()
  iwlwifi: pcie: fix context info memory leak
  iwlwifi: mvm: guard against device removal in reprobe

Mark Brown (1):
  regulator: Fix lockdep warning resolving supplies

Masami Hiramatsu (1):
  tracing/kprobe: Fix to support kretprobe events on unloaded modules

Pan Bian (1):
  chtls: Fix potential resource leak

Peter Gonda (1):
  Fix unsynchronized access to sev members through svm_register_enc_region

Phillip Lougher (3):
  squashfs: add more sanity checks in id lookup
  squashfs: add more sanity checks in inode lookup
  squashfs: add more sanity checks in xattr id lookup

Qii Wang (1):
  i2c: mediatek: Move suspend and resume handling to NOIRQ phase

Ricardo Ribalda (1):
  ASoC: Intel: Skylake: Zero snd_ctl_elem_value

Sara Sharon (1):
  iwlwifi: mvm: skip power command when unbinding vif during CSA

Shay Bar (1):
  mac80211: 160MHz with extended NSS BW in CSA

Trond Myklebust (1):
  pNFS/NFSv4: Try to return invalid layout in pnfs_layout_process()



Re: Linux 4.19.176

2021-02-13 Thread Greg Kroah-Hartman
diff --git a/Makefile b/Makefile
index db37b39fae69..6bebe3b22b45 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 VERSION = 4
 PATCHLEVEL = 19
-SUBLEVEL = 175
+SUBLEVEL = 176
 EXTRAVERSION =
 NAME = "People's Front"
 
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index f1e86051aa5f..b34d11f22213 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1832,6 +1832,8 @@ static struct page **sev_pin_memory(struct kvm *kvm, 
unsigned long uaddr,
struct page **pages;
unsigned long first, last;
 
+   lockdep_assert_held(&kvm->lock);
+
if (ulen == 0 || uaddr + ulen < uaddr)
return NULL;
 
@@ -7084,12 +7086,21 @@ static int svm_register_enc_region(struct kvm *kvm,
if (!region)
return -ENOMEM;
 
+   mutex_lock(&kvm->lock);
region->pages = sev_pin_memory(kvm, range->addr, range->size, 
®ion->npages, 1);
if (!region->pages) {
ret = -ENOMEM;
+   mutex_unlock(&kvm->lock);
goto e_free;
}
 
+   region->uaddr = range->addr;
+   region->size = range->size;
+
+   mutex_lock(&kvm->lock);
+   list_add_tail(®ion->list, &sev->regions_list);
+   mutex_unlock(&kvm->lock);
+
/*
 * The guest may change the memory encryption attribute from C=0 -> C=1
 * or vice versa for this memory range. Lets make sure caches are
@@ -7098,13 +7109,6 @@ static int svm_register_enc_region(struct kvm *kvm,
 */
sev_clflush_pages(region->pages, region->npages);
 
-   region->uaddr = range->addr;
-   region->size = range->size;
-
-   mutex_lock(&kvm->lock);
-   list_add_tail(®ion->list, &sev->regions_list);
-   mutex_unlock(&kvm->lock);
-
return ret;
 
 e_free:
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 0df43515ff94..195526b93895 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2324,11 +2324,6 @@ static void blk_mq_map_swqueue(struct request_queue *q)
struct blk_mq_ctx *ctx;
struct blk_mq_tag_set *set = q->tag_set;
 
-   /*
-* Avoid others reading imcomplete hctx->cpumask through sysfs
-*/
-   mutex_lock(&q->sysfs_lock);
-
queue_for_each_hw_ctx(q, hctx, i) {
cpumask_clear(hctx->cpumask);
hctx->nr_ctx = 0;
@@ -2362,8 +2357,6 @@ static void blk_mq_map_swqueue(struct request_queue *q)
hctx->ctxs[hctx->nr_ctx++] = ctx;
}
 
-   mutex_unlock(&q->sysfs_lock);
-
queue_for_each_hw_ctx(q, hctx, i) {
/*
 * If no software queues are mapped to this hardware queue,
diff --git a/block/elevator.c b/block/elevator.c
index fae58b2f906f..ddbcd36616a8 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -980,23 +980,19 @@ int elevator_init_mq(struct request_queue *q)
if (q->nr_hw_queues != 1)
return 0;
 
-   /*
-* q->sysfs_lock must be held to provide mutual exclusion between
-* elevator_switch() and here.
-*/
-   mutex_lock(&q->sysfs_lock);
+   WARN_ON_ONCE(test_bit(QUEUE_FLAG_REGISTERED, &q->queue_flags));
+
if (unlikely(q->elevator))
-   goto out_unlock;
+   goto out;
 
e = elevator_get(q, "mq-deadline", false);
if (!e)
-   goto out_unlock;
+   goto out;
 
err = blk_mq_init_sched(q, e);
if (err)
elevator_put(e);
-out_unlock:
-   mutex_unlock(&q->sysfs_lock);
+out:
return err;
 }
 
diff --git a/block/genhd.c b/block/genhd.c
index 2b536ab570ac..6965dde96373 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -652,10 +652,12 @@ static void register_disk(struct device *parent, struct 
gendisk *disk)
kobject_uevent(&part_to_dev(part)->kobj, KOBJ_ADD);
disk_part_iter_exit(&piter);
 
-   err = sysfs_create_link(&ddev->kobj,
-   &disk->queue->backing_dev_info->dev->kobj,
-   "bdi");
-   WARN_ON(err);
+   if (disk->queue->backing_dev_info->dev) {
+   err = sysfs_create_link(&ddev->kobj,
+ &disk->queue->backing_dev_info->dev->kobj,
+ "bdi");
+   WARN_ON(err);
+   }
 }
 
 /**
diff --git a/drivers/crypto/chelsio/chtls/chtls_cm.c 
b/drivers/crypto/chelsio/chtls/chtls_cm.c
index fd3092a4378e..08ed3ff8b255 100644
--- a/drivers/crypto/chelsio/chtls/chtls_cm.c
+++ b/drivers/crypto/chelsio/chtls/chtls_cm.c
@@ -1051,11 +1051,9 @@ static struct sock *chtls_recv_sock(struct sock *lsk,
tcph = (struct tcphdr *)(iph + 1);
n = dst_neigh_lookup(dst, &iph->saddr);
if (!n || !n->dev)
-   goto free_sk;
+   goto free_dst;
 
ndev = n->dev;
-   if (!ndev)
-   goto free_dst;
if (is_vlan_dev(ndev))
ndev = vlan_dev_real_dev(ndev);
 
@@ -1

Re: Linux 5.4.98

2021-02-13 Thread Greg Kroah-Hartman
diff --git a/Makefile b/Makefile
index 032751f6be0c..4f6bfcf434e8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 VERSION = 5
 PATCHLEVEL = 4
-SUBLEVEL = 97
+SUBLEVEL = 98
 EXTRAVERSION =
 NAME = Kleptomaniac Octopus
 
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 4906e480b5bb..296b0d7570d0 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1835,6 +1835,8 @@ static struct page **sev_pin_memory(struct kvm *kvm, 
unsigned long uaddr,
struct page **pages;
unsigned long first, last;
 
+   lockdep_assert_held(&kvm->lock);
+
if (ulen == 0 || uaddr + ulen < uaddr)
return NULL;
 
@@ -7091,12 +7093,21 @@ static int svm_register_enc_region(struct kvm *kvm,
if (!region)
return -ENOMEM;
 
+   mutex_lock(&kvm->lock);
region->pages = sev_pin_memory(kvm, range->addr, range->size, 
®ion->npages, 1);
if (!region->pages) {
ret = -ENOMEM;
+   mutex_unlock(&kvm->lock);
goto e_free;
}
 
+   region->uaddr = range->addr;
+   region->size = range->size;
+
+   mutex_lock(&kvm->lock);
+   list_add_tail(®ion->list, &sev->regions_list);
+   mutex_unlock(&kvm->lock);
+
/*
 * The guest may change the memory encryption attribute from C=0 -> C=1
 * or vice versa for this memory range. Lets make sure caches are
@@ -7105,13 +7116,6 @@ static int svm_register_enc_region(struct kvm *kvm,
 */
sev_clflush_pages(region->pages, region->npages);
 
-   region->uaddr = range->addr;
-   region->size = range->size;
-
-   mutex_lock(&kvm->lock);
-   list_add_tail(®ion->list, &sev->regions_list);
-   mutex_unlock(&kvm->lock);
-
return ret;
 
 e_free:
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 3d34ac02d76e..cb3d44d20005 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1089,6 +1089,8 @@ static void blkcg_css_offline(struct cgroup_subsys_state 
*css)
  */
 void blkcg_destroy_blkgs(struct blkcg *blkcg)
 {
+   might_sleep();
+
spin_lock_irq(&blkcg->lock);
 
while (!hlist_empty(&blkcg->blkg_list)) {
@@ -1096,14 +1098,20 @@ void blkcg_destroy_blkgs(struct blkcg *blkcg)
struct blkcg_gq, blkcg_node);
struct request_queue *q = blkg->q;
 
-   if (spin_trylock(&q->queue_lock)) {
-   blkg_destroy(blkg);
-   spin_unlock(&q->queue_lock);
-   } else {
+   if (need_resched() || !spin_trylock(&q->queue_lock)) {
+   /*
+* Given that the system can accumulate a huge number
+* of blkgs in pathological cases, check to see if we
+* need to rescheduling to avoid softlockup.
+*/
spin_unlock_irq(&blkcg->lock);
-   cpu_relax();
+   cond_resched();
spin_lock_irq(&blkcg->lock);
+   continue;
}
+
+   blkg_destroy(blkg);
+   spin_unlock(&q->queue_lock);
}
 
spin_unlock_irq(&blkcg->lock);
diff --git a/drivers/crypto/chelsio/chtls/chtls_cm.c 
b/drivers/crypto/chelsio/chtls/chtls_cm.c
index eddc6d1bdb2d..82b76df43ae5 100644
--- a/drivers/crypto/chelsio/chtls/chtls_cm.c
+++ b/drivers/crypto/chelsio/chtls/chtls_cm.c
@@ -1047,11 +1047,9 @@ static struct sock *chtls_recv_sock(struct sock *lsk,
 
n = dst_neigh_lookup(dst, &iph->saddr);
if (!n || !n->dev)
-   goto free_sk;
+   goto free_dst;
 
ndev = n->dev;
-   if (!ndev)
-   goto free_dst;
if (is_vlan_dev(ndev))
ndev = vlan_dev_real_dev(ndev);
 
@@ -1117,7 +1115,8 @@ static struct sock *chtls_recv_sock(struct sock *lsk,
 free_csk:
chtls_sock_release(&csk->kref);
 free_dst:
-   neigh_release(n);
+   if (n)
+   neigh_release(n);
dst_release(dst);
 free_sk:
inet_csk_prepare_forced_close(newsk);
diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
index 5a9f0d17f52c..e1ef0122ef75 100644
--- a/drivers/i2c/busses/i2c-mt65xx.c
+++ b/drivers/i2c/busses/i2c-mt65xx.c
@@ -1008,7 +1008,8 @@ static int mtk_i2c_probe(struct platform_device *pdev)
mtk_i2c_clock_disable(i2c);
 
ret = devm_request_irq(&pdev->dev, irq, mtk_i2c_irq,
-  IRQF_TRIGGER_NONE, I2C_DRV_NAME, i2c);
+  IRQF_NO_SUSPEND | IRQF_TRIGGER_NONE,
+  I2C_DRV_NAME, i2c);
if (ret < 0) {
dev_err(&pdev->dev,
"Request I2C IRQ %d fail\n", irq);
@@ -1035,7 +1036,16 @@ static int mtk_i2c_remove(struct platform_device *pdev)
 }
 
 #ifdef CONFIG_PM_SLEEP
-

Re: Linux 5.10.16

2021-02-13 Thread Greg Kroah-Hartman
diff --git a/Makefile b/Makefile
index b62d2d4ea7b0..9a1f26680d83 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 VERSION = 5
 PATCHLEVEL = 10
-SUBLEVEL = 15
+SUBLEVEL = 16
 EXTRAVERSION =
 NAME = Kleptomaniac Octopus
 
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index 8dad44262e75..495ffc9cf5e2 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -475,7 +475,7 @@ static __init void vdso_setup_trampolines(struct 
lib32_elfinfo *v32,
 */
 
 #ifdef CONFIG_PPC64
-   vdso64_rt_sigtramp = find_function64(v64, "__kernel_sigtramp_rt64");
+   vdso64_rt_sigtramp = find_function64(v64, 
"__kernel_start_sigtramp_rt64");
 #endif
vdso32_sigtramp= find_function32(v32, "__kernel_sigtramp32");
vdso32_rt_sigtramp = find_function32(v32, "__kernel_sigtramp_rt32");
diff --git a/arch/powerpc/kernel/vdso64/sigtramp.S 
b/arch/powerpc/kernel/vdso64/sigtramp.S
index bbf68cd01088..2d4067561293 100644
--- a/arch/powerpc/kernel/vdso64/sigtramp.S
+++ b/arch/powerpc/kernel/vdso64/sigtramp.S
@@ -15,11 +15,20 @@
 
.text
 
+/*
+ * __kernel_start_sigtramp_rt64 and __kernel_sigtramp_rt64 together
+ * are one function split in two parts. The kernel jumps to the former
+ * and the signal handler indirectly (by blr) returns to the latter.
+ * __kernel_sigtramp_rt64 needs to point to the return address so
+ * glibc can correctly identify the trampoline stack frame.
+ */
.balign 8
.balign IFETCH_ALIGN_BYTES
-V_FUNCTION_BEGIN(__kernel_sigtramp_rt64)
+V_FUNCTION_BEGIN(__kernel_start_sigtramp_rt64)
 .Lsigrt_start:
bctrl   /* call the handler */
+V_FUNCTION_END(__kernel_start_sigtramp_rt64)
+V_FUNCTION_BEGIN(__kernel_sigtramp_rt64)
addir1, r1, __SIGNAL_FRAMESIZE
li  r0,__NR_rt_sigreturn
sc
diff --git a/arch/powerpc/kernel/vdso64/vdso64.lds.S 
b/arch/powerpc/kernel/vdso64/vdso64.lds.S
index 256fb9720298..bd120f590b9e 100644
--- a/arch/powerpc/kernel/vdso64/vdso64.lds.S
+++ b/arch/powerpc/kernel/vdso64/vdso64.lds.S
@@ -150,6 +150,7 @@ VERSION
__kernel_get_tbfreq;
__kernel_sync_dicache;
__kernel_sync_dicache_p5;
+   __kernel_start_sigtramp_rt64;
__kernel_sigtramp_rt64;
__kernel_getcpu;
__kernel_time;
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 54fbe1e80cc4..f13688c4b931 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1017,6 +1017,8 @@ static void blkcg_css_offline(struct cgroup_subsys_state 
*css)
  */
 void blkcg_destroy_blkgs(struct blkcg *blkcg)
 {
+   might_sleep();
+
spin_lock_irq(&blkcg->lock);
 
while (!hlist_empty(&blkcg->blkg_list)) {
@@ -1024,14 +1026,20 @@ void blkcg_destroy_blkgs(struct blkcg *blkcg)
struct blkcg_gq, blkcg_node);
struct request_queue *q = blkg->q;
 
-   if (spin_trylock(&q->queue_lock)) {
-   blkg_destroy(blkg);
-   spin_unlock(&q->queue_lock);
-   } else {
+   if (need_resched() || !spin_trylock(&q->queue_lock)) {
+   /*
+* Given that the system can accumulate a huge number
+* of blkgs in pathological cases, check to see if we
+* need to rescheduling to avoid softlockup.
+*/
spin_unlock_irq(&blkcg->lock);
-   cpu_relax();
+   cond_resched();
spin_lock_irq(&blkcg->lock);
+   continue;
}
+
+   blkg_destroy(blkg);
+   spin_unlock(&q->queue_lock);
}
 
spin_unlock_irq(&blkcg->lock);
diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
index 689c06cbbb45..ade3ecf2ee49 100644
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -756,6 +756,8 @@ static void edge_detector_stop(struct line *line)
cancel_delayed_work_sync(&line->work);
WRITE_ONCE(line->sw_debounced, 0);
line->eflags = 0;
+   if (line->desc)
+   WRITE_ONCE(line->desc->debounce_period_us, 0);
/* do not change line->level - see comment in debounced_value() */
 }
 
diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c 
b/drivers/gpu/drm/i915/display/intel_ddi.c
index 40dfb4d0ffbe..db62e6a934d9 100644
--- a/drivers/gpu/drm/i915/display/intel_ddi.c
+++ b/drivers/gpu/drm/i915/display/intel_ddi.c
@@ -2597,6 +2597,9 @@ static void icl_mg_phy_ddi_vswing_sequence(struct 
intel_encoder *encoder,
u32 n_entries, val;
int ln, rate = 0;
 
+   if (enc_to_dig_port(encoder)->tc_mode == TC_PORT_TBT_ALT)
+   return;
+
if (type != INTEL_OUTPUT_HDMI) {
struct intel_dp *intel_dp = enc_to_intel_dp(encod

  1   2   3   >