linux-next: manual merge of the memblock tree with the pidfd tree

2020-07-05 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the memblock tree got a conflict in:

  arch/unicore32/kernel/process.c

between commit:

  8496da092a53 ("unicore: switch to copy_thread_tls()")
  714acdbd1c94 ("arch: rename copy_thread_tls() back to copy_thread()")

from the pidfd tree and commit:

  fb37409a01b0 ("arch: remove unicore32 port")

from the memblock tree.

I fixed it up (I just removed the file) and can carry the fix as
necessary. This is now fixed as far as linux-next is concerned, but any
non trivial conflicts should be mentioned to your upstream maintainer
when your tree is submitted for merging.  You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell


pgpTTkGQzLaEQ.pgp
Description: OpenPGP digital signature


[rcu:dev.2020.07.02a] BUILD SUCCESS 9e4ad971bf0a551b3922c94eda1f361be04dcde2

2020-07-05 Thread kernel test robot
tree/branch: 
https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git  
dev.2020.07.02a
branch HEAD: 9e4ad971bf0a551b3922c94eda1f361be04dcde2  squash! kernel/smp: 
Provide CSD lock timeout diagnostics

elapsed time: 2235m

configs tested: 219
configs skipped: 34

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

arm defconfig
arm  allyesconfig
arm  allmodconfig
arm   allnoconfig
arm64allyesconfig
arm64   defconfig
arm64allmodconfig
arm64 allnoconfig
m68km5407c3_defconfig
sh   allmodconfig
arm s5pv210_defconfig
arm ezx_defconfig
arm  colibri_pxa270_defconfig
h8300   h8s-sim_defconfig
arcnsim_700_defconfig
c6xevmc6472_defconfig
m68km5272c3_defconfig
arcnsimosci_defconfig
powerpc pq2fads_defconfig
mips  malta_kvm_defconfig
arm  ep93xx_defconfig
openrisc simple_smp_defconfig
riscvalldefconfig
h8300h8300h-sim_defconfig
arm s3c2410_defconfig
mipsvocore2_defconfig
mips   ip27_defconfig
sh apsh4a3a_defconfig
arc nsimosci_hs_smp_defconfig
shtitan_defconfig
powerpc skiroot_defconfig
arm cm_x300_defconfig
sh kfr2r09-romimage_defconfig
mips tb0219_defconfig
sh   j2_defconfig
arm  lpd270_defconfig
h8300 edosk2674_defconfig
nios2 10m50_defconfig
ia64 allmodconfig
arm assabet_defconfig
xtensa  defconfig
arm  jornada720_defconfig
xtensa virt_defconfig
sh  landisk_defconfig
m68kstmark2_defconfig
sh   se7780_defconfig
sh  rsk7264_defconfig
sparcalldefconfig
mips  mips_paravirt_defconfig
shdreamcast_defconfig
sh sh7710voipgw_defconfig
nios2alldefconfig
m68kq40_defconfig
shedosk7760_defconfig
powerpc   maple_defconfig
arcvdk_hs38_defconfig
mips bigsur_defconfig
mips  rb532_defconfig
arm   tegra_defconfig
mips  ath25_defconfig
mipsjmr3927_defconfig
arm nhk8815_defconfig
arm pxa_defconfig
powerpc  mgcoge_defconfig
arm bcm2835_defconfig
mipsmaltaup_defconfig
m68kmac_defconfig
sh magicpanelr2_defconfig
mips allyesconfig
arc   tb10x_defconfig
ia64 bigsur_defconfig
sh   se7705_defconfig
parisc   alldefconfig
powerpc  ppc6xx_defconfig
arm  imote2_defconfig
armclps711x_defconfig
xtensaxip_kc705_defconfig
nios2   defconfig
mips rt305x_defconfig
sh  rsk7269_defconfig
sparc64  alldefconfig
powerpc wii_defconfig
arm  colibri_pxa300_defconfig
armmps2_defconfig
armoxnas_v6_defconfig
arm   imx_v4_v5_defconfig
arm rpc_defconfig
arm mv78xx0_defconfig
s390defconfig
sh   cayman_defconfig
arm socfpga_defconfig
h8300   defconfig
mipse55_defconfig
powerpc powernv_defconfig
arm s3c6400_defconfig
m68k  atari_defconfig
arm   u8500_defconfig
mipsmaltaup_xpa_defconfig
arm  zx_defconfig
powerpc  g5_defconfig
arc  

[PATCH] cpuidle/powernv : Remove dead code block

2020-07-05 Thread Abhishek Goel
Commit 1961acad2f88559c2cdd2ef67c58c3627f1f6e54 removes usage of
function "validate_dt_prop_sizes". This patch removes this unused
function.

Signed-off-by: Abhishek Goel 
---
 drivers/cpuidle/cpuidle-powernv.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/drivers/cpuidle/cpuidle-powernv.c 
b/drivers/cpuidle/cpuidle-powernv.c
index 1b299e801f74..addaa6e6718b 100644
--- a/drivers/cpuidle/cpuidle-powernv.c
+++ b/drivers/cpuidle/cpuidle-powernv.c
@@ -244,20 +244,6 @@ static inline void add_powernv_state(int index, const char 
*name,
stop_psscr_table[index].mask = psscr_mask;
 }
 
-/*
- * Returns 0 if prop1_len == prop2_len. Else returns -1
- */
-static inline int validate_dt_prop_sizes(const char *prop1, int prop1_len,
-const char *prop2, int prop2_len)
-{
-   if (prop1_len == prop2_len)
-   return 0;
-
-   pr_warn("cpuidle-powernv: array sizes don't match for %s and %s\n",
-   prop1, prop2);
-   return -1;
-}
-
 extern u32 pnv_get_supported_cpuidle_states(void);
 static int powernv_add_idle_states(void)
 {
-- 
2.17.1



Re: [PATCH 13/16] arm64: dts: allwinner: a64: Add HDMI audio

2020-07-05 Thread Maxime Ripard
On Sat, Jul 04, 2020 at 01:38:59PM +0200, Clément Péron wrote:
> From: Marcus Cooper 
> 
> Add a simple-soundcard to link audio between HDMI and I2S.
> 
> Signed-off-by: Jernej Skrabec 
> Signed-off-by: Marcus Cooper 
> Signed-off-by: Clément Péron 
> ---
>  arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 21 +++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi 
> b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
> index c662f6a170ce..6a321fdc8e90 100644
> --- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
> +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
> @@ -102,6 +102,25 @@ de: display-engine {
>   status = "disabled";
>   };
>  
> + hdmi_sound: hdmi-sound {
> + compatible = "simple-audio-card";
> + simple-audio-card,format = "i2s";
> + simple-audio-card,name = "sun50i-a64-hdmi";
> + simple-audio-card,mclk-fs = <128>;
> + simple-audio-card,frame-inversion;
> + status = "disabled";
> +
> + simple-audio-card,codec {
> + sound-dai = <>;
> + };
> +
> + simple-audio-card,cpu {
> + sound-dai = <>;
> + dai-tdm-slot-num = <2>;
> + dai-tdm-slot-width = <32>;
> + };
> + };
> +
>   osc24M: osc24M_clk {
>   #clock-cells = <0>;
>   compatible = "fixed-clock";
> @@ -856,6 +875,7 @@ i2s2: i2s@1c22800 {
>   resets = < RST_BUS_I2S2>;
>   dma-names = "tx";
>   dmas = < 27>;
> + allwinner,playback-channels = <8>;

This isn't documented anywhere

Maxime


signature.asc
Description: PGP signature


Re: [PATCH] Replace HTTP links with HTTPS ones: VMWare PVRDMA driver

2020-07-05 Thread Leon Romanovsky
On Sun, Jul 05, 2020 at 11:45:28PM +0200, Alexander A. Klimov wrote:
> Rationale:
> Reduces attack surface on kernel devs opening the links for MITM
> as HTTPS traffic is much harder to manipulate.
>
> Deterministic algorithm:
> For each file:
>   If not .svg:
> For each line:
>   If doesn't contain `\bxmlns\b`:
> For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
>   If both the HTTP and HTTPS versions
>   return 200 OK and serve the same content:
> Replace HTTP with HTTPS.
>
> Signed-off-by: Alexander A. Klimov 
> ---

All these links and text that surround them should be replaced with SPDX tags.

Thanks


RE: [EXT] Re: [PATCH v5 3/3] ARM: imx6plus: optionally enable internal routing of clk_enet_ref

2020-07-05 Thread Andy Duan
From: Sven Van Asbroeck  Sent: Sunday, July 5, 2020 11:34 
PM
> 
>   ext phy-| \
>   |  |
>   enet_ref-o--|M |pad--| \
>|  |_/  |  |
>|   |M |mac_gtx
>|   |  |
>o---|_/
> 
> 
> How do we tell the clock framework that clk_pad has a mux that can be
> connected to _any_ external clock? and also enet_ref?

The clock depends on board design, HW refer guide can describe the clk
usage in detail and customer select one clk path as their board design.

To make thing simple, we can just control the second "M" that is controlled
by gpr bit.



Re: [PATCH 08/16] arm64: dts: allwinner: h6: Add HDMI audio node

2020-07-05 Thread Maxime Ripard
Hi,

On Sat, Jul 04, 2020 at 01:38:54PM +0200, Clément Péron wrote:
> From: Jernej Skrabec 
> 
> Add a simple-soundcard to link audio between HDMI and I2S.
> 
> Signed-off-by: Jernej Skrabec 
> Signed-off-by: Marcus Cooper 
> Signed-off-by: Clément Péron 
> ---
>  arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 33 
>  1 file changed, 33 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi 
> b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> index 78b1361dfbb9..ae169d07b939 100644
> --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> @@ -67,6 +67,25 @@ de: display-engine {
>   status = "disabled";
>   };
>  
> + hdmi_sound: hdmi-sound {
> + compatible = "simple-audio-card";
> + simple-audio-card,format = "i2s";
> + simple-audio-card,name = "sun50i-h6-hdmi";
> + simple-audio-card,mclk-fs = <128>;
> + simple-audio-card,frame-inversion;

Have you figured that one out?

> + status = "disabled";
> +
> + simple-audio-card,codec {
> + sound-dai = <>;
> + };
> +
> + simple-audio-card,cpu {
> + sound-dai = <>;
> + dai-tdm-slot-num = <2>;
> + dai-tdm-slot-width = <32>;

I'm not sure why you need to use the TDM stuff here. IIRC the HDMI
controller can output on up to 6 channels, so how would that work out?

Maxime


signature.asc
Description: PGP signature


Re: [PATCH 07/16] ASoC: sun4i-i2s: Fix sun8i volatile regs

2020-07-05 Thread Maxime Ripard
On Sat, Jul 04, 2020 at 01:38:53PM +0200, Clément Péron wrote:
> The FIFO TX reg is volatile and sun8i i2s register
> mapping is different from sun4i.
> 
> Even if in this case it's doesn't create an issue,
> Avoid setting some regs that are undefined in sun8i.
> 
> Signed-off-by: Clément Péron 

Acked-by: Maxime Ripard 
Maxime


signature.asc
Description: PGP signature


Re: [PATCH 06/16] ASoC: sun4i-i2s: Adjust regmap settings

2020-07-05 Thread Maxime Ripard
On Sat, Jul 04, 2020 at 01:38:52PM +0200, Clément Péron wrote:
> From: Marcus Cooper 
> 
> Bypass the regmap cache when flushing or reading the i2s FIFOs.
> 
> Signed-off-by: Marcus Cooper 
> Signed-off-by: Clément Péron 

Acked-by: Maxime Ripard 

Thanks
Maxime


signature.asc
Description: PGP signature


Re: [PATCH v2] dmaengine: ioat setting ioat timeout as module parameter

2020-07-05 Thread Vinod Koul
On 01-07-20, 21:48, leonid.rav...@dell.com wrote:
> From: Leonid Ravich 
> 
> DMA transaction time to completion  is a function of
> PCI bandwidth,transaction size and a queue depth.

space after , pls

> So hard coded value for timeouts might be wrong
> for some scenarios.

I ahve fixed above and applied

-- 
~Vinod


Re: [PATCH 05/16] ASoc: sun4i-i2s: Add 20 and 24 bit support

2020-07-05 Thread Maxime Ripard
On Sat, Jul 04, 2020 at 01:38:51PM +0200, Clément Péron wrote:
> From: Marcus Cooper 
> 
> Extend the functionality of the driver to include support of 20 and
> 24 bits per sample.
> 
> Signed-off-by: Marcus Cooper 
> Signed-off-by: Clément Péron 

Acked-by: Maxime Ripard 

Thanks!
Maxime


signature.asc
Description: PGP signature


RE: [PATCH v2] rtc: rtc-ds1374: wdt: Use watchdog core for watchdog part

2020-07-05 Thread 陳昭勳
Hi,

Thanks for your good suggestions!

> > diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index
> > b54d87d45c89..5e2444af5657 100644
> > --- a/drivers/rtc/Kconfig
> > +++ b/drivers/rtc/Kconfig
> > @@ -282,6 +282,7 @@ config RTC_DRV_DS1374  config
> RTC_DRV_DS1374_WDT
> > bool "Dallas/Maxim DS1374 watchdog timer"
> > depends on RTC_DRV_DS1374
> > +   select WATCHDOG_CORE
> 
> This has to be
> 
>   select WATCHDOG_CORE if WATCHDOG
> 
> to fix the problem reported by 0-day.
> 
> > help
> >   If you say Y here you will get support for the
> >   watchdog timer in the Dallas Semiconductor DS1374 diff --git
> > a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index
> > 9c51a12cf70f..57a4e503b34a 100644
> > --- a/drivers/rtc/rtc-ds1374.c
> > +++ b/drivers/rtc/rtc-ds1374.c
> > @@ -46,6 +46,7 @@
> >  #define DS1374_REG_WDALM2  0x06
> >  #define DS1374_REG_CR  0x07 /* Control */
> >  #define DS1374_REG_CR_AIE  0x01 /* Alarm Int. Enable */
> > +#define DS1374_REG_CR_WDSTR0x08 /* 1=INT, 0=RST */
> >  #define DS1374_REG_CR_WDALM0x20 /* 1=Watchdog, 0=Alarm */
> >  #define DS1374_REG_CR_WACE 0x40 /* WD/Alarm counter enable */
> >  #define DS1374_REG_SR  0x08 /* Status */
> > @@ -71,7 +72,9 @@ struct ds1374 {
> > struct i2c_client *client;
> > struct rtc_device *rtc;
> > struct work_struct work;
> > -
> > +#ifdef CONFIG_RTC_DRV_DS1374_WDT
> > +   struct watchdog_device wdt;
> > +#endif
> > /* The mutex protects alarm operations, and prevents a race
> >  * between the enable_irq() in the workqueue and the free_irq()
> >  * in the remove function.
> > @@ -371,72 +374,76 @@ static const struct rtc_class_ops ds1374_rtc_ops =
> {
> >   */
> >  static struct i2c_client *save_client;
> 
> This is no longer necessary. struct watchdog_device is part of struct ds1374, 
> so
> it is possible to derive the pointer to struct ds1374 from it and get the 
> client
> pointer from there.
> 
> >  /* Default margin */
> > -#define WD_TIMO 131762
> > +#define TIMER_MARGIN_DEFAULT   32
> > +#define TIMER_MARGIN_MIN   1
> > +#define TIMER_MARGIN_MAX   4095 /* 24-bit value */
> >
> >  #define DRV_NAME "DS1374 Watchdog"
> >
> > -static int wdt_margin = WD_TIMO;
> > -static unsigned long wdt_is_open;
> > +static int wdt_margin = TIMER_MARGIN_DEFAULT;
> 
> Should be 0, not TIMER_MARGIN_DEFAULT.
> 
> >  module_param(wdt_margin, int, 0);
> >  MODULE_PARM_DESC(wdt_margin, "Watchdog timeout in seconds
> (default
> > 32s)");
> >
> > +static bool nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout,
> > +bool, 0); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped
> once
> > +started (default ="
> > +   __MODULE_STRING(WATCHDOG_NOWAYOUT)")");
> > +
> > +
> >  static const struct watchdog_info ds1374_wdt_info = {
> > .identity   = "DS1374 WTD",
> > .options= WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
> > WDIOF_MAGICCLOSE,
> >  };
> >
> > -static int ds1374_wdt_settimeout(unsigned int timeout)
> > +static int ds1374_wdt_settimeout(struct watchdog_device *wdt,
> > +unsigned int timeout)
> >  {
> > -   int ret = -ENOIOCTLCMD;
> > -   int cr;
> > +   int ret, cr;
> >
> > -   ret = cr = i2c_smbus_read_byte_data(save_client, DS1374_REG_CR);
> > -   if (ret < 0)
> > -   goto out;
> > +   wdt->timeout = timeout;
> > +
> > +   cr = i2c_smbus_read_byte_data(save_client, DS1374_REG_CR);
> > +   if (cr < 0)
> > +   return cr;
> >
> > /* Disable any existing watchdog/alarm before setting the new one */
> > cr &= ~DS1374_REG_CR_WACE;
> >
> > ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
> > if (ret < 0)
> > -   goto out;
> > +   return ret;
> >
> > /* Set new watchdog time */
> > +   timeout = timeout * 4096;
> > ret = ds1374_write_rtc(save_client, timeout, DS1374_REG_WDALM0, 3);
> > if (ret) {
> > pr_info("couldn't set new watchdog time\n");
> 
> dev_info() can now be used since we have a device. _info seems to be wrong,
> though, since this is an error.
> 
> > -   goto out;
> > +   return ret;
> > }
> >
> > /* Enable watchdog timer */
> > cr |= DS1374_REG_CR_WACE | DS1374_REG_CR_WDALM;
> > +   cr &= ~DS1374_REG_CR_WDSTR;/* for RST PIN */
> > cr &= ~DS1374_REG_CR_AIE;
> >
> > ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
> > if (ret < 0)
> > -   goto out;
> > +   return ret;
> >
> > return 0;
> > -out:
> > -   return ret;
> >  }
> >
> > -
> >  /*
> >   * Reload the watchdog timer.  (ie, pat the watchdog)
> >   */
> > -static void ds1374_wdt_ping(void)
> > +static int ds1374_wdt_start(struct watchdog_device *wdt)
> >  {
> > u32 val;
> > -   int ret = 0;
> >
> > -   ret = ds1374_read_rtc(save_client, , DS1374_REG_WDALM0, 3);
> > -   if (ret)
> > -   pr_info("WD TICK FAIL!! %i\n", ret);
> > +   return 

Re: [PATCH 04/16] ASoC: sun4i-i2s: Set sign extend sample

2020-07-05 Thread Maxime Ripard
On Sat, Jul 04, 2020 at 01:38:50PM +0200, Clément Péron wrote:
> From: Marcus Cooper 
> 
> On the newer SoCs such as the H3 and A64 this is set by default
> to transfer a 0 after each sample in each slot. However the A10
> and A20 SoCs that this driver was developed on had a default
> setting where it padded the audio gain with zeros.
> 
> This isn't a problem while we have only support for 16bit audio
> but with larger sample resolution rates in the pipeline then SEXT
> bits should be cleared so that they also pad at the LSB. Without
> this the audio gets distorted.
> 
> Set sign extend sample for all the sunxi generations even if they
> are not affected. This will keep coherency and avoid relying on
> default.

Isn't it coherence? But I guess consistency would be a better fit here.

Maxime


signature.asc
Description: PGP signature


回复: [PATCH] usb: gadget: function: fix missing spinlock in f_uac1_legacy

2020-07-05 Thread Zhang, Qiang


发件人: linux-kernel-ow...@vger.kernel.org  代表 
qiang.zh...@windriver.com 
发送时间: 2020年7月5日 9:59
收件人: ba...@kernel.org
抄送: gre...@linuxfoundation.org; colin.k...@canonical.com; 
linux-...@vger.kernel.org; linux-kernel@vger.kernel.org
主题: [PATCH] usb: gadget: function: fix missing spinlock in f_uac1_legacy

From: Zhang Qiang 

Signed-off-by: Zhang Qiang 
---
 drivers/usb/gadget/function/f_uac1_legacy.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/gadget/function/f_uac1_legacy.c 
b/drivers/usb/gadget/function/f_uac1_legacy.c
index 349deae7cabd..e2d7f69128a0 100644
--- a/drivers/usb/gadget/function/f_uac1_legacy.c
+++ b/drivers/usb/gadget/function/f_uac1_legacy.c
@@ -336,7 +336,9 @@ static int f_audio_out_ep_complete(struct usb_ep *ep, 
struct usb_request *req)

/* Copy buffer is full, add it to the play_queue */
if (audio_buf_size - copy_buf->actual < req->actual) {
+   spin_lock_irq(>lock);
list_add_tail(_buf->list, >play_queue);
+   spin_unlock_irq(>lock);
schedule_work(>playback_work);
copy_buf = f_audio_buffer_alloc(audio_buf_size);
if (IS_ERR(copy_buf))
--
2.24.1



Re: [PATCH 01/16] ASoC: sun4i-i2s: Add support for H6 I2S

2020-07-05 Thread Maxime Ripard
Hi,

On Sat, Jul 04, 2020 at 01:38:47PM +0200, Clément Péron wrote:
> From: Jernej Skrabec 
> 
> H6 I2S is very similar to that in H3, except it supports up to 16
> channels.
> 
> Signed-off-by: Jernej Skrabec 
> Signed-off-by: Marcus Cooper 
> Signed-off-by: Clément Péron 
> ---
>  sound/soc/sunxi/sun4i-i2s.c | 227 
>  1 file changed, 227 insertions(+)
> 
> diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
> index d0a8d5810c0a..9690389cb68e 100644
> --- a/sound/soc/sunxi/sun4i-i2s.c
> +++ b/sound/soc/sunxi/sun4i-i2s.c
> @@ -124,6 +124,21 @@
>  #define SUN8I_I2S_RX_CHAN_SEL_REG0x54
>  #define SUN8I_I2S_RX_CHAN_MAP_REG0x58
>  
> +/* Defines required for sun50i-h6 support */
> +#define SUN50I_H6_I2S_TX_CHAN_SEL_OFFSET_MASKGENMASK(21, 20)
> +#define SUN50I_H6_I2S_TX_CHAN_SEL_OFFSET(offset) ((offset) << 20)
> +#define SUN50I_H6_I2S_TX_CHAN_SEL_MASK   GENMASK(19, 16)
> +#define SUN50I_H6_I2S_TX_CHAN_SEL(chan)  ((chan - 1) << 16)
> +#define SUN50I_H6_I2S_TX_CHAN_EN_MASKGENMASK(15, 0)
> +#define SUN50I_H6_I2S_TX_CHAN_EN(num_chan)   (((1 << num_chan) - 1))
> +
> +#define SUN50I_H6_I2S_TX_CHAN_MAP0_REG   0x44
> +#define SUN50I_H6_I2S_TX_CHAN_MAP1_REG   0x48
> +
> +#define SUN50I_H6_I2S_RX_CHAN_SEL_REG0x64
> +#define SUN50I_H6_I2S_RX_CHAN_MAP0_REG   0x68
> +#define SUN50I_H6_I2S_RX_CHAN_MAP1_REG   0x6C
> +
>  struct sun4i_i2s;
>  
>  /**
> @@ -466,6 +481,65 @@ static int sun8i_i2s_set_chan_cfg(const struct sun4i_i2s 
> *i2s,
>   return 0;
>  }
>  
> +static int sun50i_i2s_set_chan_cfg(const struct sun4i_i2s *i2s,
> +const struct snd_pcm_hw_params *params)

We should have sun50i_h6 as prefix. The A64 is also part of the sun50i
family and supported through the sun8i callbacks, so it's pretty
confusing if you don't have the soc name in there.

Maxime


signature.asc
Description: PGP signature


Re: [PATCH 2/3] arm64: dts: allwinner: Add support for PinePhone revision 1.2

2020-07-05 Thread Maxime Ripard
Hi,

On Fri, Jul 03, 2020 at 09:48:41PM +0200, Ondrej Jirman wrote:
> Revision 1.2 should be the final production version of the PinePhone.
> It has most of the known HW quirks fixed.
> 
> Interrupt to the magnetometer is routed correctly, in this revision.
> 
> The bulk of the changes are in how modem and the USB-C HDMI bridge
> chip is powered and where the signals from the modem are connected.
> 
> Also backlight intensity seemingly behaves differently, than on the
> 1.1 and 1.0 boards, and the PWM duty cycle where backlight starts
> to work is 10% (as tested on 2 1.2 PinePhones I have access to).
> 
> Signed-off-by: Ondrej Jirman 
> ---
>  arch/arm64/boot/dts/allwinner/Makefile|  1 +
>  .../allwinner/sun50i-a64-pinephone-1.2.dts| 40 +++
>  .../dts/allwinner/sun50i-a64-pinephone.dtsi   |  2 +-
>  3 files changed, 42 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.2.dts
> 
> diff --git a/arch/arm64/boot/dts/allwinner/Makefile 
> b/arch/arm64/boot/dts/allwinner/Makefile
> index e4d3cd0ac5bb..916d10d5b87c 100644
> --- a/arch/arm64/boot/dts/allwinner/Makefile
> +++ b/arch/arm64/boot/dts/allwinner/Makefile
> @@ -11,6 +11,7 @@ dtb-$(CONFIG_ARCH_SUNXI) += sun50i-a64-pine64-plus.dtb 
> sun50i-a64-pine64.dtb
>  dtb-$(CONFIG_ARCH_SUNXI) += sun50i-a64-pinebook.dtb
>  dtb-$(CONFIG_ARCH_SUNXI) += sun50i-a64-pinephone-1.0.dtb
>  dtb-$(CONFIG_ARCH_SUNXI) += sun50i-a64-pinephone-1.1.dtb
> +dtb-$(CONFIG_ARCH_SUNXI) += sun50i-a64-pinephone-1.2.dtb
>  dtb-$(CONFIG_ARCH_SUNXI) += sun50i-a64-pinetab.dtb
>  dtb-$(CONFIG_ARCH_SUNXI) += sun50i-a64-sopine-baseboard.dtb
>  dtb-$(CONFIG_ARCH_SUNXI) += sun50i-a64-teres-i.dtb
> diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.2.dts 
> b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.2.dts
> new file mode 100644
> index ..a9f5b670c9b8
> --- /dev/null
> +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.2.dts
> @@ -0,0 +1,40 @@
> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> +// Copyright (C) 2020 Ondrej Jirman 
> +
> +/dts-v1/;
> +
> +#include "sun50i-a64-pinephone.dtsi"
> +
> +/ {
> + model = "Pine64 PinePhone (1.2)";
> + compatible = "pine64,pinephone-1.2", "allwinner,sun50i-a64";
> +};
> +
> + {
> + power-supply = <_ldo_io0>;
> + /*
> +  * PWM backlight circuit on this PinePhone revision was changed since 
> 1.0,
> +  * and the lowest PWM duty cycle that doesn't lead to backlight being 
> off
> +  * is around 10%. Duty cycle for the lowest brightness level also 
> varries
> +  * quite a bit between individual boards, so the lowest value here was
> +  * chosen as a safe default.
> +  */
> + brightness-levels = <
> + 5000 5248 5506 5858 6345
> + 6987 7805 8823 10062 11543
> + 13287 15317 17654 20319 23336
> + 26724 30505 34702 39335 44427
> + 5
> + >;
> + num-interpolated-steps = <50>;
> + default-brightness-level = <500>;
> +};
> +
> + {
> + /*
> +  * Board revision 1.2 fixed routing of the interrupt to DRDY pin,
> +  * enable interrupts.
> +  */
> + interrupt-parent = <>;
> + interrupts = <1 1 IRQ_TYPE_EDGE_RISING>; /* PB1 */
> +};
> diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi 
> b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
> index a3b400ff972b..904122711a89 100644
> --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
> +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
> @@ -142,7 +142,7 @@  {
>   status = "okay";
>  
>   /* Magnetometer */
> - lis3mdl@1e {
> + lis3mdl: lis3mdl@1e {

I just applied all three patches, but the node name here is wrong and
should be the class of the device.

Can you send a follow-up patch renaming the node name to magnetometer?

Thanks!
Maxime


signature.asc
Description: PGP signature


linux-next: manual merge of the pidfd tree with the csky tree

2020-07-05 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the pidfd tree got a conflict in:

  arch/csky/kernel/process.c

between commit:

  29adb883aa77 ("csky: remove unusued thread_saved_pc and *_segments 
functions/macros")

from the csky tree and commit:

  714acdbd1c94 ("arch: rename copy_thread_tls() back to copy_thread()")

from the pidfd tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/csky/kernel/process.c
index 3da63cf0bfde,28cfeaaf902a..
--- a/arch/csky/kernel/process.c
+++ b/arch/csky/kernel/process.c
@@@ -30,7 -30,17 +30,7 @@@ asmlinkage void ret_from_kernel_thread(
   */
  void flush_thread(void){}
  
- int copy_thread_tls(unsigned long clone_flags,
 -/*
 - * Return saved PC from a blocked thread
 - */
 -unsigned long thread_saved_pc(struct task_struct *tsk)
 -{
 -  struct switch_stack *sw = (struct switch_stack *)tsk->thread.sp;
 -
 -  return sw->r15;
 -}
 -
+ int copy_thread(unsigned long clone_flags,
unsigned long usp,
unsigned long kthread_arg,
struct task_struct *p,


pgpPPpPU6N7An.pgp
Description: OpenPGP digital signature


drivers/hwspinlock/omap_hwspinlock.c:165:34: warning: unused variable 'omap_hwspinlock_of_match'

2020-07-05 Thread kernel test robot
Hi Baolin,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   dcb7fd82c75ee2d6e6f9d8cc71c52519ed52e258
commit: ffd0bbfb378ecd56eac22bf932ccdbf89ac7f725 hwspinlock: Allow drivers to 
be built with COMPILE_TEST
date:   3 months ago
config: s390-randconfig-r022-20200706 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 
a378c0449507e00e96534ff9ce9034e185425182)
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
# install s390 cross compiling tool for clang build
# apt-get install binutils-s390x-linux-gnu
git checkout ffd0bbfb378ecd56eac22bf932ccdbf89ac7f725
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390 

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

All warnings (new ones prefixed by >>):

   In file included from arch/s390/include/asm/io.h:72:
   include/asm-generic/io.h:492:45: warning: performing pointer arithmetic on a 
null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   val = __le32_to_cpu(__raw_readl(PCI_IOBASE + addr));
   ~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro 
'__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
 ^
   include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
   ___constant_swab32(x) : \
  ^
   include/uapi/linux/swab.h:19:12: note: expanded from macro 
'___constant_swab32'
   (((__u32)(x) & (__u32)0x00ffUL) << 24) |\
 ^
   In file included from drivers/hwspinlock/omap_hwspinlock.c:16:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:72:
   include/asm-generic/io.h:492:45: warning: performing pointer arithmetic on a 
null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   val = __le32_to_cpu(__raw_readl(PCI_IOBASE + addr));
   ~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro 
'__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
 ^
   include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
   ___constant_swab32(x) : \
  ^
   include/uapi/linux/swab.h:20:12: note: expanded from macro 
'___constant_swab32'
   (((__u32)(x) & (__u32)0xff00UL) <<  8) |\
 ^
   In file included from drivers/hwspinlock/omap_hwspinlock.c:16:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:72:
   include/asm-generic/io.h:492:45: warning: performing pointer arithmetic on a 
null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   val = __le32_to_cpu(__raw_readl(PCI_IOBASE + addr));
   ~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro 
'__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
 ^
   include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
   ___constant_swab32(x) : \
  ^
   include/uapi/linux/swab.h:21:12: note: expanded from macro 
'___constant_swab32'
   (((__u32)(x) & (__u32)0x00ffUL) >>  8) |\
 ^
   In file included from drivers/hwspinlock/omap_hwspinlock.c:16:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:72:
   include/asm-generic/io.h:492:45: warning: performing pointer arithmetic on a 
null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   val = __le32_to_cpu(__raw_readl(PCI_IOBASE + addr));
   ~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro 
'__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
 ^
   include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
   ___constant_swab32(x) : \
  ^
   include/uapi/linux/swab.h:22:12: note: expanded from macro 
'___constant_swab32'
   (((__u32)(x) & (__u32)0xff00UL) >> 24)))
 ^
   In file included from 

linux-next: manual merge of the pidfd tree with the csky tree

2020-07-05 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the pidfd tree got a conflict in:

  arch/csky/Kconfig

between commit:

  f4dd2edafba0 ("csky: add support for SECCOMP and SECCOMP_FILTER")

from the csky tree and commit:

  140c8180eb7c ("arch: remove HAVE_COPY_THREAD_TLS")

from the pidfd tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/csky/Kconfig
index 822362d0598e,902f1142d550..
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@@ -38,8 -38,6 +38,7 @@@ config CSK
select GX6605S_TIMER if CPU_CK610
select HAVE_ARCH_TRACEHOOK
select HAVE_ARCH_AUDITSYSCALL
 +  select HAVE_ARCH_SECCOMP_FILTER
-   select HAVE_COPY_THREAD_TLS
select HAVE_DEBUG_BUGVERBOSE
select HAVE_DYNAMIC_FTRACE
select HAVE_DYNAMIC_FTRACE_WITH_REGS


pgplDhyTMF95f.pgp
Description: OpenPGP digital signature


Re: [PATCH v1] dmaengine: fsl-edma-common: correct DSIZE_32BYTE

2020-07-05 Thread Vinod Koul
On 30-06-20, 00:59, Robin Gong wrote:
> Correct EDMA_TCD_ATTR_DSIZE_32BYTE define since it's broken by the below:
> '0x0005 --> BIT(3) | BIT(0))'

Applied, thanks

-- 
~Vinod


[RFC v2 2/2] powerpc/powernv : Introduce capability for firmware-enabled-stop

2020-07-05 Thread Abhishek Goel
This patch introduces the capability for firmware to handle the stop
states instead. A bit is set based on the discovery of the feature
and correspondingly also the responsibility to handle the stop states.

If Kernel does not know about stop version, it can fallback to opal for
idle stop support if firmware-stop-supported property is present.

Earlier part of this patch was posted in this series :
https://lkml.org/lkml/2020/3/4/589

Signed-off-by: Abhishek Goel 
Signed-off-by: Pratik Rajesh Sampat 
---
v1->v2 : Combined patch 2 and 3 from previous iteration and rebased it.

 arch/powerpc/include/asm/processor.h  | 18 ++
 arch/powerpc/kernel/dt_cpu_ftrs.c | 13 +
 arch/powerpc/platforms/powernv/idle.c | 20 
 drivers/cpuidle/cpuidle-powernv.c |  3 ++-
 4 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/include/asm/processor.h 
b/arch/powerpc/include/asm/processor.h
index bfa336fbcfeb..b8de7146387c 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -428,6 +428,24 @@ extern void power4_idle_nap(void);
 extern unsigned long cpuidle_disable;
 enum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_POWERSAVE_OFF};
 
+#define STOP_ENABLE0x0001
+#define FIRMWARE_STOP_ENABLE   0x0010
+
+#define STOP_VERSION_P9   0x1
+
+/*
+ * Classify the dependencies of the stop states
+ * @idle_stop: function handler to handle the quirk stop version
+ * @cpuidle_prop: Signify support for stop states through kernel and/or 
firmware
+ * @stop_version: Classify quirk versions for stop states
+ */
+typedef struct {
+   unsigned long (*idle_stop)(unsigned long psscr, bool mmu_on);
+   uint8_t cpuidle_prop;
+   uint8_t stop_version;
+} stop_deps_t;
+extern stop_deps_t stop_dep;
+
 extern int powersave_nap;  /* set if nap mode can be used in idle loop */
 
 extern void power7_idle_type(unsigned long type);
diff --git a/arch/powerpc/kernel/dt_cpu_ftrs.c 
b/arch/powerpc/kernel/dt_cpu_ftrs.c
index 36bc0d5c4f3a..737686fae3c7 100644
--- a/arch/powerpc/kernel/dt_cpu_ftrs.c
+++ b/arch/powerpc/kernel/dt_cpu_ftrs.c
@@ -291,6 +291,15 @@ static int __init feat_enable_idle_stop(struct 
dt_cpu_feature *f)
lpcr |=  LPCR_PECE1;
lpcr |=  LPCR_PECE2;
mtspr(SPRN_LPCR, lpcr);
+   stop_dep.cpuidle_prop |= STOP_ENABLE;
+   stop_dep.stop_version = STOP_VERSION_P9;
+
+   return 1;
+}
+
+static int __init feat_enable_firmware_stop(struct dt_cpu_feature *f)
+{
+   stop_dep.cpuidle_prop |= FIRMWARE_STOP_ENABLE;
 
return 1;
 }
@@ -589,6 +598,7 @@ static struct dt_cpu_feature_match __initdata
{"idle-nap", feat_enable_idle_nap, 0},
{"alignment-interrupt-dsisr", feat_enable_align_dsisr, 0},
{"idle-stop", feat_enable_idle_stop, 0},
+   {"firmware-stop-supported", feat_enable_firmware_stop, 0},
{"machine-check-power8", feat_enable_mce_power8, 0},
{"performance-monitor-power8", feat_enable_pmu_power8, 0},
{"data-stream-control-register", feat_enable_dscr, CPU_FTR_DSCR},
@@ -656,6 +666,9 @@ static void __init cpufeatures_setup_start(u32 isa)
}
 }
 
+stop_deps_t stop_dep = {NULL, 0x0, 0x0};
+EXPORT_SYMBOL(stop_dep);
+
 static bool __init cpufeatures_process_feature(struct dt_cpu_feature *f)
 {
const struct dt_cpu_feature_match *m;
diff --git a/arch/powerpc/platforms/powernv/idle.c 
b/arch/powerpc/platforms/powernv/idle.c
index 3afd4293f729..3602950f6c08 100644
--- a/arch/powerpc/platforms/powernv/idle.c
+++ b/arch/powerpc/platforms/powernv/idle.c
@@ -824,7 +824,7 @@ static unsigned long power9_offline_stop(unsigned long 
psscr)
 
 #ifndef CONFIG_KVM_BOOK3S_HV_POSSIBLE
__ppc64_runlatch_off();
-   srr1 = power9_idle_stop(psscr, true);
+   srr1 = stop_dep.idle_stop(psscr, true);
__ppc64_runlatch_on();
 #else
/*
@@ -840,7 +840,7 @@ static unsigned long power9_offline_stop(unsigned long 
psscr)
local_paca->kvm_hstate.hwthread_state = KVM_HWTHREAD_IN_IDLE;
 
__ppc64_runlatch_off();
-   srr1 = power9_idle_stop(psscr, false);
+   srr1 = stop_dep.idle_stop(psscr, true);
__ppc64_runlatch_on();
 
local_paca->kvm_hstate.hwthread_state = KVM_HWTHREAD_IN_KERNEL;
@@ -868,7 +868,7 @@ void power9_idle_type(unsigned long stop_psscr_val,
psscr = (psscr & ~stop_psscr_mask) | stop_psscr_val;
 
__ppc64_runlatch_off();
-   srr1 = power9_idle_stop(psscr, true);
+   srr1 = stop_dep.idle_stop(psscr, true);
__ppc64_runlatch_on();
 
fini_irq_for_idle_irqsoff();
@@ -1365,8 +1365,20 @@ static int __init pnv_init_idle_states(void)
nr_pnv_idle_states = 0;
supported_cpuidle_states = 0;
 
-   if (cpuidle_disable != IDLE_NO_OVERRIDE)
+   if (cpuidle_disable != IDLE_NO_OVERRIDE ||
+   !(stop_dep.cpuidle_prop & STOP_ENABLE))
goto out;
+
+   /* Check for supported version 

[RFC v2 1/2] powerpc/powernv : Add support for pre-entry and post-exit of stop state using OPAL V4 OS services

2020-07-05 Thread Abhishek Goel
This patch provides kernel framework fro opal support of save restore
of sprs in idle stop loop. Opal support for stop states is needed to
selectively enable stop states or to introduce a quirk quickly in case
a buggy stop state is present.

We make a opal call from kernel if firmware-stop-support for stop
states is present and enabled. All the quirks for pre-entry of stop
state is handled inside opal. A call from opal is made into kernel
where we execute stop afer saving of NVGPRs.
After waking up from 0x100 vector in kernel, we enter back into opal.
All the quirks in post exit path, if any, are then handled in opal,
from where we return successfully back to kernel.

Signed-off-by: Abhishek Goel 
---
v1->v2 : Rebased the patch on Nick's Opal V4 OS patchset

 arch/powerpc/include/asm/opal-api.h|  4 +++-
 arch/powerpc/include/asm/opal.h|  1 +
 arch/powerpc/platforms/powernv/idle.c  | 12 
 arch/powerpc/platforms/powernv/opal-call.c |  1 +
 arch/powerpc/platforms/powernv/opal.c  | 15 +++
 5 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/opal-api.h 
b/arch/powerpc/include/asm/opal-api.h
index 97c5e5423827..437b6937685d 100644
--- a/arch/powerpc/include/asm/opal-api.h
+++ b/arch/powerpc/include/asm/opal-api.h
@@ -219,7 +219,8 @@
 #define OPAL_REPORT_TRAP   183
 #define OPAL_FIND_VM_AREA  184
 #define OPAL_REGISTER_OS_OPS   185
-#define OPAL_LAST  185
+#define OPAL_CPU_IDLE  186
+#define OPAL_LAST  186
 
 #define QUIESCE_HOLD   1 /* Spin all calls at entry */
 #define QUIESCE_REJECT 2 /* Fail all calls with OPAL_BUSY */
@@ -1207,6 +1208,7 @@ struct opal_os_ops {
__be64  os_printf; /* void printf(int32_t level, const char *str) */
__be64  os_vm_map; /* int64_t os_vm_map(uint64_t ea, uint64_t pa, 
uint64_t flags) */
__be64  os_vm_unmap; /* void os_vm_unmap(uint64_t ea) */
+   __be64  os_idle_stop; /* void os_idle_stop(uint64_t srr1_addr, uint64_t 
psscr) */
 };
 
 #endif /* __ASSEMBLY__ */
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 09985b7718b3..1774c056acb8 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -407,6 +407,7 @@ void opal_sensor_groups_init(void);
 
 int64_t opal_find_vm_area(uint64_t addr, struct opal_vm_area *opal_vm_area);
 int64_t opal_register_os_ops(struct opal_os_ops *ops, uint64_t size);
+int64_t opal_cpu_idle(uint64_t srr1_addr, uint64_t psscr);
 
 #endif /* __ASSEMBLY__ */
 
diff --git a/arch/powerpc/platforms/powernv/idle.c 
b/arch/powerpc/platforms/powernv/idle.c
index 78599bca66c2..3afd4293f729 100644
--- a/arch/powerpc/platforms/powernv/idle.c
+++ b/arch/powerpc/platforms/powernv/idle.c
@@ -805,6 +805,18 @@ static unsigned long power9_idle_stop(unsigned long psscr, 
bool mmu_on)
return srr1;
 }
 
+static unsigned long power9_firmware_idle_stop(unsigned long psscr, bool 
mmu_on)
+{
+   unsigned long srr1;
+   int rc;
+
+   rc = opal_cpu_idle(cpu_to_be64(), (uint64_t) psscr);
+
+   if (mmu_on)
+   mtmsr(MSR_KERNEL);
+   return srr1;
+}
+
 #ifdef CONFIG_HOTPLUG_CPU
 static unsigned long power9_offline_stop(unsigned long psscr)
 {
diff --git a/arch/powerpc/platforms/powernv/opal-call.c 
b/arch/powerpc/platforms/powernv/opal-call.c
index 11f419e76059..79076ca2de03 100644
--- a/arch/powerpc/platforms/powernv/opal-call.c
+++ b/arch/powerpc/platforms/powernv/opal-call.c
@@ -351,3 +351,4 @@ OPAL_CALL(opal_sym_to_addr, 
OPAL_SYM_TO_ADDR);
 OPAL_CALL(opal_report_trap,OPAL_REPORT_TRAP);
 OPAL_CALL(opal_find_vm_area,   OPAL_FIND_VM_AREA);
 OPAL_CALL(opal_register_os_ops,OPAL_REGISTER_OS_OPS);
+OPAL_CALL(opal_cpu_idle,   OPAL_CPU_IDLE);
diff --git a/arch/powerpc/platforms/powernv/opal.c 
b/arch/powerpc/platforms/powernv/opal.c
index 93b9afaf33b3..1fbf7065f918 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -1150,6 +1150,20 @@ static void os_vm_unmap(uint64_t ea)
local_flush_tlb_mm(mm);
 }
 
+int64_t os_idle_stop(uint64_t srr1_addr, uint64_t psscr)
+{
+   /*
+* For lite state which does not lose even GPRS we call
+* idle_stop_noloss while for all other states we call
+* idle_stop_mayloss. Saving and restoration of other additional
+* SPRs if required is handled in OPAL. All the quirks are also
+* handled in OPAL.
+*/
+   if (!(psscr & (PSSCR_EC|PSSCR_ESL)))
+   return isa300_idle_stop_noloss(psscr);
+   return isa300_idle_stop_mayloss(psscr);
+}
+
 static int __init opal_init_mm(void)
 {
struct mm_struct *mm;
@@ -1231,6 +1245,7 @@ static int __init opal_init_early(void)
  

Re: [PATCH] kbuild: make Clang build userprogs for target architecture

2020-07-05 Thread Miguel Ojeda
Hi Masahiro,

On Sun, Jul 5, 2020 at 5:30 PM Masahiro Yamada  wrote:
>
> Hmm, adding '#include ' did not make any difference.

That should have worked, because POSIX defines it to be there. It
sounds like you need --sysroot to point it to the proper ones.

> If I add -std=c99, I get a different error.

Yeah, that is the expected behavior. C99 does not have the implicit
int rule anymore (unlike older C) so ssize_t (an unknown type given
that program) is not being interpreted as int anymore (which is what
triggers the warning later about the mismatch between size_t and int
in the format string).

> In contrast, 'size_t' has no problem.

That is expected too, because size_t is defined via stdio.h (size_t is
a C standard type, ssize_t is not -- it is a POSIX one).

Hope that helps,

Cheers,
Miguel


Re: [PATCH 01/17] Documentation/driver-api: dmaengine/provider: drop doubled word

2020-07-05 Thread Vinod Koul
On 03-07-20, 20:44, Randy Dunlap wrote:
> Drop the doubled word "has".

Applied, thanks

> 
> Signed-off-by: Randy Dunlap 
> Cc: Jonathan Corbet 
> Cc: linux-...@vger.kernel.org
> Cc: Vinod Koul 
> Cc: dmaeng...@vger.kernel.org
> ---
>  Documentation/driver-api/dmaengine/provider.rst |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- linux-next-20200701.orig/Documentation/driver-api/dmaengine/provider.rst
> +++ linux-next-20200701/Documentation/driver-api/dmaengine/provider.rst
> @@ -507,7 +507,7 @@ dma_cookie_t
>  DMA_CTRL_ACK
>  
>  - If clear, the descriptor cannot be reused by provider until the
> -  client acknowledges receipt, i.e. has has a chance to establish any
> +  client acknowledges receipt, i.e. has a chance to establish any
>dependency chains
>  
>  - This can be acked by invoking async_tx_ack()

-- 
~Vinod


Re: linux-next: manual merge of the dmaengine tree with the dmaengine-fixes tree

2020-07-05 Thread Vinod Koul
On 05-07-20, 21:23, Dave Jiang wrote:
> 
> 
> On 7/5/2020 8:56 PM, Stephen Rothwell wrote:
> > Hi all,
> > 
> > Today's linux-next merge of the dmaengine tree got a conflict in:
> > 
> >drivers/dma/idxd/sysfs.c
> > 
> > between commit:
> > 
> >da32b28c95a7 ("dmaengine: idxd: cleanup workqueue config after 
> > disabling")
> > 
> > from the dmaengine-fixes tree and commit:
> > 
> >f50b150e315e ("dmaengine: idxd: add work queue drain support")
> > 
> > from the dmaengine tree.
> > 
> > I fixed it up (see below) and can carry the fix as necessary. This
> > is now fixed as far as linux-next is concerned, but any non trivial
> > conflicts should be mentioned to your upstream maintainer when your tree
> > is submitted for merging.  You may also want to consider cooperating
> > with the maintainer of the conflicting tree to minimise any particularly
> > complex conflicts.
> > 
> 
> Hi Stephen. Thanks for the fixup. I think there are two more bits that are
> needed from f50b150e315e if you don't mind adding:

I will merge the fixes into next so it should be resolved for tomorrow,
thanks

> 
> diff --cc drivers/dma/idxd/sysfs.c
> index 2e2c5082f322,6f0711a822a1..
> --- a/drivers/dma/idxd/sysfs.c
> +++ b/drivers/dma/idxd/sysfs.c
> @@@ -313,14 -303,7 +303,12 @@@ static int idxd_config_bus_remove(struc
>   }
> 
>   idxd_unregister_dma_device(idxd);
> - spin_lock_irqsave(>dev_lock, flags);
>   rc = idxd_device_disable(idxd);
>  +for (i = 0; i < idxd->max_wqs; i++) {
>  +struct idxd_wq *wq = >wqs[i];
>  +
> 
> > mutex_lock(>wq_lock);
> 
>  +idxd_wq_disable_cleanup(wq);
> 
> > mutex_unlock(>wq_lock);
> 
>  +}
> - spin_unlock_irqrestore(>dev_lock, flags);
>   module_put(THIS_MODULE);
>   if (rc < 0)
>   dev_warn(dev, "Device disable failed\n");

-- 
~Vinod


Re: [PATCH 0/7] Add initial Keem Bay SoC / Board support

2020-07-05 Thread Jassi Brar
On Tue, Jun 16, 2020 at 10:56 AM Daniele Alessandrelli
 wrote:
>
> Hi,
>
> This patch-set adds initial support for a new Intel Movidius SoC code-named
> Keem Bay. The SoC couples an ARM Cortex A53 CPU with an Intel Movidius VPU.
>
> This initial patch-set enables only the minimal set of components required to
> make the Keem Bay EVM board boot into initramfs.
>
> Brief summary of the patch-set:
> * Patches 1-2 add the Keem Bay SCMI Mailbox driver (needed to enable SCMI in
>   Keem Bay)
> * Patch 3 adds the ARCH_KEEMBAY config option
> * Patches 4-7 add minimal device tree for Keem Bay SoC and Keem Bay EVM
>   (together with information about the SoC maintainers)
>
Please break this into two patchsets - first enabling platform support
and second adding mailbox support.

thanks.


[PATCH v3 6/6] powerpc/qspinlock: optimised atomic_try_cmpxchg_lock that adds the lock hint

2020-07-05 Thread Nicholas Piggin
This brings the behaviour of the uncontended fast path back to
roughly equivalent to simple spinlocks -- a single atomic op with
lock hint.

Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/include/asm/atomic.h| 28 
 arch/powerpc/include/asm/qspinlock.h |  2 +-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/atomic.h 
b/arch/powerpc/include/asm/atomic.h
index 498785ffc25f..f6a3d145ffb7 100644
--- a/arch/powerpc/include/asm/atomic.h
+++ b/arch/powerpc/include/asm/atomic.h
@@ -193,6 +193,34 @@ static __inline__ int atomic_dec_return_relaxed(atomic_t 
*v)
 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
 #define atomic_xchg_relaxed(v, new) xchg_relaxed(&((v)->counter), (new))
 
+/*
+ * Don't want to override the generic atomic_try_cmpxchg_acquire, because
+ * we add a lock hint to the lwarx, which may not be wanted for the
+ * _acquire case (and is not used by the other _acquire variants so it
+ * would be a surprise).
+ */
+static __always_inline bool
+atomic_try_cmpxchg_lock(atomic_t *v, int *old, int new)
+{
+   int r, o = *old;
+
+   __asm__ __volatile__ (
+"1:\t" PPC_LWARX(%0,0,%2,1) "  # atomic_try_cmpxchg_acquire\n"
+"  cmpw0,%0,%3 \n"
+"  bne-2f  \n"
+"  stwcx.  %4,0,%2 \n"
+"  bne-1b  \n"
+"\t"   PPC_ACQUIRE_BARRIER "   \n"
+"2:\n"
+   : "=" (r), "+m" (v->counter)
+   : "r" (>counter), "r" (o), "r" (new)
+   : "cr0", "memory");
+
+   if (unlikely(r != o))
+   *old = r;
+   return likely(r == o);
+}
+
 /**
  * atomic_fetch_add_unless - add unless the number is a given value
  * @v: pointer of type atomic_t
diff --git a/arch/powerpc/include/asm/qspinlock.h 
b/arch/powerpc/include/asm/qspinlock.h
index f5066f00a08c..b752d34517b3 100644
--- a/arch/powerpc/include/asm/qspinlock.h
+++ b/arch/powerpc/include/asm/qspinlock.h
@@ -37,7 +37,7 @@ static __always_inline void queued_spin_lock(struct qspinlock 
*lock)
 {
u32 val = 0;
 
-   if (likely(atomic_try_cmpxchg_acquire(>val, , _Q_LOCKED_VAL)))
+   if (likely(atomic_try_cmpxchg_lock(>val, , _Q_LOCKED_VAL)))
return;
 
queued_spin_lock_slowpath(lock, val);
-- 
2.23.0



[PATCH v3 5/6] powerpc/pseries: implement paravirt qspinlocks for SPLPAR

2020-07-05 Thread Nicholas Piggin
Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/include/asm/paravirt.h   | 28 
 arch/powerpc/include/asm/qspinlock.h  | 66 +++
 arch/powerpc/include/asm/qspinlock_paravirt.h |  7 ++
 arch/powerpc/platforms/pseries/Kconfig|  5 ++
 arch/powerpc/platforms/pseries/setup.c|  6 +-
 include/asm-generic/qspinlock.h   |  2 +
 6 files changed, 113 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/include/asm/qspinlock_paravirt.h

diff --git a/arch/powerpc/include/asm/paravirt.h 
b/arch/powerpc/include/asm/paravirt.h
index 7a8546660a63..f2d51f929cf5 100644
--- a/arch/powerpc/include/asm/paravirt.h
+++ b/arch/powerpc/include/asm/paravirt.h
@@ -29,6 +29,16 @@ static inline void yield_to_preempted(int cpu, u32 
yield_count)
 {
plpar_hcall_norets(H_CONFER, get_hard_smp_processor_id(cpu), 
yield_count);
 }
+
+static inline void prod_cpu(int cpu)
+{
+   plpar_hcall_norets(H_PROD, get_hard_smp_processor_id(cpu));
+}
+
+static inline void yield_to_any(void)
+{
+   plpar_hcall_norets(H_CONFER, -1, 0);
+}
 #else
 static inline bool is_shared_processor(void)
 {
@@ -45,6 +55,19 @@ static inline void yield_to_preempted(int cpu, u32 
yield_count)
 {
___bad_yield_to_preempted(); /* This would be a bug */
 }
+
+extern void ___bad_yield_to_any(void);
+static inline void yield_to_any(void)
+{
+   ___bad_yield_to_any(); /* This would be a bug */
+}
+
+extern void ___bad_prod_cpu(void);
+static inline void prod_cpu(int cpu)
+{
+   ___bad_prod_cpu(); /* This would be a bug */
+}
+
 #endif
 
 #define vcpu_is_preempted vcpu_is_preempted
@@ -57,5 +80,10 @@ static inline bool vcpu_is_preempted(int cpu)
return false;
 }
 
+static inline bool pv_is_native_spin_unlock(void)
+{
+ return !is_shared_processor();
+}
+
 #endif /* __KERNEL__ */
 #endif /* __ASM_PARAVIRT_H */
diff --git a/arch/powerpc/include/asm/qspinlock.h 
b/arch/powerpc/include/asm/qspinlock.h
index c49e33e24edd..f5066f00a08c 100644
--- a/arch/powerpc/include/asm/qspinlock.h
+++ b/arch/powerpc/include/asm/qspinlock.h
@@ -3,9 +3,47 @@
 #define _ASM_POWERPC_QSPINLOCK_H
 
 #include 
+#include 
 
 #define _Q_PENDING_LOOPS   (1 << 9) /* not tuned */
 
+#ifdef CONFIG_PARAVIRT_SPINLOCKS
+extern void native_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
+extern void __pv_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
+extern void __pv_queued_spin_unlock(struct qspinlock *lock);
+
+static __always_inline void queued_spin_lock_slowpath(struct qspinlock *lock, 
u32 val)
+{
+   if (!is_shared_processor())
+   native_queued_spin_lock_slowpath(lock, val);
+   else
+   __pv_queued_spin_lock_slowpath(lock, val);
+}
+
+#define queued_spin_unlock queued_spin_unlock
+static inline void queued_spin_unlock(struct qspinlock *lock)
+{
+   if (!is_shared_processor())
+   smp_store_release(>locked, 0);
+   else
+   __pv_queued_spin_unlock(lock);
+}
+
+#else
+extern void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
+#endif
+
+static __always_inline void queued_spin_lock(struct qspinlock *lock)
+{
+   u32 val = 0;
+
+   if (likely(atomic_try_cmpxchg_acquire(>val, , _Q_LOCKED_VAL)))
+   return;
+
+   queued_spin_lock_slowpath(lock, val);
+}
+#define queued_spin_lock queued_spin_lock
+
 #define smp_mb__after_spinlock()   smp_mb()
 
 static __always_inline int queued_spin_is_locked(struct qspinlock *lock)
@@ -20,6 +58,34 @@ static __always_inline int queued_spin_is_locked(struct 
qspinlock *lock)
 }
 #define queued_spin_is_locked queued_spin_is_locked
 
+#ifdef CONFIG_PARAVIRT_SPINLOCKS
+#define SPIN_THRESHOLD (1<<15) /* not tuned */
+
+static __always_inline void pv_wait(u8 *ptr, u8 val)
+{
+   if (*ptr != val)
+   return;
+   yield_to_any();
+   /*
+* We could pass in a CPU here if waiting in the queue and yield to
+* the previous CPU in the queue.
+*/
+}
+
+static __always_inline void pv_kick(int cpu)
+{
+   prod_cpu(cpu);
+}
+
+extern void __pv_init_lock_hash(void);
+
+static inline void pv_spinlocks_init(void)
+{
+   __pv_init_lock_hash();
+}
+
+#endif
+
 #include 
 
 #endif /* _ASM_POWERPC_QSPINLOCK_H */
diff --git a/arch/powerpc/include/asm/qspinlock_paravirt.h 
b/arch/powerpc/include/asm/qspinlock_paravirt.h
new file mode 100644
index ..750d1b5e0202
--- /dev/null
+++ b/arch/powerpc/include/asm/qspinlock_paravirt.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef __ASM_QSPINLOCK_PARAVIRT_H
+#define __ASM_QSPINLOCK_PARAVIRT_H
+
+EXPORT_SYMBOL(__pv_queued_spin_unlock);
+
+#endif /* __ASM_QSPINLOCK_PARAVIRT_H */
diff --git a/arch/powerpc/platforms/pseries/Kconfig 
b/arch/powerpc/platforms/pseries/Kconfig
index 24c18362e5ea..756e727b383f 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -25,9 +25,14 @@ config 

[PATCH v3 3/6] powerpc: move spinlock implementation to simple_spinlock

2020-07-05 Thread Nicholas Piggin
To prepare for queued spinlocks. This is a simple rename except to update
preprocessor guard name and a file reference.

Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/include/asm/simple_spinlock.h| 292 ++
 .../include/asm/simple_spinlock_types.h   |  21 ++
 arch/powerpc/include/asm/spinlock.h   | 285 +
 arch/powerpc/include/asm/spinlock_types.h |  12 +-
 4 files changed, 315 insertions(+), 295 deletions(-)
 create mode 100644 arch/powerpc/include/asm/simple_spinlock.h
 create mode 100644 arch/powerpc/include/asm/simple_spinlock_types.h

diff --git a/arch/powerpc/include/asm/simple_spinlock.h 
b/arch/powerpc/include/asm/simple_spinlock.h
new file mode 100644
index ..e048c041c4a9
--- /dev/null
+++ b/arch/powerpc/include/asm/simple_spinlock.h
@@ -0,0 +1,292 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef __ASM_SIMPLE_SPINLOCK_H
+#define __ASM_SIMPLE_SPINLOCK_H
+#ifdef __KERNEL__
+
+/*
+ * Simple spin lock operations.  
+ *
+ * Copyright (C) 2001-2004 Paul Mackerras , IBM
+ * Copyright (C) 2001 Anton Blanchard , IBM
+ * Copyright (C) 2002 Dave Engebretsen , IBM
+ * Rework to support virtual processors
+ *
+ * Type of int is used as a full 64b word is not necessary.
+ *
+ * (the type definitions are in asm/simple_spinlock_types.h)
+ */
+#include 
+#include 
+#ifdef CONFIG_PPC64
+#include 
+#endif
+#include 
+#include 
+
+#ifdef CONFIG_PPC64
+/* use 0x80yy when locked, where yy == CPU number */
+#ifdef __BIG_ENDIAN__
+#define LOCK_TOKEN (*(u32 *)(_paca()->lock_token))
+#else
+#define LOCK_TOKEN (*(u32 *)(_paca()->paca_index))
+#endif
+#else
+#define LOCK_TOKEN 1
+#endif
+
+static __always_inline int arch_spin_value_unlocked(arch_spinlock_t lock)
+{
+   return lock.slock == 0;
+}
+
+static inline int arch_spin_is_locked(arch_spinlock_t *lock)
+{
+   smp_mb();
+   return !arch_spin_value_unlocked(*lock);
+}
+
+/*
+ * This returns the old value in the lock, so we succeeded
+ * in getting the lock if the return value is 0.
+ */
+static inline unsigned long __arch_spin_trylock(arch_spinlock_t *lock)
+{
+   unsigned long tmp, token;
+
+   token = LOCK_TOKEN;
+   __asm__ __volatile__(
+"1:" PPC_LWARX(%0,0,%2,1) "\n\
+   cmpwi   0,%0,0\n\
+   bne-2f\n\
+   stwcx.  %1,0,%2\n\
+   bne-1b\n"
+   PPC_ACQUIRE_BARRIER
+"2:"
+   : "=" (tmp)
+   : "r" (token), "r" (>slock)
+   : "cr0", "memory");
+
+   return tmp;
+}
+
+static inline int arch_spin_trylock(arch_spinlock_t *lock)
+{
+   return __arch_spin_trylock(lock) == 0;
+}
+
+/*
+ * On a system with shared processors (that is, where a physical
+ * processor is multiplexed between several virtual processors),
+ * there is no point spinning on a lock if the holder of the lock
+ * isn't currently scheduled on a physical processor.  Instead
+ * we detect this situation and ask the hypervisor to give the
+ * rest of our timeslice to the lock holder.
+ *
+ * So that we can tell which virtual processor is holding a lock,
+ * we put 0x8000 | smp_processor_id() in the lock when it is
+ * held.  Conveniently, we have a word in the paca that holds this
+ * value.
+ */
+
+#if defined(CONFIG_PPC_SPLPAR)
+/* We only yield to the hypervisor if we are in shared processor mode */
+void splpar_spin_yield(arch_spinlock_t *lock);
+void splpar_rw_yield(arch_rwlock_t *lock);
+#else /* SPLPAR */
+static inline void splpar_spin_yield(arch_spinlock_t *lock) {};
+static inline void splpar_rw_yield(arch_rwlock_t *lock) {};
+#endif
+
+static inline void spin_yield(arch_spinlock_t *lock)
+{
+   if (is_shared_processor())
+   splpar_spin_yield(lock);
+   else
+   barrier();
+}
+
+static inline void rw_yield(arch_rwlock_t *lock)
+{
+   if (is_shared_processor())
+   splpar_rw_yield(lock);
+   else
+   barrier();
+}
+
+static inline void arch_spin_lock(arch_spinlock_t *lock)
+{
+   while (1) {
+   if (likely(__arch_spin_trylock(lock) == 0))
+   break;
+   do {
+   HMT_low();
+   if (is_shared_processor())
+   splpar_spin_yield(lock);
+   } while (unlikely(lock->slock != 0));
+   HMT_medium();
+   }
+}
+
+static inline
+void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
+{
+   unsigned long flags_dis;
+
+   while (1) {
+   if (likely(__arch_spin_trylock(lock) == 0))
+   break;
+   local_save_flags(flags_dis);
+   local_irq_restore(flags);
+   do {
+   HMT_low();
+   if (is_shared_processor())
+   splpar_spin_yield(lock);
+   } while (unlikely(lock->slock != 0));
+   HMT_medium();
+   

[PATCH v3 4/6] powerpc/64s: implement queued spinlocks and rwlocks

2020-07-05 Thread Nicholas Piggin
These have shown significantly improved performance and fairness when
spinlock contention is moderate to high on very large systems.

 [ Numbers hopefully forthcoming after more testing, but initial
   results look good ]

Thanks to the fast path, single threaded performance is not noticably
hurt.

Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/Kconfig  | 13 
 arch/powerpc/include/asm/Kbuild   |  2 ++
 arch/powerpc/include/asm/qspinlock.h  | 25 +++
 arch/powerpc/include/asm/spinlock.h   |  5 +
 arch/powerpc/include/asm/spinlock_types.h |  5 +
 arch/powerpc/lib/Makefile |  3 +++
 include/asm-generic/qspinlock.h   |  2 ++
 7 files changed, 55 insertions(+)
 create mode 100644 arch/powerpc/include/asm/qspinlock.h

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 24ac85c868db..17663ea57697 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -146,6 +146,8 @@ config PPC
select ARCH_SUPPORTS_ATOMIC_RMW
select ARCH_USE_BUILTIN_BSWAP
select ARCH_USE_CMPXCHG_LOCKREF if PPC64
+   select ARCH_USE_QUEUED_RWLOCKS  if PPC_QUEUED_SPINLOCKS
+   select ARCH_USE_QUEUED_SPINLOCKSif PPC_QUEUED_SPINLOCKS
select ARCH_WANT_IPC_PARSE_VERSION
select ARCH_WEAK_RELEASE_ACQUIRE
select BINFMT_ELF
@@ -492,6 +494,17 @@ config HOTPLUG_CPU
 
  Say N if you are unsure.
 
+config PPC_QUEUED_SPINLOCKS
+   bool "Queued spinlocks"
+   depends on SMP
+   default "y" if PPC_BOOK3S_64
+   help
+ Say Y here to use to use queued spinlocks which are more complex
+ but give better salability and fairness on large SMP and NUMA
+ systems.
+
+ If unsure, say "Y" if you have lots of cores, otherwise "N".
+
 config ARCH_CPU_PROBE_RELEASE
def_bool y
depends on HOTPLUG_CPU
diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild
index dadbcf3a0b1e..1dd8b6adff5e 100644
--- a/arch/powerpc/include/asm/Kbuild
+++ b/arch/powerpc/include/asm/Kbuild
@@ -6,5 +6,7 @@ generated-y += syscall_table_spu.h
 generic-y += export.h
 generic-y += local64.h
 generic-y += mcs_spinlock.h
+generic-y += qrwlock.h
+generic-y += qspinlock.h
 generic-y += vtime.h
 generic-y += early_ioremap.h
diff --git a/arch/powerpc/include/asm/qspinlock.h 
b/arch/powerpc/include/asm/qspinlock.h
new file mode 100644
index ..c49e33e24edd
--- /dev/null
+++ b/arch/powerpc/include/asm/qspinlock.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_POWERPC_QSPINLOCK_H
+#define _ASM_POWERPC_QSPINLOCK_H
+
+#include 
+
+#define _Q_PENDING_LOOPS   (1 << 9) /* not tuned */
+
+#define smp_mb__after_spinlock()   smp_mb()
+
+static __always_inline int queued_spin_is_locked(struct qspinlock *lock)
+{
+   /*
+* This barrier was added to simple spinlocks by commit 51d7d5205d338,
+* but it should now be possible to remove it, asm arm64 has done with
+* commit c6f5d02b6a0f.
+*/
+   smp_mb();
+   return atomic_read(>val);
+}
+#define queued_spin_is_locked queued_spin_is_locked
+
+#include 
+
+#endif /* _ASM_POWERPC_QSPINLOCK_H */
diff --git a/arch/powerpc/include/asm/spinlock.h 
b/arch/powerpc/include/asm/spinlock.h
index 21357fe05fe0..434615f1d761 100644
--- a/arch/powerpc/include/asm/spinlock.h
+++ b/arch/powerpc/include/asm/spinlock.h
@@ -3,7 +3,12 @@
 #define __ASM_SPINLOCK_H
 #ifdef __KERNEL__
 
+#ifdef CONFIG_PPC_QUEUED_SPINLOCKS
+#include 
+#include 
+#else
 #include 
+#endif
 
 #endif /* __KERNEL__ */
 #endif /* __ASM_SPINLOCK_H */
diff --git a/arch/powerpc/include/asm/spinlock_types.h 
b/arch/powerpc/include/asm/spinlock_types.h
index 3906f52dae65..c5d742f18021 100644
--- a/arch/powerpc/include/asm/spinlock_types.h
+++ b/arch/powerpc/include/asm/spinlock_types.h
@@ -6,6 +6,11 @@
 # error "please don't include this file directly"
 #endif
 
+#ifdef CONFIG_PPC_QUEUED_SPINLOCKS
+#include 
+#include 
+#else
 #include 
+#endif
 
 #endif
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 5e994cda8e40..d66a645503eb 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -41,7 +41,10 @@ obj-$(CONFIG_PPC_BOOK3S_64) += copyuser_power7.o 
copypage_power7.o \
 obj64-y+= copypage_64.o copyuser_64.o mem_64.o hweight_64.o \
   memcpy_64.o memcpy_mcsafe_64.o
 
+ifndef CONFIG_PPC_QUEUED_SPINLOCKS
 obj64-$(CONFIG_SMP)+= locks.o
+endif
+
 obj64-$(CONFIG_ALTIVEC)+= vmx-helper.o
 obj64-$(CONFIG_KPROBES_SANITY_TEST)+= test_emulate_step.o \
   test_emulate_step_exec_instr.o
diff --git a/include/asm-generic/qspinlock.h b/include/asm-generic/qspinlock.h
index fde943d180e0..fb0a814d4395 100644
--- a/include/asm-generic/qspinlock.h
+++ b/include/asm-generic/qspinlock.h
@@ -12,6 +12,7 @@
 
 #include 
 
+#ifndef queued_spin_is_locked
 /**
  * 

[PATCH v3 2/6] powerpc/pseries: move some PAPR paravirt functions to their own file

2020-07-05 Thread Nicholas Piggin
Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/include/asm/paravirt.h | 61 +
 arch/powerpc/include/asm/spinlock.h | 24 +---
 arch/powerpc/lib/locks.c| 12 +++---
 3 files changed, 68 insertions(+), 29 deletions(-)
 create mode 100644 arch/powerpc/include/asm/paravirt.h

diff --git a/arch/powerpc/include/asm/paravirt.h 
b/arch/powerpc/include/asm/paravirt.h
new file mode 100644
index ..7a8546660a63
--- /dev/null
+++ b/arch/powerpc/include/asm/paravirt.h
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef __ASM_PARAVIRT_H
+#define __ASM_PARAVIRT_H
+#ifdef __KERNEL__
+
+#include 
+#include 
+#ifdef CONFIG_PPC64
+#include 
+#include 
+#endif
+
+#ifdef CONFIG_PPC_SPLPAR
+DECLARE_STATIC_KEY_FALSE(shared_processor);
+
+static inline bool is_shared_processor(void)
+{
+   return static_branch_unlikely(_processor);
+}
+
+/* If bit 0 is set, the cpu has been preempted */
+static inline u32 yield_count_of(int cpu)
+{
+   __be32 yield_count = READ_ONCE(lppaca_of(cpu).yield_count);
+   return be32_to_cpu(yield_count);
+}
+
+static inline void yield_to_preempted(int cpu, u32 yield_count)
+{
+   plpar_hcall_norets(H_CONFER, get_hard_smp_processor_id(cpu), 
yield_count);
+}
+#else
+static inline bool is_shared_processor(void)
+{
+   return false;
+}
+
+static inline u32 yield_count_of(int cpu)
+{
+   return 0;
+}
+
+extern void ___bad_yield_to_preempted(void);
+static inline void yield_to_preempted(int cpu, u32 yield_count)
+{
+   ___bad_yield_to_preempted(); /* This would be a bug */
+}
+#endif
+
+#define vcpu_is_preempted vcpu_is_preempted
+static inline bool vcpu_is_preempted(int cpu)
+{
+   if (!is_shared_processor())
+   return false;
+   if (yield_count_of(cpu) & 1)
+   return true;
+   return false;
+}
+
+#endif /* __KERNEL__ */
+#endif /* __ASM_PARAVIRT_H */
diff --git a/arch/powerpc/include/asm/spinlock.h 
b/arch/powerpc/include/asm/spinlock.h
index 2d620896cdae..79be9bb10bbb 100644
--- a/arch/powerpc/include/asm/spinlock.h
+++ b/arch/powerpc/include/asm/spinlock.h
@@ -15,11 +15,10 @@
  *
  * (the type definitions are in asm/spinlock_types.h)
  */
-#include 
 #include 
+#include 
 #ifdef CONFIG_PPC64
 #include 
-#include 
 #endif
 #include 
 #include 
@@ -35,18 +34,6 @@
 #define LOCK_TOKEN 1
 #endif
 
-#ifdef CONFIG_PPC_PSERIES
-DECLARE_STATIC_KEY_FALSE(shared_processor);
-
-#define vcpu_is_preempted vcpu_is_preempted
-static inline bool vcpu_is_preempted(int cpu)
-{
-   if (!static_branch_unlikely(_processor))
-   return false;
-   return !!(be32_to_cpu(lppaca_of(cpu).yield_count) & 1);
-}
-#endif
-
 static __always_inline int arch_spin_value_unlocked(arch_spinlock_t lock)
 {
return lock.slock == 0;
@@ -110,15 +97,6 @@ static inline void splpar_spin_yield(arch_spinlock_t *lock) 
{};
 static inline void splpar_rw_yield(arch_rwlock_t *lock) {};
 #endif
 
-static inline bool is_shared_processor(void)
-{
-#ifdef CONFIG_PPC_SPLPAR
-   return static_branch_unlikely(_processor);
-#else
-   return false;
-#endif
-}
-
 static inline void spin_yield(arch_spinlock_t *lock)
 {
if (is_shared_processor())
diff --git a/arch/powerpc/lib/locks.c b/arch/powerpc/lib/locks.c
index 6440d5943c00..04165b7a163f 100644
--- a/arch/powerpc/lib/locks.c
+++ b/arch/powerpc/lib/locks.c
@@ -27,14 +27,14 @@ void splpar_spin_yield(arch_spinlock_t *lock)
return;
holder_cpu = lock_value & 0x;
BUG_ON(holder_cpu >= NR_CPUS);
-   yield_count = be32_to_cpu(lppaca_of(holder_cpu).yield_count);
+
+   yield_count = yield_count_of(holder_cpu);
if ((yield_count & 1) == 0)
return; /* virtual cpu is currently running */
rmb();
if (lock->slock != lock_value)
return; /* something has changed */
-   plpar_hcall_norets(H_CONFER,
-   get_hard_smp_processor_id(holder_cpu), yield_count);
+   yield_to_preempted(holder_cpu, yield_count);
 }
 EXPORT_SYMBOL_GPL(splpar_spin_yield);
 
@@ -53,13 +53,13 @@ void splpar_rw_yield(arch_rwlock_t *rw)
return; /* no write lock at present */
holder_cpu = lock_value & 0x;
BUG_ON(holder_cpu >= NR_CPUS);
-   yield_count = be32_to_cpu(lppaca_of(holder_cpu).yield_count);
+
+   yield_count = yield_count_of(holder_cpu);
if ((yield_count & 1) == 0)
return; /* virtual cpu is currently running */
rmb();
if (rw->lock != lock_value)
return; /* something has changed */
-   plpar_hcall_norets(H_CONFER,
-   get_hard_smp_processor_id(holder_cpu), yield_count);
+   yield_to_preempted(holder_cpu, yield_count);
 }
 #endif
-- 
2.23.0



Re: [PATCH 0/2] PCI: dwc: Add support to handle prefetchable memory separately

2020-07-05 Thread Vidya Sagar




On 18-Jun-20 12:26 AM, Vidya Sagar wrote:



On 02-Jun-20 10:37 PM, Gustavo Pimentel wrote:

External email: Use caution opening links or attachments


On Tue, Jun 2, 2020 at 11:9:38, Vidya Sagar  wrote:


In this patch series,
Patch-1
adds required infrastructure to deal with prefetchable memory region
information coming from 'ranges' property of the respective 
device-tree node

separately from non-prefetchable memory region information.
Patch-2
Adds support to use ATU region-3 for establishing the mapping between 
CPU

addresses and PCIe bus addresses.
It also changes the logic to determine whether mapping is required or 
not by

checking both CPU address and PCIe bus address for both prefetchable and
non-prefetchable regions. If the addresses are same, then, it is 
understood

that 1:1 mapping is in place and there is no need to setup ATU mapping
whereas if the addresses are not the same, then, there is a need to 
setup ATU
mapping. This is certainly true for Tegra194 and what I heard from 
our HW
engineers is that it should generally be true for any DWC based 
implementation

also.
Hence, I request Synopsys folks (Jingoo Han & Gustavo Pimentel ??) to 
confirm
the same so that this particular patch won't cause any regressions 
for other

DWC based platforms.


Hi Vidya,

Unfortunately due to the COVID-19 lockdown, I can't access my development
prototype setup to test your patch.
It might take some while until I get the possibility to get access to it
again.

Hi Gustavo,
Did you find time to check this?
Adding Kishon and Alan as well to take a look at this and verify on 
their platforms if possible.
Hi Kishon and Alan, did you find time to verify this on your respective 
platforms?


Thanks,
Vidya Sagar


Thanks,
Vidya Sagar



-Gustavo



Vidya Sagar (2):
   PCI: dwc: Add support to handle prefetchable memory separately
   PCI: dwc: Use ATU region to map prefetchable memory region

  .../pci/controller/dwc/pcie-designware-host.c | 46 ++-
  drivers/pci/controller/dwc/pcie-designware.c  |  6 ++-
  drivers/pci/controller/dwc/pcie-designware.h  |  8 +++-
  3 files changed, 45 insertions(+), 15 deletions(-)

--
2.17.1





[PATCH v3 1/6] powerpc/powernv: must include hvcall.h to get PAPR defines

2020-07-05 Thread Nicholas Piggin
An include goes away in future patches which breaks compilation
without this.

Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/platforms/powernv/pci-ioda-tce.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda-tce.c 
b/arch/powerpc/platforms/powernv/pci-ioda-tce.c
index f923359d8afc..8eba6ece7808 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda-tce.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda-tce.c
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include  /* share error returns with PAPR */
 #include "pci.h"
 
 unsigned long pnv_ioda_parse_tce_sizes(struct pnv_phb *phb)
-- 
2.23.0



[PATCH v3 0/6] powerpc: queued spinlocks and rwlocks

2020-07-05 Thread Nicholas Piggin
v3 is updated to use __pv_queued_spin_unlock, noticed by Waiman (thank you).

Thanks,
Nick

Nicholas Piggin (6):
  powerpc/powernv: must include hvcall.h to get PAPR defines
  powerpc/pseries: move some PAPR paravirt functions to their own file
  powerpc: move spinlock implementation to simple_spinlock
  powerpc/64s: implement queued spinlocks and rwlocks
  powerpc/pseries: implement paravirt qspinlocks for SPLPAR
  powerpc/qspinlock: optimised atomic_try_cmpxchg_lock that adds the
lock hint

 arch/powerpc/Kconfig  |  13 +
 arch/powerpc/include/asm/Kbuild   |   2 +
 arch/powerpc/include/asm/atomic.h |  28 ++
 arch/powerpc/include/asm/paravirt.h   |  89 +
 arch/powerpc/include/asm/qspinlock.h  |  91 ++
 arch/powerpc/include/asm/qspinlock_paravirt.h |   7 +
 arch/powerpc/include/asm/simple_spinlock.h| 292 +
 .../include/asm/simple_spinlock_types.h   |  21 ++
 arch/powerpc/include/asm/spinlock.h   | 308 +-
 arch/powerpc/include/asm/spinlock_types.h |  17 +-
 arch/powerpc/lib/Makefile |   3 +
 arch/powerpc/lib/locks.c  |  12 +-
 arch/powerpc/platforms/powernv/pci-ioda-tce.c |   1 +
 arch/powerpc/platforms/pseries/Kconfig|   5 +
 arch/powerpc/platforms/pseries/setup.c|   6 +-
 include/asm-generic/qspinlock.h   |   4 +
 16 files changed, 577 insertions(+), 322 deletions(-)
 create mode 100644 arch/powerpc/include/asm/paravirt.h
 create mode 100644 arch/powerpc/include/asm/qspinlock.h
 create mode 100644 arch/powerpc/include/asm/qspinlock_paravirt.h
 create mode 100644 arch/powerpc/include/asm/simple_spinlock.h
 create mode 100644 arch/powerpc/include/asm/simple_spinlock_types.h

-- 
2.23.0



[PATCH net-next v2 0/3] net: ethtool: Untangle PHYLIB dependency

2020-07-05 Thread Florian Fainelli
Hi all,

This patch series untangles the ethtool netlink dependency with PHYLIB
which exists because the cable test feature calls directly into PHY
library functions. The approach taken here is to introduce
ethtool_phy_ops function pointers which can be dynamically registered
when PHYLIB loads.

Florian Fainelli (3):
  net: ethtool: Introduce ethtool_phy_ops
  net: phy: Register ethtool PHY operations
  net: ethtool: Remove PHYLIB direct dependency

 drivers/net/phy/phy_device.c |  7 +++
 include/linux/ethtool.h  | 25 +
 net/Kconfig  |  1 -
 net/ethtool/cabletest.c  | 18 --
 net/ethtool/common.c | 11 +++
 net/ethtool/common.h |  2 ++
 6 files changed, 61 insertions(+), 3 deletions(-)

-- 
2.25.1



[PATCH net-next v2 2/3] net: phy: Register ethtool PHY operations

2020-07-05 Thread Florian Fainelli
Utilize ethtool_set_ethtool_phy_ops to register a suitable set of PHY
ethtool operations in a dynamic fashion such that ethtool will no longer
directy reference PHY library symbols.

Signed-off-by: Florian Fainelli 
---
 drivers/net/phy/phy_device.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index eb1068a77ce1..94a5aa30b70f 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3029,6 +3029,11 @@ static struct phy_driver genphy_driver = {
.set_loopback   = genphy_loopback,
 };
 
+static const struct ethtool_phy_ops phy_ethtool_phy_ops = {
+   .start_cable_test   = phy_start_cable_test,
+   .start_cable_test_tdr   = phy_start_cable_test_tdr,
+};
+
 static int __init phy_init(void)
 {
int rc;
@@ -3037,6 +3042,7 @@ static int __init phy_init(void)
if (rc)
return rc;
 
+   ethtool_set_ethtool_phy_ops(_ethtool_phy_ops);
features_init();
 
rc = phy_driver_register(_c45_driver, THIS_MODULE);
@@ -3058,6 +3064,7 @@ static void __exit phy_exit(void)
phy_driver_unregister(_c45_driver);
phy_driver_unregister(_driver);
mdio_bus_exit();
+   ethtool_set_ethtool_phy_ops(NULL);
 }
 
 subsys_initcall(phy_init);
-- 
2.25.1



[PATCH net-next v2 3/3] net: ethtool: Remove PHYLIB direct dependency

2020-07-05 Thread Florian Fainelli
Now that we have introduced ethtool_phy_ops and the PHY library
dynamically registers its operations with that function pointer, we can
remove the direct PHYLIB dependency in favor of using dynamic
operations.

Signed-off-by: Florian Fainelli 
---
 net/Kconfig |  1 -
 net/ethtool/cabletest.c | 18 --
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/net/Kconfig b/net/Kconfig
index d1672280d6a4..3831206977a1 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -455,7 +455,6 @@ config FAILOVER
 config ETHTOOL_NETLINK
bool "Netlink interface for ethtool"
default y
-   depends on PHYLIB=y || PHYLIB=n
help
  An alternative userspace interface for ethtool based on generic
  netlink. It provides better extensibility and some new features,
diff --git a/net/ethtool/cabletest.c b/net/ethtool/cabletest.c
index 7194956aa09e..4f9fbdf7610c 100644
--- a/net/ethtool/cabletest.c
+++ b/net/ethtool/cabletest.c
@@ -58,6 +58,7 @@ int ethnl_act_cable_test(struct sk_buff *skb, struct 
genl_info *info)
 {
struct nlattr *tb[ETHTOOL_A_CABLE_TEST_MAX + 1];
struct ethnl_req_info req_info = {};
+   const struct ethtool_phy_ops *ops;
struct net_device *dev;
int ret;
 
@@ -81,11 +82,17 @@ int ethnl_act_cable_test(struct sk_buff *skb, struct 
genl_info *info)
}
 
rtnl_lock();
+   ops = ethtool_phy_ops;
+   if (!ops || !ops->start_cable_test) {
+   ret = -EOPNOTSUPP;
+   goto out_rtnl;
+   }
+
ret = ethnl_ops_begin(dev);
if (ret < 0)
goto out_rtnl;
 
-   ret = phy_start_cable_test(dev->phydev, info->extack);
+   ret = ops->start_cable_test(dev->phydev, info->extack);
 
ethnl_ops_complete(dev);
 
@@ -308,6 +315,7 @@ int ethnl_act_cable_test_tdr(struct sk_buff *skb, struct 
genl_info *info)
 {
struct nlattr *tb[ETHTOOL_A_CABLE_TEST_TDR_MAX + 1];
struct ethnl_req_info req_info = {};
+   const struct ethtool_phy_ops *ops;
struct phy_tdr_config cfg;
struct net_device *dev;
int ret;
@@ -337,11 +345,17 @@ int ethnl_act_cable_test_tdr(struct sk_buff *skb, struct 
genl_info *info)
goto out_dev_put;
 
rtnl_lock();
+   ops = ethtool_phy_ops;
+   if (!ops || !ops->start_cable_test_tdr) {
+   ret = -EOPNOTSUPP;
+   goto out_rtnl;
+   }
+
ret = ethnl_ops_begin(dev);
if (ret < 0)
goto out_rtnl;
 
-   ret = phy_start_cable_test_tdr(dev->phydev, info->extack, );
+   ret = ops->start_cable_test_tdr(dev->phydev, info->extack, );
 
ethnl_ops_complete(dev);
 
-- 
2.25.1



[PATCH net-next v2 1/3] net: ethtool: Introduce ethtool_phy_ops

2020-07-05 Thread Florian Fainelli
In order to decouple ethtool from its PHY library dependency, define an
ethtool_phy_ops singleton which can be overriden by the PHY library when
it loads with an appropriate set of function pointers.

Signed-off-by: Florian Fainelli 
---
 include/linux/ethtool.h | 25 +
 net/ethtool/common.c| 11 +++
 net/ethtool/common.h|  2 ++
 3 files changed, 38 insertions(+)

diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 48ad3b6a0150..0c139a93b67a 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -502,5 +502,30 @@ int ethtool_virtdev_set_link_ksettings(struct net_device 
*dev,
   const struct ethtool_link_ksettings *cmd,
   u32 *dev_speed, u8 *dev_duplex);
 
+struct netlink_ext_ack;
+struct phy_device;
+struct phy_tdr_config;
+
+/**
+ * struct ethtool_phy_ops - Optional PHY device options
+ * @start_cable_test - Start a cable test
+ * @start_cable_test_tdr - Start a Time Domain Reflectometry cable test
+ *
+ * All operations are optional (i.e. the function pointer may be set to %NULL)
+ * and callers must take this into account. Callers must hold the RTNL lock.
+ */
+struct ethtool_phy_ops {
+   int (*start_cable_test)(struct phy_device *phydev,
+   struct netlink_ext_ack *extack);
+   int (*start_cable_test_tdr)(struct phy_device *phydev,
+   struct netlink_ext_ack *extack,
+   const struct phy_tdr_config *config);
+};
+
+/**
+ * ethtool_set_ethtool_phy_ops - Set the ethtool_phy_ops singleton
+ * @ops: Ethtool PHY operations to set
+ */
+void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops);
 
 #endif /* _LINUX_ETHTOOL_H */
diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index aaecfc916a4d..ce4dbae5a943 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -2,6 +2,7 @@
 
 #include 
 #include 
+#include 
 
 #include "common.h"
 
@@ -373,3 +374,13 @@ int __ethtool_get_ts_info(struct net_device *dev, struct 
ethtool_ts_info *info)
 
return 0;
 }
+
+const struct ethtool_phy_ops *ethtool_phy_ops;
+
+void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops)
+{
+   rtnl_lock();
+   ethtool_phy_ops = ops;
+   rtnl_unlock();
+}
+EXPORT_SYMBOL_GPL(ethtool_set_ethtool_phy_ops);
diff --git a/net/ethtool/common.h b/net/ethtool/common.h
index a62f68ccc43a..b83bef38368c 100644
--- a/net/ethtool/common.h
+++ b/net/ethtool/common.h
@@ -37,4 +37,6 @@ bool convert_legacy_settings_to_link_ksettings(
 int ethtool_get_max_rxfh_channel(struct net_device *dev, u32 *max);
 int __ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info 
*info);
 
+extern const struct ethtool_phy_ops *ethtool_phy_ops;
+
 #endif /* _ETHTOOL_COMMON_H */
-- 
2.25.1



Re: linux-next: manual merge of the dmaengine tree with the dmaengine-fixes tree

2020-07-05 Thread Dave Jiang




On 7/5/2020 8:56 PM, Stephen Rothwell wrote:

Hi all,

Today's linux-next merge of the dmaengine tree got a conflict in:

   drivers/dma/idxd/sysfs.c

between commit:

   da32b28c95a7 ("dmaengine: idxd: cleanup workqueue config after disabling")

from the dmaengine-fixes tree and commit:

   f50b150e315e ("dmaengine: idxd: add work queue drain support")

from the dmaengine tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.



Hi Stephen. Thanks for the fixup. I think there are two more bits that are 
needed from f50b150e315e if you don't mind adding:


diff --cc drivers/dma/idxd/sysfs.c
index 2e2c5082f322,6f0711a822a1..
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@@ -313,14 -303,7 +303,12 @@@ static int idxd_config_bus_remove(struc
}

idxd_unregister_dma_device(idxd);
-   spin_lock_irqsave(>dev_lock, flags);
rc = idxd_device_disable(idxd);
 +  for (i = 0; i < idxd->max_wqs; i++) {
 +  struct idxd_wq *wq = >wqs[i];
 +

>mutex_lock(>wq_lock);

 +  idxd_wq_disable_cleanup(wq);

>mutex_unlock(>wq_lock);

 +  }
-   spin_unlock_irqrestore(>dev_lock, flags);
module_put(THIS_MODULE);
if (rc < 0)
dev_warn(dev, "Device disable failed\n");


Re: [tip: x86/urgent] x86/entry/32: Fix XEN_PV build dependency

2020-07-05 Thread Jürgen Groß

On 05.07.20 22:24, Andy Lutomirski wrote:




On Jul 5, 2020, at 12:44 PM, tip-bot2 for Ingo Molnar  
wrote:

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID: a4c0e91d1d65bc58f928b80ed824e10e165da22c
Gitweb:
https://git.kernel.org/tip/a4c0e91d1d65bc58f928b80ed824e10e165da22c
Author:Ingo Molnar 
AuthorDate:Sun, 05 Jul 2020 21:33:11 +02:00
Committer: Ingo Molnar 
CommitterDate: Sun, 05 Jul 2020 21:39:23 +02:00

x86/entry/32: Fix XEN_PV build dependency

xenpv_exc_nmi() and xenpv_exc_debug() are only defined on 64-bit kernels,
but they snuck into the 32-bit build via , causing the link
to fail:

  ld: arch/x86/entry/entry_32.o: in function `asm_xenpv_exc_nmi':
  (.entry.text+0x817): undefined reference to `xenpv_exc_nmi'

  ld: arch/x86/entry/entry_32.o: in function `asm_xenpv_exc_debug':
  (.entry.text+0x827): undefined reference to `xenpv_exc_debug'

Only use them on 64-bit kernels.


Jürgen, can you queue a revert for when PV32 goes away?


Yes, will do.


Juergen


Re: [RFC V2 1/2] arm64/mm: Change THP helpers per generic memory semantics

2020-07-05 Thread Anshuman Khandual



On 07/02/2020 05:41 PM, Catalin Marinas wrote:
> Hi Anshuman,

Hi Catalin,

> 
> On Mon, Jun 15, 2020 at 06:45:17PM +0530, Anshuman Khandual wrote:
>> --- a/arch/arm64/include/asm/pgtable.h
>> +++ b/arch/arm64/include/asm/pgtable.h
>> @@ -353,15 +353,92 @@ static inline int pmd_protnone(pmd_t pmd)
>>  }
>>  #endif
>>  
>> +#define pmd_table(pmd)  ((pmd_val(pmd) & PMD_TYPE_MASK) ==  
>> PMD_TYPE_TABLE)
>> +#define pmd_sect(pmd)   ((pmd_val(pmd) & PMD_TYPE_MASK) ==  
>> PMD_TYPE_SECT)
>> +
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>  /*
>> - * THP definitions.
>> + * PMD Level Encoding (THP Enabled)
>> + *
>> + * 0b00 - Not valid Not present NA
>> + * 0b10 - Not valid Present Huge  (Splitting)
>> + * 0b01 - Valid Present Huge  (Mapped)
>> + * 0b11 - Valid Present Table (Mapped)
>>   */
> 
> I wonder whether it would be easier to read if we add a dedicated
> PMD_SPLITTING bit, only when bit 0 is cleared. This bit can be high (say
> 59), it doesn't really matter as the entry is not valid.

Could make (PMD[0b00] = 0b10) be represented as PMD_SPLITTING just for
better reading purpose. But if possible, IMHO it is efficient and less
vulnerable to use HW defined PTE attribute bit positions including SW
usable ones than the reserved bits, for a PMD state representation.

Earlier proposal used PTE_SPECIAL (bit 56) instead. Using PMD_TABLE_BIT
helps save bit 56 for later. Thinking about it again, would not these
unused higher bits [59..63] create any problem ? For example while
enabling THP swapping without split via ARCH_WANTS_THP_SWAP or something
else later when these higher bits might be required. I am not sure, just
speculating.

But, do you see any particular problem with PMD_TABLE_BIT ?

> 
> The only doubt I have is that pmd_mkinvalid() is used in other contexts
> when it's not necessarily splitting a pmd (search for the
> pmdp_invalidate() calls). So maybe a better name like PMD_PRESENT with a
> comment that pmd_to_page() is valid (i.e. no migration or swap entry).
> Feel free to suggest a better name.

PMD_INVALID_PRESENT sounds better ?

> 
>> +static inline pmd_t pmd_mksplitting(pmd_t pmd)
>> +{
>> +unsigned long val = pmd_val(pmd);
>>  
>> -#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>> -#define pmd_trans_huge(pmd) (pmd_val(pmd) && !(pmd_val(pmd) & 
>> PMD_TABLE_BIT))
>> +return __pmd((val & ~PMD_TYPE_MASK) | PMD_TABLE_BIT);
>> +}
>> +
>> +static inline pmd_t pmd_clrsplitting(pmd_t pmd)
>> +{
>> +unsigned long val = pmd_val(pmd);
>> +
>> +return __pmd((val & ~PMD_TYPE_MASK) | PMD_TYPE_SECT);
>> +}
>> +
>> +static inline bool pmd_splitting(pmd_t pmd)
>> +{
>> +unsigned long val = pmd_val(pmd);
>> +
>> +if ((val & PMD_TYPE_MASK) == PMD_TABLE_BIT)
>> +return true;
>> +return false;
>> +}
>> +
>> +static inline bool pmd_mapped(pmd_t pmd)
>> +{
>> +return pmd_sect(pmd);
>> +}
>> +
>> +static inline pmd_t pmd_mkinvalid(pmd_t pmd)
>> +{
>> +/*
>> + * Invalidation should not have been invoked on
>> + * a PMD table entry. Just warn here otherwise.
>> + */
>> +WARN_ON(pmd_table(pmd));
>> +return pmd_mksplitting(pmd);
>> +}
> 
> And here we wouldn't need t worry about table checks.> 
This is just a temporary sanity check validating the assumption
that a table entry would never be called with pmdp_invalidate().
This can be dropped later on if required.

>> +static inline int pmd_present(pmd_t pmd);
>> +
>> +static inline int pmd_trans_huge(pmd_t pmd)
>> +{
>> +if (!pmd_present(pmd))
>> +return 0;
>> +
>> +if (!pmd_val(pmd))
>> +return 0;
>> +
>> +if (pmd_mapped(pmd))
>> +return 1;
>> +
>> +if (pmd_splitting(pmd))
>> +return 1;
>> +return 0;
> 
> Doesn't your new pmd_present() already check for splitting? I think

I actually meant pte_present() here instead, my bad.

> checking for bit 0 and the new PMD_PRESENT. That would be similar to
> what we do with PTE_PROT_NONE. Actually, you could use the same bit for
> both.

IIUC PROT NONE is supported at PMD level as well. Hence with valid bit
cleared, there is a chance for misinterpretation between pmd_protnone()
and pmd_splitting() if the same bit (PTE_PROT_NONE) is used.

> 
>> +}
>> +
>> +void set_pmd_at(struct mm_struct *mm, unsigned long addr,
>> +pmd_t *pmdp, pmd_t pmd);
>>  #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
>>  
>> -#define pmd_present(pmd)pte_present(pmd_pte(pmd))
>> +static inline int pmd_present(pmd_t pmd)
>> +{
>> +pte_t pte = pmd_pte(pmd);
>> +
>> +if (pte_present(pte))
>> +return 1;
>> +
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>> +if (pmd_splitting(pmd))
>> +return 1;
>> +#endif
>> +return 0;
>> +}
> 
> [...]
> 
>> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
>> index 990929c8837e..337519031115 100644
>> --- a/arch/arm64/mm/mmu.c
>> +++ b/arch/arm64/mm/mmu.c
>> @@ -22,6 +22,8 @@
>>  #include 
>>  

linux-next: manual merge of the dmaengine tree with the dmaengine-fixes tree

2020-07-05 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the dmaengine tree got a conflict in:

  drivers/dma/idxd/sysfs.c

between commit:

  da32b28c95a7 ("dmaengine: idxd: cleanup workqueue config after disabling")

from the dmaengine-fixes tree and commit:

  f50b150e315e ("dmaengine: idxd: add work queue drain support")

from the dmaengine tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/dma/idxd/sysfs.c
index 2e2c5082f322,6f0711a822a1..
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@@ -313,14 -303,7 +303,12 @@@ static int idxd_config_bus_remove(struc
}
  
idxd_unregister_dma_device(idxd);
-   spin_lock_irqsave(>dev_lock, flags);
rc = idxd_device_disable(idxd);
 +  for (i = 0; i < idxd->max_wqs; i++) {
 +  struct idxd_wq *wq = >wqs[i];
 +
 +  idxd_wq_disable_cleanup(wq);
 +  }
-   spin_unlock_irqrestore(>dev_lock, flags);
module_put(THIS_MODULE);
if (rc < 0)
dev_warn(dev, "Device disable failed\n");


pgpJlbHAhDnnt.pgp
Description: OpenPGP digital signature


Re: [PATCH v2] phy: samsung: Use readl_poll_timeout function

2020-07-05 Thread Anand Moon
Hi Krzysztof,

Thanks for your review comments.

On Sun, 5 Jul 2020 at 23:32, Krzysztof Kozlowski  wrote:
>
> On Sun, Jul 05, 2020 at 06:04:35AM +, Anand Moon wrote:
> > User readl_poll_timeout function instead of open
> > coded handling in crport_handshake function.
>
> Your change does not replace only the "open coded handling" with
> readl_poll_timeout(). Your change does more - switches busy waiting with
> udelay to a sleeping mode. I am not sure if it is correct but definitly
> it should be mentioned.  Otherwise how can we be sure that you checked
> if this is allowed in this section? Did you test everything with
> DEBUG_ATOMIC_SLEEP?
Yes this DEBUG_ATOMIC_SLEEP is enabled in exynos_defconfig.
>
Ok how about the below commit message.

Instead of a busy waiting loop while loop using udelay use readl_poll_timeout
function to check the condition is met or timeout occurs in
crport_handshake function.

> >
> > Fixes: d8c80bb3b55b ("phy: exynos5-usbdrd: Calibrate LOS levels for 
> > exynos5420/5800")
> > Signed-off-by: Anand Moon 
> > ---
> > Changes v2:
> > --used the default timeout values.
> > --Added missing Fixed tags.
> > ---
> >  drivers/phy/samsung/phy-exynos5-usbdrd.c | 37 +---
> >  1 file changed, 13 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c 
> > b/drivers/phy/samsung/phy-exynos5-usbdrd.c
> > index e510732afb8b..c97f5fb6a9a0 100644
> > --- a/drivers/phy/samsung/phy-exynos5-usbdrd.c
> > +++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c
> > @@ -16,6 +16,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -556,40 +557,28 @@ static int exynos5_usbdrd_phy_power_off(struct phy 
> > *phy)
> >  static int crport_handshake(struct exynos5_usbdrd_phy *phy_drd,
> >   u32 val, u32 cmd)
> >  {
> > - u32 usec = 100;
> > + u32 timeout_us = 100, sleep_us = 1;
>
> No need for the variables actually and their type does not match. Just
> use the values directly.
Ok thanks
>
> >   unsigned int result;
> > + int err;
> >
> >   writel(val | cmd, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0);
> >
> > - do {
> > - result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1);
> > - if (result & PHYREG1_CR_ACK)
> > - break;
> > -
> > - udelay(1);
> > - } while (usec-- > 0);
> > -
> > - if (!usec) {
> > - dev_err(phy_drd->dev,
> > - "CRPORT handshake timeout1 (0x%08x)\n", val);
> > + err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1,
> > + result, (result & PHYREG1_CR_ACK), sleep_us, 
> > timeout_us);
> > + if (err) {
> > + dev_err(phy_drd->dev, "CRPORT handshake timeout1 (0x%08x)\n", 
> > val);
> >   return -ETIME;
> >   }
> >
> > - usec = 100;
> > + timeout_us = 100;
> > + sleep_us = 1;
>
> Why defining then again?
I had removed this in this but last minute I added this code again.
>
> Best regards,
> Krzysztof
>

Best Regards
-Anand


[PATCH] usb: gadget: function: fix missing spinlock in f_uac1_legacy

2020-07-05 Thread qiang.zhang
From: Zhang Qiang 

Signed-off-by: Zhang Qiang 
---
 drivers/usb/gadget/function/f_uac1_legacy.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/gadget/function/f_uac1_legacy.c 
b/drivers/usb/gadget/function/f_uac1_legacy.c
index 349deae7cabd..e2d7f69128a0 100644
--- a/drivers/usb/gadget/function/f_uac1_legacy.c
+++ b/drivers/usb/gadget/function/f_uac1_legacy.c
@@ -336,7 +336,9 @@ static int f_audio_out_ep_complete(struct usb_ep *ep, 
struct usb_request *req)
 
/* Copy buffer is full, add it to the play_queue */
if (audio_buf_size - copy_buf->actual < req->actual) {
+   spin_lock_irq(>lock);
list_add_tail(_buf->list, >play_queue);
+   spin_unlock_irq(>lock);
schedule_work(>playback_work);
copy_buf = f_audio_buffer_alloc(audio_buf_size);
if (IS_ERR(copy_buf))
-- 
2.24.1



Re: use-after-free in Bluetooth: 6lowpan (was Re: KASAN: use-after-free Write in refcount_warn_saturate)

2020-07-05 Thread Kees Cook
On Thu, Feb 27, 2020 at 11:50:11PM -0800, syzbot wrote:
> Hello,
> 
> syzbot found the following crash on:
> 
> HEAD commit:f8788d86 Linux 5.6-rc3
> git tree:   upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=13005fd9e0
> kernel config:  https://syzkaller.appspot.com/x/.config?x=9833e26bab355358
> dashboard link: https://syzkaller.appspot.com/bug?extid=7dd7f2f77a7a01d1dc14
> compiler:   gcc (GCC) 9.0.0 20181231 (experimental)
> userspace arch: i386
> syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=17e3ebede0
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16a9f8f9e0
> 
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+7dd7f2f77a7a01d1d...@syzkaller.appspotmail.com
> 
> ==
> BUG: KASAN: use-after-free in atomic_set 
> include/asm-generic/atomic-instrumented.h:44 [inline]
> BUG: KASAN: use-after-free in refcount_set include/linux/refcount.h:123 
> [inline]
> BUG: KASAN: use-after-free in refcount_warn_saturate+0x1f/0x1f0 
> lib/refcount.c:15
> Write of size 4 at addr 888090eb4018 by task kworker/1:24/2888
> 
> CPU: 1 PID: 2888 Comm: kworker/1:24 Not tainted 5.6.0-rc3-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS 
> Google 01/01/2011
> Workqueue: events do_enable_set
> Call Trace:
>  __dump_stack lib/dump_stack.c:77 [inline]
>  dump_stack+0x197/0x210 lib/dump_stack.c:118
>  print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
>  __kasan_report.cold+0x1b/0x32 mm/kasan/report.c:506
>  kasan_report+0x12/0x20 mm/kasan/common.c:641
>  check_memory_region_inline mm/kasan/generic.c:185 [inline]
>  check_memory_region+0x134/0x1a0 mm/kasan/generic.c:192
>  __kasan_check_write+0x14/0x20 mm/kasan/common.c:101
>  atomic_set include/asm-generic/atomic-instrumented.h:44 [inline]
>  refcount_set include/linux/refcount.h:123 [inline]
>  refcount_warn_saturate+0x1f/0x1f0 lib/refcount.c:15
>  refcount_sub_and_test include/linux/refcount.h:261 [inline]
>  refcount_dec_and_test include/linux/refcount.h:281 [inline]
>  kref_put include/linux/kref.h:64 [inline]
>  l2cap_chan_put+0x1d9/0x240 net/bluetooth/l2cap_core.c:498
>  do_enable_set+0x54b/0x960 net/bluetooth/6lowpan.c:1075
>  process_one_work+0xa05/0x17a0 kernel/workqueue.c:2264
>  worker_thread+0x98/0xe40 kernel/workqueue.c:2410
>  kthread+0x361/0x430 kernel/kthread.c:255
>  ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
> 
> Allocated by task 2888:
>  save_stack+0x23/0x90 mm/kasan/common.c:72
>  set_track mm/kasan/common.c:80 [inline]
>  __kasan_kmalloc mm/kasan/common.c:515 [inline]
>  __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:488
>  kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529
>  kmem_cache_alloc_trace+0x158/0x790 mm/slab.c:3551
>  kmalloc include/linux/slab.h:555 [inline]
>  kzalloc include/linux/slab.h:669 [inline]
>  l2cap_chan_create+0x45/0x3a0 net/bluetooth/l2cap_core.c:446
>  chan_create+0x10/0xe0 net/bluetooth/6lowpan.c:640
>  bt_6lowpan_listen net/bluetooth/6lowpan.c:959 [inline]
>  do_enable_set+0x583/0x960 net/bluetooth/6lowpan.c:1078
>  process_one_work+0xa05/0x17a0 kernel/workqueue.c:2264
>  worker_thread+0x98/0xe40 kernel/workqueue.c:2410
>  kthread+0x361/0x430 kernel/kthread.c:255
>  ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
> 
> Freed by task 2975:
>  save_stack+0x23/0x90 mm/kasan/common.c:72
>  set_track mm/kasan/common.c:80 [inline]
>  kasan_set_free_info mm/kasan/common.c:337 [inline]
>  __kasan_slab_free+0x102/0x150 mm/kasan/common.c:476
>  kasan_slab_free+0xe/0x10 mm/kasan/common.c:485
>  __cache_free mm/slab.c:3426 [inline]
>  kfree+0x10a/0x2c0 mm/slab.c:3757
>  l2cap_chan_destroy net/bluetooth/l2cap_core.c:484 [inline]
>  kref_put include/linux/kref.h:65 [inline]
>  l2cap_chan_put+0x1b7/0x240 net/bluetooth/l2cap_core.c:498
>  do_enable_set+0x54b/0x960 net/bluetooth/6lowpan.c:1075
>  process_one_work+0xa05/0x17a0 kernel/workqueue.c:2264
>  worker_thread+0x98/0xe40 kernel/workqueue.c:2410
>  kthread+0x361/0x430 kernel/kthread.c:255
>  ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

The free and use-after-free are both via the same do_enable_set() path
which implies there are racing writes to the debugfs write handler. It
seems locking is missing for both listen_chan and enable_6lowpan. The
latter seems misused in is_bt_6lowpan(), which should likely just be
checking for chan->ops == _6lowpan_chan_ops, I think?

I have no way to actually test changes to this code...

-- 
Kees Cook


[PATCH 1/1] ALSA: opl3: fix infoleak in opl3

2020-07-05 Thread Xidong Wang
From: xidongwang 

The stack object “info” in snd_opl3_ioctl() has a leaking problem.
It has 2 padding bytes which are not initialized and leaked via
“copy_to_user”.

Signed-off-by: xidongwang 
---
 sound/drivers/opl3/opl3_synth.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/drivers/opl3/opl3_synth.c b/sound/drivers/opl3/opl3_synth.c
index e69a4ef..08c10ac 100644
--- a/sound/drivers/opl3/opl3_synth.c
+++ b/sound/drivers/opl3/opl3_synth.c
@@ -91,6 +91,8 @@ int snd_opl3_ioctl(struct snd_hwdep * hw, struct file *file,
{
struct snd_dm_fm_info info;
 
+   memset(, 0, sizeof(info));
+
info.fm_mode = opl3->fm_mode;
info.rhythm = opl3->rhythm;
if (copy_to_user(argp, , sizeof(struct 
snd_dm_fm_info)))
-- 
2.7.4



linux-next: manual merge of the driver-core tree with the devicetree tree

2020-07-05 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the driver-core tree got a conflict in:

  include/linux/device.h

between commit:

  7d34ca385484 ("driver core: Add device_is_dependent() to linux/device.h")

from the devicetree tree and commit:

  67dd07723969 ("device: remove 'extern' attribute from function prototypes in 
device.h")

from the driver-core tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc include/linux/device.h
index b5ac86e356d9,9a62f7f43d55..
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@@ -814,27 -808,25 +813,26 @@@ static inline bool dev_has_sync_state(s
  /*
   * High level routines for use by the bus drivers
   */
- extern int __must_check device_register(struct device *dev);
- extern void device_unregister(struct device *dev);
- extern void device_initialize(struct device *dev);
- extern int __must_check device_add(struct device *dev);
- extern void device_del(struct device *dev);
- extern int device_for_each_child(struct device *dev, void *data,
-int (*fn)(struct device *dev, void *data));
- extern int device_for_each_child_reverse(struct device *dev, void *data,
-int (*fn)(struct device *dev, void *data));
- extern struct device *device_find_child(struct device *dev, void *data,
-   int (*match)(struct device *dev, void *data));
- extern struct device *device_find_child_by_name(struct device *parent,
-   const char *name);
- extern int device_rename(struct device *dev, const char *new_name);
- extern int device_move(struct device *dev, struct device *new_parent,
-  enum dpm_order dpm_order);
- extern int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid);
- extern const char *device_get_devnode(struct device *dev,
- umode_t *mode, kuid_t *uid, kgid_t *gid,
- const char **tmp);
- extern int device_is_dependent(struct device *dev, void *target);
+ int __must_check device_register(struct device *dev);
+ void device_unregister(struct device *dev);
+ void device_initialize(struct device *dev);
+ int __must_check device_add(struct device *dev);
+ void device_del(struct device *dev);
+ int device_for_each_child(struct device *dev, void *data,
+ int (*fn)(struct device *dev, void *data));
+ int device_for_each_child_reverse(struct device *dev, void *data,
+ int (*fn)(struct device *dev, void *data));
+ struct device *device_find_child(struct device *dev, void *data,
+int (*match)(struct device *dev, void *data));
+ struct device *device_find_child_by_name(struct device *parent,
+const char *name);
+ int device_rename(struct device *dev, const char *new_name);
+ int device_move(struct device *dev, struct device *new_parent,
+   enum dpm_order dpm_order);
+ int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid);
+ const char *device_get_devnode(struct device *dev, umode_t *mode, kuid_t *uid,
+  kgid_t *gid, const char **tmp);
++int device_is_dependent(struct device *dev, void *target);
  
  static inline bool device_supports_offline(struct device *dev)
  {


pgphCT03mEsQj.pgp
Description: OpenPGP digital signature


Re: [PATCH 1/1] power: supply: axp20x_usb_power: fix spelling mistake

2020-07-05 Thread Chen-Yu Tsai
On Wed, Jun 24, 2020 at 4:41 PM Flavio Suligoi  wrote:
>
> Fix typo: "triger" --> "trigger"
>
> Signed-off-by: Flavio Suligoi 

Acked-by: Chen-Yu Tsai 


[PATCH v3] kthread: Work could not be queued when worker being destroyed

2020-07-05 Thread qiang.zhang
From: Zhang Qiang 

Before the work is put into the queue of the worker thread,
the state of the worker thread needs to be detected,because
the worker thread may be in the destruction state at this time.

Signed-off-by: Zhang Qiang 
Suggested-by: Petr Mladek 
Reviewed-by: Petr Mladek 
---
 v1->v2:
 Add warning information for condition "!worker->task".
 v2->v3:
 Modify submission information and add "Reviewed-by" tags. 

 kernel/kthread.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index bfbfa481be3a..cac5184ffd86 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -791,6 +791,9 @@ static inline bool queuing_blocked(struct kthread_worker 
*worker,
 {
lockdep_assert_held(>lock);
 
+   if (WARN_ON(!worker->task))
+   return true;
+
return !list_empty(>node) || work->canceling;
 }
 
-- 
2.24.1



[PATCH v2] cpuidle: change enter_s2idle() prototype

2020-07-05 Thread Neal Liu
Control Flow Integrity(CFI) is a security mechanism that disallows
changes to the original control flow graph of a compiled binary,
making it significantly harder to perform such attacks.

init_state_node() assign same function callback to different
function pointer declarations.

static int init_state_node(struct cpuidle_state *idle_state,
   const struct of_device_id *matches,
   struct device_node *state_node) { ...
idle_state->enter = match_id->data; ...
idle_state->enter_s2idle = match_id->data; }

Function declarations:

struct cpuidle_state { ...
int (*enter) (struct cpuidle_device *dev,
  struct cpuidle_driver *drv,
  int index);

void (*enter_s2idle) (struct cpuidle_device *dev,
  struct cpuidle_driver *drv,
  int index); };

In this case, either enter() or enter_s2idle() would cause CFI check
failed since they use same callee.

Align function prototype of enter() since it needs return value for
some use cases. The return value of enter_s2idle() is no
need currently.

Signed-off-by: Neal Liu 
---
 drivers/acpi/processor_idle.c   |6 --
 drivers/cpuidle/cpuidle-tegra.c |8 +---
 drivers/idle/intel_idle.c   |6 --
 include/linux/cpuidle.h |6 +++---
 4 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 75534c5..6ffb6c9 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -655,8 +655,8 @@ static int acpi_idle_enter(struct cpuidle_device *dev,
return index;
 }
 
-static void acpi_idle_enter_s2idle(struct cpuidle_device *dev,
-  struct cpuidle_driver *drv, int index)
+static int acpi_idle_enter_s2idle(struct cpuidle_device *dev,
+ struct cpuidle_driver *drv, int index)
 {
struct acpi_processor_cx *cx = per_cpu(acpi_cstate[index], dev->cpu);
 
@@ -674,6 +674,8 @@ static void acpi_idle_enter_s2idle(struct cpuidle_device 
*dev,
}
}
acpi_idle_do_entry(cx);
+
+   return 0;
 }
 
 static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
diff --git a/drivers/cpuidle/cpuidle-tegra.c b/drivers/cpuidle/cpuidle-tegra.c
index 1500458..a12fb14 100644
--- a/drivers/cpuidle/cpuidle-tegra.c
+++ b/drivers/cpuidle/cpuidle-tegra.c
@@ -253,11 +253,13 @@ static int tegra_cpuidle_enter(struct cpuidle_device *dev,
return err ? -1 : index;
 }
 
-static void tegra114_enter_s2idle(struct cpuidle_device *dev,
- struct cpuidle_driver *drv,
- int index)
+static int tegra114_enter_s2idle(struct cpuidle_device *dev,
+struct cpuidle_driver *drv,
+int index)
 {
tegra_cpuidle_enter(dev, drv, index);
+
+   return 0;
 }
 
 /*
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index f449584..b178da3 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -175,13 +175,15 @@ static __cpuidle int intel_idle(struct cpuidle_device 
*dev,
  * Invoked as a suspend-to-idle callback routine with frozen user space, frozen
  * scheduler tick and suspended scheduler clock on the target CPU.
  */
-static __cpuidle void intel_idle_s2idle(struct cpuidle_device *dev,
-   struct cpuidle_driver *drv, int index)
+static __cpuidle int intel_idle_s2idle(struct cpuidle_device *dev,
+  struct cpuidle_driver *drv, int index)
 {
unsigned long eax = flg2MWAIT(drv->states[index].flags);
unsigned long ecx = 1; /* break on interrupt flag */
 
mwait_idle_with_hints(eax, ecx);
+
+   return 0;
 }
 
 /*
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index ec2ef63..bee10c0 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -66,9 +66,9 @@ struct cpuidle_state {
 * suspended, so it must not re-enable interrupts at any point (even
 * temporarily) or attempt to change states of clock event devices.
 */
-   void (*enter_s2idle) (struct cpuidle_device *dev,
- struct cpuidle_driver *drv,
- int index);
+   int (*enter_s2idle)(struct cpuidle_device *dev,
+   struct cpuidle_driver *drv,
+   int index);
 };
 
 /* Idle State Flags */
-- 
1.7.9.5


Re: [PATCH] CodingStyle: Inclusive Terminology

2020-07-05 Thread Daniel Palmer
Hi Willy,

On Sun, 5 Jul 2020 at 13:55, Willy Tarreau  wrote:

> I'm personally thinking that for a non-native speaker it's already
> difficult to find the best term to describe something,

I'm a nobody in the kernel world but this point made me think.

I'm a native English speaker but I don't live in an English speaking
place and my experience is that a lot of technology terms have been
directly imported from English into the local language almost as-is.

In my case master/slave have been directly transliterated into
Japanese as masuta and sureebu and exists like that in technical
documentation for example:
https://www.analog.com/jp/analog-dialogue/articles/introduction-to-spi-interface.html#

I can imagine that by changing terminology that has been in use for so
long that it's been imported into other languages directly or is
common enough that non-native speakers know what it means might have
exactly the opposite result by excluding people that aren't native
English speakers and can't decode synonyms that are obvious to a
native speaker.

Cheers,

Daniel


[PATCH v2] cpuidle: Fix CFI failure

2020-07-05 Thread Neal Liu
changes since v1:
- add more description in commit message.

*** BLURB HERE ***

Neal Liu (1):
  cpuidle: change enter_s2idle() prototype

 drivers/acpi/processor_idle.c   | 6 --
 drivers/cpuidle/cpuidle-tegra.c | 8 +---
 drivers/idle/intel_idle.c   | 6 --
 include/linux/cpuidle.h | 6 +++---
 4 files changed, 16 insertions(+), 10 deletions(-)

-- 
2.18.0


drivers/video/fbdev/geode/lxfb_ops.c:604:28: sparse: sparse: incorrect type in argument 2 (different address spaces)

2020-07-05 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   dcb7fd82c75ee2d6e6f9d8cc71c52519ed52e258
commit: 670d0a4b10704667765f7d18f7592993d02783aa sparse: use identifiers to 
define address spaces
date:   2 weeks ago
config: i386-randconfig-s002-20200706 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-14-g8fce3d7a-dirty
git checkout 670d0a4b10704667765f7d18f7592993d02783aa
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

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


sparse warnings: (new ones prefixed by >>)

>> drivers/video/fbdev/geode/lxfb_ops.c:604:28: sparse: sparse: incorrect type 
>> in argument 2 (different address spaces) @@ expected void const *q @@
>>  got void [noderef] __iomem *gp_regs @@
   drivers/video/fbdev/geode/lxfb_ops.c:604:28: sparse: expected void const 
*q
   drivers/video/fbdev/geode/lxfb_ops.c:604:28: sparse: got void [noderef] 
__iomem *gp_regs
>> drivers/video/fbdev/geode/lxfb_ops.c:605:28: sparse: sparse: incorrect type 
>> in argument 2 (different address spaces) @@ expected void const *q @@
>>  got void [noderef] __iomem *dc_regs @@
   drivers/video/fbdev/geode/lxfb_ops.c:605:28: sparse: expected void const 
*q
   drivers/video/fbdev/geode/lxfb_ops.c:605:28: sparse: got void [noderef] 
__iomem *dc_regs
>> drivers/video/fbdev/geode/lxfb_ops.c:606:28: sparse: sparse: incorrect type 
>> in argument 2 (different address spaces) @@ expected void const *q @@
>>  got void [noderef] __iomem *vp_regs @@
   drivers/video/fbdev/geode/lxfb_ops.c:606:28: sparse: expected void const 
*q
   drivers/video/fbdev/geode/lxfb_ops.c:606:28: sparse: got void [noderef] 
__iomem *vp_regs
>> drivers/video/fbdev/geode/lxfb_ops.c:607:38: sparse: sparse: incorrect type 
>> in argument 2 (different address spaces) @@ expected void const *q @@
>>  got void [noderef] __iomem * @@
   drivers/video/fbdev/geode/lxfb_ops.c:607:38: sparse: expected void const 
*q
   drivers/video/fbdev/geode/lxfb_ops.c:607:38: sparse: got void [noderef] 
__iomem *
   drivers/video/fbdev/geode/lxfb_ops.c:635:44: sparse: sparse: incorrect type 
in argument 2 (different address spaces) @@ expected void const *q @@ 
got void [noderef] __iomem * @@
   drivers/video/fbdev/geode/lxfb_ops.c:635:44: sparse: expected void const 
*q
   drivers/video/fbdev/geode/lxfb_ops.c:635:44: sparse: got void [noderef] 
__iomem *
>> drivers/video/fbdev/geode/lxfb_ops.c:761:29: sparse: sparse: incorrect type 
>> in argument 1 (different address spaces) @@ expected void *p @@ got 
>> void [noderef] __iomem * @@
   drivers/video/fbdev/geode/lxfb_ops.c:761:29: sparse: expected void *p
   drivers/video/fbdev/geode/lxfb_ops.c:761:29: sparse: got void [noderef] 
__iomem *

vim +604 drivers/video/fbdev/geode/lxfb_ops.c

f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  584  
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  585  
static void lx_save_regs(struct lxfb_par *par)
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  586  {
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  587
uint32_t filt;
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  588
int i;
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  589  
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  590
/* wait for the BLT engine to stop being busy */
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  591
do {
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  592
i = read_gp(par, GP_BLT_STATUS);
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  593
} while ((i & GP_BLT_STATUS_PB) || !(i & GP_BLT_STATUS_CE));
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  594  
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  595
/* save MSRs */
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  596
rdmsrl(MSR_LX_MSR_PADSEL, par->msr.padsel);
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  597
rdmsrl(MSR_GLCP_DOTPLL, par->msr.dotpll);
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  598
rdmsrl(MSR_LX_GLD_MSR_CONFIG, par->msr.dfglcfg);
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  599
rdmsrl(MSR_LX_SPARE_MSR, par->msr.dcspare);
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  600  
f694e53bd0db69 drivers/video/geode/lxfb_ops.c Andres Salomon 2008-04-28  601
write_dc(par, DC_UNLOCK, DC_UNLOCK_UNLOCK);

[PATCH v2] mm/page_alloc: skip setting nodemask when we are in interrupt

2020-07-05 Thread Muchun Song
When we are in the interrupt context, it is irrelevant to the
current task context. If we use current task's mems_allowed, we
can fair to alloc pages in the fast path and fall back to slow
path memory allocation when the current node(which is the current
task mems_allowed) does not have enough memory to allocate. In
this case, it slows down the memory allocation speed of interrupt
context. So we can skip setting the nodemask to allow any node
to allocate memory, so that fast path allocation can success.

Signed-off-by: Muchun Song 
---

changelog in v2:
 1) rework the code suggested by Pekka Enberg
 2) add a comment

 mm/page_alloc.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9808339a6e93b..6678c4c1c3087 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4799,7 +4799,11 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, 
unsigned int order,
 
if (cpusets_enabled()) {
*alloc_mask |= __GFP_HARDWALL;
-   if (!ac->nodemask)
+   /*
+* When we are in the interrupt context, it is irrelevant
+* to the current task context. It means that any node ok.
+*/
+   if (!in_interrupt() && !ac->nodemask)
ac->nodemask = _current_mems_allowed;
else
*alloc_flags |= ALLOC_CPUSET;
-- 
2.11.0



[PATCH V4 3/3] arm64/mm: Enable vmem_altmap support for vmemmap mappings

2020-07-05 Thread Anshuman Khandual
Device memory ranges when getting hot added into ZONE_DEVICE, might require
their vmemmap mapping's backing memory to be allocated from their own range
instead of consuming system memory. This prevents large system memory usage
for potentially large device memory ranges. Device driver communicates this
request via vmem_altmap structure. Architecture needs to take this request
into account while creating and tearing down vemmmap mappings.

This enables vmem_altmap support in vmemmap_populate() and vmemmap_free()
which includes vmemmap_populate_basepages() used for ARM64_16K_PAGES and
ARM64_64K_PAGES configs.

Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: Mark Rutland 
Cc: Steve Capper 
Cc: David Hildenbrand 
Cc: Yu Zhao 
Cc: Hsin-Yi Wang 
Cc: Thomas Gleixner 
Cc: Andrew Morton 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Tested-by: Jia He 
Reviewed-by: Catalin Marinas 
Signed-off-by: Anshuman Khandual 
---
 arch/arm64/mm/mmu.c | 58 +
 1 file changed, 38 insertions(+), 20 deletions(-)

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 9c08d1882106..51a1b0e886ff 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -760,15 +760,20 @@ int kern_addr_valid(unsigned long addr)
 }
 
 #ifdef CONFIG_MEMORY_HOTPLUG
-static void free_hotplug_page_range(struct page *page, size_t size)
+static void free_hotplug_page_range(struct page *page, size_t size,
+   struct vmem_altmap *altmap)
 {
-   WARN_ON(PageReserved(page));
-   free_pages((unsigned long)page_address(page), get_order(size));
+   if (altmap) {
+   vmem_altmap_free(altmap, size >> PAGE_SHIFT);
+   } else {
+   WARN_ON(PageReserved(page));
+   free_pages((unsigned long)page_address(page), get_order(size));
+   }
 }
 
 static void free_hotplug_pgtable_page(struct page *page)
 {
-   free_hotplug_page_range(page, PAGE_SIZE);
+   free_hotplug_page_range(page, PAGE_SIZE, NULL);
 }
 
 static bool pgtable_range_aligned(unsigned long start, unsigned long end,
@@ -791,7 +796,8 @@ static bool pgtable_range_aligned(unsigned long start, 
unsigned long end,
 }
 
 static void unmap_hotplug_pte_range(pmd_t *pmdp, unsigned long addr,
-   unsigned long end, bool free_mapped)
+   unsigned long end, bool free_mapped,
+   struct vmem_altmap *altmap)
 {
pte_t *ptep, pte;
 
@@ -805,12 +811,14 @@ static void unmap_hotplug_pte_range(pmd_t *pmdp, unsigned 
long addr,
pte_clear(_mm, addr, ptep);
flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
if (free_mapped)
-   free_hotplug_page_range(pte_page(pte), PAGE_SIZE);
+   free_hotplug_page_range(pte_page(pte),
+   PAGE_SIZE, altmap);
} while (addr += PAGE_SIZE, addr < end);
 }
 
 static void unmap_hotplug_pmd_range(pud_t *pudp, unsigned long addr,
-   unsigned long end, bool free_mapped)
+   unsigned long end, bool free_mapped,
+   struct vmem_altmap *altmap)
 {
unsigned long next;
pmd_t *pmdp, pmd;
@@ -833,16 +841,17 @@ static void unmap_hotplug_pmd_range(pud_t *pudp, unsigned 
long addr,
flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
if (free_mapped)
free_hotplug_page_range(pmd_page(pmd),
-   PMD_SIZE);
+   PMD_SIZE, altmap);
continue;
}
WARN_ON(!pmd_table(pmd));
-   unmap_hotplug_pte_range(pmdp, addr, next, free_mapped);
+   unmap_hotplug_pte_range(pmdp, addr, next, free_mapped, altmap);
} while (addr = next, addr < end);
 }
 
 static void unmap_hotplug_pud_range(p4d_t *p4dp, unsigned long addr,
-   unsigned long end, bool free_mapped)
+   unsigned long end, bool free_mapped,
+   struct vmem_altmap *altmap)
 {
unsigned long next;
pud_t *pudp, pud;
@@ -865,16 +874,17 @@ static void unmap_hotplug_pud_range(p4d_t *p4dp, unsigned 
long addr,
flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
if (free_mapped)
free_hotplug_page_range(pud_page(pud),
-   PUD_SIZE);
+   PUD_SIZE, altmap);
continue;
}
WARN_ON(!pud_table(pud));
-   unmap_hotplug_pmd_range(pudp, addr, next, free_mapped);
+ 

[PATCH V4 0/3] arm64: Enable vmemmap mapping from device memory

2020-07-05 Thread Anshuman Khandual
This series enables vmemmap backing memory allocation from device memory
ranges on arm64. But before that, it enables vmemmap_populate_basepages()
and vmemmap_alloc_block_buf() to accommodate struct vmem_altmap based
alocation requests.

This series applies on 5.8-rc4.

Changes in V4:

- Dropped 'fallback' from vmemmap_alloc_block_buf() per Catalin

Changes in V3: 
(https://patchwork.kernel.org/project/linux-mm/list/?series=304707)

- Dropped comment from free_hotplug_page_range() per Robin
- Modified comment in unmap_hotplug_range() per Robin
- Enabled altmap support in vmemmap_alloc_block_buf() per Robin

Changes in V2: (https://lkml.org/lkml/2020/3/4/475)

- Rebased on latest hot-remove series (v14) adding P4D page table support

Changes in V1: (https://lkml.org/lkml/2020/1/23/12)

- Added an WARN_ON() in unmap_hotplug_range() when altmap is
  provided without the page table backing memory being freed

Changes in RFC V2: (https://lkml.org/lkml/2019/10/21/11)

- Changed the commit message on 1/2 patch per Will
- Changed the commit message on 2/2 patch as well
- Rebased on arm64 memory hot remove series (v10)

RFC V1: (https://lkml.org/lkml/2019/6/28/32)

Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: Mark Rutland 
Cc: Paul Walmsley 
Cc: Palmer Dabbelt 
Cc: Tony Luck 
Cc: Fenghua Yu 
Cc: Dave Hansen 
Cc: Andy Lutomirski 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: David Hildenbrand 
Cc: Mike Rapoport 
Cc: Michal Hocko 
Cc: "Matthew Wilcox (Oracle)" 
Cc: "Kirill A. Shutemov" 
Cc: Andrew Morton 
Cc: Dan Williams 
Cc: Pavel Tatashin 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-i...@vger.kernel.org
Cc: linux-ri...@lists.infradead.org
Cc: x...@kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux...@kvack.org
Cc: linux-kernel@vger.kernel.org


Anshuman Khandual (3):
  mm/sparsemem: Enable vmem_altmap support in vmemmap_populate_basepages()
  mm/sparsemem: Enable vmem_altmap support in vmemmap_alloc_block_buf()
  arm64/mm: Enable vmem_altmap support for vmemmap mappings

 Documentation/vm/memory-model.rst |  2 +-
 arch/arm64/mm/mmu.c   | 58 ---
 arch/ia64/mm/discontig.c  |  2 +-
 arch/powerpc/mm/init_64.c |  4 +--
 arch/riscv/mm/init.c  |  2 +-
 arch/x86/mm/init_64.c | 11 +++---
 include/linux/mm.h|  9 ++---
 mm/sparse-vmemmap.c   | 36 ++-
 8 files changed, 72 insertions(+), 52 deletions(-)

-- 
2.20.1



[PATCH V4 2/3] mm/sparsemem: Enable vmem_altmap support in vmemmap_alloc_block_buf()

2020-07-05 Thread Anshuman Khandual
There are many instances where vmemap allocation is often switched between
regular memory and device memory just based on whether altmap is available
or not. vmemmap_alloc_block_buf() is used in various platforms to allocate
vmemmap mappings. Lets also enable it to handle altmap based device memory
allocation along with existing regular memory allocations. This will help
in avoiding the altmap based allocation switch in many places. To summarize
there are two different methods to call vmemmap_alloc_block_buf().

vmemmap_alloc_block_buf(size, node, NULL)   /* Allocate from system RAM */
vmemmap_alloc_block_buf(size, node, altmap) /* Allocate from altmap */

This converts altmap_alloc_block_buf() into a static function, drops it's
entry from the header and updates Documentation/vm/memory-model.rst.

Cc: Jonathan Corbet 
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Dave Hansen 
Cc: Andy Lutomirski 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: "H. Peter Anvin" 
Cc: Andrew Morton 
Cc: linux-...@vger.kernel.org
Cc: x...@kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux...@kvack.org
Cc: linux-kernel@vger.kernel.org
Tested-by: Jia He 
Suggested-by: Robin Murphy 
Signed-off-by: Anshuman Khandual 
---
 Documentation/vm/memory-model.rst |  2 +-
 arch/arm64/mm/mmu.c   |  2 +-
 arch/powerpc/mm/init_64.c |  4 ++--
 arch/x86/mm/init_64.c |  5 +
 include/linux/mm.h|  4 ++--
 mm/sparse-vmemmap.c   | 28 +---
 6 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/Documentation/vm/memory-model.rst 
b/Documentation/vm/memory-model.rst
index 91228044ed16..f26142cf24f2 100644
--- a/Documentation/vm/memory-model.rst
+++ b/Documentation/vm/memory-model.rst
@@ -178,7 +178,7 @@ for persistent memory devices in pre-allocated storage on 
those
 devices. This storage is represented with :c:type:`struct vmem_altmap`
 that is eventually passed to vmemmap_populate() through a long chain
 of function calls. The vmemmap_populate() implementation may use the
-`vmem_altmap` along with :c:func:`altmap_alloc_block_buf` helper to
+`vmem_altmap` along with :c:func:`vmemmap_alloc_block_buf` helper to
 allocate memory map on the persistent memory device.
 
 ZONE_DEVICE
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 63b74fd56cd8..9c08d1882106 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -1101,7 +1101,7 @@ int __meminit vmemmap_populate(unsigned long start, 
unsigned long end, int node,
if (pmd_none(READ_ONCE(*pmdp))) {
void *p = NULL;
 
-   p = vmemmap_alloc_block_buf(PMD_SIZE, node);
+   p = vmemmap_alloc_block_buf(PMD_SIZE, node, NULL);
if (!p)
return -ENOMEM;
 
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index bc73abf0bc25..3fd504d72c5e 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -225,12 +225,12 @@ int __meminit vmemmap_populate(unsigned long start, 
unsigned long end, int node,
 * fall back to system memory if the altmap allocation fail.
 */
if (altmap && !altmap_cross_boundary(altmap, start, page_size)) 
{
-   p = altmap_alloc_block_buf(page_size, altmap);
+   p = vmemmap_alloc_block_buf(page_size, node, altmap);
if (!p)
pr_debug("altmap block allocation failed, 
falling back to system memory");
}
if (!p)
-   p = vmemmap_alloc_block_buf(page_size, node);
+   p = vmemmap_alloc_block_buf(page_size, node, NULL);
if (!p)
return -ENOMEM;
 
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 19c0ed3271a3..5a7a45e7c5ea 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1463,10 +1463,7 @@ static int __meminit vmemmap_populate_hugepages(unsigned 
long start,
if (pmd_none(*pmd)) {
void *p;
 
-   if (altmap)
-   p = altmap_alloc_block_buf(PMD_SIZE, altmap);
-   else
-   p = vmemmap_alloc_block_buf(PMD_SIZE, node);
+   p = vmemmap_alloc_block_buf(PMD_SIZE, node, altmap);
if (p) {
pte_t entry;
 
diff --git a/include/linux/mm.h b/include/linux/mm.h
index e40ac543d248..1973872ed3ab 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3015,8 +3015,8 @@ pte_t *vmemmap_pte_populate(pmd_t *pmd, unsigned long 
addr, int node,
struct vmem_altmap *altmap);
 void 

[PATCH V4 1/3] mm/sparsemem: Enable vmem_altmap support in vmemmap_populate_basepages()

2020-07-05 Thread Anshuman Khandual
vmemmap_populate_basepages() is used across platforms to allocate backing
memory for vmemmap mapping. This is used as a standard default choice or
as a fallback when intended huge pages allocation fails. This just creates
entire vmemmap mapping with base pages (PAGE_SIZE).

On arm64 platforms, vmemmap_populate_basepages() is called instead of the
platform specific vmemmap_populate() when ARM64_SWAPPER_USES_SECTION_MAPS
is not enabled as in case for ARM64_16K_PAGES and ARM64_64K_PAGES configs.

At present vmemmap_populate_basepages() does not support allocating from
driver defined struct vmem_altmap while trying to create vmemmap mapping
for a device memory range. It prevents ARM64_16K_PAGES and ARM64_64K_PAGES
configs on arm64 from supporting device memory with vmemap_altmap request.

This enables vmem_altmap support in vmemmap_populate_basepages() unlocking
device memory allocation for vmemap mapping on arm64 platforms with 16K or
64K base page configs.

Each architecture should evaluate and decide on subscribing device memory
based base page allocation through vmemmap_populate_basepages(). Hence lets
keep it disabled on all archs in order to preserve the existing semantics.
A subsequent patch enables it on arm64.

Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: Mark Rutland 
Cc: Paul Walmsley 
Cc: Palmer Dabbelt 
Cc: Tony Luck 
Cc: Fenghua Yu 
Cc: Dave Hansen 
Cc: Andy Lutomirski 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: David Hildenbrand 
Cc: Mike Rapoport 
Cc: Michal Hocko 
Cc: "Matthew Wilcox (Oracle)" 
Cc: "Kirill A. Shutemov" 
Cc: Andrew Morton 
Cc: Dan Williams 
Cc: Pavel Tatashin 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-i...@vger.kernel.org
Cc: linux-ri...@lists.infradead.org
Cc: x...@kernel.org
Cc: linux-kernel@vger.kernel.org
Tested-by: Jia He 
Acked-by: Will Deacon 
Acked-by: Catalin Marinas 
Signed-off-by: Anshuman Khandual 
---
 arch/arm64/mm/mmu.c  |  2 +-
 arch/ia64/mm/discontig.c |  2 +-
 arch/riscv/mm/init.c |  2 +-
 arch/x86/mm/init_64.c|  6 +++---
 include/linux/mm.h   |  5 +++--
 mm/sparse-vmemmap.c  | 16 +++-
 6 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 1df25f26571d..63b74fd56cd8 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -1069,7 +1069,7 @@ static void free_empty_tables(unsigned long addr, 
unsigned long end,
 int __meminit vmemmap_populate(unsigned long start, unsigned long end, int 
node,
struct vmem_altmap *altmap)
 {
-   return vmemmap_populate_basepages(start, end, node);
+   return vmemmap_populate_basepages(start, end, node, NULL);
 }
 #else  /* !ARM64_SWAPPER_USES_SECTION_MAPS */
 int __meminit vmemmap_populate(unsigned long start, unsigned long end, int 
node,
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index dd8284bcbf16..4d23c81f96d8 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -656,7 +656,7 @@ void arch_refresh_nodedata(int update_node, pg_data_t 
*update_pgdat)
 int __meminit vmemmap_populate(unsigned long start, unsigned long end, int 
node,
struct vmem_altmap *altmap)
 {
-   return vmemmap_populate_basepages(start, end, node);
+   return vmemmap_populate_basepages(start, end, node, NULL);
 }
 
 void vmemmap_free(unsigned long start, unsigned long end,
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index f4adb3684f3d..8101170f54ac 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -530,6 +530,6 @@ void __init paging_init(void)
 int __meminit vmemmap_populate(unsigned long start, unsigned long end, int 
node,
   struct vmem_altmap *altmap)
 {
-   return vmemmap_populate_basepages(start, end, node);
+   return vmemmap_populate_basepages(start, end, node, NULL);
 }
 #endif
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index dbae185511cd..19c0ed3271a3 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1493,7 +1493,7 @@ static int __meminit vmemmap_populate_hugepages(unsigned 
long start,
vmemmap_verify((pte_t *)pmd, node, addr, next);
continue;
}
-   if (vmemmap_populate_basepages(addr, next, node))
+   if (vmemmap_populate_basepages(addr, next, node, NULL))
return -ENOMEM;
}
return 0;
@@ -1505,7 +1505,7 @@ int __meminit vmemmap_populate(unsigned long start, 
unsigned long end, int node,
int err;
 
if (end - start < PAGES_PER_SECTION * sizeof(struct page))
-   err = vmemmap_populate_basepages(start, end, node);
+   err = vmemmap_populate_basepages(start, end, node, NULL);
else if (boot_cpu_has(X86_FEATURE_PSE))
err = vmemmap_populate_hugepages(start, end, node, altmap);
else if (altmap) {
@@ -1513,7 +1513,7 @@ int __meminit vmemmap_populate(unsigned long 

sound/soc/codecs/zl38060.c:614:34: warning: unused variable 'zl38_dt_ids'

2020-07-05 Thread kernel test robot
Hi Sven,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   dcb7fd82c75ee2d6e6f9d8cc71c52519ed52e258
commit: 52e8a94baf9026276fcdc9ff21a50dc2ca0bc94b ASoC: Add initial ZL38060 
driver
date:   3 months ago
config: x86_64-randconfig-a012-20200706 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 
a378c0449507e00e96534ff9ce9034e185425182)
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
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
git checkout 52e8a94baf9026276fcdc9ff21a50dc2ca0bc94b
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross 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 >>):

>> sound/soc/codecs/zl38060.c:614:34: warning: unused variable 'zl38_dt_ids' 
>> [-Wunused-const-variable]
   static const struct of_device_id zl38_dt_ids[] = {
^
   1 warning generated.

vim +/zl38_dt_ids +614 sound/soc/codecs/zl38060.c

   613  
 > 614  static const struct of_device_id zl38_dt_ids[] = {
   615  { .compatible = "mscc,zl38060", },
   616  { /* sentinel */ }
   617  };
   618  MODULE_DEVICE_TABLE(of, zl38_dt_ids);
   619  

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


.config.gz
Description: application/gzip


Re: [RFC PATCH] riscv: enable per-task stack canaries

2020-07-05 Thread Guo Ren
On Mon, Jul 6, 2020 at 9:21 AM Kees Cook  wrote:
>
> On Mon, Jul 06, 2020 at 09:01:51AM +0800, Guo Ren wrote:
> > Yeah! :) I just want to show you, how about the format: use tp in gpr
> > to do that. The format is similar to arm64.
> >
> > tp is the task_struct point in riscv.
>
> Sounds good to me, yes. Thanks! Is there anyone looking at the GCC and
> Clang sides of this?
My colleague is working on gcc's.

-- 
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/


Re: [mm] 4e2c82a409: ltp.overcommit_memory01.fail

2020-07-05 Thread Qian Cai
On Mon, Jul 06, 2020 at 09:43:13AM +0800, Feng Tang wrote:
> On Sun, Jul 05, 2020 at 11:52:32AM -0400, Qian Cai wrote:
> > On Sun, Jul 05, 2020 at 08:58:54PM +0800, Feng Tang wrote:
> > > On Sun, Jul 05, 2020 at 08:15:03AM -0400, Qian Cai wrote:
> > > > 
> > > > 
> > > > > On Jul 5, 2020, at 12:45 AM, Feng Tang  wrote:
> > > > > 
> > > > > I did reproduce the problem, and from the debugging, this should
> > > > > be the same root cause as 
> > > > > lore.kernel.org/lkml/20200526181459.gd...@lca.pw/
> > > > > that loosing the batch cause some accuracy problem, and the solution 
> > > > > of
> > > > > adding some sync is still needed, which is dicussed in
> > > > 
> > > > Well, before taking any of those patches now to fix the regression,
> > > > we will need some performance data first. If it turned out the
> > > > original performance gain is no longer relevant anymore due to this
> > > > regression fix on top, it is best to drop this patchset and restore
> > > > that VM_WARN_ONCE, so you can retry later once you found a better
> > > > way to optimize.
> > > 
> > > The fix of adding sync only happens when the memory policy is being
> > > changed to OVERCOMMIT_NEVER, which is not a frequent operation in
> > > normal cases.
> > > 
> > > For the performance improvment data both in commit log and 0day report
> > > https://lore.kernel.org/lkml/20200622132548.GS5535@shao2-debian/
> > > it is for the will-it-scale's mmap testcase, which will not runtime
> > > change memory overcommit policy, so the data should be still valid
> > > with this fix.
> > 
> > Well, I would expect people are perfectly reasonable to use
> > OVERCOMMIT_NEVER for some workloads making it more frequent operations.
> 
> In my last email, I was not saying OVERCOMMIT_NEVER is not a normal case,
> but I don't think user will too frequently runtime change the overcommit
> policy. And the fix patch of syncing 'vm_committed_as' is only called when
> user calls 'sysctl -w vm.overcommit_memory=2'.
> 
> > The question is now if any of those regression fixes would now regress
> > performance of OVERCOMMIT_NEVER workloads or just in-par with the data
> > before the patchset?
> 
> For the original patchset, it keeps vm_committed_as unchanged for
> OVERCOMMIT_NEVER policy and enlarge it for the other 2 loose policies
> OVERCOMMIT_ALWAYS and OVERCOMMIT_GUESS, and I don't expect the 
> "OVERCOMMIT_NEVER
> workloads" performance  will be impacted. If you have suggetions for this
> kind of benchmarks, I can test them to better verify the patchset, thanks!

Then, please capture those information into a proper commit log when you
submit the regression fix on top of the patchset, and CC PER-CPU MEMORY
ALLOCATOR maintainers, so they might be able to review it properly.

> 
> - Feng
> 
> > 
> > Given now this patchset has had so much churn recently, I would think
> > "should be still valid" is not really the answer we are looking for.
> > 
> > > 
> > > Thanks,
> > > Feng
> > > 
> > > 


Re: [dm-devel] [PATCH v2] dm crypt: add flags to optionally bypass dm-crypt workqueues

2020-07-05 Thread Nobuto Murata

On 6/27/20 6:03 AM, Ignat Korchagin wrote:

This is a follow up from [1]. Consider the following script:

sudo modprobe brd rd_nr=1 rd_size=4194304

echo '0 8388608 crypt capi:ecb(cipher_null) - 0 /dev/ram0 0' | \
sudo dmsetup create eram0

echo '0 8388608 crypt capi:ecb(cipher_null) - 0 /dev/ram0 0 1 
no_write_workqueue' | \
sudo dmsetup create eram0-inline-write

echo '0 8388608 crypt capi:ecb(cipher_null) - 0 /dev/ram0 0 1 
no_read_workqueue' | \
sudo dmsetup create eram0-inline-read

devices="/dev/ram0 /dev/mapper/eram0 /dev/mapper/eram0-inline-read "
devices+="/dev/mapper/eram0-inline-write"

for dev in $devices; do
   echo "reading from $dev"
   sudo fio --filename=$dev --readwrite=read --bs=4k --direct=1 \
   --loops=100 --runtime=3m --name=plain | grep READ
done

for dev in $devices; do
   echo "writing to $dev"
   sudo fio --filename=$dev --readwrite=write --bs=4k --direct=1 \
   --loops=100 --runtime=3m --name=plain | grep WRITE
done

This script creates a ramdisk (to eliminate hardware bias in the benchmark) and
three dm-crypt instances on top. All dm-crypt instances use the NULL cipher
to eliminate potentially expensive crypto bias (the NULL cipher just uses memcpy
for "encyption"). The first instance is the current dm-crypt implementation from
5.8-rc2, the two others have new optional flags enabled, which bypass kcryptd
workqueues for reads and writes respectively and write sorting for writes. On
my VM (Debian in VirtualBox with 4 cores on 2.8 GHz Quad-Core Intel Core i7) I
get the following output (formatted for better readability):

reading from /dev/ram0
READ: bw=508MiB/s (533MB/s), 508MiB/s-508MiB/s (533MB/s-533MB/s), 
io=89.3GiB (95.9GB), run=18-18msec

reading from /dev/mapper/eram0
READ: bw=80.6MiB/s (84.5MB/s), 80.6MiB/s-80.6MiB/s (84.5MB/s-84.5MB/s), 
io=14.2GiB (15.2GB), run=18-18msec

reading from /dev/mapper/eram0-inline-read
READ: bw=295MiB/s (309MB/s), 295MiB/s-295MiB/s (309MB/s-309MB/s), 
io=51.8GiB (55.6GB), run=18-18msec

reading from /dev/mapper/eram0-inline-write
READ: bw=114MiB/s (120MB/s), 114MiB/s-114MiB/s (120MB/s-120MB/s), 
io=20.1GiB (21.5GB), run=18-18msec

writing to /dev/ram0
   WRITE: bw=516MiB/s (541MB/s), 516MiB/s-516MiB/s (541MB/s-541MB/s), 
io=90.7GiB (97.4GB), run=180001-180001msec

writing to /dev/mapper/eram0
   WRITE: bw=40.4MiB/s (42.4MB/s), 40.4MiB/s-40.4MiB/s (42.4MB/s-42.4MB/s), 
io=7271MiB (7624MB), run=180001-180001msec

writing to /dev/mapper/eram0-inline-read
   WRITE: bw=38.9MiB/s (40.8MB/s), 38.9MiB/s-38.9MiB/s (40.8MB/s-40.8MB/s), 
io=7000MiB (7340MB), run=180001-180001msec

writing to /dev/mapper/eram0-inline-write
   WRITE: bw=277MiB/s (290MB/s), 277MiB/s-277MiB/s (290MB/s-290MB/s), 
io=48.6GiB (52.2GB), run=18-18msec


I've applied this v2 patch on top of Ubuntu 5.4 kernel and followed the 
test case on my personal testbed (bare metal) with AMD Ryzen 7 2700. 
Indeed it made things faster in general, but I saw mixed results when 
running it with some scenarios close to the actual workloads. I went 
back to the test case and ran it with various blocksize, iodepth, and 
numjobs, then I saw similar and mixed trends. One of the cases where 
no_(read|write)_workqueue doesn't perform well is as follows:


##
# 4m ioengine=libaio iodepth=16 numjobs=1
##
reading from /dev/ram0
   READ: bw=6208MiB/s (6510MB/s)
reading from /dev/mapper/eram0
   READ: bw=4773MiB/s (5005MB/s)
reading from /dev/mapper/eram0-inline-read
   READ: bw=2782MiB/s (2918MB/s)
reading from /dev/mapper/eram0-inline-write
   READ: bw=4757MiB/s (4988MB/s)
writing to /dev/ram0
  WRITE: bw=5497MiB/s (5764MB/s)
writing to /dev/mapper/eram0
  WRITE: bw=3143MiB/s (3296MB/s)
writing to /dev/mapper/eram0-inline-read
  WRITE: bw=3144MiB/s (3297MB/s)
writing to /dev/mapper/eram0-inline-write
  WRITE: bw=1818MiB/s (1906MB/s)

I've collected the output in:
https://gist.github.com/nobuto-m/74849fb181d9016ddde17c806dac2421#file-patch-v2-testcase_result-txt

Do you see similar trends when blocksize, iodepth, and numjobs are 
changed? Wondered if I should test it again with the latest kernel as 
5.8-rcX properly instead of 5.4.


Thanks,



Current dm-crypt implementation creates a significant IO performance overhead
(at least on small IO block sizes) for both latency and throughput. We suspect
offloading IO request processing into workqueues and async threads is more
harmful these days with the modern fast storage. I also did some digging into
the dm-crypt git history and much of this async processing is not needed
anymore, because the reasons it was added are mostly gone from the kernel. More
details can be found in [2] (see "Git archeology" section).

This change adds no_(read|write)_workqueue flags separately for read and write
BIOs, which direct dm-crypt not to offload crypto operations into kcryptd
workqueues and process everything 

Re: [PATCH 5/5] nvme-pci: Use standard block status macro

2020-07-05 Thread Chaitanya Kulkarni
On 7/2/20 7:55 PM, Baolin Wang wrote:
> Use standard block status macro.
> 
> Signed-off-by: Baolin Wang

Looks good.

Reviewed-by: Chaitanya Kulkarni 


Re: [PATCH 4/5] nvme-pci: Use the consistent return type of nvme_pci_iod_alloc_size()

2020-07-05 Thread Chaitanya Kulkarni
On 7/2/20 7:55 PM, Baolin Wang wrote:
> The nvme_pci_iod_alloc_size() should return 'size_t' type to keep
> consistent.
> 
> Signed-off-by: Baolin Wang

Looks good.

Reviewed-by: Chaitanya Kulkarni 


Re: [PATCH 3/5] nvme-pci: Remove redundant segment validation

2020-07-05 Thread Chaitanya Kulkarni
On 7/2/20 7:54 PM, Baolin Wang wrote:
> We've validated the segment counts before calling nvme_map_data(),
> so there is no need to validate again in nvme_pci_use_sgls() only
> called from nvme_map_data().
> 
> Signed-off-by: Baolin Wang

Indeed we do call blk_rq_nr_phys_segments() in nvme_queue_rq().

Looks good to me.

Reviewed-by: Chaitanya Kulkarni 


[PATCH v2] kasan: fix KASAN unit tests for tag-based KASAN

2020-07-05 Thread Walter Wu
We use tag-based KASAN, then KASAN unit tests don't detect out-of-bounds
memory access. They need to be fixed.

With tag-based KASAN, the state of each 16 aligned bytes of memory is
encoded in one shadow byte and the shadow value is tag of pointer, so
we need to read next shadow byte, the shadow value is not equal to tag
value of pointer, so that tag-based KASAN will detect out-of-bounds
memory access.

Signed-off-by: Walter Wu 
Cc: Andrey Ryabinin 
Cc: Dmitry Vyukov 
Cc: Alexander Potapenko 
Cc: Matthias Brugger 
Cc: Andrey Konovalov 
Cc: Andrew Morton 
---

changes since v1:
- Reduce amount of non-compiled code.
- KUnit-KASAN Integration patchset are not merged yet. My patch should
  have conflict with it, if needed, we can continue to wait it.

---

 lib/test_kasan.c | 81 ++--
 1 file changed, 64 insertions(+), 17 deletions(-)

diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index e3087d90e00d..660664439d52 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -40,7 +40,11 @@ static noinline void __init kmalloc_oob_right(void)
return;
}
 
-   ptr[size] = 'x';
+   if (IS_ENABLED(CONFIG_KASAN_GENERIC))
+   ptr[size] = 'x';
+   else
+   ptr[size + 5] = 'x';
+
kfree(ptr);
 }
 
@@ -92,7 +96,11 @@ static noinline void __init kmalloc_pagealloc_oob_right(void)
return;
}
 
-   ptr[size] = 0;
+   if (IS_ENABLED(CONFIG_KASAN_GENERIC))
+   ptr[size] = 0;
+   else
+   ptr[size + 6] = 0;
+
kfree(ptr);
 }
 
@@ -162,7 +170,11 @@ static noinline void __init kmalloc_oob_krealloc_more(void)
return;
}
 
-   ptr2[size2] = 'x';
+   if (IS_ENABLED(CONFIG_KASAN_GENERIC))
+   ptr2[size2] = 'x';
+   else
+   ptr2[size2 + 13] = 'x';
+
kfree(ptr2);
 }
 
@@ -180,7 +192,12 @@ static noinline void __init kmalloc_oob_krealloc_less(void)
kfree(ptr1);
return;
}
-   ptr2[size2] = 'x';
+
+   if (IS_ENABLED(CONFIG_KASAN_GENERIC))
+   ptr2[size2] = 'x';
+   else
+   ptr2[size2 + 2] = 'x';
+
kfree(ptr2);
 }
 
@@ -216,7 +233,11 @@ static noinline void __init kmalloc_oob_memset_2(void)
return;
}
 
-   memset(ptr+7, 0, 2);
+   if (IS_ENABLED(CONFIG_KASAN_GENERIC))
+   memset(ptr+7, 0, 2);
+   else
+   memset(ptr+15, 0, 2);
+
kfree(ptr);
 }
 
@@ -232,7 +253,11 @@ static noinline void __init kmalloc_oob_memset_4(void)
return;
}
 
-   memset(ptr+5, 0, 4);
+   if (IS_ENABLED(CONFIG_KASAN_GENERIC))
+   memset(ptr+5, 0, 4);
+   else
+   memset(ptr+15, 0, 4);
+
kfree(ptr);
 }
 
@@ -249,7 +274,11 @@ static noinline void __init kmalloc_oob_memset_8(void)
return;
}
 
-   memset(ptr+1, 0, 8);
+   if (IS_ENABLED(CONFIG_KASAN_GENERIC))
+   memset(ptr+1, 0, 8);
+   else
+   memset(ptr+15, 0, 8);
+
kfree(ptr);
 }
 
@@ -265,7 +294,11 @@ static noinline void __init kmalloc_oob_memset_16(void)
return;
}
 
-   memset(ptr+1, 0, 16);
+   if (IS_ENABLED(CONFIG_KASAN_GENERIC))
+   memset(ptr+1, 0, 16);
+   else
+   memset(ptr+15, 0, 16);
+
kfree(ptr);
 }
 
@@ -281,7 +314,11 @@ static noinline void __init kmalloc_oob_in_memset(void)
return;
}
 
-   memset(ptr, 0, size+5);
+   if (IS_ENABLED(CONFIG_KASAN_GENERIC))
+   memset(ptr, 0, size+5);
+   else
+   memset(ptr, 0, size+7);
+
kfree(ptr);
 }
 
@@ -415,7 +452,11 @@ static noinline void __init kmem_cache_oob(void)
return;
}
 
-   *p = p[size];
+   if (IS_ENABLED(CONFIG_KASAN_GENERIC))
+   *p = p[size];
+   else
+   *p = p[size + 8];
+
kmem_cache_free(cache, p);
kmem_cache_destroy(cache);
 }
@@ -497,6 +538,7 @@ static noinline void __init copy_user_test(void)
char __user *usermem;
size_t size = 10;
int unused;
+   size_t oob_size;
 
kmem = kmalloc(size, GFP_KERNEL);
if (!kmem)
@@ -511,26 +553,31 @@ static noinline void __init copy_user_test(void)
return;
}
 
+   if (IS_ENABLED(CONFIG_KASAN_GENERIC))
+   oob_size = 1;
+   else
+   oob_size = 7;
+
pr_info("out-of-bounds in copy_from_user()\n");
-   unused = copy_from_user(kmem, usermem, size + 1);
+   unused = copy_from_user(kmem, usermem, size + oob_size);
 
pr_info("out-of-bounds in copy_to_user()\n");
-   unused = copy_to_user(usermem, kmem, size + 1);
+   unused = copy_to_user(usermem, kmem, size + oob_size);
 
pr_info("out-of-bounds in __copy_from_user()\n");
-   unused = 

mainline/master bisection: baseline.dmesg.crit on qemu_arm-vexpress-a15

2020-07-05 Thread kernelci.org bot
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This automated bisection report was sent to you on the basis  *
* that you may be involved with the breaking commit it has  *
* found.  No manual investigation has been done to verify it,   *
* and the root cause of the problem may be somewhere else.  *
*   *
* If you do send a fix, please include this trailer:*
*   Reported-by: "kernelci.org bot"   *
*   *
* Hope this helps!  *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

mainline/master bisection: baseline.dmesg.crit on qemu_arm-vexpress-a15

Summary:
  Start:  bb5a93aaf252 x86/ldt: use "pr_info_once()" instead of open-coding 
it badly
  Plain log:  
https://storage.kernelci.org/mainline/master/v5.8-rc3-225-gbb5a93aaf252/arm/vexpress_defconfig/gcc-8/lab-cip/baseline-vexpress-v2p-ca15-tc1.txt
  HTML log:   
https://storage.kernelci.org/mainline/master/v5.8-rc3-225-gbb5a93aaf252/arm/vexpress_defconfig/gcc-8/lab-cip/baseline-vexpress-v2p-ca15-tc1.html
  Result: 38ac46002d1d arm: dts: vexpress: Move mcc node back into 
motherboard node

Checks:
  revert: PASS
  verify: PASS

Parameters:
  Tree:   mainline
  URL:https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
  Branch: master
  Target: qemu_arm-vexpress-a15
  CPU arch:   arm
  Lab:lab-cip
  Compiler:   gcc-8
  Config: vexpress_defconfig
  Test case:  baseline.dmesg.crit

Breaking commit found:

---
commit 38ac46002d1df5707566a73486452851341028d2
Author: Andre Przywara 
Date:   Wed Jun 3 17:22:37 2020 +0100

arm: dts: vexpress: Move mcc node back into motherboard node

Commit d9258898ad49 ("arm64: dts: arm: vexpress: Move fixed devices
out of bus node") moved the "mcc" DT node into the root node, because
it does not have any children using "reg" properties, so does violate
some dtc checks about "simple-bus" nodes.

However this broke the vexpress config-bus code, which walks up the
device tree to find the first node with an "arm,vexpress,site" property.
This gave the wrong result (matching the root node instead of the
motherboard node), so broke the clocks and some other devices for
VExpress boards.

Move the whole node back into its original position. This re-introduces
the dtc warning, but is conceptually the right thing to do. The dtc
warning seems to be overzealous here, there are discussions on fixing or
relaxing this check instead.

Link: 
https://lore.kernel.org/r/20200603162237.16319-1-andre.przyw...@arm.com
Fixes: d9258898ad49 ("arm64: dts: vexpress: Move fixed devices out of bus 
node")
Reported-and-tested-by: Guenter Roeck 
Signed-off-by: Andre Przywara 
Signed-off-by: Sudeep Holla 

diff --git a/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi 
b/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi
index e6308fb76183..a88ee5294d35 100644
--- a/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi
+++ b/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi
@@ -100,79 +100,6 @@
};
};
 
-   mcc {
-   compatible = "arm,vexpress,config-bus";
-   arm,vexpress,config-bridge = <_sysreg>;
-
-   oscclk0 {
-   /* MCC static memory clock */
-   compatible = "arm,vexpress-osc";
-   arm,vexpress-sysreg,func = <1 0>;
-   freq-range = <2500 6000>;
-   #clock-cells = <0>;
-   clock-output-names = "v2m:oscclk0";
-   };
-
-   v2m_oscclk1: oscclk1 {
-   /* CLCD clock */
-   compatible = "arm,vexpress-osc";
-   arm,vexpress-sysreg,func = <1 1>;
-   freq-range = <2375 6500>;
-   #clock-cells = <0>;
-   clock-output-names = "v2m:oscclk1";
-   };
-
-   v2m_oscclk2: oscclk2 {
-   /* IO FPGA peripheral clock */
-   compatible = "arm,vexpress-osc";
-   arm,vexpress-sysreg,func = <1 2>;
-   freq-range = <2400 2400>;
-   #clock-cells = <0>;
-   clock-output-names = "v2m:oscclk2";
-   };
-
-   volt-vio {
-   /* Logic level voltage */
-   compatible = "arm,vexpress-volt";
-   arm,vexpress-sysreg,func = <2 0>;
-   regulator-name = "VIO";
-   regulator-always-on;
-   label = "VIO";
-   };
-
-   temp-mcc {
-   

Re: [PATCH 1/5] nvme-pci: Fix some comments issues

2020-07-05 Thread Chaitanya Kulkarni
On 7/2/20 7:54 PM, Baolin Wang wrote:
> Fix comments' typo and remove whitespaces before tabs to cleanup
> checkpatch errors.
> 
> Signed-off-by: Baolin Wang

Looks good to me.

Reviewed-by: Chaitanya Kulkarni 


Re: [PATCH 2/5] nvme-pci: Add a blank line after declarations

2020-07-05 Thread Chaitanya Kulkarni
On 7/2/20 7:54 PM, Baolin Wang wrote:
> Add a blank line after declarations to make code more readable.
> 
> Signed-off-by: Baolin Wang
> ---

Looks good to me.

Reviewed-by: Chaitanya Kulkarni 


new binary algorithm

2020-07-05 Thread Andre Coelho

hey,


for those who read my email, i upgraded tjhe algorithm

here it is

#include 


 // The algorithm works by first getting a base of , and change one 
bit at a time (0001,0010,etc);
// Then it uess a base of  and change one bit at a time 
(1110,1101,etc...)



int main() {
    char zeros[] = { '0','0','0','0','0','0','\0'};
                 char ones[] = { '1','1','1','1','1','1','\0'};

                 printf("\n%s",zeros);

                 int iterator;

                 for (iterator=0 ; iterator < (sizeof(zeros)-1) ; 
iterator++) {

                    zeros[iterator] = '1';
                    printf("\n%s",zeros);
                    zeros[iterator] = '0';
                }
                 printf("\n%s",ones);

                 for (iterator=0 ; iterator < (sizeof(ones)-1); 
iterator++) {

                        ones[iterator] = '0';
                        printf("\n%s",ones);
                        ones[iterator] = '1';
                    }
}



Re: linux-next: manual merge of the drm-intel tree with the drm-intel-fixes tree

2020-07-05 Thread Stephen Rothwell
Hi all,

On Tue, 30 Jun 2020 11:52:02 +1000 Stephen Rothwell  
wrote:
>
> Today's linux-next merge of the drm-intel tree got a conflict in:
> 
>   drivers/gpu/drm/i915/gvt/handlers.c
> 
> between commit:
> 
>   fc1e3aa0337c ("drm/i915/gvt: Fix incorrect check of enabled bits in mask 
> registers")
> 
> from the drm-intel-fixes tree and commit:
> 
>   5f4ae2704d59 ("drm/i915: Identify Cometlake platform")
> 
> from the drm-intel tree.
> 
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging.  You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
> 
> diff --cc drivers/gpu/drm/i915/gvt/handlers.c
> index fadd2adb8030,26cae4846c82..
> --- a/drivers/gpu/drm/i915/gvt/handlers.c
> +++ b/drivers/gpu/drm/i915/gvt/handlers.c
> @@@ -1731,8 -1734,9 +1734,9 @@@ static int ring_mode_mmio_write(struct 
>   return 0;
>   }
>   
> - if (IS_COFFEELAKE(vgpu->gvt->gt->i915) &&
> + if ((IS_COFFEELAKE(vgpu->gvt->gt->i915) ||
> +  IS_COMETLAKE(vgpu->gvt->gt->i915)) &&
>  -data & _MASKED_BIT_ENABLE(2)) {
>  +IS_MASKED_BITS_ENABLED(data, 2)) {
>   enter_failsafe_mode(vgpu, GVT_FAILSAFE_UNSUPPORTED_GUEST);
>   return 0;
>   }

This is now a conflict between the drm tree and Linus' tree.

-- 
Cheers,
Stephen Rothwell


pgpNaQIp01nFx.pgp
Description: OpenPGP digital signature


RE: [PATCH v2 4/4] iommu/vt-d: Add page response ops support

2020-07-05 Thread Tian, Kevin
> From: Lu Baolu
> Sent: Monday, July 6, 2020 8:26 AM
> 
> After a page request is handled, software must response the device which
> raised the page request with the handling result. This is done through

'response' is a noun. 

> the iommu ops.page_response if the request was reported to outside of
> vendor iommu driver through iommu_report_device_fault(). This adds the
> VT-d implementation of page_response ops.
> 
> Co-developed-by: Jacob Pan 
> Signed-off-by: Jacob Pan 
> Co-developed-by: Liu Yi L 
> Signed-off-by: Liu Yi L 
> Signed-off-by: Lu Baolu 
> ---
>  drivers/iommu/intel/iommu.c |  1 +
>  drivers/iommu/intel/svm.c   | 74
> +
>  include/linux/intel-iommu.h |  3 ++
>  3 files changed, 78 insertions(+)
> 
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index de17952ed133..7eb29167e8f9 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -6057,6 +6057,7 @@ const struct iommu_ops intel_iommu_ops = {
>   .sva_bind   = intel_svm_bind,
>   .sva_unbind = intel_svm_unbind,
>   .sva_get_pasid  = intel_svm_get_pasid,
> + .page_response  = intel_svm_page_response,
>  #endif
>  };
> 
> diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
> index 08c58c2b1a06..1c7d8a9ea124 100644
> --- a/drivers/iommu/intel/svm.c
> +++ b/drivers/iommu/intel/svm.c
> @@ -1078,3 +1078,77 @@ int intel_svm_get_pasid(struct iommu_sva *sva)
> 
>   return pasid;
>  }
> +
> +int intel_svm_page_response(struct device *dev,
> + struct iommu_fault_event *evt,
> + struct iommu_page_response *msg)
> +{
> + struct iommu_fault_page_request *prm;
> + struct intel_svm_dev *sdev;
> + struct intel_iommu *iommu;
> + struct intel_svm *svm;
> + bool private_present;
> + bool pasid_present;
> + bool last_page;
> + u8 bus, devfn;
> + int ret = 0;
> + u16 sid;
> +
> + if (!dev || !dev_is_pci(dev))
> + return -ENODEV;

but we didn't do same check when reporting fault?

> +
> + iommu = device_to_iommu(dev, , );
> + if (!iommu)
> + return -ENODEV;
> +
> + if (!msg || !evt)
> + return -EINVAL;
> +
> + mutex_lock(_mutex);
> +
> + prm = >fault.prm;
> + sid = PCI_DEVID(bus, devfn);
> + pasid_present = prm->flags &
> IOMMU_FAULT_PAGE_REQUEST_PASID_VALID;
> + private_present = prm->flags &
> IOMMU_FAULT_PAGE_REQUEST_PRIV_DATA;
> + last_page = prm->flags &
> IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE;
> +
> + if (pasid_present) {
> + if (prm->pasid == 0 || prm->pasid >= PASID_MAX) {
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + ret = pasid_to_svm_sdev(dev, prm->pasid, , );
> + if (ret || !sdev) {
> + ret = -ENODEV;
> + goto out;
> + }
> + }

what about pasid_present==0? Do we support recoverable fault now
with this patch?

and who guarantees that the external fault handler (e.g. guest)
cannot do bad thing with this interface, e.g. by specifying a PASID
belonging to other guests (when Scalable IOV is enabled)?

Thanks
Kevin

> +
> + /*
> +  * Per VT-d spec. v3.0 ch7.7, system software must respond
> +  * with page group response if private data is present (PDP)
> +  * or last page in group (LPIG) bit is set. This is an
> +  * additional VT-d requirement beyond PCI ATS spec.
> +  */
> + if (last_page || private_present) {
> + struct qi_desc desc;
> +
> + desc.qw0 = QI_PGRP_PASID(prm->pasid) | QI_PGRP_DID(sid)
> |
> + QI_PGRP_PASID_P(pasid_present) |
> + QI_PGRP_PDP(private_present) |
> + QI_PGRP_RESP_CODE(msg->code) |
> + QI_PGRP_RESP_TYPE;
> + desc.qw1 = QI_PGRP_IDX(prm->grpid) |
> QI_PGRP_LPIG(last_page);
> + desc.qw2 = 0;
> + desc.qw3 = 0;
> + if (private_present)
> + memcpy(, prm->private_data,
> +sizeof(prm->private_data));
> +
> + qi_submit_sync(iommu, , 1, 0);
> + }
> +out:
> + mutex_unlock(_mutex);
> + return ret;
> +}
> diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
> index fc2cfc3db6e1..bf6009a344f5 100644
> --- a/include/linux/intel-iommu.h
> +++ b/include/linux/intel-iommu.h
> @@ -741,6 +741,9 @@ struct iommu_sva *intel_svm_bind(struct device
> *dev, struct mm_struct *mm,
>void *drvdata);
>  void intel_svm_unbind(struct iommu_sva *handle);
>  int intel_svm_get_pasid(struct iommu_sva *handle);
> +int intel_svm_page_response(struct device *dev, struct iommu_fault_event
> *evt,
> + struct iommu_page_response *msg);
> +
>  struct 

Re: linux-next: manual merge of the bpf-next tree with the bpf tree

2020-07-05 Thread Stephen Rothwell
Hi all,

On Fri, 26 Jun 2020 10:05:27 +1000 Stephen Rothwell  
wrote:
>
> Today's linux-next merge of the bpf-next tree got a conflict in:
> 
>   tools/testing/selftests/bpf/progs/bpf_iter_netlink.c
> 
> between commits:
> 
>   9c82a63cf370 ("libbpf: Fix CO-RE relocs against .text section")
>   647b502e3d54 ("selftests/bpf: Refactor some net macros to 
> bpf_tracing_net.h")
> 
> from the bpf tree and commit:
> 
>   84544f5637ff ("selftests/bpf: Move newer bpf_iter_* type redefining to a 
> new header file")
> 
> from the bpf-next tree.
> 
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging.  You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
> 
> diff --cc tools/testing/selftests/bpf/progs/bpf_iter_netlink.c
> index 75ecf956a2df,cec82a419800..
> --- a/tools/testing/selftests/bpf/progs/bpf_iter_netlink.c
> +++ b/tools/testing/selftests/bpf/progs/bpf_iter_netlink.c
> @@@ -11,21 -7,7 +7,7 @@@
>   
>   char _license[] SEC("license") = "GPL";
>   
> - #define sk_rmem_alloc   sk_backlog.rmem_alloc
> - #define sk_refcnt   __sk_common.skc_refcnt
> - 
> - struct bpf_iter_meta {
> - struct seq_file *seq;
> - __u64 session_id;
> - __u64 seq_num;
> - } __attribute__((preserve_access_index));
> - 
> - struct bpf_iter__netlink {
> - struct bpf_iter_meta *meta;
> - struct netlink_sock *sk;
> - } __attribute__((preserve_access_index));
> - 
>  -static inline struct inode *SOCK_INODE(struct socket *socket)
>  +static __attribute__((noinline)) struct inode *SOCK_INODE(struct socket 
> *socket)
>   {
>   return _of(socket, struct socket_alloc, socket)->vfs_inode;
>   }

This is now a conflict between net-next tree and the net tree.

-- 
Cheers,
Stephen Rothwell


pgpREKAPwc69X.pgp
Description: OpenPGP digital signature


Re: [mm] 4e2c82a409: ltp.overcommit_memory01.fail

2020-07-05 Thread Feng Tang
On Sun, Jul 05, 2020 at 11:52:32AM -0400, Qian Cai wrote:
> On Sun, Jul 05, 2020 at 08:58:54PM +0800, Feng Tang wrote:
> > On Sun, Jul 05, 2020 at 08:15:03AM -0400, Qian Cai wrote:
> > > 
> > > 
> > > > On Jul 5, 2020, at 12:45 AM, Feng Tang  wrote:
> > > > 
> > > > I did reproduce the problem, and from the debugging, this should
> > > > be the same root cause as 
> > > > lore.kernel.org/lkml/20200526181459.gd...@lca.pw/
> > > > that loosing the batch cause some accuracy problem, and the solution of
> > > > adding some sync is still needed, which is dicussed in
> > > 
> > > Well, before taking any of those patches now to fix the regression,
> > > we will need some performance data first. If it turned out the
> > > original performance gain is no longer relevant anymore due to this
> > > regression fix on top, it is best to drop this patchset and restore
> > > that VM_WARN_ONCE, so you can retry later once you found a better
> > > way to optimize.
> > 
> > The fix of adding sync only happens when the memory policy is being
> > changed to OVERCOMMIT_NEVER, which is not a frequent operation in
> > normal cases.
> > 
> > For the performance improvment data both in commit log and 0day report
> > https://lore.kernel.org/lkml/20200622132548.GS5535@shao2-debian/
> > it is for the will-it-scale's mmap testcase, which will not runtime
> > change memory overcommit policy, so the data should be still valid
> > with this fix.
> 
> Well, I would expect people are perfectly reasonable to use
> OVERCOMMIT_NEVER for some workloads making it more frequent operations.

In my last email, I was not saying OVERCOMMIT_NEVER is not a normal case,
but I don't think user will too frequently runtime change the overcommit
policy. And the fix patch of syncing 'vm_committed_as' is only called when
user calls 'sysctl -w vm.overcommit_memory=2'.

> The question is now if any of those regression fixes would now regress
> performance of OVERCOMMIT_NEVER workloads or just in-par with the data
> before the patchset?

For the original patchset, it keeps vm_committed_as unchanged for
OVERCOMMIT_NEVER policy and enlarge it for the other 2 loose policies
OVERCOMMIT_ALWAYS and OVERCOMMIT_GUESS, and I don't expect the "OVERCOMMIT_NEVER
workloads" performance  will be impacted. If you have suggetions for this
kind of benchmarks, I can test them to better verify the patchset, thanks!

- Feng

> 
> Given now this patchset has had so much churn recently, I would think
> "should be still valid" is not really the answer we are looking for.
> 
> > 
> > Thanks,
> > Feng
> > 
> > 


Re: [RFC 1/3] perf jevents: Add support for parsing perchip/percore events

2020-07-05 Thread Ian Rogers
On Thu, Jul 2, 2020 at 11:20 PM kajoljain  wrote:
>
> On 6/25/20 7:38 PM, Ian Rogers wrote:
> > On Thu, Jun 25, 2020 at 4:47 AM Kajol Jain  wrote:
> >>
> >> Set up the "PerChip" field  so that perf knows they are
> >> per chip events.
> >>
> >> Set up the "PerCore" field  so that perf knows they are
> >> per core events and add these fields to pmu_event structure.
> >>
> >> Similar to the way we had "PerPkg field
> >> to specify perpkg events.
> >>
> >> Signed-off-by: Kajol Jain 
> >> ---
> >>  tools/perf/pmu-events/jevents.c| 34 --
> >>  tools/perf/pmu-events/jevents.h|  3 ++-
> >>  tools/perf/pmu-events/pmu-events.h |  2 ++
> >>  3 files changed, 32 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/tools/perf/pmu-events/jevents.c 
> >> b/tools/perf/pmu-events/jevents.c
> >> index fa86c5f997cc..21fd7990ded5 100644
> >> --- a/tools/perf/pmu-events/jevents.c
> >> +++ b/tools/perf/pmu-events/jevents.c
> >> @@ -323,7 +323,8 @@ static int print_events_table_entry(void *data, char 
> >> *name, char *event,
> >> char *pmu, char *unit, char *perpkg,
> >> char *metric_expr,
> >> char *metric_name, char *metric_group,
> >> -   char *deprecated, char 
> >> *metric_constraint)
> >> +   char *deprecated, char *perchip, char 
> >> *percore,
> >> +   char *metric_constraint)
> >>  {
> >> struct perf_entry_data *pd = data;
> >> FILE *outfp = pd->outfp;
> >> @@ -357,6 +358,10 @@ static int print_events_table_entry(void *data, char 
> >> *name, char *event,
> >> fprintf(outfp, "\t.metric_group = \"%s\",\n", 
> >> metric_group);
> >> if (deprecated)
> >> fprintf(outfp, "\t.deprecated = \"%s\",\n", deprecated);
> >> +   if (perchip)
> >> +   fprintf(outfp, "\t.perchip = \"%s\",\n", perchip);
> >> +   if (percore)
> >> +   fprintf(outfp, "\t.percore = \"%s\",\n", percore);
> >> if (metric_constraint)
> >> fprintf(outfp, "\t.metric_constraint = \"%s\",\n", 
> >> metric_constraint);
> >> fprintf(outfp, "},\n");
> >> @@ -378,6 +383,8 @@ struct event_struct {
> >> char *metric_group;
> >> char *deprecated;
> >> char *metric_constraint;
> >> +   char *perchip;
> >> +   char *percore;
> >>  };
> >>
> >>  #define ADD_EVENT_FIELD(field) do { if (field) {   \
> >> @@ -406,6 +413,8 @@ struct event_struct {
> >> op(metric_name);\
> >> op(metric_group);   \
> >> op(deprecated); \
> >> +   op(perchip);\
> >> +   op(percore);\
> >>  } while (0)
> >>
> >>  static LIST_HEAD(arch_std_events);
> >> @@ -425,7 +434,8 @@ static int save_arch_std_events(void *data, char 
> >> *name, char *event,
> >> char *desc, char *long_desc, char *pmu,
> >> char *unit, char *perpkg, char 
> >> *metric_expr,
> >> char *metric_name, char *metric_group,
> >> -   char *deprecated, char *metric_constraint)
> >> +   char *deprecated, char *perchip, char 
> >> *percore,
> >> +   char *metric_constraint)
> >>  {
> >> struct event_struct *es;
> >>
> >> @@ -489,7 +499,8 @@ try_fixup(const char *fn, char *arch_std, char 
> >> **event, char **desc,
> >>   char **name, char **long_desc, char **pmu, char **filter,
> >>   char **perpkg, char **unit, char **metric_expr, char 
> >> **metric_name,
> >>   char **metric_group, unsigned long long eventcode,
> >> - char **deprecated, char **metric_constraint)
> >> + char **deprecated, char **perchip, char **percore,
> >> + char **metric_constraint)
> >>  {
> >> /* try to find matching event from arch standard values */
> >> struct event_struct *es;
> >> @@ -518,7 +529,8 @@ int json_events(const char *fn,
> >>   char *pmu, char *unit, char *perpkg,
> >>   char *metric_expr,
> >>   char *metric_name, char *metric_group,
> >> - char *deprecated, char *metric_constraint),
> >> + char *deprecated, char *perchip, char *percore,
> >> + char *metric_constraint),
> >>   void *data)
> >>  {
> >> int err;
> >> @@ -548,6 +560,8 @@ int json_events(const char *fn,
> >> char *metric_name = NULL;
> >> char *metric_group = NULL;
> >> char *deprecated = NULL;
> >> +   char 

RE: [PATCH v2 3/4] iommu/vt-d: Report page request faults for guest SVA

2020-07-05 Thread Tian, Kevin
> From: Tian, Kevin
> Sent: Monday, July 6, 2020 9:30 AM
> 
> > From: Lu Baolu 
> > Sent: Monday, July 6, 2020 8:26 AM
> >
> > A pasid might be bound to a page table from a VM guest via the iommu
> > ops.sva_bind_gpasid. In this case, when a DMA page fault is detected
> > on the physical IOMMU, we need to inject the page fault request into
> > the guest. After the guest completes handling the page fault, a page
> > response need to be sent back via the iommu ops.page_response().
> >
> > This adds support to report a page request fault. Any external module
> > which is interested in handling this fault should regiester a notifier
> > callback.
> 
> be specific on which notifier to be registered...
> 
> >
> > Co-developed-by: Jacob Pan 
> > Signed-off-by: Jacob Pan 
> > Co-developed-by: Liu Yi L 
> > Signed-off-by: Liu Yi L 
> > Signed-off-by: Lu Baolu 
> > ---
> >  drivers/iommu/intel/svm.c | 99 -
> --
> >  1 file changed, 81 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
> > index c23167877b2b..08c58c2b1a06 100644
> > --- a/drivers/iommu/intel/svm.c
> > +++ b/drivers/iommu/intel/svm.c
> > @@ -815,6 +815,57 @@ static void intel_svm_drain_prq(struct device *dev,
> > int pasid)
> > }
> >  }
> >
> > +static int prq_to_iommu_prot(struct page_req_dsc *req)
> > +{
> > +   int prot = 0;
> > +
> > +   if (req->rd_req)
> > +   prot |= IOMMU_FAULT_PERM_READ;
> > +   if (req->wr_req)
> > +   prot |= IOMMU_FAULT_PERM_WRITE;
> > +   if (req->exe_req)
> > +   prot |= IOMMU_FAULT_PERM_EXEC;
> > +   if (req->pm_req)
> > +   prot |= IOMMU_FAULT_PERM_PRIV;
> > +
> > +   return prot;
> > +}
> > +
> > +static int
> > +intel_svm_prq_report(struct device *dev, struct page_req_dsc *desc)
> > +{
> > +   struct iommu_fault_event event;
> > +   u8 bus, devfn;
> > +
> > +   memset(, 0, sizeof(struct iommu_fault_event));
> > +   bus = PCI_BUS_NUM(desc->rid);
> > +   devfn = desc->rid & 0xff;
> 
> not required.
> 
> > +
> > +   /* Fill in event data for device specific processing */
> > +   event.fault.type = IOMMU_FAULT_PAGE_REQ;
> > +   event.fault.prm.addr = desc->addr;
> > +   event.fault.prm.pasid = desc->pasid;
> > +   event.fault.prm.grpid = desc->prg_index;
> > +   event.fault.prm.perm = prq_to_iommu_prot(desc);
> > +
> > +   /*
> > +* Set last page in group bit if private data is present,
> > +* page response is required as it does for LPIG.
> > +*/
> 
> move to priv_data_present check?
> 
> > +   if (desc->lpig)
> > +   event.fault.prm.flags |=
> > IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE;
> > +   if (desc->pasid_present)
> > +   event.fault.prm.flags |=
> > IOMMU_FAULT_PAGE_REQUEST_PASID_VALID;
> > +   if (desc->priv_data_present) {
> > +   event.fault.prm.flags |=
> > IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE;

btw earlier comment is more about the behavior of the fault
handler (e.g. the guest), but not about why we need convert
to last_page prm flag. Let's make it clear that doing so is 
because iommu_report_device_fault doesn't understand this
vt-d specific requirement thus we set last_page as a workaround.

Thanks
Kevin

> > +   event.fault.prm.flags |=
> > IOMMU_FAULT_PAGE_REQUEST_PRIV_DATA;
> > +   memcpy(event.fault.prm.private_data, desc->priv_data,
> > +  sizeof(desc->priv_data));
> > +   }
> > +
> > +   return iommu_report_device_fault(dev, );
> > +}
> > +
> >  static irqreturn_t prq_event_thread(int irq, void *d)
> >  {
> > struct intel_iommu *iommu = d;
> > @@ -828,7 +879,7 @@ static irqreturn_t prq_event_thread(int irq, void *d)
> > tail = dmar_readq(iommu->reg + DMAR_PQT_REG) &
> > PRQ_RING_MASK;
> > head = dmar_readq(iommu->reg + DMAR_PQH_REG) &
> > PRQ_RING_MASK;
> > while (head != tail) {
> > -   struct intel_svm_dev *sdev;
> > +   struct intel_svm_dev *sdev = NULL;
> 
> move to outside of the loop, otherwise later check always hit "if (!sdev)"
> 
> > struct vm_area_struct *vma;
> > struct page_req_dsc *req;
> > struct qi_desc resp;
> > @@ -864,6 +915,20 @@ static irqreturn_t prq_event_thread(int irq, void
> *d)
> > }
> > }
> >
> > +   if (!sdev || sdev->sid != req->rid) {
> > +   struct intel_svm_dev *t;
> > +
> > +   sdev = NULL;
> > +   rcu_read_lock();
> > +   list_for_each_entry_rcu(t, >devs, list) {
> > +   if (t->sid == req->rid) {
> > +   sdev = t;
> > +   break;
> > +   }
> > +   }
> > +   rcu_read_unlock();
> > +   }
> > +
> > result = QI_RESP_INVALID;
> > /* Since we're using init_mm.pgd directly, we should never
> > take
> >  * any faults on kernel addresses. 

Re: [PATCH] perf/tools/pmu-events/powerpc: Added nest imc metric events

2020-07-05 Thread Ian Rogers
On Thu, Jul 2, 2020 at 11:57 PM Kajol Jain  wrote:
>
> Added nest imc metric events.

Acked-by: Ian Rogers 

> Signed-off-by: Kajol Jain 
> ---
>  .../arch/powerpc/power9/nest_metrics.json | 35 +++
>  1 file changed, 35 insertions(+)
>
> diff --git a/tools/perf/pmu-events/arch/powerpc/power9/nest_metrics.json 
> b/tools/perf/pmu-events/arch/powerpc/power9/nest_metrics.json
> index c121e526442a..8383a37647ad 100644
> --- a/tools/perf/pmu-events/arch/powerpc/power9/nest_metrics.json
> +++ b/tools/perf/pmu-events/arch/powerpc/power9/nest_metrics.json
> @@ -15,5 +15,40 @@
> "MetricExpr": "(hv_24x7@PM_PB_CYC\\,chip\\=?@ )",
>  "MetricName": "PowerBUS_Frequency",
>  "ScaleUnit": "2.5e-7GHz"
> +},
> +{
> +   "MetricExpr" : "nest_mcs01_imc@PM_MCS01_128B_RD_DISP_PORT01@ + 
> nest_mcs01_imc@PM_MCS01_128B_RD_DISP_PORT23@",
> +   "MetricName" : "mcs01-read",
> +   "MetricGroup" : "memory_bw",
> +   "ScaleUnit": "6.1e-5MB"

nit: I'm guessing this is from:
64.0/(1024.0*1024.0) = 6.103515625e-05
and for reference:
64.0/(1000.0*1000.0) = 6.3997e-05
should the unit be MiB?
https://en.wikipedia.org/wiki/Kibibyte

Searching around I only see knightslanding using MiB but it seems to
be using it in the 1000^2 case which probably means it should be MB:
knightslanding/uncore-memory.json:"ScaleUnit": "6.4e-05MiB"

Given there is some confusion I wonder if it makes sense to just make
this 0.015625B and then we have a utility function that selects the
best unit for "bytes" with config options similar to --big-num?

Thanks,
Ian

> +},
> +{
> +   "MetricExpr" : "nest_mcs23_imc@PM_MCS23_128B_RD_DISP_PORT01@ + 
> nest_mcs23_imc@PM_MCS23_128B_RD_DISP_PORT23@",
> +   "MetricName" : "mcs23-read",
> +   "MetricGroup" : "memory_bw",
> +   "ScaleUnit": "6.1e-5MB"
> +},
> +{
> +   "MetricExpr" : "nest_mcs01_imc@PM_MCS01_128B_WR_DISP_PORT01@ + 
> nest_mcs01_imc@PM_MCS01_128B_WR_DISP_PORT23@",
> +   "MetricName" : "mcs01-write",
> +   "MetricGroup" : "memory_bw",
> +   "ScaleUnit": "6.1e-5MB"
> +},
> +{
> +   "MetricExpr" : "nest_mcs23_imc@PM_MCS23_128B_WR_DISP_PORT01@ + 
> nest_mcs23_imc@PM_MCS23_128B_WR_DISP_PORT23@",
> +   "MetricName" : "mcs23-write",
> +   "MetricGroup" : "memory-bandwidth",
> +   "ScaleUnit": "6.1e-5MB"
> +},
> +{
> +   "MetricExpr" : "nest_powerbus0_imc@PM_PB_CYC@",
> +   "MetricName" : "powerbus_freq",
> +   "ScaleUnit": "1e-9GHz"
> +},
> +{
> +   "MetricExpr" : "(nest_mcs01_imc@PM_MCS01_128B_RD_DISP_PORT01@ + 
> nest_mcs01_imc@PM_MCS01_128B_RD_DISP_PORT23@ + 
> nest_mcs23_imc@PM_MCS23_128B_RD_DISP_PORT01@ + 
> nest_mcs23_imc@PM_MCS23_128B_RD_DISP_PORT23@ + 
> nest_mcs01_imc@PM_MCS01_128B_WR_DISP_PORT01@ + 
> nest_mcs01_imc@PM_MCS01_128B_WR_DISP_PORT23@ + 
> nest_mcs23_imc@PM_MCS23_128B_WR_DISP_PORT01@ + 
> nest_mcs23_imc@PM_MCS23_128B_WR_DISP_PORT23@)",
> +   "MetricName" : "Memory-bandwidth-MCS",
> +   "MetricGroup" : "memory_bw",
> +   "ScaleUnit": "6.1e-5MB"
>  }
>  ]
> --
> 2.17.1
>


RE: [PATCH v2 3/4] iommu/vt-d: Report page request faults for guest SVA

2020-07-05 Thread Tian, Kevin
> From: Lu Baolu 
> Sent: Monday, July 6, 2020 8:26 AM
> 
> A pasid might be bound to a page table from a VM guest via the iommu
> ops.sva_bind_gpasid. In this case, when a DMA page fault is detected
> on the physical IOMMU, we need to inject the page fault request into
> the guest. After the guest completes handling the page fault, a page
> response need to be sent back via the iommu ops.page_response().
> 
> This adds support to report a page request fault. Any external module
> which is interested in handling this fault should regiester a notifier
> callback.

be specific on which notifier to be registered...

> 
> Co-developed-by: Jacob Pan 
> Signed-off-by: Jacob Pan 
> Co-developed-by: Liu Yi L 
> Signed-off-by: Liu Yi L 
> Signed-off-by: Lu Baolu 
> ---
>  drivers/iommu/intel/svm.c | 99 ---
>  1 file changed, 81 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
> index c23167877b2b..08c58c2b1a06 100644
> --- a/drivers/iommu/intel/svm.c
> +++ b/drivers/iommu/intel/svm.c
> @@ -815,6 +815,57 @@ static void intel_svm_drain_prq(struct device *dev,
> int pasid)
>   }
>  }
> 
> +static int prq_to_iommu_prot(struct page_req_dsc *req)
> +{
> + int prot = 0;
> +
> + if (req->rd_req)
> + prot |= IOMMU_FAULT_PERM_READ;
> + if (req->wr_req)
> + prot |= IOMMU_FAULT_PERM_WRITE;
> + if (req->exe_req)
> + prot |= IOMMU_FAULT_PERM_EXEC;
> + if (req->pm_req)
> + prot |= IOMMU_FAULT_PERM_PRIV;
> +
> + return prot;
> +}
> +
> +static int
> +intel_svm_prq_report(struct device *dev, struct page_req_dsc *desc)
> +{
> + struct iommu_fault_event event;
> + u8 bus, devfn;
> +
> + memset(, 0, sizeof(struct iommu_fault_event));
> + bus = PCI_BUS_NUM(desc->rid);
> + devfn = desc->rid & 0xff;

not required.

> +
> + /* Fill in event data for device specific processing */
> + event.fault.type = IOMMU_FAULT_PAGE_REQ;
> + event.fault.prm.addr = desc->addr;
> + event.fault.prm.pasid = desc->pasid;
> + event.fault.prm.grpid = desc->prg_index;
> + event.fault.prm.perm = prq_to_iommu_prot(desc);
> +
> + /*
> +  * Set last page in group bit if private data is present,
> +  * page response is required as it does for LPIG.
> +  */

move to priv_data_present check?

> + if (desc->lpig)
> + event.fault.prm.flags |=
> IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE;
> + if (desc->pasid_present)
> + event.fault.prm.flags |=
> IOMMU_FAULT_PAGE_REQUEST_PASID_VALID;
> + if (desc->priv_data_present) {
> + event.fault.prm.flags |=
> IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE;
> + event.fault.prm.flags |=
> IOMMU_FAULT_PAGE_REQUEST_PRIV_DATA;
> + memcpy(event.fault.prm.private_data, desc->priv_data,
> +sizeof(desc->priv_data));
> + }
> +
> + return iommu_report_device_fault(dev, );
> +}
> +
>  static irqreturn_t prq_event_thread(int irq, void *d)
>  {
>   struct intel_iommu *iommu = d;
> @@ -828,7 +879,7 @@ static irqreturn_t prq_event_thread(int irq, void *d)
>   tail = dmar_readq(iommu->reg + DMAR_PQT_REG) &
> PRQ_RING_MASK;
>   head = dmar_readq(iommu->reg + DMAR_PQH_REG) &
> PRQ_RING_MASK;
>   while (head != tail) {
> - struct intel_svm_dev *sdev;
> + struct intel_svm_dev *sdev = NULL;

move to outside of the loop, otherwise later check always hit "if (!sdev)"

>   struct vm_area_struct *vma;
>   struct page_req_dsc *req;
>   struct qi_desc resp;
> @@ -864,6 +915,20 @@ static irqreturn_t prq_event_thread(int irq, void *d)
>   }
>   }
> 
> + if (!sdev || sdev->sid != req->rid) {
> + struct intel_svm_dev *t;
> +
> + sdev = NULL;
> + rcu_read_lock();
> + list_for_each_entry_rcu(t, >devs, list) {
> + if (t->sid == req->rid) {
> + sdev = t;
> + break;
> + }
> + }
> + rcu_read_unlock();
> + }
> +
>   result = QI_RESP_INVALID;
>   /* Since we're using init_mm.pgd directly, we should never
> take
>* any faults on kernel addresses. */
> @@ -874,6 +939,17 @@ static irqreturn_t prq_event_thread(int irq, void *d)
>   if (!is_canonical_address(address))
>   goto bad_req;
> 
> + /*
> +  * If prq is to be handled outside iommu driver via receiver of
> +  * the fault notifiers, we skip the page response here.
> +  */
> + if (svm->flags & SVM_FLAG_GUEST_MODE) {
> + if (sdev && !intel_svm_prq_report(sdev->dev, req))
> +

[PATCH v5 12/14] irqchip/riscv-intc: Fix potential resource leak

2020-07-05 Thread Tiezhu Yang
In the function riscv_intc_init(), system resource "intc_domain"
was not released in an error case. Thus add a call of the function
"irq_domain_remove" in the if branch.

Fixes: 6b7ce8927b5a ("irqchip: RISC-V per-HART local interrupt controller 
driver")
Signed-off-by: Tiezhu Yang 
Reviewed-by: Anup Patel 
---
 drivers/irqchip/irq-riscv-intc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c
index a6f97fa..8d6286c 100644
--- a/drivers/irqchip/irq-riscv-intc.c
+++ b/drivers/irqchip/irq-riscv-intc.c
@@ -122,6 +122,7 @@ static int __init riscv_intc_init(struct device_node *node,
rc = set_handle_irq(_intc_irq);
if (rc) {
pr_err("failed to set irq handler\n");
+   irq_domain_remove(intc_domain);
return rc;
}
 
-- 
2.1.0



[PATCH v5 13/14] irqchip/s3c24xx: Fix potential resource leaks

2020-07-05 Thread Tiezhu Yang
In the function s3c_init_intc_of(), system resource "reg_base", "domain"
and "intc" were not released in a few error cases. Thus add jump targets
for the completion of the desired exception handling.

Fixes: f0774d41da0e ("irqchip: s3c24xx: add devicetree support")
Signed-off-by: Tiezhu Yang 
---
 drivers/irqchip/irq-s3c24xx.c | 23 +--
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c
index d2031fe..cf48e4b 100644
--- a/drivers/irqchip/irq-s3c24xx.c
+++ b/drivers/irqchip/irq-s3c24xx.c
@@ -1227,7 +1227,7 @@ static int __init s3c_init_intc_of(struct device_node *np,
struct s3c24xx_irq_of_ctrl *ctrl;
struct irq_domain *domain;
void __iomem *reg_base;
-   int i;
+   int i, ret;
 
reg_base = of_iomap(np, 0);
if (!reg_base) {
@@ -1239,7 +1239,8 @@ static int __init s3c_init_intc_of(struct device_node *np,
 _irq_ops_of, NULL);
if (!domain) {
pr_err("irq: could not create irq-domain\n");
-   return -EINVAL;
+   ret = -EINVAL;
+   goto err_iounmap;
}
 
for (i = 0; i < num_ctrl; i++) {
@@ -1248,15 +1249,17 @@ static int __init s3c_init_intc_of(struct device_node 
*np,
pr_debug("irq: found controller %s\n", ctrl->name);
 
intc = kzalloc(sizeof(struct s3c_irq_intc), GFP_KERNEL);
-   if (!intc)
-   return -ENOMEM;
+   if (!intc) {
+   ret = -ENOMEM;
+   goto err_domain_remove;
+   }
 
intc->domain = domain;
intc->irqs = kcalloc(32, sizeof(struct s3c_irq_data),
 GFP_KERNEL);
if (!intc->irqs) {
-   kfree(intc);
-   return -ENOMEM;
+   ret = -ENOMEM;
+   goto err_free;
}
 
if (ctrl->parent) {
@@ -1285,6 +1288,14 @@ static int __init s3c_init_intc_of(struct device_node 
*np,
set_handle_irq(s3c24xx_handle_irq);
 
return 0;
+
+err_free:
+   kfree(intc);
+err_domain_remove:
+   irq_domain_remove(domain);
+err_iounmap:
+   iounmap(reg_base);
+   return ret;
 }
 
 static struct s3c24xx_irq_of_ctrl s3c2410_ctrl[] = {
-- 
2.1.0



Re: [PATCH v2 1/2] hwmon: shtc1: add support for device tree bindings

2020-07-05 Thread Chris Ruehl

Hi

On 5/7/2020 10:25 pm, Guenter Roeck wrote:

On Sun, Jul 05, 2020 at 11:47:25AM +0800, Chris Ruehl wrote:

Add support for DTS bindings for the sensirion shtc1,shtw1 and shtc3.

Signed-off-by: Chris Ruehl 
---
  drivers/hwmon/shtc1.c | 22 --
  1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/shtc1.c b/drivers/hwmon/shtc1.c
index a0078ccede03..61e9275eb666 100644
--- a/drivers/hwmon/shtc1.c
+++ b/drivers/hwmon/shtc1.c
@@ -14,6 +14,7 @@
  #include 
  #include 
  #include 
+#include 
  
  /* commands (high precision mode) */

  static const unsigned char shtc1_cmd_measure_blocking_hpm[]= { 0x7C, 0xA2 
};
@@ -196,6 +197,7 @@ static int shtc1_probe(struct i2c_client *client,
enum shtcx_chips chip = id->driver_data;
struct i2c_adapter *adap = client->adapter;
struct device *dev = >dev;
+   struct device_node *np = dev->of_node;
  
  	if (!i2c_check_functionality(adap, I2C_FUNC_I2C)) {

dev_err(dev, "plain i2c transactions not supported\n");
@@ -233,8 +235,13 @@ static int shtc1_probe(struct i2c_client *client,
data->client = client;
data->chip = chip;
  
-	if (client->dev.platform_data)

+   if (np) {
+   data->setup.blocking_io = of_property_read_bool(np, 
"sensirion,blocking_io");
+   data->setup.high_precision = of_property_read_bool(np, 
"sensicon,low_precision");
+   }
+   else if (client->dev.platform_data)
data->setup = *(struct shtc1_platform_data *)dev->platform_data;


CHECK: braces {} should be used on all arms of this statement
#46: FILE: drivers/hwmon/shtc1.c:238:
+   if (np) {
[...]
+   else if (client->dev.platform_data)
[...]

ERROR: else should follow close brace '}'
#50: FILE: drivers/hwmon/shtc1.c:242:
+   }
+   else if (client->dev.platform_data)



it bites back not using the check-patch script! I _should_ know better! :-(

v3 then.

But i will wait a moment to see if someone else lift a finger.

Chris


[PATCH v5 06/14] irqchip/digicolor: Fix potential resource leaks

2020-07-05 Thread Tiezhu Yang
In the function digicolor_of_init(), system resources "reg_base" and
"digicolor_irq_domain" were not released in a few error cases. Thus
add jump targets for the completion of the desired exception handling.

Fixes: 8041dfbd31cf ("irqchip: Conexant CX92755 interrupts controller driver")
Signed-off-by: Tiezhu Yang 
---
 drivers/irqchip/irq-digicolor.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-digicolor.c b/drivers/irqchip/irq-digicolor.c
index fc38d2d..18c6e77 100644
--- a/drivers/irqchip/irq-digicolor.c
+++ b/drivers/irqchip/irq-digicolor.c
@@ -89,7 +89,8 @@ static int __init digicolor_of_init(struct device_node *node,
ucregs = syscon_regmap_lookup_by_phandle(node, "syscon");
if (IS_ERR(ucregs)) {
pr_err("%pOF: unable to map UC registers\n", node);
-   return PTR_ERR(ucregs);
+   ret = PTR_ERR(ucregs);
+   goto err_iounmap;
}
/* channel 1, regular IRQs */
regmap_write(ucregs, UC_IRQ_CONTROL, 1);
@@ -98,7 +99,8 @@ static int __init digicolor_of_init(struct device_node *node,
irq_domain_add_linear(node, 64, _generic_chip_ops, NULL);
if (!digicolor_irq_domain) {
pr_err("%pOF: unable to create IRQ domain\n", node);
-   return -ENOMEM;
+   ret = -ENOMEM;
+   goto err_iounmap;
}
 
ret = irq_alloc_domain_generic_chips(digicolor_irq_domain, 32, 1,
@@ -106,7 +108,7 @@ static int __init digicolor_of_init(struct device_node 
*node,
 clr, 0, 0);
if (ret) {
pr_err("%pOF: unable to allocate IRQ gc\n", node);
-   return ret;
+   goto err_domain_remove;
}
 
digicolor_set_gc(reg_base, 0, IC_INT0ENABLE_LO, IC_FLAG_CLEAR_LO);
@@ -115,5 +117,11 @@ static int __init digicolor_of_init(struct device_node 
*node,
set_handle_irq(digicolor_handle_irq);
 
return 0;
+
+err_domain_remove:
+   irq_domain_remove(digicolor_irq_domain);
+err_iounmap:
+   iounmap(reg_base);
+   return ret;
 }
 IRQCHIP_DECLARE(conexant_digicolor_ic, "cnxt,cx92755-ic", digicolor_of_init);
-- 
2.1.0



[PATCH v5 14/14] irqchip/xilinx-intc: Fix potential resource leak

2020-07-05 Thread Tiezhu Yang
In the function xilinx_intc_of_init(), system resource "irqc->root_domain"
was not released in an error case. Thus add a jump target to call the
function "irq_domain_remove" for the completion of the desired exception
handling.

Fixes: 9689c99e4950 ("irqchip/xilinx: Add support for parent intc")
Signed-off-by: Tiezhu Yang 
---
 drivers/irqchip/irq-xilinx-intc.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/irqchip/irq-xilinx-intc.c 
b/drivers/irqchip/irq-xilinx-intc.c
index 1d3d273..41d9412 100644
--- a/drivers/irqchip/irq-xilinx-intc.c
+++ b/drivers/irqchip/irq-xilinx-intc.c
@@ -192,7 +192,7 @@ static int __init xilinx_intc_of_init(struct device_node 
*intc,
ret = of_property_read_u32(intc, "xlnx,num-intr-inputs", >nr_irq);
if (ret < 0) {
pr_err("irq-xilinx: unable to read xlnx,num-intr-inputs\n");
-   goto error;
+   goto err_iounmap;
}
 
ret = of_property_read_u32(intc, "xlnx,kind-of-intr", >intr_mask);
@@ -229,7 +229,7 @@ static int __init xilinx_intc_of_init(struct device_node 
*intc,
if (!irqc->root_domain) {
pr_err("irq-xilinx: Unable to create IRQ domain\n");
ret = -EINVAL;
-   goto error;
+   goto err_iounmap;
}
 
if (parent) {
@@ -241,7 +241,7 @@ static int __init xilinx_intc_of_init(struct device_node 
*intc,
} else {
pr_err("irq-xilinx: interrupts property not in DT\n");
ret = -EINVAL;
-   goto error;
+   goto err_domain_remove;
}
} else {
primary_intc = irqc;
@@ -250,11 +250,12 @@ static int __init xilinx_intc_of_init(struct device_node 
*intc,
 
return 0;
 
-error:
+err_domain_remove:
+   irq_domain_remove(irqc->root_domain);
+err_iounmap:
iounmap(irqc->base);
kfree(irqc);
return ret;
-
 }
 
 IRQCHIP_DECLARE(xilinx_intc_xps, "xlnx,xps-intc-1.00.a", xilinx_intc_of_init);
-- 
2.1.0



[PATCH v5 07/14] irqchip/dw-apb-ictl: Fix potential resource leaks

2020-07-05 Thread Tiezhu Yang
In the function dw_apb_ictl_init(), system resources "irq" and "domain"
were not released in a few error cases. Thus add jump targets for the
completion of the desired exception handling.

Fixes: 350d71b94fc9 ("irqchip: add DesignWare APB ICTL interrupt controller")
Signed-off-by: Tiezhu Yang 
---
 drivers/irqchip/irq-dw-apb-ictl.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-dw-apb-ictl.c 
b/drivers/irqchip/irq-dw-apb-ictl.c
index e4550e9..bc9b750 100644
--- a/drivers/irqchip/irq-dw-apb-ictl.c
+++ b/drivers/irqchip/irq-dw-apb-ictl.c
@@ -86,12 +86,13 @@ static int __init dw_apb_ictl_init(struct device_node *np,
ret = of_address_to_resource(np, 0, );
if (ret) {
pr_err("%pOF: unable to get resource\n", np);
-   return ret;
+   goto err_irq_dispose;
}
 
if (!request_mem_region(r.start, resource_size(), np->full_name)) {
pr_err("%pOF: unable to request mem region\n", np);
-   return -ENOMEM;
+   ret = -ENOMEM;
+   goto err_irq_dispose;
}
 
iobase = ioremap(r.start, resource_size());
@@ -133,7 +134,7 @@ static int __init dw_apb_ictl_init(struct device_node *np,
 IRQ_GC_INIT_MASK_CACHE);
if (ret) {
pr_err("%pOF: unable to alloc irq domain gc\n", np);
-   goto err_unmap;
+   goto err_domain_remove;
}
 
for (i = 0; i < DIV_ROUND_UP(nrirqs, 32); i++) {
@@ -150,10 +151,14 @@ static int __init dw_apb_ictl_init(struct device_node *np,
 
return 0;
 
+err_domain_remove:
+   irq_domain_remove(domain);
 err_unmap:
iounmap(iobase);
 err_release:
release_mem_region(r.start, resource_size());
+err_irq_dispose:
+   irq_dispose_mapping(irq);
return ret;
 }
 IRQCHIP_DECLARE(dw_apb_ictl,
-- 
2.1.0



Fwd: [PATCH] CodingStyle: Inclusive Terminology

2020-07-05 Thread Nick
Hi

The proposal is not just! It's bloat! Not directed at the problem!
Like ISO 9001 processes which were defined, but which were
circumvented/ignored by every single employee, for god reasons.

If the coding style document would explicite state function, names and
identifiers should be descriptive (it states this for helper
functions) the terms blacklist, master, slave would not be viable
names for anything in the kernel. Most Likely every racist wording
would be similarly excludend.
ie. black has descriptive proportion in coding/technical context, at
this point it's neither functional nor descriptive to the function a
list is used in. Same goes for master, slave and most likely every
racist connoted term.

Reference to african slavery denotes any other racist
behavior/background, which is racist itself.

So I would suggest,

1. to make a clear definition of how function, names and identifiers
should be formed.
so explicite promote the current "short descriptive functional terminology".
As far as I understand that is what linux implicitly expects today anyway.
This would make it easier for greenhorns like me to start contributing.

2.It could help to try to understand the coding style document, trying
to ignore any previous knowledge of linux programming. To my
understanding some paragraphs swallow half of the content.

3. make the maintainers reject every patch not conforming these rules,
except where it is needed for legacy/standard purpose.

4. explain just this is introduced to move away from inconsiderate
conoted racism terms. (1-2 sentence, IMHO) The rest belongs to COC.
The current draft focused to african american slavery is ill fated.


Re: [RFC PATCH] riscv: enable per-task stack canaries

2020-07-05 Thread Kees Cook
On Mon, Jul 06, 2020 at 09:01:51AM +0800, Guo Ren wrote:
> Yeah! :) I just want to show you, how about the format: use tp in gpr
> to do that. The format is similar to arm64.
> 
> tp is the task_struct point in riscv.

Sounds good to me, yes. Thanks! Is there anyone looking at the GCC and
Clang sides of this?

-- 
Kees Cook


[PATCH v5 11/14] irqchip/omap-intc: Fix potential resource leak

2020-07-05 Thread Tiezhu Yang
In the function omap_init_irq_of(), system resource "omap_irq_base"
was not released in an error case. Thus add a call of the function
"iounmap" in the if branch.

Fixes: 8598066cddd1 ("arm: omap: irq: move irq.c to drivers/irqchip/")
Signed-off-by: Tiezhu Yang 
---
 drivers/irqchip/irq-omap-intc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-omap-intc.c b/drivers/irqchip/irq-omap-intc.c
index d360a6e..e711530 100644
--- a/drivers/irqchip/irq-omap-intc.c
+++ b/drivers/irqchip/irq-omap-intc.c
@@ -254,8 +254,10 @@ static int __init omap_init_irq_of(struct device_node 
*node)
omap_irq_soft_reset();
 
ret = omap_alloc_gc_of(domain, omap_irq_base);
-   if (ret < 0)
+   if (ret < 0) {
irq_domain_remove(domain);
+   iounmap(omap_irq_base);
+   }
 
return ret;
 }
-- 
2.1.0



[PATCH 3/3] mm/memory_hotplug: fix unpaired mem_hotplug_begin/done

2020-07-05 Thread Jia He
When check_memblock_offlined_cb() returns failed rc(e.g. the memblock is
online at that time), mem_hotplug_begin/done is unpaired in such case.

Therefore a warning:
 Call Trace:
  percpu_up_write+0x33/0x40
  try_remove_memory+0x66/0x120
  ? _cond_resched+0x19/0x30
  remove_memory+0x2b/0x40
  dev_dax_kmem_remove+0x36/0x72 [kmem]
  device_release_driver_internal+0xf0/0x1c0
  device_release_driver+0x12/0x20
  bus_remove_device+0xe1/0x150
  device_del+0x17b/0x3e0
  unregister_dev_dax+0x29/0x60
  devm_action_release+0x15/0x20
  release_nodes+0x19a/0x1e0
  devres_release_all+0x3f/0x50
  device_release_driver_internal+0x100/0x1c0
  driver_detach+0x4c/0x8f
  bus_remove_driver+0x5c/0xd0
  driver_unregister+0x31/0x50
  dax_pmem_exit+0x10/0xfe0 [dax_pmem]

This fixes it by moving mem_hotplug_done ahead of "done"

Signed-off-by: Jia He 
---
 mm/memory_hotplug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index e1e290577b45..86b36714342b 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1769,8 +1769,8 @@ static int __ref try_remove_memory(int nid, u64 start, 
u64 size)
 
try_offline_node(nid);
 
-done:
mem_hotplug_done();
+done:
return rc;
 }
 
-- 
2.17.1



Re: [PATCH] riscv: Add STACKPROTECTOR supported

2020-07-05 Thread Kees Cook
On Mon, Jul 06, 2020 at 08:55:35AM +0800, Guo Ren wrote:
> On Mon, Jul 6, 2020 at 4:31 AM Kees Cook  wrote:
> > Sure -- I assume get_cycles64() is architecturally "simple"? (i.e. it
> > doesn't require that the entire time-keeping subsystem has started?)
> Yes, it's just a csr read. But it's necessary? get_random_bytes should enough.

Well, that depends on how early _all_ riscv platforms are able to
initialize their random pool correctly. I'd include a csr mix.

-- 
Kees Cook


[PATCH 0/3] Fix and enable pmem as RAM on arm64

2020-07-05 Thread Jia He
This fix a few issues when I tried to enable pmem as RAM device on arm64.

Tested on ThunderX2 host/qemu "-M virt" guest.

Jia He (3):
  arm64/numa: set numa_off to false when numa node is fake
  mm/memory_hotplug: harden try_offline_node against bogus nid
  mm/memory_hotplug: fix unpaired mem_hotplug_begin/done

 arch/arm64/mm/numa.c | 3 ++-
 mm/memory_hotplug.c  | 5 -
 2 files changed, 6 insertions(+), 2 deletions(-)

-- 
2.17.1



[PATCH v5 03/14] irqchip/csky-mpintc: Fix potential resource leaks

2020-07-05 Thread Tiezhu Yang
In the function csky_mpintc_init(), system resources "__trigger",
"INTCG_base" and "root_domain" were not released in a few error
cases. Thus add jump targets for the completion of the desired
exception handling. By the way, do some coding-style cleanups
suggested by Markus.

Fixes: d8a5f5f79122 ("irqchip: add C-SKY SMP interrupt controller")
Signed-off-by: Tiezhu Yang 
---
 drivers/irqchip/irq-csky-mpintc.c | 31 ++-
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/irqchip/irq-csky-mpintc.c 
b/drivers/irqchip/irq-csky-mpintc.c
index a1534ed..df41735 100644
--- a/drivers/irqchip/irq-csky-mpintc.c
+++ b/drivers/irqchip/irq-csky-mpintc.c
@@ -241,14 +241,16 @@ csky_mpintc_init(struct device_node *node, struct 
device_node *parent)
nr_irq = INTC_IRQS;
 
__trigger  = kcalloc(nr_irq, sizeof(unsigned long), GFP_KERNEL);
-   if (__trigger == NULL)
+   if (!__trigger)
return -ENXIO;
 
-   if (INTCG_base == NULL) {
+   if (!INTCG_base) {
INTCG_base = ioremap(mfcr("cr<31, 14>"),
-INTCL_SIZE*nr_cpu_ids + INTCG_SIZE);
-   if (INTCG_base == NULL)
-   return -EIO;
+INTCL_SIZE * nr_cpu_ids + INTCG_SIZE);
+   if (!INTCG_base) {
+   ret = -EIO;
+   goto err_free;
+   }
 
INTCL_base = INTCG_base + INTCG_SIZE;
 
@@ -257,8 +259,10 @@ csky_mpintc_init(struct device_node *node, struct 
device_node *parent)
 
root_domain = irq_domain_add_linear(node, nr_irq, _irqdomain_ops,
NULL);
-   if (!root_domain)
-   return -ENXIO;
+   if (!root_domain) {
+   ret = -ENXIO;
+   goto err_iounmap;
+   }
 
/* for every cpu */
for_each_present_cpu(cpu) {
@@ -270,12 +274,21 @@ csky_mpintc_init(struct device_node *node, struct 
device_node *parent)
 
 #ifdef CONFIG_SMP
ipi_irq = irq_create_mapping(root_domain, IPI_IRQ);
-   if (!ipi_irq)
-   return -EIO;
+   if (!ipi_irq) {
+   irq_domain_remove(root_domain);
+   ret = -EIO;
+   goto err_iounmap;
+   }
 
set_send_ipi(_mpintc_send_ipi, ipi_irq);
 #endif
 
return 0;
+
+err_iounmap:
+   iounmap(INTCG_base);
+err_free:
+   kfree(__trigger);
+   return ret;
 }
 IRQCHIP_DECLARE(csky_mpintc, "csky,mpintc", csky_mpintc_init);
-- 
2.1.0



[PATCH 1/3] arm64/numa: set numa_off to false when numa node is fake

2020-07-05 Thread Jia He
Previously, numa_off is set to true unconditionally in dummy_numa_init(),
even if there is a fake numa node.

But acpi will translate node id to NUMA_NO_NODE(-1) in acpi_map_pxm_to_node()
because it regards numa_off as turning off the numa node.

Without this patch, pmem can't be probed as a RAM device on arm64 if SRAT table
isn't present.

$ndctl create-namespace -fe namespace0.0 --mode=devdax --map=dev -s 1g -a 64K
kmem dax0.0: rejecting DAX region [mem 0x24040-0x2bfff] with invalid 
node: -1
kmem: probe of dax0.0 failed with error -22

This fixes it by setting numa_off to false.

Signed-off-by: Jia He 
---
 arch/arm64/mm/numa.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c
index aafcee3e3f7e..7689986020d9 100644
--- a/arch/arm64/mm/numa.c
+++ b/arch/arm64/mm/numa.c
@@ -440,7 +440,8 @@ static int __init dummy_numa_init(void)
return ret;
}
 
-   numa_off = true;
+   /* force numa_off to be false since we have a fake numa node here */
+   numa_off = false;
return 0;
 }
 
-- 
2.17.1



[PATCH v5 01/14] irqchip/ath79-misc: Fix potential resource leaks

2020-07-05 Thread Tiezhu Yang
In the function ath79_misc_intc_of_init(), system resources "irq" and
"base" were not released in a few error cases. Thus add jump targets
for the completion of the desired exception handling.

Fixes: 07ba4b061a79 ("irqchip/ath79-misc: Move the MISC driver from 
arch/mips/ath79/")
Signed-off-by: Tiezhu Yang 
---
 drivers/irqchip/irq-ath79-misc.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-ath79-misc.c b/drivers/irqchip/irq-ath79-misc.c
index 3d641bb..53e0c50 100644
--- a/drivers/irqchip/irq-ath79-misc.c
+++ b/drivers/irqchip/irq-ath79-misc.c
@@ -133,7 +133,7 @@ static int __init ath79_misc_intc_of_init(
 {
struct irq_domain *domain;
void __iomem *base;
-   int irq;
+   int irq, ret;
 
irq = irq_of_parse_and_map(node, 0);
if (!irq) {
@@ -144,18 +144,26 @@ static int __init ath79_misc_intc_of_init(
base = of_iomap(node, 0);
if (!base) {
pr_err("Failed to get MISC IRQ registers\n");
-   return -ENOMEM;
+   ret = -ENOMEM;
+   goto err_irq_dispose;
}
 
domain = irq_domain_add_linear(node, ATH79_MISC_IRQ_COUNT,
_irq_domain_ops, base);
if (!domain) {
pr_err("Failed to add MISC irqdomain\n");
-   return -EINVAL;
+   ret = -EINVAL;
+   goto err_iounmap;
}
 
ath79_misc_intc_domain_init(domain, irq);
return 0;
+
+err_iounmap:
+   iounmap(base);
+err_irq_dispose:
+   irq_dispose_mapping(irq);
+   return ret;
 }
 
 static int __init ar7100_misc_intc_of_init(
-- 
2.1.0



[PATCH 2/3] mm/memory_hotplug: harden try_offline_node against bogus nid

2020-07-05 Thread Jia He
When testing the remove_memory path of dax pmem, there will be a panic with
call trace:
  try_remove_memory+0x84/0x170
  remove_memory+0x38/0x58
  dev_dax_kmem_remove+0x3c/0x84 [kmem]
  device_release_driver_internal+0xfc/0x1c8
  device_release_driver+0x28/0x38
  bus_remove_device+0xd4/0x158
  device_del+0x160/0x3a0
  unregister_dev_dax+0x30/0x68
  devm_action_release+0x20/0x30
  release_nodes+0x150/0x240
  devres_release_all+0x6c/0x1d0
  device_release_driver_internal+0x10c/0x1c8
  driver_detach+0xac/0x170
  bus_remove_driver+0x64/0x130
  driver_unregister+0x34/0x60
  dax_pmem_exit+0x14/0xffc4 [dax_pmem]
  __arm64_sys_delete_module+0x18c/0x2d0
  el0_svc_common.constprop.2+0x78/0x168
  do_el0_svc+0x34/0xa0
  el0_sync_handler+0xe0/0x188
  el0_sync+0x164/0x180

It is caused by the bogus nid (-1). Although the root cause is pmem dax
translates from pxm to node_id incorrectly due to numa_off, it is worth
hardening the codes in try_offline_node(), quiting if !pgdat.

Signed-off-by: Jia He 
---
 mm/memory_hotplug.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index da374cd3d45b..e1e290577b45 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1680,6 +1680,9 @@ void try_offline_node(int nid)
pg_data_t *pgdat = NODE_DATA(nid);
int rc;
 
+   if (WARN_ON(!pgdat))
+   return;
+
/*
 * If the node still spans pages (especially ZONE_DEVICE), don't
 * offline it. A node spans memory after move_pfn_range_to_zone(),
-- 
2.17.1



[PATCH v5 02/14] irqchip/csky-apb-intc: Fix potential resource leaks

2020-07-05 Thread Tiezhu Yang
In the function ck_intc_init_comm(), system resources "reg_base" and
"root_domain" were not released in two error cases. Thus add jump
targets for the completion of the desired exception handling.

Fixes: edff1b4835b7 ("irqchip: add C-SKY APB bus interrupt controller")
Signed-off-by: Tiezhu Yang 
---
 drivers/irqchip/irq-csky-apb-intc.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-csky-apb-intc.c 
b/drivers/irqchip/irq-csky-apb-intc.c
index 5a2ec43..66aeb84 100644
--- a/drivers/irqchip/irq-csky-apb-intc.c
+++ b/drivers/irqchip/irq-csky-apb-intc.c
@@ -118,7 +118,8 @@ ck_intc_init_comm(struct device_node *node, struct 
device_node *parent)
_generic_chip_ops, NULL);
if (!root_domain) {
pr_err("C-SKY Intc irq_domain_add failed.\n");
-   return -ENOMEM;
+   ret = -ENOMEM;
+   goto err_iounmap;
}
 
ret = irq_alloc_domain_generic_chips(root_domain, 32, 1,
@@ -126,10 +127,16 @@ ck_intc_init_comm(struct device_node *node, struct 
device_node *parent)
IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN, 0, 0);
if (ret) {
pr_err("C-SKY Intc irq_alloc_gc failed.\n");
-   return -ENOMEM;
+   goto err_domain_remove;
}
 
return 0;
+
+err_domain_remove:
+   irq_domain_remove(root_domain);
+err_iounmap:
+   iounmap(reg_base);
+   return ret;
 }
 
 static inline bool handle_irq_perbit(struct pt_regs *regs, u32 hwirq,
-- 
2.1.0



[PATCH v5 10/14] irqchip/nvic: Fix potential resource leaks

2020-07-05 Thread Tiezhu Yang
In the function nvic_of_init(), system resource "nvic_base" and
"nvic_irq_domain" were not released in two error cases. Thus add
jump targets for the completion of the desired exception handling.

Fixes: 292ec080491d ("irqchip: Add support for ARMv7-M NVIC")
Signed-off-by: Tiezhu Yang 
---
 drivers/irqchip/irq-nvic.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-nvic.c b/drivers/irqchip/irq-nvic.c
index f747e22..cd17f5d 100644
--- a/drivers/irqchip/irq-nvic.c
+++ b/drivers/irqchip/irq-nvic.c
@@ -94,7 +94,8 @@ static int __init nvic_of_init(struct device_node *node,
 
if (!nvic_irq_domain) {
pr_warn("Failed to allocate irq domain\n");
-   return -ENOMEM;
+   ret = -ENOMEM;
+   goto err_iounmap;
}
 
ret = irq_alloc_domain_generic_chips(nvic_irq_domain, 32, 1,
@@ -102,8 +103,7 @@ static int __init nvic_of_init(struct device_node *node,
 clr, 0, IRQ_GC_INIT_MASK_CACHE);
if (ret) {
pr_warn("Failed to allocate irq chips\n");
-   irq_domain_remove(nvic_irq_domain);
-   return ret;
+   goto err_domain_remove;
}
 
for (i = 0; i < numbanks; ++i) {
@@ -129,5 +129,11 @@ static int __init nvic_of_init(struct device_node *node,
writel_relaxed(0, nvic_base + NVIC_IPR + i);
 
return 0;
+
+err_domain_remove:
+   irq_domain_remove(nvic_irq_domain);
+err_iounmap:
+   iounmap(nvic_base);
+   return ret;
 }
 IRQCHIP_DECLARE(armv7m_nvic, "arm,armv7m-nvic", nvic_of_init);
-- 
2.1.0



[PATCH v5 05/14] irqchip/davinci-cp-intc: Fix potential resource leaks

2020-07-05 Thread Tiezhu Yang
In the function davinci_cp_intc_do_init(), system resources
"config->reg.start", "davinci_cp_intc_base" and "irq_base"
were not released in a few error cases. Thus add jump targets
for the completion of the desired exception handling.

Fixes: 0fc3d74cf946 ("irqchip: davinci-cp-intc: move the driver to 
drivers/irqchip")
Signed-off-by: Tiezhu Yang 
---
 drivers/irqchip/irq-davinci-cp-intc.c | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-davinci-cp-intc.c 
b/drivers/irqchip/irq-davinci-cp-intc.c
index 276da277..2c2e115 100644
--- a/drivers/irqchip/irq-davinci-cp-intc.c
+++ b/drivers/irqchip/irq-davinci-cp-intc.c
@@ -162,6 +162,7 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config 
*config,
unsigned int num_regs = BITS_TO_LONGS(config->num_irqs);
int offset, irq_base;
void __iomem *req;
+   int ret;
 
req = request_mem_region(config->reg.start,
 resource_size(>reg),
@@ -175,7 +176,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config 
*config,
   resource_size(>reg));
if (!davinci_cp_intc_base) {
pr_err("%s: unable to ioremap register range\n", __func__);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto err_release;
}
 
davinci_cp_intc_write(0, DAVINCI_CP_INTC_GLOBAL_ENABLE);
@@ -210,7 +212,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config 
*config,
if (irq_base < 0) {
pr_err("%s: unable to allocate interrupt descriptors: %d\n",
   __func__, irq_base);
-   return irq_base;
+   ret = irq_base;
+   goto err_iounmap;
}
 
davinci_cp_intc_irq_domain = irq_domain_add_legacy(
@@ -219,7 +222,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config 
*config,
 
if (!davinci_cp_intc_irq_domain) {
pr_err("%s: unable to create an interrupt domain\n", __func__);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto err_free_descs;
}
 
set_handle_irq(davinci_cp_intc_handle_irq);
@@ -228,6 +232,14 @@ davinci_cp_intc_do_init(const struct 
davinci_cp_intc_config *config,
davinci_cp_intc_write(1, DAVINCI_CP_INTC_GLOBAL_ENABLE);
 
return 0;
+
+err_free_descs:
+   irq_free_descs(irq_base, config->num_irqs);
+err_iounmap:
+   iounmap(davinci_cp_intc_base);
+err_release:
+   release_mem_region(config->reg.start, resource_size(>reg));
+   return ret;
 }
 
 int __init davinci_cp_intc_init(const struct davinci_cp_intc_config *config)
-- 
2.1.0



[PATCH v5 00/14] irqchip: Fix potential resource leaks

2020-07-05 Thread Tiezhu Yang
When I test the irqchip code of Loongson, I read the related code of other
chips in drivers/irqchip and I find some potential resource leaks in the
error path, I think it is better to fix them.

v2:
  - Split the first patch into a new patch series which
includes small patches and add "Fixes" tag
  - Use "goto" label to handle error path in some patches

v3:
  - Add missed variable "ret" in the patch #5 and #13

v4:
  - Modify the commit message of each patch suggested by Markus Elfring
  - Make "irq_domain_remove(root_domain)" under CONFIG_SMP in patch #3
  - Add a return statement before goto label in patch #4

v5:
  - Modify the commit messages and do some code cleanups

Tiezhu Yang (14):
  irqchip/ath79-misc: Fix potential resource leaks
  irqchip/csky-apb-intc: Fix potential resource leaks
  irqchip/csky-mpintc: Fix potential resource leaks
  irqchip/davinci-aintc: Fix potential resource leaks
  irqchip/davinci-cp-intc: Fix potential resource leaks
  irqchip/digicolor: Fix potential resource leaks
  irqchip/dw-apb-ictl: Fix potential resource leaks
  irqchip/ls1x: Fix potential resource leaks
  irqchip/mscc-ocelot: Fix potential resource leaks
  irqchip/nvic: Fix potential resource leaks
  irqchip/omap-intc: Fix potential resource leak
  irqchip/riscv-intc: Fix potential resource leak
  irqchip/s3c24xx: Fix potential resource leaks
  irqchip/xilinx-intc: Fix potential resource leak

 drivers/irqchip/irq-ath79-misc.c  | 14 +++---
 drivers/irqchip/irq-csky-apb-intc.c   | 11 +--
 drivers/irqchip/irq-csky-mpintc.c | 31 ++-
 drivers/irqchip/irq-davinci-aintc.c   | 18 ++
 drivers/irqchip/irq-davinci-cp-intc.c | 18 +++---
 drivers/irqchip/irq-digicolor.c   | 14 +++---
 drivers/irqchip/irq-dw-apb-ictl.c | 11 ---
 drivers/irqchip/irq-ls1x.c|  4 +++-
 drivers/irqchip/irq-mscc-ocelot.c |  6 --
 drivers/irqchip/irq-nvic.c| 12 +---
 drivers/irqchip/irq-omap-intc.c   |  4 +++-
 drivers/irqchip/irq-riscv-intc.c  |  1 +
 drivers/irqchip/irq-s3c24xx.c | 23 +--
 drivers/irqchip/irq-xilinx-intc.c | 11 ++-
 14 files changed, 133 insertions(+), 45 deletions(-)

-- 
2.1.0



[PATCH v5 04/14] irqchip/davinci-aintc: Fix potential resource leaks

2020-07-05 Thread Tiezhu Yang
In the function davinci_aintc_init(), system resources "config->reg.start",
"davinci_aintc_base", "irq_base" and "davinci_aintc_irq_domain" were not
released in a few error cases. Thus add jump targets for the completion of
the desired exception handling.

Fixes: 0145beed9d26 ("irqchip: davinci-aintc: move the driver to 
drivers/irqchip")
Signed-off-by: Tiezhu Yang 
---
 drivers/irqchip/irq-davinci-aintc.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/irq-davinci-aintc.c 
b/drivers/irqchip/irq-davinci-aintc.c
index 810ccc4..2a96dc9 100644
--- a/drivers/irqchip/irq-davinci-aintc.c
+++ b/drivers/irqchip/irq-davinci-aintc.c
@@ -96,7 +96,7 @@ void __init davinci_aintc_init(const struct 
davinci_aintc_config *config)
 resource_size(>reg));
if (!davinci_aintc_base) {
pr_err("%s: unable to ioremap register range\n", __func__);
-   return;
+   goto err_release;
}
 
/* Clear all interrupt requests */
@@ -133,7 +133,7 @@ void __init davinci_aintc_init(const struct 
davinci_aintc_config *config)
if (irq_base < 0) {
pr_err("%s: unable to allocate interrupt descriptors: %d\n",
   __func__, irq_base);
-   return;
+   goto err_iounmap;
}
 
davinci_aintc_irq_domain = irq_domain_add_legacy(NULL,
@@ -141,7 +141,7 @@ void __init davinci_aintc_init(const struct 
davinci_aintc_config *config)
_domain_simple_ops, NULL);
if (!davinci_aintc_irq_domain) {
pr_err("%s: unable to create interrupt domain\n", __func__);
-   return;
+   goto err_free_descs;
}
 
ret = irq_alloc_domain_generic_chips(davinci_aintc_irq_domain, 32, 1,
@@ -150,7 +150,7 @@ void __init davinci_aintc_init(const struct 
davinci_aintc_config *config)
if (ret) {
pr_err("%s: unable to allocate generic irq chips for domain\n",
   __func__);
-   return;
+   goto err_domain_remove;
}
 
for (irq_off = 0, reg_off = 0;
@@ -160,4 +160,14 @@ void __init davinci_aintc_init(const struct 
davinci_aintc_config *config)
   irq_base + irq_off, 32);
 
set_handle_irq(davinci_aintc_handle_irq);
+   return;
+
+err_domain_remove:
+   irq_domain_remove(davinci_aintc_irq_domain);
+err_free_descs:
+   irq_free_descs(irq_base, config->num_irqs);
+err_iounmap:
+   iounmap(davinci_aintc_base);
+err_release:
+   release_mem_region(config->reg.start, resource_size(>reg));
 }
-- 
2.1.0



[PATCH v5 09/14] irqchip/mscc-ocelot: Fix potential resource leaks

2020-07-05 Thread Tiezhu Yang
In the function ocelot_irq_init(), system resource "parent_irq"
was not released in a few error cases. Thus add a jump target
for the completion of the desired exception handling.

Fixes: 19d99164480a ("irqchip: Add a driver for the Microsemi Ocelot 
controller")
Signed-off-by: Tiezhu Yang 
---
 drivers/irqchip/irq-mscc-ocelot.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-mscc-ocelot.c 
b/drivers/irqchip/irq-mscc-ocelot.c
index 88143c0..e676ae2 100644
--- a/drivers/irqchip/irq-mscc-ocelot.c
+++ b/drivers/irqchip/irq-mscc-ocelot.c
@@ -73,7 +73,8 @@ static int __init ocelot_irq_init(struct device_node *node,
   _generic_chip_ops, NULL);
if (!domain) {
pr_err("%pOFn: unable to add irq domain\n", node);
-   return -ENOMEM;
+   ret = -ENOMEM;
+   goto err_irq_dispose;
}
 
ret = irq_alloc_domain_generic_chips(domain, OCELOT_NR_IRQ, 1,
@@ -109,9 +110,10 @@ static int __init ocelot_irq_init(struct device_node *node,
 
 err_gc_free:
irq_free_generic_chip(gc);
-
 err_domain_remove:
irq_domain_remove(domain);
+err_irq_dispose:
+   irq_dispose_mapping(parent_irq);
 
return ret;
 }
-- 
2.1.0



  1   2   3   4   5   >