Re: [PATCH v2 1/3] dt-bindings: pwm-stm32: document pinctrl sleep state

2019-10-16 Thread Thierry Reding
On Fri, Oct 04, 2019 at 02:53:51PM +0200, Fabrice Gasnier wrote:
> Add documentation for pinctrl sleep state that can be used by
> STM32 timers PWM.
> 
> Signed-off-by: Fabrice Gasnier 
> ---
>  Documentation/devicetree/bindings/pwm/pwm-stm32.txt | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)

Applied, thanks.

Thierry


signature.asc
Description: PGP signature


Re: [PATCH] tpm: Salt tpm_get_random() result with get_random_bytes()

2019-10-16 Thread Janne Karhunen
On Tue, Oct 15, 2019 at 3:50 PM Jarkko Sakkinen
 wrote:
>
> Salt the result that comes from the TPM RNG with random bytes from the
> kernel RNG. This will allow to use tpm_get_random() as a substitute for
> get_random_bytes().  TPM could have a bug (making results predicatable),
> backdoor or even an inteposer in the bus. Salting gives protections
> against these concerns.

The current issue in the randomness from my point of view is that
encrypted filesystems, ima etc in common deployments require high
quality entropy just few seconds after the system has powered on for
the first time. It is likely that people want to keep their keys
device specific, so the keys need to be generated on the first boot
before any of the filesystems mount.

Issue is wider than the tpm alone. Tpm is not generally present in the
mobile (or even embedded-) systems, but the kernel entropy pool is.
Kernel entropy pool on the other hand normally takes ages to
initialize, and it is initialized from a source (interrupt timestamps)
that does not classify as high-quality entropy. Thus, in the default
configurations the first boot cannot proceed as there is no entropy to
generate keys from and the boot cannot be paused or the entropy
collection ends. I have a hunch that to get past this deadlock many
people end up using very, very low quality entropy present at the krng
at that time. Solving this properly should be in everyone's interests.
This is a bad trap.

I'm personally working around this by using multiple entropy sources
to feed the kernel entropy pool directly from the hwrng driver
initialization function(s) before we enter the userspace. Maybe we
could create a KConfig option that forces people to consciously choose
from the trust sources present in the system which ones are to be used
to feed the krng before we enter the userspace. It would be mandatory
to choose one or more sources rather than us silently running them
into a trap. During the boot some sort of message should be displayed
telling the user how the krng actually got initialized. There is lot
of junk happening on the console early on, but this absolutely vital
piece of information is completely hidden - that you have to read from
the source.


--
Janne


Re: [PATCH v2 2/3] pwm: stm32: split breakinput apply routine to ease PM support

2019-10-16 Thread Thierry Reding
On Fri, Oct 04, 2019 at 02:53:52PM +0200, Fabrice Gasnier wrote:
> Split breakinput routine that configures STM32 timers 'break' safety
> feature upon probe, into two routines:
> - stm32_pwm_apply_breakinputs() sets all the break inputs into registers.
> - stm32_pwm_probe_breakinputs() probes the device tree break input settings
>   before calling stm32_pwm_apply_breakinputs()
> 
> This is a precursor patch to ease PM support. Registers content may get
> lost during low power. So, break input settings applied upon probe need
> to be restored upon resume (e.g. by calling stm32_pwm_apply_breakinputs()).
> 
> Signed-off-by: Fabrice Gasnier 
> ---
>  drivers/pwm/pwm-stm32.c | 48 
>  1 file changed, 28 insertions(+), 20 deletions(-)

Applied, thanks. I've made some minor changes, mostly for consistency
with other drivers and the PWM core. See below.

> diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
> index 359b085..cf8658c 100644
> --- a/drivers/pwm/pwm-stm32.c
> +++ b/drivers/pwm/pwm-stm32.c
> @@ -19,6 +19,12 @@
>  #define CCMR_CHANNEL_MASK  0xFF
>  #define MAX_BREAKINPUT 2
>  
> +struct stm32_breakinput {
> + u32 index;
> + u32 level;
> + u32 filter;
> +};
> +
>  struct stm32_pwm {
>   struct pwm_chip chip;
>   struct mutex lock; /* protect pwm config/enable */
> @@ -26,15 +32,11 @@ struct stm32_pwm {
>   struct regmap *regmap;
>   u32 max_arr;
>   bool have_complementary_output;
> + struct stm32_breakinput breakinput[MAX_BREAKINPUT];
> + unsigned int nbreakinput;

I changed these to breakinputs and num_breakinputs since they are
slightly more consistent with the naming elsewhere in PWM.

>   u32 capture[4] cacheline_aligned; /* DMA'able buffer */
>  };
>  
> -struct stm32_breakinput {
> - u32 index;
> - u32 level;
> - u32 filter;
> -};
> -
>  static inline struct stm32_pwm *to_stm32_pwm_dev(struct pwm_chip *chip)
>  {
>   return container_of(chip, struct stm32_pwm, chip);
> @@ -512,15 +514,27 @@ static int stm32_pwm_set_breakinput(struct stm32_pwm 
> *priv,
>   return (bdtr & bke) ? 0 : -EINVAL;
>  }
>  
> -static int stm32_pwm_apply_breakinputs(struct stm32_pwm *priv,
> +static int stm32_pwm_apply_breakinputs(struct stm32_pwm *priv)
> +{
> + int i, ret = 0;

Made i unsigned int.

> +
> + for (i = 0; i < priv->nbreakinput && !ret; i++) {
> + ret = stm32_pwm_set_breakinput(priv,
> +priv->breakinput[i].index,
> +priv->breakinput[i].level,
> +priv->breakinput[i].filter);
> + }

I thought this was a little odd, so I changed it to explicitly check the
value of ret and return on error.

> +
> + return ret;

And then this became "return 0;"

> +}
> +
> +static int stm32_pwm_probe_breakinputs(struct stm32_pwm *priv,
>  struct device_node *np)
>  {
> - struct stm32_breakinput breakinput[MAX_BREAKINPUT];
> - int nb, ret, i, array_size;
> + int nb, ret, array_size;
>  
>   nb = of_property_count_elems_of_size(np, "st,breakinput",
>sizeof(struct stm32_breakinput));
> -

Dropped this since it made the code look cluttered.

Thierry

>   /*
>* Because "st,breakinput" parameter is optional do not make probe
>* failed if it doesn't exist.
> @@ -531,20 +545,14 @@ static int stm32_pwm_apply_breakinputs(struct stm32_pwm 
> *priv,
>   if (nb > MAX_BREAKINPUT)
>   return -EINVAL;
>  
> + priv->nbreakinput = nb;
>   array_size = nb * sizeof(struct stm32_breakinput) / sizeof(u32);
>   ret = of_property_read_u32_array(np, "st,breakinput",
> -  (u32 *)breakinput, array_size);
> +  (u32 *)priv->breakinput, array_size);
>   if (ret)
>   return ret;
>  
> - for (i = 0; i < nb && !ret; i++) {
> - ret = stm32_pwm_set_breakinput(priv,
> -breakinput[i].index,
> -breakinput[i].level,
> -breakinput[i].filter);
> - }
> -
> - return ret;
> + return stm32_pwm_apply_breakinputs(priv);
>  }
>  
>  static void stm32_pwm_detect_complementary(struct stm32_pwm *priv)
> @@ -614,7 +622,7 @@ static int stm32_pwm_probe(struct platform_device *pdev)
>   if (!priv->regmap || !priv->clk)
>   return -EINVAL;
>  
> - ret = stm32_pwm_apply_breakinputs(priv, np);
> + ret = stm32_pwm_probe_breakinputs(priv, np);
>   if (ret)
>   return ret;
>  
> -- 
> 2.7.4
> 


signature.asc
Description: PGP signature


Re: [PATCH v2 3/3] pwm: stm32: add power management support

2019-10-16 Thread Thierry Reding
On Fri, Oct 04, 2019 at 02:53:53PM +0200, Fabrice Gasnier wrote:
> Add suspend/resume PM sleep ops. When going to low power, enforce the PWM
> channel isn't active. Let the PWM consumers disable it during their own
> suspend sequence, see [1]. So, perform a check here, and handle the
> pinctrl states. Also restore the break inputs upon resume, as registers
> content may be lost when going to low power mode.
> 
> [1] https://lkml.org/lkml/2019/2/5/770
> 
> Signed-off-by: Fabrice Gasnier 
> ---
> Changes in v2:
> Follow Uwe suggestions/remarks:
> - Add a precursor patch to ease reviewing
> - Use registers read instead of pwm_get_state
> - Add a comment to mention registers content may be lost in low power mode
> ---
>  drivers/pwm/pwm-stm32.c | 38 ++
>  1 file changed, 38 insertions(+)

Applied, thanks. I made two minor changes, though, see below.

> 
> diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
> index cf8658c..546b661 100644
> --- a/drivers/pwm/pwm-stm32.c
> +++ b/drivers/pwm/pwm-stm32.c
> @@ -12,6 +12,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -655,6 +656,42 @@ static int stm32_pwm_remove(struct platform_device *pdev)
>   return 0;
>  }
>  
> +static int __maybe_unused stm32_pwm_suspend(struct device *dev)
> +{
> + struct stm32_pwm *priv = dev_get_drvdata(dev);
> + unsigned int ch;

I renamed this to just "i", which is more idiomatic for loop variables.
The function is small enough not to need to differentiate between loop
variables.

> + u32 ccer, mask;
> +
> + /* Look for active channels */
> + ccer = active_channels(priv);
> +
> + for (ch = 0; ch < priv->chip.npwm; ch++) {
> + mask = TIM_CCER_CC1E << (ch * 4);
> + if (ccer & mask) {
> + dev_err(dev, "The consumer didn't stop us (%s)\n",
> + priv->chip.pwms[ch].label);

Changed this to:

"PWM %u still in use by consumer %s\n", i, priv->chip.pwms[i].label

I think that might help clarify which PWM is still enabled in case the
consumers don't set a label.

Thierry

> + return -EBUSY;
> + }
> + }
> +
> + return pinctrl_pm_select_sleep_state(dev);
> +}
> +
> +static int __maybe_unused stm32_pwm_resume(struct device *dev)
> +{
> + struct stm32_pwm *priv = dev_get_drvdata(dev);
> + int ret;
> +
> + ret = pinctrl_pm_select_default_state(dev);
> + if (ret)
> + return ret;
> +
> + /* restore breakinput registers that may have been lost in low power */
> + return stm32_pwm_apply_breakinputs(priv);
> +}
> +
> +static SIMPLE_DEV_PM_OPS(stm32_pwm_pm_ops, stm32_pwm_suspend, 
> stm32_pwm_resume);
> +
>  static const struct of_device_id stm32_pwm_of_match[] = {
>   { .compatible = "st,stm32-pwm", },
>   { /* end node */ },
> @@ -667,6 +704,7 @@ static struct platform_driver stm32_pwm_driver = {
>   .driver = {
>   .name = "stm32-pwm",
>   .of_match_table = stm32_pwm_of_match,
> + .pm = &stm32_pwm_pm_ops,
>   },
>  };
>  module_platform_driver(stm32_pwm_driver);
> -- 
> 2.7.4
> 


signature.asc
Description: PGP signature


[PATCH v6 7/7] ASoC: sun4i-i2s: Add support for H6 I2S

2019-10-16 Thread codekipper
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 
---
 sound/soc/sunxi/sun4i-i2s.c | 143 
 1 file changed, 143 insertions(+)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 63ae9da180f2..564b31788f29 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -126,6 +126,21 @@
 #define SUN8I_I2S_RX_CHAN_SEL_REG  0x54
 #define SUN8I_I2S_RX_CHAN_MAP_REG  0x58
 
+/* Defines required for sun50i-h6 support */
+#define SUN50I_H6_I2S_TX_CHAN_SEL_OFFSET_MASK  GENMASK(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_MASK  GENMASK(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_REG  0x64
+#define SUN50I_H6_I2S_RX_CHAN_MAP0_REG 0x68
+#define SUN50I_H6_I2S_RX_CHAN_MAP1_REG 0x6C
+
 struct sun4i_i2s;
 
 /**
@@ -484,6 +499,24 @@ static void sun8i_i2s_set_rxchanoffset(const struct 
sun4i_i2s *i2s)
   SUN8I_I2S_TX_CHAN_OFFSET(i2s->offset));
 }
 
+static void sun50i_h6_i2s_set_txchanoffset(const struct sun4i_i2s *i2s, int 
output)
+{
+   if (output >= 0 && output < 4)
+   regmap_update_bits(i2s->regmap,
+  SUN8I_I2S_TX_CHAN_SEL_REG + (output * 4),
+  SUN50I_H6_I2S_TX_CHAN_SEL_OFFSET_MASK,
+  
SUN50I_H6_I2S_TX_CHAN_SEL_OFFSET(i2s->offset));
+
+}
+
+static void sun50i_h6_i2s_set_rxchanoffset(const struct sun4i_i2s *i2s)
+{
+   regmap_update_bits(i2s->regmap,
+  SUN50I_H6_I2S_RX_CHAN_SEL_REG,
+  SUN50I_H6_I2S_TX_CHAN_SEL_OFFSET_MASK,
+  SUN50I_H6_I2S_TX_CHAN_SEL_OFFSET(i2s->offset));
+}
+
 static void sun8i_i2s_set_txchanen(const struct sun4i_i2s *i2s, int output,
   int channel)
 {
@@ -502,6 +535,25 @@ static void sun8i_i2s_set_rxchanen(const struct sun4i_i2s 
*i2s, int channel)
   SUN8I_I2S_TX_CHAN_EN(channel));
 }
 
+
+static void sun50i_h6_i2s_set_txchanen(const struct sun4i_i2s *i2s, int output,
+  int channel)
+{
+   if (output >= 0 && output < 4)
+   regmap_update_bits(i2s->regmap,
+  SUN8I_I2S_TX_CHAN_SEL_REG + (output * 4),
+  SUN50I_H6_I2S_TX_CHAN_EN_MASK,
+  SUN50I_H6_I2S_TX_CHAN_EN(channel));
+}
+
+static void sun50i_h6_i2s_set_rxchanen(const struct sun4i_i2s *i2s, int 
channel)
+{
+   regmap_update_bits(i2s->regmap,
+  SUN50I_H6_I2S_RX_CHAN_SEL_REG,
+  SUN50I_H6_I2S_TX_CHAN_EN_MASK,
+  SUN50I_H6_I2S_TX_CHAN_EN(channel));
+}
+
 static void sun4i_i2s_set_txchansel(const struct sun4i_i2s *i2s, int output,
int channel)
 {
@@ -536,6 +588,24 @@ static void sun8i_i2s_set_rxchansel(const struct sun4i_i2s 
*i2s, int channel)
   SUN8I_I2S_TX_CHAN_SEL(channel));
 }
 
+static void sun50i_h6_i2s_set_txchansel(const struct sun4i_i2s *i2s, int 
output,
+  int channel)
+{
+   if (output >= 0 && output < 4)
+   regmap_update_bits(i2s->regmap,
+  SUN8I_I2S_TX_CHAN_SEL_REG + (output * 4),
+  SUN50I_H6_I2S_TX_CHAN_SEL_MASK,
+  SUN50I_H6_I2S_TX_CHAN_SEL(channel));
+}
+
+static void sun50i_h6_i2s_set_rxchansel(const struct sun4i_i2s *i2s, int 
channel)
+{
+   regmap_update_bits(i2s->regmap,
+  SUN50I_H6_I2S_RX_CHAN_SEL_REG,
+  SUN50I_H6_I2S_TX_CHAN_SEL_MASK,
+  SUN50I_H6_I2S_TX_CHAN_SEL(channel));
+}
+
 static void sun4i_i2s_set_txchanmap(const struct sun4i_i2s *i2s, int output,
int channel)
 {
@@ -561,6 +631,20 @@ static void sun8i_i2s_set_rxchanmap(const struct sun4i_i2s 
*i2s, int channel)
regmap_write(i2s->regmap, SUN8I_I2S_RX_CHAN_MAP_REG, channel);
 }
 
+static void sun50i_h6_i2s_set_txchanmap(const struct sun4i_i2s *i2s, int 
output,
+  int channel)
+{
+   if (output >= 0 && output < 4)
+   regmap_write(i2s->regmap,
+SUN50I_H6_I2S_TX_CHAN_MAP1_REG + (output * 8),
+channel);
+}
+
+static void sun50i_h6_i2s_set_rxchanmap(const struct sun4i_i2s *i2s, int 
c

[PATCH v6 1/7] ASoC: sun4i-i2s: Move channel select offset

2019-10-16 Thread codekipper
From: Marcus Cooper 

On the newer SoCs the offset is used to set the mode of the
connection. As it is to be used elsewhere then it makes sense
to move it to the main structure.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index d0a8d5810c0a..f1a80973c450 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -156,7 +156,7 @@ struct sun4i_i2s_quirks {
s8  (*get_wss)(const struct sun4i_i2s *, int);
int (*set_chan_cfg)(const struct sun4i_i2s *,
const struct snd_pcm_hw_params *);
-   int (*set_fmt)(const struct sun4i_i2s *, unsigned int);
+   int (*set_fmt)(struct sun4i_i2s *, unsigned int);
 };
 
 struct sun4i_i2s {
@@ -169,6 +169,7 @@ struct sun4i_i2s {
unsigned intmclk_freq;
unsigned intslots;
unsigned intslot_width;
+   unsigned intoffset;
 
struct snd_dmaengine_dai_dma_data   capture_dma_data;
struct snd_dmaengine_dai_dma_data   playback_dma_data;
@@ -516,7 +517,7 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream 
*substream,
  slots, slot_width);
 }
 
-static int sun4i_i2s_set_soc_fmt(const struct sun4i_i2s *i2s,
+static int sun4i_i2s_set_soc_fmt(struct sun4i_i2s *i2s,
 unsigned int fmt)
 {
u32 val;
@@ -589,11 +590,10 @@ static int sun4i_i2s_set_soc_fmt(const struct sun4i_i2s 
*i2s,
return 0;
 }
 
-static int sun8i_i2s_set_soc_fmt(const struct sun4i_i2s *i2s,
+static int sun8i_i2s_set_soc_fmt(struct sun4i_i2s *i2s,
 unsigned int fmt)
 {
u32 mode, val;
-   u8 offset;
 
/*
 * DAI clock polarity
@@ -632,27 +632,27 @@ static int sun8i_i2s_set_soc_fmt(const struct sun4i_i2s 
*i2s,
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_DSP_A:
mode = SUN8I_I2S_CTRL_MODE_PCM;
-   offset = 1;
+   i2s->offset = 1;
break;
 
case SND_SOC_DAIFMT_DSP_B:
mode = SUN8I_I2S_CTRL_MODE_PCM;
-   offset = 0;
+   i2s->offset = 0;
break;
 
case SND_SOC_DAIFMT_I2S:
mode = SUN8I_I2S_CTRL_MODE_LEFT;
-   offset = 1;
+   i2s->offset = 1;
break;
 
case SND_SOC_DAIFMT_LEFT_J:
mode = SUN8I_I2S_CTRL_MODE_LEFT;
-   offset = 0;
+   i2s->offset = 0;
break;
 
case SND_SOC_DAIFMT_RIGHT_J:
mode = SUN8I_I2S_CTRL_MODE_RIGHT;
-   offset = 0;
+   i2s->offset = 0;
break;
 
default:
@@ -663,10 +663,10 @@ static int sun8i_i2s_set_soc_fmt(const struct sun4i_i2s 
*i2s,
   SUN8I_I2S_CTRL_MODE_MASK, mode);
regmap_update_bits(i2s->regmap, SUN8I_I2S_TX_CHAN_SEL_REG,
   SUN8I_I2S_TX_CHAN_OFFSET_MASK,
-  SUN8I_I2S_TX_CHAN_OFFSET(offset));
+  SUN8I_I2S_TX_CHAN_OFFSET(i2s->offset));
regmap_update_bits(i2s->regmap, SUN8I_I2S_RX_CHAN_SEL_REG,
   SUN8I_I2S_TX_CHAN_OFFSET_MASK,
-  SUN8I_I2S_TX_CHAN_OFFSET(offset));
+  SUN8I_I2S_TX_CHAN_OFFSET(i2s->offset));
 
/* DAI clock master masks */
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
-- 
2.23.0



[PATCH v6 2/7] ASoC: sun4i-i2s: Add functions for RX and TX channel offsets

2019-10-16 Thread codekipper
From: Marcus Cooper 

Newer SoCs like the H6 have the channel offset bits in a different
position to what is on the H3. As we will eventually add multi-
channel support then create function calls as opposed to regmap
fields to add support for different devices.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 31 +--
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index f1a80973c450..875567881f30 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -157,6 +157,8 @@ struct sun4i_i2s_quirks {
int (*set_chan_cfg)(const struct sun4i_i2s *,
const struct snd_pcm_hw_params *);
int (*set_fmt)(struct sun4i_i2s *, unsigned int);
+   void(*set_txchanoffset)(const struct sun4i_i2s *, int);
+   void(*set_rxchanoffset)(const struct sun4i_i2s *);
 };
 
 struct sun4i_i2s {
@@ -467,6 +469,23 @@ static int sun8i_i2s_set_chan_cfg(const struct sun4i_i2s 
*i2s,
return 0;
 }
 
+static void sun8i_i2s_set_txchanoffset(const struct sun4i_i2s *i2s, int output)
+{
+   if (output >= 0 && output < 4)
+   regmap_update_bits(i2s->regmap,
+  SUN8I_I2S_TX_CHAN_SEL_REG + (output * 4),
+  SUN8I_I2S_TX_CHAN_OFFSET_MASK,
+  SUN8I_I2S_TX_CHAN_OFFSET(i2s->offset));
+}
+
+static void sun8i_i2s_set_rxchanoffset(const struct sun4i_i2s *i2s)
+{
+   regmap_update_bits(i2s->regmap,
+  SUN8I_I2S_RX_CHAN_SEL_REG,
+  SUN8I_I2S_TX_CHAN_OFFSET_MASK,
+  SUN8I_I2S_TX_CHAN_OFFSET(i2s->offset));
+}
+
 static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream,
   struct snd_pcm_hw_params *params,
   struct snd_soc_dai *dai)
@@ -661,12 +680,10 @@ static int sun8i_i2s_set_soc_fmt(struct sun4i_i2s *i2s,
 
regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
   SUN8I_I2S_CTRL_MODE_MASK, mode);
-   regmap_update_bits(i2s->regmap, SUN8I_I2S_TX_CHAN_SEL_REG,
-  SUN8I_I2S_TX_CHAN_OFFSET_MASK,
-  SUN8I_I2S_TX_CHAN_OFFSET(i2s->offset));
-   regmap_update_bits(i2s->regmap, SUN8I_I2S_RX_CHAN_SEL_REG,
-  SUN8I_I2S_TX_CHAN_OFFSET_MASK,
-  SUN8I_I2S_TX_CHAN_OFFSET(i2s->offset));
+   if (i2s->variant->set_txchanoffset)
+   i2s->variant->set_txchanoffset(i2s, 0);
+   if (i2s->variant->set_rxchanoffset)
+   i2s->variant->set_rxchanoffset(i2s);
 
/* DAI clock master masks */
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -1136,6 +1153,8 @@ static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks 
= {
.get_wss= sun8i_i2s_get_sr_wss,
.set_chan_cfg   = sun8i_i2s_set_chan_cfg,
.set_fmt= sun8i_i2s_set_soc_fmt,
+   .set_txchanoffset   = sun8i_i2s_set_txchanoffset,
+   .set_rxchanoffset   = sun8i_i2s_set_rxchanoffset,
 };
 
 static const struct sun4i_i2s_quirks sun50i_a64_codec_i2s_quirks = {
-- 
2.23.0



[PATCH v6 6/7] dt-bindings: ASoC: sun4i-i2s: Add H6 compatible

2019-10-16 Thread codekipper
From: Jernej Skrabec 

H6 I2S is very similar to H3, except that it supports up to 16 channels
and thus few registers have fields on different position.

Signed-off-by: Jernej Skrabec 
Signed-off-by: Marcus Cooper 
---
 .../devicetree/bindings/sound/allwinner,sun4i-a10-i2s.yaml  | 2 ++
 1 file changed, 2 insertions(+)

diff --git 
a/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-i2s.yaml 
b/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-i2s.yaml
index eb3992138eec..6928d0a1dcc8 100644
--- a/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-i2s.yaml
+++ b/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-i2s.yaml
@@ -24,6 +24,7 @@ properties:
   - items:
   - const: allwinner,sun50i-a64-i2s
   - const: allwinner,sun8i-h3-i2s
+  - const: allwinner,sun50i-h6-i2s
 
   reg:
 maxItems: 1
@@ -59,6 +60,7 @@ allOf:
   - allwinner,sun8i-a83t-i2s
   - allwinner,sun8i-h3-i2s
   - allwinner,sun50i-a64-codec-i2s
+  - allwinner,sun50i-h6-i2s
 
 then:
   required:
-- 
2.23.0



Re: [PATCH 12/14] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-10-16 Thread Paolo Bonzini
On 16/10/19 01:42, Andrea Arcangeli wrote:
> On Wed, Oct 16, 2019 at 12:22:31AM +0200, Paolo Bonzini wrote:
>> Oh come on.  0.9 is not 12-years old.  virtio 1.0 is 3.5 years old
>> (March 2016).  Anything older than 2017 is going to use 0.9.
> 
> Sorry if I got the date wrong, but still I don't see the point in
> optimizing for legacy virtio. I can't justify forcing everyone to
> execute that additional branch for inb/outb, in the attempt to make
> legacy virtio faster that nobody should use in combination with
> bleeding edge KVM in the host.

Yet you would add CPUID to the list even though it is not even there in
your benchmarks, and is *never* invoked in a hot path by *any* sane
program? Some OSes have never gotten virtio 1.0 drivers.  OpenBSD only
got it earlier this year.

>> Your tables give:
>>
>>  Samples   Samples%  Time% Min Time  Max time   Avg time
>> HLT 10112875.33%99.66%0.43us901000.66us310.88us
>> HLT 11847419.11%95.88%0.33us707693.05us43.56us
>>
>> If "avg time" means the average time to serve an HLT vmexit, I don't
>> understand how you can have an average time of 0.3ms (1/3000th of a
>> second) and 10 samples per second.  Can you explain that to me?
> 
> I described it wrong, the bpftrace record was a sleep 5, not a sleep
> 1. The pipe loop was sure a sleep 1.

It still doesn't add up.  0.3ms / 5 is 1/15000th of a second; 43us is
1/25000th of a second.  Do you have multiple vCPU perhaps?

> The issue is that in production you get a flood more of those with
> hundred of CPUs, so the exact number doesn't move the needle.
> This just needs to be frequent enough that the branch cost pay itself off,
> but the sure thing is that HLT vmexit will not go away unless you execute
> mwait in guest mode by isolating the CPU in the host.

The number of vmexits doesn't count (for HLT).  What counts is how long
they take to be serviced, and as long as it's 1us or more the
optimization is pointless.

Consider these pictures

 w/o optimization   with optimization
 -- -
0us  vmexit vmexit
500nsretpoline  call vmexit handler directly
600nsretpoline  kvm_vcpu_check_block()
700nsretpoline  kvm_vcpu_check_block()
800nskvm_vcpu_check_block() kvm_vcpu_check_block()
900nskvm_vcpu_check_block() kvm_vcpu_check_block()
...
39900ns  kvm_vcpu_check_block() kvm_vcpu_check_block()



4ns  kvm_vcpu_check_block() kvm_vcpu_check_block()


Unless the interrupt arrives exactly in the few nanoseconds that it
takes to execute the retpoline, a direct handling of HLT vmexits makes
*absolutely no difference*.

>> Again: what is the real workload that does thousands of CPUIDs per second?
> 
> None, but there are always background CPUID vmexits while there are
> never inb/outb vmexits.
> 
> So the cpuid retpoline removal has a slight chance to pay for the cost
> of the branch, the inb/outb retpoline removal cannot pay off the cost
> of the branch.

Please stop considering only the exact configuration of your benchmarks.
 There are known, valid configurations where outb is a very hot vmexit.

Thanks,

Paolo


[PATCH v6 5/7] ASoC: sun4i-i2s: Add functions for RX and TX channel mapping

2019-10-16 Thread codekipper
From: Marcus Cooper 

As we will eventually add multi-channel audio support to the i2s
then create function calls as opposed to regmap fields to add
support for different devices.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 45 +
 1 file changed, 41 insertions(+), 4 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 19988d61a085..63ae9da180f2 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -165,6 +165,8 @@ struct sun4i_i2s_quirks {
void(*set_rxchanen)(const struct sun4i_i2s *, int);
void(*set_txchansel)(const struct sun4i_i2s *, int, int);
void(*set_rxchansel)(const struct sun4i_i2s *, int);
+   void(*set_txchanmap)(const struct sun4i_i2s *, int, int);
+   void(*set_rxchanmap)(const struct sun4i_i2s *, int);
 };
 
 struct sun4i_i2s {
@@ -405,8 +407,8 @@ static int sun4i_i2s_set_chan_cfg(const struct sun4i_i2s 
*i2s,
unsigned int channels = params_channels(params);
 
/* Map the channels for playback and capture */
-   regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_MAP_REG, 0x76543210);
-   regmap_write(i2s->regmap, SUN4I_I2S_RX_CHAN_MAP_REG, 0x3210);
+   i2s->variant->set_txchanmap(i2s, 0, 0x76543210);
+   i2s->variant->set_rxchanmap(i2s, 0x3210);
 
/* Configure the channels */
i2s->variant->set_txchansel(i2s, 0, channels);
@@ -426,8 +428,8 @@ static int sun8i_i2s_set_chan_cfg(const struct sun4i_i2s 
*i2s,
slots = i2s->slots;
 
/* Map the channels for playback and capture */
-   regmap_write(i2s->regmap, SUN8I_I2S_TX_CHAN_MAP_REG, 0x76543210);
-   regmap_write(i2s->regmap, SUN8I_I2S_RX_CHAN_MAP_REG, 0x76543210);
+   i2s->variant->set_txchanmap(i2s, 0, 0x76543210);
+   i2s->variant->set_rxchanmap(i2s, 0x3210);
 
/* Configure the channels */
i2s->variant->set_txchansel(i2s, 0, channels);
@@ -534,6 +536,31 @@ static void sun8i_i2s_set_rxchansel(const struct sun4i_i2s 
*i2s, int channel)
   SUN8I_I2S_TX_CHAN_SEL(channel));
 }
 
+static void sun4i_i2s_set_txchanmap(const struct sun4i_i2s *i2s, int output,
+   int channel)
+{
+   if (output == 0)
+   regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_MAP_REG, channel);
+}
+
+static void sun8i_i2s_set_txchanmap(const struct sun4i_i2s *i2s, int output,
+   int channel)
+{
+   if (output >= 0 && output < 4)
+   regmap_write(i2s->regmap,
+SUN8I_I2S_TX_CHAN_MAP_REG + (output * 4), channel);
+}
+
+static void sun4i_i2s_set_rxchanmap(const struct sun4i_i2s *i2s, int channel)
+{
+   regmap_write(i2s->regmap, SUN4I_I2S_RX_CHAN_MAP_REG, channel);
+}
+
+static void sun8i_i2s_set_rxchanmap(const struct sun4i_i2s *i2s, int channel)
+{
+   regmap_write(i2s->regmap, SUN8I_I2S_RX_CHAN_MAP_REG, channel);
+}
+
 static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream,
   struct snd_pcm_hw_params *params,
   struct snd_soc_dai *dai)
@@ -1154,6 +1181,8 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks 
= {
.set_fmt= sun4i_i2s_set_soc_fmt,
.set_txchansel  = sun4i_i2s_set_txchansel,
.set_rxchansel  = sun4i_i2s_set_rxchansel,
+   .set_txchanmap  = sun4i_i2s_set_txchanmap,
+   .set_rxchanmap  = sun4i_i2s_set_rxchanmap,
 };
 
 static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = {
@@ -1174,6 +1203,8 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks 
= {
.set_fmt= sun4i_i2s_set_soc_fmt,
.set_txchansel  = sun4i_i2s_set_txchansel,
.set_rxchansel  = sun4i_i2s_set_rxchansel,
+   .set_txchanmap  = sun4i_i2s_set_txchanmap,
+   .set_rxchanmap  = sun4i_i2s_set_rxchanmap,
 };
 
 /*
@@ -1199,6 +1230,8 @@ static const struct sun4i_i2s_quirks 
sun8i_a83t_i2s_quirks = {
.set_fmt= sun4i_i2s_set_soc_fmt,
.set_txchansel  = sun4i_i2s_set_txchansel,
.set_rxchansel  = sun4i_i2s_set_rxchansel,
+   .set_txchanmap  = sun4i_i2s_set_txchanmap,
+   .set_rxchanmap  = sun4i_i2s_set_rxchanmap,
 };
 
 static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks = {
@@ -1223,6 +1256,8 @@ static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks 
= {
.set_rxchanen   = sun8i_i2s_set_rxchanen,
.set_txchansel  = sun8i_i2s_set_txchansel,
.set_rxchansel  = sun8i_i2s_set_rxchansel,
+   .set_txchanmap  = sun8i_i2s_set_txchanmap,
+   .set_rxchanmap  = sun8i_i2s_set_rxchanmap,
 };
 
 static const struct sun4i_i2s_quirks sun50i_a64_codec_i2s_quirks = {
@@ -1243,6 +1278,8 @@ static const struct sun4i_i2

[PATCH v6 0/7] ASoC: sun4i-i2s: Updates to the driver

2019-10-16 Thread codekipper
From: Marcus Cooper 

Hi All,
To be able to add support for the Allwinner H6 I've changed some of the
original reg fields into function calls as this made it easier to setup
for multi-channel audio especially across different SoCs. I've also
stripped out all the other patches unrelated to this which I will deliver
after support for the H6 has gone in.

These other patches are required for HDMI audio which is driving this
patchset and they can be found here
https://github.com/codekipper/linux-sunxi/commits/upstream-i2s
BR,
CK

---
v6 changes compared to v5 are:
- rebased onto the recent tdm delivery
- stripped out patches not required for the H6 delivery

v5 changes compared to v4 are:
- removed delivered patches.
- Added more details to commit messages.
- replaced some reg fields with function calls.
- Added DSP_A and DSP_B support for H3 and later SoCs.
- Added support for the Allwinner H6.

v4 changes compared to v3 are:
- Moved patches around so that the more controversial of patches are
  at the top of the stack.
- Added more details to commit messages.
- Fixed 20bit audio PCM format to use 4 bytes.
- Reduced number of flags used to indicate a new SoC.

v3 changes compared to v2 are:
 - added back slave mode changes
 - added back the use of tdm properties
 - changes to regmap and caching
 - removed loopback functionality
 - fixes to the channel offset mask

v2 changes compared to v1 are:
 - removed slave mode changes which didn't set mclk and bclk div.
 - removed use of tdm and now use a dedicated property.
 - fix commit message to better explain reason for sign extending
 - add divider calculations for newer SoCs.
 - add support for multi-lane i2s data output.
 - add support for 20, 24 and 32 bit samples.
 - add loopback property so blocks can be tested without a codec.

---
Jernej Skrabec (2):
  dt-bindings: ASoC: sun4i-i2s: Add H6 compatible
  ASoC: sun4i-i2s: Add support for H6 I2S

Marcus Cooper (5):
  ASoC: sun4i-i2s: Move channel select offset
  ASoC: sun4i-i2s: Add functions for RX and TX channel offsets
  ASoC: sun4i-i2s: Add functions for RX and TX channel enables
  ASoC: sun4i-i2s: Add functions for RX and TX channel selects
  ASoC: sun4i-i2s: Add functions for RX and TX channel mapping

 .../sound/allwinner,sun4i-a10-i2s.yaml|   2 +
 sound/soc/sunxi/sun4i-i2s.c   | 337 --
 2 files changed, 305 insertions(+), 34 deletions(-)

-- 
2.23.0



Re: [PATCH] xtensa: implement arch_dma_coherent_to_pfn

2019-10-16 Thread Christoph Hellwig
On Tue, Oct 15, 2019 at 02:25:26PM -0700, Max Filippov wrote:
> Add trivial implementation for arch_dma_coherent_to_pfn.
> This change enables communication with PCI ALSA devices through mmapped
> buffers.

This looks fine, although I'd much rather convert xtensa to the
generic DMA remap / uncached segment support.

Do you want this fix for 5.4?  If so please queue it up ASAP so that
I can do the proper thing for 5.5.  If you don't need it that urgent
I'd rather go straight to the generic code.


[PATCH v6 3/7] ASoC: sun4i-i2s: Add functions for RX and TX channel enables

2019-10-16 Thread codekipper
From: Marcus Cooper 

Newer SoCs like the H6 have the channel enable bits in a different
position to what is on the H3. As we will eventually add multi-
channel support then create function calls as opposed to regmap
fields to add support for different devices.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 32 +---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 875567881f30..8d28a386872f 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -159,6 +159,8 @@ struct sun4i_i2s_quirks {
int (*set_fmt)(struct sun4i_i2s *, unsigned int);
void(*set_txchanoffset)(const struct sun4i_i2s *, int);
void(*set_rxchanoffset)(const struct sun4i_i2s *);
+   void(*set_txchanen)(const struct sun4i_i2s *, int, int);
+   void(*set_rxchanen)(const struct sun4i_i2s *, int);
 };
 
 struct sun4i_i2s {
@@ -462,9 +464,7 @@ static int sun8i_i2s_set_chan_cfg(const struct sun4i_i2s 
*i2s,
   SUN8I_I2S_FMT0_LRCK_PERIOD_MASK,
   SUN8I_I2S_FMT0_LRCK_PERIOD(lrck_period));
 
-   regmap_update_bits(i2s->regmap, SUN8I_I2S_TX_CHAN_SEL_REG,
-  SUN8I_I2S_TX_CHAN_EN_MASK,
-  SUN8I_I2S_TX_CHAN_EN(channels));
+   i2s->variant->set_txchanen(i2s, 0, channels);
 
return 0;
 }
@@ -486,6 +486,24 @@ static void sun8i_i2s_set_rxchanoffset(const struct 
sun4i_i2s *i2s)
   SUN8I_I2S_TX_CHAN_OFFSET(i2s->offset));
 }
 
+static void sun8i_i2s_set_txchanen(const struct sun4i_i2s *i2s, int output,
+  int channel)
+{
+   if (output >= 0 && output < 4)
+   regmap_update_bits(i2s->regmap,
+  SUN8I_I2S_TX_CHAN_SEL_REG + (output * 4),
+  SUN8I_I2S_TX_CHAN_EN_MASK,
+  SUN8I_I2S_TX_CHAN_EN(channel));
+}
+
+static void sun8i_i2s_set_rxchanen(const struct sun4i_i2s *i2s, int channel)
+{
+   regmap_update_bits(i2s->regmap,
+  SUN8I_I2S_RX_CHAN_SEL_REG,
+  SUN8I_I2S_TX_CHAN_EN_MASK,
+  SUN8I_I2S_TX_CHAN_EN(channel));
+}
+
 static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream,
   struct snd_pcm_hw_params *params,
   struct snd_soc_dai *dai)
@@ -510,6 +528,12 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream 
*substream,
return ret;
}
 
+   if (i2s->variant->set_txchanen)
+   i2s->variant->set_txchanen(i2s, 0, channels);
+
+   if (i2s->variant->set_rxchanen)
+   i2s->variant->set_rxchanen(i2s, channels);
+
switch (params_physical_width(params)) {
case 16:
width = DMA_SLAVE_BUSWIDTH_2_BYTES;
@@ -1155,6 +1179,8 @@ static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks 
= {
.set_fmt= sun8i_i2s_set_soc_fmt,
.set_txchanoffset   = sun8i_i2s_set_txchanoffset,
.set_rxchanoffset   = sun8i_i2s_set_rxchanoffset,
+   .set_txchanen   = sun8i_i2s_set_txchanen,
+   .set_rxchanen   = sun8i_i2s_set_rxchanen,
 };
 
 static const struct sun4i_i2s_quirks sun50i_a64_codec_i2s_quirks = {
-- 
2.23.0



[PATCH v6 4/7] ASoC: sun4i-i2s: Add functions for RX and TX channel selects

2019-10-16 Thread codekipper
From: Marcus Cooper 

Newer SoCs like the H6 have the channel select bits in a different
positions than what is on the H3. As we will eventually add multi-
channel support then create function calls as opposed to regmap
fields to add support for different devices.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 68 ++---
 1 file changed, 56 insertions(+), 12 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 8d28a386872f..19988d61a085 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -120,6 +120,8 @@
 #define SUN8I_I2S_TX_CHAN_OFFSET(offset)   (offset << 12)
 #define SUN8I_I2S_TX_CHAN_EN_MASK  GENMASK(11, 4)
 #define SUN8I_I2S_TX_CHAN_EN(num_chan) (((1 << num_chan) - 1) << 4)
+#define SUN8I_I2S_TX_CHAN_SEL_MASK GENMASK(2, 0)
+#define SUN8I_I2S_TX_CHAN_SEL(chan)(chan - 1)
 
 #define SUN8I_I2S_RX_CHAN_SEL_REG  0x54
 #define SUN8I_I2S_RX_CHAN_MAP_REG  0x58
@@ -161,6 +163,8 @@ struct sun4i_i2s_quirks {
void(*set_rxchanoffset)(const struct sun4i_i2s *);
void(*set_txchanen)(const struct sun4i_i2s *, int, int);
void(*set_rxchanen)(const struct sun4i_i2s *, int);
+   void(*set_txchansel)(const struct sun4i_i2s *, int, int);
+   void(*set_rxchansel)(const struct sun4i_i2s *, int);
 };
 
 struct sun4i_i2s {
@@ -405,12 +409,8 @@ static int sun4i_i2s_set_chan_cfg(const struct sun4i_i2s 
*i2s,
regmap_write(i2s->regmap, SUN4I_I2S_RX_CHAN_MAP_REG, 0x3210);
 
/* Configure the channels */
-   regmap_update_bits(i2s->regmap, SUN4I_I2S_TX_CHAN_SEL_REG,
-  SUN4I_I2S_CHAN_SEL_MASK,
-  SUN4I_I2S_CHAN_SEL(channels));
-   regmap_update_bits(i2s->regmap, SUN4I_I2S_RX_CHAN_SEL_REG,
-  SUN4I_I2S_CHAN_SEL_MASK,
-  SUN4I_I2S_CHAN_SEL(channels));
+   i2s->variant->set_txchansel(i2s, 0, channels);
+   i2s->variant->set_rxchansel(i2s, channels);
 
return 0;
 }
@@ -430,12 +430,8 @@ static int sun8i_i2s_set_chan_cfg(const struct sun4i_i2s 
*i2s,
regmap_write(i2s->regmap, SUN8I_I2S_RX_CHAN_MAP_REG, 0x76543210);
 
/* Configure the channels */
-   regmap_update_bits(i2s->regmap, SUN8I_I2S_TX_CHAN_SEL_REG,
-  SUN4I_I2S_CHAN_SEL_MASK,
-  SUN4I_I2S_CHAN_SEL(channels));
-   regmap_update_bits(i2s->regmap, SUN8I_I2S_RX_CHAN_SEL_REG,
-  SUN4I_I2S_CHAN_SEL_MASK,
-  SUN4I_I2S_CHAN_SEL(channels));
+   i2s->variant->set_txchansel(i2s, 0, channels);
+   i2s->variant->set_rxchansel(i2s, channels);
 
regmap_update_bits(i2s->regmap, SUN8I_I2S_CHAN_CFG_REG,
   SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM_MASK,
@@ -504,6 +500,40 @@ static void sun8i_i2s_set_rxchanen(const struct sun4i_i2s 
*i2s, int channel)
   SUN8I_I2S_TX_CHAN_EN(channel));
 }
 
+static void sun4i_i2s_set_txchansel(const struct sun4i_i2s *i2s, int output,
+   int channel)
+{
+   if (output == 0)
+   regmap_write(i2s->regmap,
+SUN4I_I2S_TX_CHAN_SEL_REG,
+SUN4I_I2S_CHAN_SEL(channel));
+}
+
+static void sun8i_i2s_set_txchansel(const struct sun4i_i2s *i2s, int output,
+   int channel)
+{
+   if (output >= 0 && output < 4)
+   regmap_update_bits(i2s->regmap,
+  SUN8I_I2S_TX_CHAN_SEL_REG + (output * 4),
+  SUN8I_I2S_TX_CHAN_SEL_MASK,
+  SUN8I_I2S_TX_CHAN_SEL(channel));
+}
+
+static void sun4i_i2s_set_rxchansel(const struct sun4i_i2s *i2s, int channel)
+{
+   regmap_write(i2s->regmap,
+SUN4I_I2S_RX_CHAN_SEL_REG,
+SUN4I_I2S_CHAN_SEL(channel));
+}
+
+static void sun8i_i2s_set_rxchansel(const struct sun4i_i2s *i2s, int channel)
+{
+   regmap_update_bits(i2s->regmap,
+  SUN8I_I2S_RX_CHAN_SEL_REG,
+  SUN8I_I2S_TX_CHAN_SEL_MASK,
+  SUN8I_I2S_TX_CHAN_SEL(channel));
+}
+
 static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream,
   struct snd_pcm_hw_params *params,
   struct snd_soc_dai *dai)
@@ -528,6 +558,10 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream 
*substream,
return ret;
}
 
+   /* Configure the channels */
+   i2s->variant->set_txchansel(i2s, 0, channels);
+   i2s->variant->set_rxchansel(i2s, channels);
+
if (i2s->variant->set_txchanen)
i2s->variant->set_txchanen(i2s, 0, channels);
 
@@ -1118,6 +1152,8 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks 
= {
 

[PATCH] mm, soft-offline: convert parameter to pfn

2019-10-16 Thread Naoya Horiguchi
Hi,

I wrote a simple cleanup for parameter of soft_offline_page(),
based on thread https://lkml.org/lkml/2019/10/11/57.

I know that we need more cleanup on hwpoison-inject, but I think
that will be mentioned in re-write patchset Oscar is preparing now.
So let me shared only this part as a separate one now.

Thanks,
Naoya Horiguchi
---
From: Naoya Horiguchi 
Date: Wed, 16 Oct 2019 15:49:00 +0900
Subject: [PATCH] mm, soft-offline: convert parameter to pfn

Currently soft_offline_page() receives struct page, and its sibling
memory_failure() receives pfn. This discrepancy looks weird and makes
precheck on pfn validity tricky. So let's align them.

Signed-off-by: Naoya Horiguchi 
---
 drivers/base/memory.c | 2 +-
 include/linux/mm.h| 2 +-
 mm/madvise.c  | 2 +-
 mm/memory-failure.c   | 8 
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index e5485c22ef77..04e469c82852 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -540,7 +540,7 @@ static ssize_t soft_offline_page_store(struct device *dev,
pfn >>= PAGE_SHIFT;
if (!pfn_valid(pfn))
return -ENXIO;
-   ret = soft_offline_page(pfn_to_page(pfn));
+   ret = soft_offline_page(pfn);
return ret == 0 ? count : ret;
 }
 
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 3eba26324ff1..0a452020edf5 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2783,7 +2783,7 @@ extern int sysctl_memory_failure_early_kill;
 extern int sysctl_memory_failure_recovery;
 extern void shake_page(struct page *p, int access);
 extern atomic_long_t num_poisoned_pages __read_mostly;
-extern int soft_offline_page(struct page *page);
+extern int soft_offline_page(unsigned long pfn);
 
 
 /*
diff --git a/mm/madvise.c b/mm/madvise.c
index fd221b610b52..df198d1e5e2e 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -893,7 +893,7 @@ static int madvise_inject_error(int behavior,
if (behavior == MADV_SOFT_OFFLINE) {
pr_info("Soft offlining pfn %#lx at process virtual 
address %#lx\n",
 pfn, start);
-   ret = soft_offline_page(page);
+   ret = soft_offline_page(pfn);
if (ret)
return ret;
} else {
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 4f16e0a7e7cc..eb4fd5e8d5e1 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1514,7 +1514,7 @@ static void memory_failure_work_func(struct work_struct 
*work)
if (!gotten)
break;
if (entry.flags & MF_SOFT_OFFLINE)
-   soft_offline_page(pfn_to_page(entry.pfn));
+   soft_offline_page(entry.pfn);
else
memory_failure(entry.pfn, entry.flags);
}
@@ -1822,7 +1822,7 @@ static int soft_offline_free_page(struct page *page)
 
 /**
  * soft_offline_page - Soft offline a page.
- * @page: page to offline
+ * @pfn: pfn to soft-offline
  *
  * Returns 0 on success, otherwise negated errno.
  *
@@ -1841,10 +1841,10 @@ static int soft_offline_free_page(struct page *page)
  * This is not a 100% solution for all memory, but tries to be
  * ``good enough'' for the majority of memory.
  */
-int soft_offline_page(struct page *page)
+int soft_offline_page(unsigned long pfn)
 {
int ret;
-   unsigned long pfn = page_to_pfn(page);
+   struct page *page = pfn_to_page(pfn);
 
if (is_zone_device_page(page)) {
pr_debug_ratelimited("soft_offline: %#lx page is device page\n",
-- 
2.17.1



[PATCH net-next 00/12] net: hns3: add some bugfixes and optimizations

2019-10-16 Thread Huazhong Tan
This patch-set includes some bugfixes and code optimizations
for the HNS3 ethernet controller driver.

[patch 01/12] removes unused and unnecessary structures.

[patch 02/12] fixes a TX queue not restarted problem.

[patch 03/12] fixes a use-after-free issue.

[patch 04/12] fixes a mis-counting IRQ number issue.

[patch 05/12] fixes VF VLAN table entries inconsistent issue.

[patch 06/12] uses a ETH_ALEN u8 array to replace two mac_addr_*
field in struct hclge_mac_mgr_tbl_entry_cmd.

[patch 07/12] optimizes the barrier used in the IO path.

[patch 08/12] introduces macro ring_to_netdev() to get netdevive
from struct hns3_enet_ring variable.

[patch 09/12] adds a minor cleanup for hns3_handle_rx_bd().

[patch 10/12] fixes a VF ID issue for setting VF VLAN.

[patch 11/12] removes linear data allocating for fraglist SKB.

[patch 12/12] clears hardware error when resetting.

Guojia Liao (1):
  net: hns3: optimized MAC address in management table.

Jian Shen (3):
  net: hns3: fix VF VLAN table entries inconsistent issue
  net: hns3: fix VF id issue for setting VF VLAN
  net: hns3: log and clear hardware error after reset complete

Yonglong Liu (1):
  net: hns3: fix mis-counting IRQ vector numbers issue

Yunsheng Lin (7):
  net: hns3: remove struct hns3_nic_ring_data in hns3_enet module
  net: hns3: fix TX queue not restarted problem
  net: hns3: fix a use after freed problem in hns3_nic_maybe_stop_tx()
  net: hns3: minor optimization for barrier in IO path
  net: hns3: introduce ring_to_netdev() in enet module
  net: hns3: minor cleanup for hns3_handle_rx_bd()
  net: hns3: do not allocate linear data for fraglist skb

 drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h|   1 +
 drivers/net/ethernet/hisilicon/hns3/hnae3.h|   2 +
 drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c |  24 +-
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c| 255 +
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.h|  20 +-
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c |  33 ++-
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h |   4 +-
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c|  49 ++--
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h|   1 +
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c |   1 +
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c  |  11 +-
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c  |  32 ++-
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h  |   1 +
 13 files changed, 212 insertions(+), 222 deletions(-)

-- 
2.7.4



[PATCH net-next 10/12] net: hns3: fix VF id issue for setting VF VLAN

2019-10-16 Thread Huazhong Tan
From: Jian Shen 

Previously, when set VF VLAN with command "ip link set 
vf  vlan ", the vf id 0 is handled as PF incorrectly,
which should be the first VF. This patch fixes it.

This patch also adds VF VLAN information for command "ip link show".

Fixes: 21e043cd8124 ("net: hns3: fix set port based VLAN for PF")
Signed-off-by: Jian Shen 
Signed-off-by: Huazhong Tan 
---
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 21 +
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 72c19b3..60aba81 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -2940,6 +2940,9 @@ static int hclge_get_vf_config(struct hnae3_handle 
*handle, int vf,
ivf->trusted = vport->vf_info.trusted;
ivf->min_tx_rate = 0;
ivf->max_tx_rate = vport->vf_info.max_tx_rate;
+   ivf->vlan = vport->port_base_vlan_cfg.vlan_info.vlan_tag;
+   ivf->vlan_proto = htons(vport->port_base_vlan_cfg.vlan_info.vlan_proto);
+   ivf->qos = vport->port_base_vlan_cfg.vlan_info.qos;
ether_addr_copy(ivf->mac, vport->vf_info.mac);
 
return 0;
@@ -8407,13 +8410,16 @@ static int hclge_set_vf_vlan_filter(struct hnae3_handle 
*handle, int vfid,
if (hdev->pdev->revision == 0x20)
return -EOPNOTSUPP;
 
+   vport = hclge_get_vf_vport(hdev, vfid);
+   if (!vport)
+   return -EINVAL;
+
/* qos is a 3 bits value, so can not be bigger than 7 */
-   if (vfid >= hdev->num_alloc_vfs || vlan > VLAN_N_VID - 1 || qos > 7)
+   if (vlan > VLAN_N_VID - 1 || qos > 7)
return -EINVAL;
if (proto != htons(ETH_P_8021Q))
return -EPROTONOSUPPORT;
 
-   vport = &hdev->vport[vfid];
state = hclge_get_port_base_vlan_state(vport,
   vport->port_base_vlan_cfg.state,
   vlan);
@@ -8424,21 +8430,12 @@ static int hclge_set_vf_vlan_filter(struct hnae3_handle 
*handle, int vfid,
vlan_info.qos = qos;
vlan_info.vlan_proto = ntohs(proto);
 
-   /* update port based VLAN for PF */
-   if (!vfid) {
-   hclge_notify_client(hdev, HNAE3_DOWN_CLIENT);
-   ret = hclge_update_port_base_vlan_cfg(vport, state, &vlan_info);
-   hclge_notify_client(hdev, HNAE3_UP_CLIENT);
-
-   return ret;
-   }
-
if (!test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) {
return hclge_update_port_base_vlan_cfg(vport, state,
   &vlan_info);
} else {
ret = hclge_push_vf_port_base_vlan_info(&hdev->vport[0],
-   (u8)vfid, state,
+   vport->vport_id, state,
vlan, qos,
ntohs(proto));
return ret;
-- 
2.7.4



[PATCH net-next 01/12] net: hns3: remove struct hns3_nic_ring_data in hns3_enet module

2019-10-16 Thread Huazhong Tan
From: Yunsheng Lin 

Only the queue_index field in struct hns3_nic_ring_data is
used, other field is unused and unnecessary for hns3 driver,
so this patch removes it and move the queue_index field to
hns3_enet_ring.

This patch also removes an unused struct hns_queue declaration.

Signed-off-by: Yunsheng Lin 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c |  24 ++--
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c| 139 +++--
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.h|  16 +--
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c |  33 +++--
 4 files changed, 74 insertions(+), 138 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index 28961a6..fe5bc6f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -16,15 +16,14 @@ static int hns3_dbg_queue_info(struct hnae3_handle *h,
   const char *cmd_buf)
 {
struct hns3_nic_priv *priv = h->priv;
-   struct hns3_nic_ring_data *ring_data;
struct hns3_enet_ring *ring;
u32 base_add_l, base_add_h;
u32 queue_num, queue_max;
u32 value, i = 0;
int cnt;
 
-   if (!priv->ring_data) {
-   dev_err(&h->pdev->dev, "ring_data is NULL\n");
+   if (!priv->ring) {
+   dev_err(&h->pdev->dev, "priv->ring is NULL\n");
return -EFAULT;
}
 
@@ -44,7 +43,6 @@ static int hns3_dbg_queue_info(struct hnae3_handle *h,
return -EINVAL;
}
 
-   ring_data = priv->ring_data;
for (i = queue_num; i < queue_max; i++) {
/* Each cycle needs to determine whether the instance is reset,
 * to prevent reference to invalid memory. And need to ensure
@@ -54,7 +52,7 @@ static int hns3_dbg_queue_info(struct hnae3_handle *h,
test_bit(HNS3_NIC_STATE_RESETTING, &priv->state))
return -EPERM;
 
-   ring = ring_data[(u32)(i + h->kinfo.num_tqps)].ring;
+   ring = &priv->ring[(u32)(i + h->kinfo.num_tqps)];
base_add_h = readl_relaxed(ring->tqp->io_base +
   HNS3_RING_RX_RING_BASEADDR_H_REG);
base_add_l = readl_relaxed(ring->tqp->io_base +
@@ -86,7 +84,7 @@ static int hns3_dbg_queue_info(struct hnae3_handle *h,
  HNS3_RING_RX_RING_PKTNUM_RECORD_REG);
dev_info(&h->pdev->dev, "RX(%d) RING PKTNUM: %u\n", i, value);
 
-   ring = ring_data[i].ring;
+   ring = &priv->ring[i];
base_add_h = readl_relaxed(ring->tqp->io_base +
   HNS3_RING_TX_RING_BASEADDR_H_REG);
base_add_l = readl_relaxed(ring->tqp->io_base +
@@ -130,7 +128,6 @@ static int hns3_dbg_queue_info(struct hnae3_handle *h,
 static int hns3_dbg_queue_map(struct hnae3_handle *h)
 {
struct hns3_nic_priv *priv = h->priv;
-   struct hns3_nic_ring_data *ring_data;
int i;
 
if (!h->ae_algo->ops->get_global_queue_id)
@@ -143,15 +140,12 @@ static int hns3_dbg_queue_map(struct hnae3_handle *h)
u16 global_qid;
 
global_qid = h->ae_algo->ops->get_global_queue_id(h, i);
-   ring_data = &priv->ring_data[i];
-   if (!ring_data || !ring_data->ring ||
-   !ring_data->ring->tqp_vector)
+   if (!priv->ring || !priv->ring[i].tqp_vector)
continue;
 
dev_info(&h->pdev->dev,
 "  %4d%4d%4d\n",
-i, global_qid,
-ring_data->ring->tqp_vector->vector_irq);
+i, global_qid, priv->ring[i].tqp_vector->vector_irq);
}
 
return 0;
@@ -160,7 +154,6 @@ static int hns3_dbg_queue_map(struct hnae3_handle *h)
 static int hns3_dbg_bd_info(struct hnae3_handle *h, const char *cmd_buf)
 {
struct hns3_nic_priv *priv = h->priv;
-   struct hns3_nic_ring_data *ring_data;
struct hns3_desc *rx_desc, *tx_desc;
struct device *dev = &h->pdev->dev;
struct hns3_enet_ring *ring;
@@ -183,8 +176,7 @@ static int hns3_dbg_bd_info(struct hnae3_handle *h, const 
char *cmd_buf)
return -EINVAL;
}
 
-   ring_data = priv->ring_data;
-   ring  = ring_data[q_num].ring;
+   ring  = &priv->ring[q_num];
value = readl_relaxed(ring->tqp->io_base + HNS3_RING_TX_RING_TAIL_REG);
tx_index = (cnt == 1) ? value : tx_index;
 
@@ -214,7 +206,7 @@ static int hns3_dbg_bd_info(struct hnae3_handle *h, const 
char *cmd_buf)
dev_info(dev, "(TX)vld_ra_ri: %u\n", tx_desc->tx.bdtp_fe_sc_vld_ra_ri);
dev_info(dev, "(TX)mss: %u\n", tx_desc->tx.mss);
 
-   ring  = ring_data

[PATCH net-next 12/12] net: hns3: log and clear hardware error after reset complete

2019-10-16 Thread Huazhong Tan
From: Jian Shen 

When device is resetting, the CMDQ service may be stopped until
reset completed. If a new RAS error occurs at this moment, it
will no be able to clear the RAS source. This patch fixes it
by clear the RAS source after reset complete.

Signed-off-by: Jian Shen 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 60aba81..a47e46e 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -9798,6 +9798,9 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev)
return ret;
}
 
+   /* Log and clear the hw errors those already occurred */
+   hclge_handle_all_hns_hw_errors(ae_dev);
+
/* Re-enable the hw error interrupts because
 * the interrupts get disabled on global reset.
 */
-- 
2.7.4



[PATCH net-next 04/12] net: hns3: fix mis-counting IRQ vector numbers issue

2019-10-16 Thread Huazhong Tan
From: Yonglong Liu 

Currently, the num_msi_left means the vector numbers of NIC,
but if the PF supported RoCE, it contains the vector numbers
of NIC and RoCE(Not expected).

This may cause interrupts lost in some case, because of the
NIC module used the vector resources which belongs to RoCE.

This patch adds a new variable num_nic_msi to store the vector
numbers of NIC, and adjust the default TQP numbers and rss_size
according to the value of num_nic_msi.

Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility 
Layer Support")
Signed-off-by: Yonglong Liu 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h|  2 ++
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 21 +++-
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h|  1 +
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c  | 11 +++--
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c  | 28 +++---
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h  |  1 +
 6 files changed, 58 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h 
b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index c15d7fc..c99632d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -32,6 +32,8 @@
 
 #define HNAE3_MOD_VERSION "1.0"
 
+#define HNAE3_MIN_VECTOR_NUM   2 /* one for msi-x, another for IO */
+
 /* Device IDs */
 #define HNAE3_DEV_ID_GE0xA220
 #define HNAE3_DEV_ID_25GE  0xA221
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 8a3a4fd..2f0386d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -908,6 +908,9 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev)
hnae3_get_field(__le16_to_cpu(req->pf_intr_vector_number),
HCLGE_PF_VEC_NUM_M, HCLGE_PF_VEC_NUM_S);
 
+   /* nic's msix numbers is always equals to the roce's. */
+   hdev->num_nic_msi = hdev->num_roce_msi;
+
/* PF should have NIC vectors and Roce vectors,
 * NIC vectors are queued before Roce vectors.
 */
@@ -917,6 +920,15 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev)
hdev->num_msi =
hnae3_get_field(__le16_to_cpu(req->pf_intr_vector_number),
HCLGE_PF_VEC_NUM_M, HCLGE_PF_VEC_NUM_S);
+
+   hdev->num_nic_msi = hdev->num_msi;
+   }
+
+   if (hdev->num_nic_msi < HNAE3_MIN_VECTOR_NUM) {
+   dev_err(&hdev->pdev->dev,
+   "Just %u msi resources, not enough for pf(min:2).\n",
+   hdev->num_nic_msi);
+   return -EINVAL;
}
 
return 0;
@@ -1540,6 +1552,10 @@ static int  hclge_assign_tqp(struct hclge_vport *vport, 
u16 num_tqps)
kinfo->rss_size = min_t(u16, hdev->rss_size_max,
vport->alloc_tqps / hdev->tm_info.num_tc);
 
+   /* ensure one to one mapping between irq and queue at default */
+   kinfo->rss_size = min_t(u16, kinfo->rss_size,
+   (hdev->num_nic_msi - 1) / hdev->tm_info.num_tc);
+
return 0;
 }
 
@@ -2319,7 +2335,8 @@ static int hclge_init_msi(struct hclge_dev *hdev)
int vectors;
int i;
 
-   vectors = pci_alloc_irq_vectors(pdev, 1, hdev->num_msi,
+   vectors = pci_alloc_irq_vectors(pdev, HNAE3_MIN_VECTOR_NUM,
+   hdev->num_msi,
PCI_IRQ_MSI | PCI_IRQ_MSIX);
if (vectors < 0) {
dev_err(&pdev->dev,
@@ -2334,6 +2351,7 @@ static int hclge_init_msi(struct hclge_dev *hdev)
 
hdev->num_msi = vectors;
hdev->num_msi_left = vectors;
+
hdev->base_msi_vector = pdev->irq;
hdev->roce_base_vector = hdev->base_msi_vector +
hdev->roce_base_msix_offset;
@@ -3993,6 +4011,7 @@ static int hclge_get_vector(struct hnae3_handle *handle, 
u16 vector_num,
int alloc = 0;
int i, j;
 
+   vector_num = min_t(u16, hdev->num_nic_msi - 1, vector_num);
vector_num = min(hdev->num_msi_left, vector_num);
 
for (j = 0; j < vector_num; j++) {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 3153a96..9e59f0e 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -764,6 +764,7 @@ struct hclge_dev {
u32 base_msi_vector;
u16 *vector_status;
int *vector_irq;
+   u16 num_nic_msi;/* Num of nic vectors for this PF */
u16 num_roce_msi;   /* Num of roce vectors 

[PATCH net-next 09/12] net: hns3: minor cleanup for hns3_handle_rx_bd()

2019-10-16 Thread Huazhong Tan
From: Yunsheng Lin 

Since commit e55970950556 ("net: hns3: Add handling of GRO Pkts
not fully RX'ed in NAPI poll"), ring->skb is used to record the
current SKB when processing the RX BD in hns3_handle_rx_bd(),
so the parameter out_skb is unnecessary.

This patch also adjusts the err checking to reduce duplication
in hns3_handle_rx_bd(), and "err == -ENXIO" is rare case, so put
it in the unlikely annotation.

Signed-off-by: Yunsheng Lin 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 38 +
 1 file changed, 13 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 7ddeb9c..6172eb2 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2834,10 +2834,10 @@ static int hns3_alloc_skb(struct hns3_enet_ring *ring, 
unsigned int length,
 }
 
 static int hns3_add_frag(struct hns3_enet_ring *ring, struct hns3_desc *desc,
-struct sk_buff **out_skb, bool pending)
+bool pending)
 {
-   struct sk_buff *skb = *out_skb;
-   struct sk_buff *head_skb = *out_skb;
+   struct sk_buff *skb = ring->skb;
+   struct sk_buff *head_skb = skb;
struct sk_buff *new_skb;
struct hns3_desc_cb *desc_cb;
struct hns3_desc *pre_desc;
@@ -3020,8 +3020,7 @@ static int hns3_handle_bdinfo(struct hns3_enet_ring 
*ring, struct sk_buff *skb)
return 0;
 }
 
-static int hns3_handle_rx_bd(struct hns3_enet_ring *ring,
-struct sk_buff **out_skb)
+static int hns3_handle_rx_bd(struct hns3_enet_ring *ring)
 {
struct sk_buff *skb = ring->skb;
struct hns3_desc_cb *desc_cb;
@@ -3059,12 +3058,12 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring 
*ring,
 
if (!skb) {
ret = hns3_alloc_skb(ring, length, ring->va);
-   *out_skb = skb = ring->skb;
+   skb = ring->skb;
 
if (ret < 0) /* alloc buffer fail */
return ret;
if (ret > 0) { /* need add frag */
-   ret = hns3_add_frag(ring, desc, &skb, false);
+   ret = hns3_add_frag(ring, desc, false);
if (ret)
return ret;
 
@@ -3075,7 +3074,7 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring,
   ALIGN(ring->pull_len, sizeof(long)));
}
} else {
-   ret = hns3_add_frag(ring, desc, &skb, true);
+   ret = hns3_add_frag(ring, desc, true);
if (ret)
return ret;
 
@@ -3093,8 +3092,6 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring,
}
 
skb_record_rx_queue(skb, ring->tqp->tqp_index);
-   *out_skb = skb;
-
return 0;
 }
 
@@ -3103,7 +3100,6 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int 
budget,
 {
 #define RCB_NOF_ALLOC_RX_BUFF_ONCE 16
int unused_count = hns3_desc_unused(ring);
-   struct sk_buff *skb = ring->skb;
int recv_pkts = 0;
int recv_bds = 0;
int err, num;
@@ -3126,27 +3122,19 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int 
budget,
}
 
/* Poll one pkt */
-   err = hns3_handle_rx_bd(ring, &skb);
-   if (unlikely(!skb)) /* This fault cannot be repaired */
+   err = hns3_handle_rx_bd(ring);
+   /* Do not get FE for the packet or failed to alloc skb */
+   if (unlikely(!ring->skb || err == -ENXIO)) {
goto out;
-
-   if (err == -ENXIO) { /* Do not get FE for the packet */
-   goto out;
-   } else if (unlikely(err)) {  /* Do jump the err */
-   recv_bds += ring->pending_buf;
-   unused_count += ring->pending_buf;
-   ring->skb = NULL;
-   ring->pending_buf = 0;
-   continue;
+   } else if (likely(!err)) {
+   rx_fn(ring, ring->skb);
+   recv_pkts++;
}
 
-   rx_fn(ring, skb);
recv_bds += ring->pending_buf;
unused_count += ring->pending_buf;
ring->skb = NULL;
ring->pending_buf = 0;
-
-   recv_pkts++;
}
 
 out:
-- 
2.7.4



[PATCH net-next 11/12] net: hns3: do not allocate linear data for fraglist skb

2019-10-16 Thread Huazhong Tan
From: Yunsheng Lin 

Currently, napi_alloc_skb() is used to allocate skb for fraglist
when the head skb is not enough to hold the remaining data, and
the remaining data is added to the frags part of the fraglist skb,
leaving the linear part unused.

So this patch passes length of 0 to allocate fraglist skb with
zero size of linear data.

Fixes: 81ae0e0491f3 ("net: hns3: Add skb chain when num of RX buf exceeds 
MAX_SKB_FRAGS")
Signed-off-by: Yunsheng Lin 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 6172eb2..14111af 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2866,8 +2866,7 @@ static int hns3_add_frag(struct hns3_enet_ring *ring, 
struct hns3_desc *desc,
return -ENXIO;
 
if (unlikely(ring->frag_num >= MAX_SKB_FRAGS)) {
-   new_skb = napi_alloc_skb(&ring->tqp_vector->napi,
-HNS3_RX_HEAD_SIZE);
+   new_skb = napi_alloc_skb(&ring->tqp_vector->napi, 0);
if (unlikely(!new_skb)) {
hns3_rl_err(ring_to_netdev(ring),
"alloc rx fraglist skb fail\n");
-- 
2.7.4



[PATCH net-next 06/12] net: hns3: optimized MAC address in management table.

2019-10-16 Thread Huazhong Tan
From: Guojia Liao 

mac_addr_hi32 and mac_addr_lo16 are used to store the MAC address
for management table. But using array of mac_addr[ETH_ALEN] would
be more general and not need to care about the big-endian mode of
the CPU.

Signed-off-by: Guojia Liao 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h  | 4 ++--
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
index 3578832..919911f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
@@ -5,6 +5,7 @@
 #define __HCLGE_CMD_H
 #include 
 #include 
+#include 
 
 #define HCLGE_CMDQ_TX_TIMEOUT  3
 
@@ -712,8 +713,7 @@ struct hclge_mac_mgr_tbl_entry_cmd {
u8  flags;
u8  resp_code;
__le16  vlan_tag;
-   __le32  mac_addr_hi32;
-   __le16  mac_addr_lo16;
+   u8  mac_addr[ETH_ALEN];
__le16  rsv1;
__le16  ethter_type;
__le16  egress_port;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 962c4b4..72c19b3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -325,8 +325,7 @@ static const struct hclge_mac_mgr_tbl_entry_cmd 
hclge_mgr_table[] = {
{
.flags = HCLGE_MAC_MGR_MASK_VLAN_B,
.ethter_type = cpu_to_le16(ETH_P_LLDP),
-   .mac_addr_hi32 = cpu_to_le32(htonl(0x0180C200)),
-   .mac_addr_lo16 = cpu_to_le16(htons(0x000E)),
+   .mac_addr = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e},
.i_port_bitmap = 0x1,
},
 };
-- 
2.7.4



[PATCH net-next 02/12] net: hns3: fix TX queue not restarted problem

2019-10-16 Thread Huazhong Tan
From: Yunsheng Lin 

There is timing window between ring_space checking and
netif_stop_subqueue when transmiting a SKB, and the TX BD
cleaning may be executed during the time window, which may
caused TX queue not restarted problem.

This patch fixes it by rechecking the ring_space after
netif_stop_subqueue to make sure TX queue is restarted.

Also, the ring->next_to_clean is updated even when PKTs is
zero, because all the TX BD cleaned may be non-SKB, so it
needs to check if TX queue need to be restarted.

Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 
SoC")
Signed-off-by: Yunsheng Lin 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 36 -
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 635bdda..2cfdfbb 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1286,13 +1286,16 @@ static bool hns3_skb_need_linearized(struct sk_buff 
*skb, unsigned int *bd_size,
return false;
 }
 
-static int hns3_nic_maybe_stop_tx(struct hns3_enet_ring *ring,
+static int hns3_nic_maybe_stop_tx(struct net_device *netdev,
  struct sk_buff **out_skb)
 {
+   struct hns3_nic_priv *priv = netdev_priv(netdev);
unsigned int bd_size[HNS3_MAX_TSO_BD_NUM + 1U];
struct sk_buff *skb = *out_skb;
+   struct hns3_enet_ring *ring;
unsigned int bd_num;
 
+   ring = &priv->ring[skb->queue_mapping];
bd_num = hns3_tx_bd_num(skb, bd_size);
if (unlikely(bd_num > HNS3_MAX_NON_TSO_BD_NUM)) {
struct sk_buff *new_skb;
@@ -1320,10 +1323,23 @@ static int hns3_nic_maybe_stop_tx(struct hns3_enet_ring 
*ring,
}
 
 out:
-   if (unlikely(ring_space(ring) < bd_num))
-   return -EBUSY;
+   if (likely(ring_space(ring) >= bd_num))
+   return bd_num;
 
-   return bd_num;
+   netif_stop_subqueue(netdev, ring->queue_index);
+   smp_mb(); /* Memory barrier before checking ring_space */
+
+   /* Start queue in case hns3_clean_tx_ring has just made room
+* available and has not seen the queue stopped state performed
+* by netif_stop_subqueue above.
+*/
+   if (ring_space(ring) >= bd_num && netif_carrier_ok(netdev) &&
+   !test_bit(HNS3_NIC_STATE_DOWN, &priv->state)) {
+   netif_start_subqueue(netdev, ring->queue_index);
+   return bd_num;
+   }
+
+   return -EBUSY;
 }
 
 static void hns3_clear_desc(struct hns3_enet_ring *ring, int next_to_use_orig)
@@ -1400,13 +1416,13 @@ netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, 
struct net_device *netdev)
/* Prefetch the data used later */
prefetch(skb->data);
 
-   ret = hns3_nic_maybe_stop_tx(ring, &skb);
+   ret = hns3_nic_maybe_stop_tx(netdev, &skb);
if (unlikely(ret <= 0)) {
if (ret == -EBUSY) {
u64_stats_update_begin(&ring->syncp);
ring->stats.tx_busy++;
u64_stats_update_end(&ring->syncp);
-   goto out_net_tx_busy;
+   return NETDEV_TX_BUSY;
} else if (ret == -ENOMEM) {
u64_stats_update_begin(&ring->syncp);
ring->stats.sw_err_cnt++;
@@ -1457,12 +1473,6 @@ netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, 
struct net_device *netdev)
 out_err_tx_ok:
dev_kfree_skb_any(skb);
return NETDEV_TX_OK;
-
-out_net_tx_busy:
-   netif_stop_subqueue(netdev, ring->queue_index);
-   smp_mb(); /* Commit all data before submit */
-
-   return NETDEV_TX_BUSY;
 }
 
 static int hns3_nic_net_set_mac_address(struct net_device *netdev, void *p)
@@ -2515,7 +2525,7 @@ void hns3_clean_tx_ring(struct hns3_enet_ring *ring)
dev_queue = netdev_get_tx_queue(netdev, ring->tqp->tqp_index);
netdev_tx_completed_queue(dev_queue, pkts, bytes);
 
-   if (unlikely(pkts && netif_carrier_ok(netdev) &&
+   if (unlikely(netif_carrier_ok(netdev) &&
 ring_space(ring) > HNS3_MAX_TSO_BD_NUM)) {
/* Make sure that anybody stopping the queue after this
 * sees the new next_to_clean.
-- 
2.7.4



[PATCH net-next 08/12] net: hns3: introduce ring_to_netdev() in enet module

2019-10-16 Thread Huazhong Tan
From: Yunsheng Lin 

There are a few places that need to access the netdev of a ring
through ring->tqp->handle->kinfo.netdev, and ring->tqp is a struct
which both in enet and hclge modules, it is better to use the
struct that is only used in enet module.

This patch adds the ring_to_netdev() to access the netdev of ring
through ring->tqp_vector->napi.dev.

Also, struct hns3_enet_ring is a frequently used in critical data
path, so make it cacheline aligned as struct hns3_enet_tqp_vector.

Signed-off-by: Yunsheng Lin 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 14 +++---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.h |  4 +++-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index a0810b3..7ddeb9c 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2481,7 +2481,7 @@ static int is_valid_clean_head(struct hns3_enet_ring 
*ring, int h)
 
 void hns3_clean_tx_ring(struct hns3_enet_ring *ring)
 {
-   struct net_device *netdev = ring->tqp->handle->kinfo.netdev;
+   struct net_device *netdev = ring_to_netdev(ring);
struct hns3_nic_priv *priv = netdev_priv(netdev);
struct netdev_queue *dev_queue;
int bytes, pkts;
@@ -2563,7 +2563,7 @@ static void hns3_nic_alloc_rx_buffers(struct 
hns3_enet_ring *ring,
ring->stats.sw_err_cnt++;
u64_stats_update_end(&ring->syncp);
 
-   hns3_rl_err(ring->tqp_vector->napi.dev,
+   hns3_rl_err(ring_to_netdev(ring),
"alloc rx buffer failed: %d\n",
ret);
break;
@@ -2672,7 +2672,7 @@ static int hns3_gro_complete(struct sk_buff *skb, u32 
l234info)
 static void hns3_rx_checksum(struct hns3_enet_ring *ring, struct sk_buff *skb,
 u32 l234info, u32 bd_base_info, u32 ol_info)
 {
-   struct net_device *netdev = ring->tqp->handle->kinfo.netdev;
+   struct net_device *netdev = ring_to_netdev(ring);
int l3_type, l4_type;
int ol4_type;
 
@@ -2788,7 +2788,7 @@ static int hns3_alloc_skb(struct hns3_enet_ring *ring, 
unsigned int length,
 {
 #define HNS3_NEED_ADD_FRAG 1
struct hns3_desc_cb *desc_cb = &ring->desc_cb[ring->next_to_clean];
-   struct net_device *netdev = ring->tqp->handle->kinfo.netdev;
+   struct net_device *netdev = ring_to_netdev(ring);
struct sk_buff *skb;
 
ring->skb = napi_alloc_skb(&ring->tqp_vector->napi, HNS3_RX_HEAD_SIZE);
@@ -2869,7 +2869,7 @@ static int hns3_add_frag(struct hns3_enet_ring *ring, 
struct hns3_desc *desc,
new_skb = napi_alloc_skb(&ring->tqp_vector->napi,
 HNS3_RX_HEAD_SIZE);
if (unlikely(!new_skb)) {
-   hns3_rl_err(ring->tqp_vector->napi.dev,
+   hns3_rl_err(ring_to_netdev(ring),
"alloc rx fraglist skb fail\n");
return -ENXIO;
}
@@ -2945,7 +2945,7 @@ static void hns3_set_rx_skb_rss_type(struct 
hns3_enet_ring *ring,
 
 static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb)
 {
-   struct net_device *netdev = ring->tqp->handle->kinfo.netdev;
+   struct net_device *netdev = ring_to_netdev(ring);
enum hns3_pkt_l2t_type l2_frame_type;
u32 bd_base_info, l234info, ol_info;
struct hns3_desc *desc;
@@ -4227,7 +4227,7 @@ static int hns3_clear_rx_ring(struct hns3_enet_ring *ring)
/* if alloc new buffer fail, exit directly
 * and reclear in up flow.
 */
-   netdev_warn(ring->tqp->handle->kinfo.netdev,
+   netdev_warn(ring_to_netdev(ring),
"reserve buffer map failed, ret = 
%d\n",
ret);
return ret;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
index 3322284..0725dc5 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
@@ -435,7 +435,7 @@ struct hns3_enet_ring {
int pending_buf;
struct sk_buff *skb;
struct sk_buff *tail_skb;
-};
+} cacheline_internodealigned_in_smp;
 
 enum hns3_flow_level_range {
HNS3_FLOW_LOW = 0,
@@ -607,6 +607,8 @@ static inline bool hns3_nic_resetting(struct net_device 
*netdev)
 
 #define ring_to_dev(ring) ((ring)->dev)
 
+#define ring_to_net

Re: [PATCH] PNP: fix unintended sign extension on left shifts

2019-10-16 Thread walter harms



Am 15.10.2019 18:29, schrieb Rafael J. Wysocki:
> On 10/14/2019 3:16 PM, Colin King wrote:
>> From: Colin Ian King 
>>
>> Shifting a u8 left will cause the value to be promoted to an integer. If
>> the top bit of the u8 is set then the following conversion to a 64 bit
>> resource_size_t will sign extend the value causing the upper 32 bits
>> to be set in the result.
>>
>> Fix this by casting the u8 value to a resource_size_t before the shift.
>> Original commit is pre-git history.
>>
>> Signed-off-by: Colin Ian King 
> 
> Please resend this with a Cc to linux-a...@vger.kernel.org for easier
> handling.
> 
> 
>> ---
>>   drivers/pnp/isapnp/core.c | 18 --
>>   1 file changed, 12 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
>> index 179b737280e1..c947b1673041 100644
>> --- a/drivers/pnp/isapnp/core.c
>> +++ b/drivers/pnp/isapnp/core.c
>> @@ -511,10 +511,14 @@ static void __init
>> isapnp_parse_mem32_resource(struct pnp_dev *dev,
>>   unsigned char flags;
>> isapnp_peek(tmp, size);
>> -min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
>> -max = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5];
>> -align = (tmp[12] << 24) | (tmp[11] << 16) | (tmp[10] << 8) | tmp[9];
>> -len = (tmp[16] << 24) | (tmp[15] << 16) | (tmp[14] << 8) | tmp[13];
>> +min = ((resource_size_t)tmp[4] << 24) | (tmp[3] << 16) |
>> +  (tmp[2] << 8) | tmp[1];
>> +max = ((resource_size_t)tmp[8] << 24) | (tmp[7] << 16) |
>> +  (tmp[6] << 8) | tmp[5];
>> +align = ((resource_size_t)tmp[12] << 24) | (tmp[11] << 16) |
>> +  (tmp[10] << 8) | tmp[9];
>> +len = ((resource_size_t)tmp[16] << 24) | (tmp[15] << 16) |
>> +  (tmp[14] << 8) | tmp[13];
>>   flags = tmp[0];
>>   pnp_register_mem_resource(dev, option_flags,
>> min, max, align, len, flags);
>> @@ -532,8 +536,10 @@ static void __init
>> isapnp_parse_fixed_mem32_resource(struct pnp_dev *dev,
>>   unsigned char flags;
>> isapnp_peek(tmp, size);
>> -base = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
>> -len = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5];
>> +base = ((resource_size_t)tmp[4] << 24) | (tmp[3] << 16) |
>> +   (tmp[2] << 8) | tmp[1];
>> +len = ((resource_size_t)tmp[8] << 24) | (tmp[7] << 16) |
>> +  (tmp[6] << 8) | tmp[5];
>>   flags = tmp[0];
>>   pnp_register_mem_resource(dev, option_flags, base, base, 0, len,
>> flags);
>>   }
> 
> 

there was a hint to use get/put_unaligned_be*() maybe that is here also 
possible ?

re,
 wh

(ps: see: [PATCH] scsi: fix unintended sign extension on left shifts)
> 


[PATCH net-next 07/12] net: hns3: minor optimization for barrier in IO path

2019-10-16 Thread Huazhong Tan
From: Yunsheng Lin 

Currently, the TX and RX ring in a queue is bounded to the
same IRQ, there may be unnecessary barrier op when only one of
the ring need to be processed.

This patch adjusts the location of rmb() in hns3_clean_tx_ring()
and adds a checking in hns3_clean_rx_ring() to avoid unnecessary
barrier op when there is nothing to do for the ring.

Signed-off-by: Yunsheng Lin 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 5a237f94..a0810b3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2488,11 +2488,12 @@ void hns3_clean_tx_ring(struct hns3_enet_ring *ring)
int head;
 
head = readl_relaxed(ring->tqp->io_base + HNS3_RING_TX_RING_HEAD_REG);
-   rmb(); /* Make sure head is ready before touch any data */
 
if (is_ring_empty(ring) || head == ring->next_to_clean)
return; /* no data to poll */
 
+   rmb(); /* Make sure head is ready before touch any data */
+
if (unlikely(!is_valid_clean_head(ring, head))) {
netdev_err(netdev, "wrong head (%d, %d-%d)\n", head,
   ring->next_to_use, ring->next_to_clean);
@@ -3108,11 +3109,14 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int 
budget,
int err, num;
 
num = readl_relaxed(ring->tqp->io_base + HNS3_RING_RX_RING_FBDNUM_REG);
-   rmb(); /* Make sure num taken effect before the other data is touched */
-
num -= unused_count;
unused_count -= ring->pending_buf;
 
+   if (num <= 0)
+   goto out;
+
+   rmb(); /* Make sure num taken effect before the other data is touched */
+
while (recv_pkts < budget && recv_bds < num) {
/* Reuse or realloc buffers */
if (unused_count >= RCB_NOF_ALLOC_RX_BUFF_ONCE) {
-- 
2.7.4



Re: [PATCH v3 0/8] sched/fair: rework the CFS load balance

2019-10-16 Thread Parth Shah



On 9/19/19 1:03 PM, Vincent Guittot wrote:
> Several wrong task placement have been raised with the current load
> balance algorithm but their fixes are not always straight forward and
> end up with using biased values to force migrations. A cleanup and rework
> of the load balance will help to handle such UCs and enable to fine grain
> the behavior of the scheduler for other cases.
> 
> Patch 1 has already been sent separately and only consolidate asym policy
> in one place and help the review of the changes in load_balance.
> 
> Patch 2 renames the sum of h_nr_running in stats.
> 
> Patch 3 removes meaningless imbalance computation to make review of
> patch 4 easier.
> 
> Patch 4 reworks load_balance algorithm and fixes some wrong task placement
> but try to stay conservative.
> 
> Patch 5 add the sum of nr_running to monitor non cfs tasks and take that
> into account when pulling tasks.
> 
> Patch 6 replaces runnable_load by load now that the signal is only used
> when overloaded.
> 
> Patch 7 improves the spread of tasks at the 1st scheduling level.
> 
> Patch 8 uses utilization instead of load in all steps of misfit task
> path.
> 
> Patch 9 replaces runnable_load_avg by load_avg in the wake up path.
> 
> Patch 10 optimizes find_idlest_group() that was using both runnable_load
> and load. This has not been squashed with previous patch to ease the
> review.
> 
> Some benchmarks results based on 8 iterations of each tests:
> - small arm64 dual quad cores system
> 
>tip/sched/corew/ this patchsetimprovement
> schedpipe  54981 +/-0.36%55459 +/-0.31%   (+0.97%)
> 
> hackbench
> 1 groups   0.906 +/-2.34%0.906 +/-2.88%   (+0.06%)
> 
> - large arm64 2 nodes / 224 cores system
> 
>tip/sched/corew/ this patchsetimprovement
> schedpipe 125323 +/-0.98%   125624 +/-0.71%   (+0.24%)
> 
> hackbench -l (256000/#grp) -g #grp
> 1 groups  15.360 +/-1.76%   14.206 +/-1.40%   (+8.69%)
> 4 groups   5.822 +/-1.02%5.508 +/-6.45%   (+5.38%)
> 16 groups  3.103 +/-0.80%3.244 +/-0.77%   (-4.52%)
> 32 groups  2.892 +/-1.23%2.850 +/-1.81%   (+1.47%)
> 64 groups  2.825 +/-1.51%2.725 +/-1.51%   (+3.54%)
> 128 groups 3.149 +/-8.46%3.053 +/-13.15%  (+3.06%)
> 256 groups 3.511 +/-8.49%3.019 +/-1.71%  (+14.03%)
> 
> dbench
> 1 groups 329.677 +/-0.46%  329.771 +/-0.11%   (+0.03%)
> 4 groups 931.499 +/-0.79%  947.118 +/-0.94%   (+1.68%)
> 16 groups   1924.210 +/-0.89% 1947.849 +/-0.76%   (+1.23%)
> 32 groups   2350.646 +/-5.75% 2351.549 +/-6.33%   (+0.04%)
> 64 groups   2201.524 +/-3.35% 2192.749 +/-5.84%   (-0.40%)
> 128 groups  2206.858 +/-2.50% 2376.265 +/-7.44%   (+7.68%)
> 256 groups  1263.520 +/-3.34% 1633.143 +/-13.02% (+29.25%)
> 
> tip/sched/core sha1:
>   0413d7f33e60 ('sched/uclamp: Always use 'enum uclamp_id' for clamp_id 
> values')
> [...]

I am quietly impressed with this patch series as it makes easy to
understand the behavior of the load balancer just by looking at the code.

I have tested v3 on IBM POWER9 system with following configuration:
- CPU(s):  176
- Thread(s) per core:  4
- Core(s) per socket:  22
- Socket(s):   2
- Model name:  POWER9, altivec supported
- NUMA node0 CPU(s):   0-87
- NUMA node8 CPU(s):   88-175

I see results in par with the baseline (tip/sched/core) with most of my
testings.

hackbench
=
hackbench -l (256000/#grp) -g #grp (lower is better):
+++---+--+
| groups | w/ patches | Baseline  | Performance gain |
+++---+--+
|  1 | 14.948 (+/- 0.10)  | 15.13 (+/- 0.47 ) | +1.20|
|  4 | 5.938 (+/- 0.034)  | 6.085 (+/- 0.07)  | +2.4 |
|  8 | 6.594 (+/- 0.072)  | 6.223 (+/- 0.03)  | -5.9 |
| 16 | 5.916 (+/- 0.05)   | 5.559 (+/- 0.00)  | -6.4 |
| 32 | 5.288 (+/- 0.034)  | 5.23 (+/- 0.01)   | -1.1 |
| 64 | 5.147 (+/- 0.036)  | 5.193 (+/- 0.09)  | +0.8 |
|128 | 5.368 (+/- 0.0245) | 5.446 (+/- 0.04)  | +1.4 |
|256 | 5.637 (+/- 0.088)  | 5.596 (+/- 0.07)  | -0.7 |
|512 | 5.78 (+/- 0.0637)  | 5.934 (+/- 0.06)  | +2.5 |
+++---+--+


dbench

dbench  (Throughput: Higher is better):
+-+-+---+--+
| groups  | w/ patches  |baseline   |gain  |
+-+-+---+--+
|   1 |12.6419(+/-0.58) |12.6511 (+/-0.277) |   -0.00  |
|   4 |23.7712(+/-2.22) |21.8526 (+/-0.844) |   +8.7   |
|   8 |40.1333(+/-0.85) |37.0623 (+/-3.283) |   +8.2   |
|  16 |   60.5529(+/-2.35)  |60.0972 (+/-9.655) 

[PATCH net-next 03/12] net: hns3: fix a use after freed problem in hns3_nic_maybe_stop_tx()

2019-10-16 Thread Huazhong Tan
From: Yunsheng Lin 

Currently, hns3_nic_maybe_stop_tx() use skb_copy() to linearize a
SKB if the BD num required by the SKB does not meet the hardware
limitation, and it linearizes the SKB by allocating a new SKB and
freeing the old SKB, if hns3_nic_maybe_stop_tx() returns -EBUSY,
the sch_direct_xmit() still hold reference to old SKB and try to
retransmit the old SKB when dev_hard_start_xmit() return TX_BUSY,
which may cause use after freed problem.

This patch fixes it by using __skb_linearize() to linearize the
SKB in hns3_nic_maybe_stop_tx().

Fixes: 51e8439f3496 ("net: hns3: add 8 BD limit for tx flow")
Signed-off-by: Yunsheng Lin 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 19 ++-
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 2cfdfbb..5a237f94 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1287,33 +1287,26 @@ static bool hns3_skb_need_linearized(struct sk_buff 
*skb, unsigned int *bd_size,
 }
 
 static int hns3_nic_maybe_stop_tx(struct net_device *netdev,
- struct sk_buff **out_skb)
+ struct sk_buff *skb)
 {
struct hns3_nic_priv *priv = netdev_priv(netdev);
unsigned int bd_size[HNS3_MAX_TSO_BD_NUM + 1U];
-   struct sk_buff *skb = *out_skb;
struct hns3_enet_ring *ring;
unsigned int bd_num;
 
ring = &priv->ring[skb->queue_mapping];
bd_num = hns3_tx_bd_num(skb, bd_size);
if (unlikely(bd_num > HNS3_MAX_NON_TSO_BD_NUM)) {
-   struct sk_buff *new_skb;
 
if (bd_num <= HNS3_MAX_TSO_BD_NUM && skb_is_gso(skb) &&
!hns3_skb_need_linearized(skb, bd_size, bd_num))
goto out;
 
-   /* manual split the send packet */
-   new_skb = skb_copy(skb, GFP_ATOMIC);
-   if (!new_skb)
+   if (__skb_linearize(skb))
return -ENOMEM;
-   dev_kfree_skb_any(skb);
-   *out_skb = new_skb;
-
-   bd_num = hns3_tx_bd_count(new_skb->len);
-   if ((skb_is_gso(new_skb) && bd_num > HNS3_MAX_TSO_BD_NUM) ||
-   (!skb_is_gso(new_skb) &&
+   bd_num = hns3_tx_bd_count(skb->len);
+   if ((skb_is_gso(skb) && bd_num > HNS3_MAX_TSO_BD_NUM) ||
+   (!skb_is_gso(skb) &&
 bd_num > HNS3_MAX_NON_TSO_BD_NUM))
return -ENOMEM;
 
@@ -1416,7 +1409,7 @@ netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct 
net_device *netdev)
/* Prefetch the data used later */
prefetch(skb->data);
 
-   ret = hns3_nic_maybe_stop_tx(netdev, &skb);
+   ret = hns3_nic_maybe_stop_tx(netdev, skb);
if (unlikely(ret <= 0)) {
if (ret == -EBUSY) {
u64_stats_update_begin(&ring->syncp);
-- 
2.7.4



[PATCH net-next 05/12] net: hns3: fix VF VLAN table entries inconsistent issue

2019-10-16 Thread Huazhong Tan
From: Jian Shen 

Currently, if VF is loaded on the host side, the host doesn't
clear the VF's VLAN table entries when VF removing. In this
case, when doing reset and disabling sriov at the same time the
VLAN device over VF will be removed, but the VLAN table entries
in hardware are remained.

This patch fixes it by asking PF to clear the VLAN table entries for
VF when VF is removing. It also clear the VLAN table full bit
after VF VLAN table entries being cleared.

Fixes: c6075b193462 ("net: hns3: Record VF vlan tables")
Signed-off-by: Jian Shen 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h   | 1 +
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c   | 1 +
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c| 1 +
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 4 
 4 files changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h 
b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
index 0059d44..05f3442 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
@@ -46,6 +46,7 @@ enum HCLGE_MBX_OPCODE {
HCLGE_MBX_PUSH_VLAN_INFO,   /* (PF -> VF) push port base vlan */
HCLGE_MBX_GET_MEDIA_TYPE,   /* (VF -> PF) get media type */
HCLGE_MBX_PUSH_PROMISC_INFO,/* (PF -> VF) push vf promisc info */
+   HCLGE_MBX_VF_UNINIT,/* (VF -> PF) vf is unintializing */
 
HCLGE_MBX_GET_VF_FLR_STATUS = 200, /* (M7 -> PF) get vf reset status */
HCLGE_MBX_PUSH_LINK_STATUS, /* (M7 -> PF) get port link status */
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 2f0386d..962c4b4 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -8218,6 +8218,7 @@ void hclge_rm_vport_all_vlan_table(struct hclge_vport 
*vport, bool is_del_list)
kfree(vlan);
}
}
+   clear_bit(vport->vport_id, hdev->vf_vlan_full);
 }
 
 void hclge_uninit_vport_vlan_table(struct hclge_dev *hdev)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
index 97463e11..d48b2f6 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
@@ -797,6 +797,7 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
hclge_get_link_mode(vport, req);
break;
case HCLGE_MBX_GET_VF_FLR_STATUS:
+   case HCLGE_MBX_VF_UNINIT:
mutex_lock(&hdev->vport_cfg_mutex);
hclge_rm_vport_all_mac_table(vport, true,
 HCLGE_MAC_ADDR_UC);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 408e386..f426f63 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -2796,6 +2796,10 @@ static void hclgevf_uninit_hdev(struct hclgevf_dev *hdev)
 {
hclgevf_state_uninit(hdev);
 
+   if (!test_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state))
+   hclgevf_send_mbx_msg(hdev, HCLGE_MBX_VF_UNINIT, 0, NULL, 0,
+false, NULL, 0);
+
if (test_bit(HCLGEVF_STATE_IRQ_INITED, &hdev->state)) {
hclgevf_misc_irq_uninit(hdev);
hclgevf_uninit_msi(hdev);
-- 
2.7.4



Re: [PATCH v3 04/10] sched/fair: rework load_balance

2019-10-16 Thread Parth Shah



On 9/19/19 1:03 PM, Vincent Guittot wrote:

[...]

> Signed-off-by: Vincent Guittot 
> ---
>  kernel/sched/fair.c | 585 
> ++--
>  1 file changed, 380 insertions(+), 205 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 017aad0..d33379c 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7078,11 +7078,26 @@ static unsigned long __read_mostly 
> max_load_balance_interval = HZ/10;
> 
>  enum fbq_type { regular, remote, all };
> 
> +/*
> + * group_type describes the group of CPUs at the moment of the load balance.
> + * The enum is ordered by pulling priority, with the group with lowest 
> priority
> + * first so the groupe_type can be simply compared when selecting the busiest
> + * group. see update_sd_pick_busiest().
> + */
>  enum group_type {
> - group_other = 0,
> + group_has_spare = 0,
> + group_fully_busy,
>   group_misfit_task,
> + group_asym_packing,
>   group_imbalanced,
> - group_overloaded,
> + group_overloaded
> +};
> +
> +enum migration_type {
> + migrate_load = 0,
> + migrate_util,
> + migrate_task,
> + migrate_misfit
>  };
> 
>  #define LBF_ALL_PINNED   0x01
> @@ -7115,7 +7130,7 @@ struct lb_env {
>   unsigned intloop_max;
> 
>   enum fbq_type   fbq_type;
> - enum group_type src_grp_type;
> + enum migration_type balance_type;
>   struct list_headtasks;
>  };
> 
> @@ -7347,7 +7362,7 @@ static int detach_tasks(struct lb_env *env)
>  {
>   struct list_head *tasks = &env->src_rq->cfs_tasks;
>   struct task_struct *p;
> - unsigned long load;
> + unsigned long util, load;
>   int detached = 0;
> 
>   lockdep_assert_held(&env->src_rq->lock);
> @@ -7380,19 +7395,53 @@ static int detach_tasks(struct lb_env *env)
>   if (!can_migrate_task(p, env))
>   goto next;
> 
> - load = task_h_load(p);
> + switch (env->balance_type) {
> + case migrate_load:
> + load = task_h_load(p);
> 
> - if (sched_feat(LB_MIN) && load < 16 && 
> !env->sd->nr_balance_failed)
> - goto next;
> + if (sched_feat(LB_MIN) &&
> + load < 16 && !env->sd->nr_balance_failed)
> + goto next;
> 
> - if ((load / 2) > env->imbalance)
> - goto next;
> + if ((load / 2) > env->imbalance)
> + goto next;
> +
> + env->imbalance -= load;
> + break;
> +
> + case migrate_util:
> + util = task_util_est(p);
> +
> + if (util > env->imbalance)

Can you please explain what would happen for
`if (util/2 > env->imbalance)` ?
just like when migrating load, even util shouldn't be migrated if
env->imbalance is just near the utilization of the task being moved, isn't it?

> + goto next;
> +
> + env->imbalance -= util;
> + break;
> +[ ... ]

Thanks,
Parth



Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.

2019-10-16 Thread Hans de Goede

Hi,

On 10/15/19 7:39 AM, John Stultz wrote:

On Thu, Oct 3, 2019 at 1:51 PM Hans de Goede  wrote:

On 03-10-2019 22:37, John Stultz wrote:

Fair point. I'm sort of taking a larger patchset and trying to break
it up into more easily reviewable chunks, but I guess here I mis-cut.

The user is the hikey960 gpio hub driver here:

https://git.linaro.org/people/john.stultz/android-dev.git/commit/?id=b06158a2d3eb00c914f12c76c93695e92d9af00f


Hmm, that seems to tie the TypeC data-role to the power-role, which
is not going to work with role swapping.


Thanks again for the feedback here. Sorry for the slow response. Been
reworking some of the easier changes but am starting to look at how to
address your feedback here.


What is controlling the usb-role-switch, and thus ultimately
causing the notifier you are suggesting to get called ?


The tcpm_mux_set() call via tcpm_state_machine_work()


Things like TYPEC_VBUS_POWER_OFF and TYPEC_VBUS_POWER_ON
really beg to be modeled as a regulator and then the
Type-C controller (using e.g. the drivers/usb/typec/tcpm/tcpm.c
framework) can use that regulator to control things.
in case of the tcpm.c framework it can then use that
regulator to implement the set_vbus callback.


So I'm looking at the bindings and I'm not sure exactly how to tie a
regulator style driver into the tcpm for this?
Looking at the driver I just see this commented out bit:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/typec/tcpm/tcpm.c#n3075

Do you happen to have a pointer to something closer to what you are describing?


Look at the tcpm_set_vbus implementation in drivers/usb/typec/tcpm/fusb302.c
you need to do something similar in your Type-C controller driver and
export the GPIO as as a gpio-controlled regulator and tie the regulator to
the connector.

Regards,

Hans



Re: [PATCH] perf list: Hide deprecated events by default

2019-10-16 Thread Jiri Olsa
On Wed, Oct 16, 2019 at 08:59:13AM +0800, Jin, Yao wrote:
> 
> 
> On 10/15/2019 5:14 PM, Jiri Olsa wrote:
> > On Tue, Oct 15, 2019 at 10:53:57AM +0800, Jin Yao wrote:
> > > There are some deprecated events listed by perf list. But we can't remove
> > > them from perf list with ease because some old scripts may use them.
> > > 
> > > Deprecated events are old names of renamed events.  When an event gets
> > > renamed the old name is kept around for some time and marked with
> > > Deprecated. The newer Intel event lists in the tree already have these
> > > headers.
> > > 
> > > So we need to keep them in the event list, but provide a new option to
> > > show them. The new option is "--deprecated".
> > > 
> > > With this patch, the deprecated events are hidden by default but they can
> > > be displayed when option "--deprecated" is enabled.
> > 
> > not sure it's wise to hide them, because people will not read man page
> > to find --deprecated option, they will rather complain right away ;-)
> > 
> > how about to display them as another topic, like:
> > 
> > pipeline:
> > ...
> > uncore:
> > ...
> > deprecated:
> > ...
> > 
> > jirka
> > 
> 
> Hi Jiri,
> 
> I don't know if we add a new topic "deprecated" in perf list output, does
> the old script need to be modified as well?
> 
> Say the events are moved to the "deprecated" section, I just guess the
> script needs the modification.
> 
> That's just my personal guess. :)

i did not mean adding new topic all the way down,
just to display the deprecated events like that

jirka


Re: [PATCH v3 2/3] bpf: use copy_struct_from_user() in bpf_prog_get_info_by_fd()y

2019-10-16 Thread Christian Brauner
On Tue, Oct 15, 2019 at 10:25:49PM -0700, Alexei Starovoitov wrote:
> On Wed, Oct 16, 2019 at 05:44:31AM +0200, Christian Brauner wrote:
> > In v5.4-rc2 we added a new helper (cf. [1]) copy_struct_from_user().
> > This helper is intended for all codepaths that copy structs from
> > userspace that are versioned by size. bpf_prog_get_info_by_fd() does
> > exactly what copy_struct_from_user() is doing.
> > Note that copy_struct_from_user() is calling min() already. So
> > technically, the min_t() call could go. But the info_len is used further
> > below so leave it.
> > 
> > [1]: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper")
> > Cc: Alexei Starovoitov 
> > Cc: Daniel Borkmann 
> > Cc: b...@vger.kernel.org
> > Acked-by: Aleksa Sarai 
> > Signed-off-by: Christian Brauner 
> > ---
> > /* v1 */
> > Link: 
> > https://lore.kernel.org/r/20191009160907.10981-3-christian.brau...@ubuntu.com
> > 
> > /* v2 */
> > Link: 
> > https://lore.kernel.org/r/20191016004138.24845-3-christian.brau...@ubuntu.com
> > - Alexei Starovoitov :
> >   - remove unneeded initialization
> > 
> > /* v3 */
> > unchanged
> > ---
> >  kernel/bpf/syscall.c | 9 +++--
> >  1 file changed, 3 insertions(+), 6 deletions(-)
> > 
> > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> > index 40edcaeccd71..151447f314ca 100644
> > --- a/kernel/bpf/syscall.c
> > +++ b/kernel/bpf/syscall.c
> > @@ -2306,20 +2306,17 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog 
> > *prog,
> >union bpf_attr __user *uattr)
> >  {
> > struct bpf_prog_info __user *uinfo = u64_to_user_ptr(attr->info.info);
> > -   struct bpf_prog_info info = {};
> > +   struct bpf_prog_info info;
> > u32 info_len = attr->info.info_len;
> > struct bpf_prog_stats stats;
> > char __user *uinsns;
> > u32 ulen;
> > int err;
> >  
> > -   err = bpf_check_uarg_tail_zero(uinfo, sizeof(info), info_len);
> > +   info_len = min_t(u32, sizeof(info), info_len);
> > +   err = copy_struct_from_user(&info, sizeof(info), uinfo, info_len);
> 
> really?! min?!
> Frankly I'm disappointed in quality of these patches.
> Especially considering it's v3.

Ok, then I'm sorry.

Christian


Re: [PATCH] PCI: sysfs: remove pci_bridge_groups and pcie_dev_groups

2019-10-16 Thread Ben Dooks

On 16/10/2019 07:28, Christoph Hellwig wrote:

On Tue, Oct 15, 2019 at 03:00:59PM +0100, Ben Dooks wrote:

The pci_bridge_groups and pcie_dev_groups objects are
not exported and not used at-all, so remove them to
fix the following warnings from sparse:

drivers/pci/pci-sysfs.c:1546:30: warning: symbol 'pci_bridge_groups' was not 
declared. Should it be static?
drivers/pci/pci-sysfs.c:1555:30: warning: symbol 'pcie_dev_groups' was not 
declared. Should it be static?


But now pci_bridge_group is unused, and if you remove that the
attributes, etc..


Hmm, didn't get a warning for that. I'll go check.


--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html


Re: [PATCH v2 net-next] net: core: use listified Rx for GRO_NORMAL in napi_gro_receive()

2019-10-16 Thread Alexander Lobakin

David Miller wrote 16.10.2019 04:16:

From: Alexander Lobakin 
Date: Mon, 14 Oct 2019 11:00:33 +0300


Commit 323ebb61e32b4 ("net: use listified RX for handling GRO_NORMAL
skbs") made use of listified skb processing for the users of
napi_gro_frags().
The same technique can be used in a way more common napi_gro_receive()
to speed up non-merged (GRO_NORMAL) skbs for a wide range of drivers
including gro_cells and mac80211 users.
This slightly changes the return value in cases where skb is being
dropped by the core stack, but it seems to have no impact on related
drivers' functionality.
gro_normal_batch is left untouched as it's very individual for every
single system configuration and might be tuned in manual order to
achieve an optimal performance.

Signed-off-by: Alexander Lobakin 
Acked-by: Edward Cree 


Applied, thank you.


David, Edward, Eric, Ilias,
thank you for your time.

Regards,
ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ


[PATCH 04/15] drivers: thermal: tsens: Add debugfs support

2019-10-16 Thread Amit Kucheria
Dump some basic version info and sensor details into debugfs. Example
from qcs404 below:

--(/sys/kernel/debug) $ ls tsens/
4a9000.thermal-sensor  version
--(/sys/kernel/debug) $ cat tsens/version
1.4.0
--(/sys/kernel/debug) $ cat tsens/4a9000.thermal-sensor/sensors
max: 11
num: 10

  idslope   offset

   0 3200   404000
   1 3200   404000
   2 3200   404000
   3 3200   404000
   4 3200   404000
   5 3200   404000
   6 3200   404000
   7 3200   404000
   8 3200   404000
   9 3200   404000

Signed-off-by: Amit Kucheria 
Reviewed-by: Stephen Boyd 
---
 drivers/thermal/qcom/tsens-common.c | 83 +
 drivers/thermal/qcom/tsens.c|  2 +
 drivers/thermal/qcom/tsens.h|  6 +++
 3 files changed, 91 insertions(+)

diff --git a/drivers/thermal/qcom/tsens-common.c 
b/drivers/thermal/qcom/tsens-common.c
index 7437bfe196e5..ea2c46cc6a66 100644
--- a/drivers/thermal/qcom/tsens-common.c
+++ b/drivers/thermal/qcom/tsens-common.c
@@ -3,6 +3,7 @@
  * Copyright (c) 2015, The Linux Foundation. All rights reserved.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -139,6 +140,77 @@ int get_temp_common(struct tsens_sensor *s, int *temp)
return 0;
 }
 
+#ifdef CONFIG_DEBUG_FS
+static int dbg_sensors_show(struct seq_file *s, void *data)
+{
+   struct platform_device *pdev = s->private;
+   struct tsens_priv *priv = platform_get_drvdata(pdev);
+   int i;
+
+   seq_printf(s, "max: %2d\nnum: %2d\n\n",
+  priv->feat->max_sensors, priv->num_sensors);
+
+   seq_puts(s, "  idslope   offset\n--\n");
+   for (i = 0;  i < priv->num_sensors; i++) {
+   seq_printf(s, "%8d %8d %8d\n", priv->sensor[i].hw_id,
+  priv->sensor[i].slope, priv->sensor[i].offset);
+   }
+
+   return 0;
+}
+
+static int dbg_version_show(struct seq_file *s, void *data)
+{
+   struct platform_device *pdev = s->private;
+   struct tsens_priv *priv = platform_get_drvdata(pdev);
+   u32 maj_ver, min_ver, step_ver;
+   int ret;
+
+   if (tsens_ver(priv) > VER_0_1) {
+   ret = regmap_field_read(priv->rf[VER_MAJOR], &maj_ver);
+   if (ret)
+   return ret;
+   ret = regmap_field_read(priv->rf[VER_MINOR], &min_ver);
+   if (ret)
+   return ret;
+   ret = regmap_field_read(priv->rf[VER_STEP], &step_ver);
+   if (ret)
+   return ret;
+   seq_printf(s, "%d.%d.%d\n", maj_ver, min_ver, step_ver);
+   } else {
+   seq_puts(s, "0.1.0\n");
+   }
+
+   return 0;
+}
+
+DEFINE_SHOW_ATTRIBUTE(dbg_version);
+DEFINE_SHOW_ATTRIBUTE(dbg_sensors);
+
+static void tsens_debug_init(struct platform_device *pdev)
+{
+   struct tsens_priv *priv = platform_get_drvdata(pdev);
+   struct dentry *root, *file;
+
+   root = debugfs_lookup("tsens", NULL);
+   if (!root)
+   priv->debug_root = debugfs_create_dir("tsens", NULL);
+   else
+   priv->debug_root = root;
+
+   file = debugfs_lookup("version", priv->debug_root);
+   if (!file)
+   debugfs_create_file("version", 0444, priv->debug_root,
+   pdev, &dbg_version_fops);
+
+   /* A directory for each instance of the TSENS IP */
+   priv->debug = debugfs_create_dir(dev_name(&pdev->dev), 
priv->debug_root);
+   debugfs_create_file("sensors", 0444, priv->debug, pdev, 
&dbg_sensors_fops);
+}
+#else
+static inline void tsens_debug_init(struct platform_device *pdev) {}
+#endif
+
 static const struct regmap_config tsens_config = {
.name   = "tm",
.reg_bits   = 32,
@@ -199,6 +271,15 @@ int __init init_common(struct tsens_priv *priv)
goto err_put_device;
}
 
+   if (tsens_ver(priv) > VER_0_1) {
+   for (i = VER_MAJOR; i <= VER_STEP; i++) {
+   priv->rf[i] = devm_regmap_field_alloc(dev, 
priv->srot_map,
+ priv->fields[i]);
+   if (IS_ERR(priv->rf[i]))
+   return PTR_ERR(priv->rf[i]);
+   }
+   }
+
priv->rf[TSENS_EN] = devm_regmap_field_alloc(dev, priv->srot_map,
 priv->fields[TSENS_EN]);
if (IS_ERR(priv->rf[TSENS_EN])) {
@@ -238,6 +319,8 @@ int __init init_common(struct tsens_priv *priv)
}
}
 
+   tsens_debug_init(op);
+
return 0;
 
 err_put_device:
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index 06c6bbd69a1a..772aa76b50e1 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -3,6 +3,7 @@
  * Copyright (c) 2015, The Linux Foundation. 

Re: [PATCH] bus: moxtet: declare moxtet_bus_type

2019-10-16 Thread Ben Dooks

On 15/10/2019 17:32, Christoph Hellwig wrote:

On Tue, Oct 15, 2019 at 01:25:35PM +0100, Ben Dooks wrote:

The moxtet_bus_type object is exported from the bus
driver, but not declared. Add a declaration for use
and to silence the following warning:


The symbol can be marked static instead.


Then it would have to be un-exported as it's listed as
EXPORT_SYMBOL_GPL(moxtet_bus_type);



--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html


[PATCH 06/15] arm64: dts: msm8916: thermal: Fixup HW ids for cpu sensors

2019-10-16 Thread Amit Kucheria
msm8916 uses sensors 0, 1, 2, 4 and 5. Sensor 3 is NOT used. Fixup the
device tree so that the correct sensor ID is used and as a result we can
actually check the temperature for the cpu2_3 sensor.

Signed-off-by: Amit Kucheria 
Reviewed-by: Daniel Lezcano 
Reviewed-by: Stephen Boyd 
---
 arch/arm64/boot/dts/qcom/msm8916.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi 
b/arch/arm64/boot/dts/qcom/msm8916.dtsi
index 5ea9fb8f2f87..8686e101905c 100644
--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
@@ -179,7 +179,7 @@
polling-delay-passive = <250>;
polling-delay = <1000>;
 
-   thermal-sensors = <&tsens 4>;
+   thermal-sensors = <&tsens 5>;
 
trips {
cpu0_1_alert0: trip-point@0 {
@@ -209,7 +209,7 @@
polling-delay-passive = <250>;
polling-delay = <1000>;
 
-   thermal-sensors = <&tsens 3>;
+   thermal-sensors = <&tsens 4>;
 
trips {
cpu2_3_alert0: trip-point@0 {
-- 
2.17.1



[PATCH] mm/page_alloc: Make alloc_gigantic_page() available for general use

2019-10-16 Thread Anshuman Khandual
HugeTLB helper alloc_gigantic_page() implements fairly generic allocation
method where it scans over various zones looking for a large contiguous pfn
range before trying to allocate it with alloc_contig_range(). Other than
deriving the requested order from 'struct hstate', there is nothing HugeTLB
specific in there. This can be made available for general use to allocate
contiguous memory which could not have been allocated through the buddy
allocator.

alloc_gigantic_page() has been split carving out actual allocation method
which is then made available via new alloc_contig_pages() helper wrapped
under CONFIG_CONTIG_ALLOC. All references to 'gigantic' have been replaced
with more generic term 'contig'. Allocated pages here should be freed with
free_contig_range() or by calling __free_page() on each allocated page.

Cc: Mike Kravetz 
Cc: Andrew Morton 
Cc: Vlastimil Babka 
Cc: Michal Hocko 
Cc: David Rientjes 
Cc: Andrea Arcangeli 
Cc: Oscar Salvador 
Cc: Mel Gorman 
Cc: Mike Rapoport 
Cc: Dan Williams 
Cc: Pavel Tatashin 
Cc: Matthew Wilcox 
Cc: David Hildenbrand 
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual 
---
This is based on https://patchwork.kernel.org/patch/11190213/

Changes from [V5,1/2] mm/hugetlb: Make alloc_gigantic_page()...

- alloc_contig_page() takes nr_pages instead of order per Michal
- s/gigantic/contig on all related functions

 include/linux/gfp.h |  2 +
 mm/hugetlb.c| 77 +--
 mm/page_alloc.c | 97 +
 3 files changed, 101 insertions(+), 75 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index fb07b503dc45..1a11d4857027 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -589,6 +589,8 @@ static inline bool pm_suspended_storage(void)
 /* The below functions must be run on a range from a single zone. */
 extern int alloc_contig_range(unsigned long start, unsigned long end,
  unsigned migratetype, gfp_t gfp_mask);
+extern struct page *alloc_contig_pages(unsigned long nr_pages, gfp_t gfp_mask,
+  int nid, nodemask_t *nodemask);
 #endif
 void free_contig_range(unsigned long pfn, unsigned int nr_pages);
 
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 985ee15eb04b..a5c2c880af27 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1023,85 +1023,12 @@ static void free_gigantic_page(struct page *page, 
unsigned int order)
 }
 
 #ifdef CONFIG_CONTIG_ALLOC
-static int __alloc_gigantic_page(unsigned long start_pfn,
-   unsigned long nr_pages, gfp_t gfp_mask)
-{
-   unsigned long end_pfn = start_pfn + nr_pages;
-   return alloc_contig_range(start_pfn, end_pfn, MIGRATE_MOVABLE,
- gfp_mask);
-}
-
-static bool pfn_range_valid_gigantic(struct zone *z,
-   unsigned long start_pfn, unsigned long nr_pages)
-{
-   unsigned long i, end_pfn = start_pfn + nr_pages;
-   struct page *page;
-
-   for (i = start_pfn; i < end_pfn; i++) {
-   page = pfn_to_online_page(i);
-   if (!page)
-   return false;
-
-   if (page_zone(page) != z)
-   return false;
-
-   if (PageReserved(page))
-   return false;
-
-   if (page_count(page) > 0)
-   return false;
-
-   if (PageHuge(page))
-   return false;
-   }
-
-   return true;
-}
-
-static bool zone_spans_last_pfn(const struct zone *zone,
-   unsigned long start_pfn, unsigned long nr_pages)
-{
-   unsigned long last_pfn = start_pfn + nr_pages - 1;
-   return zone_spans_pfn(zone, last_pfn);
-}
-
 static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask,
int nid, nodemask_t *nodemask)
 {
-   unsigned int order = huge_page_order(h);
-   unsigned long nr_pages = 1 << order;
-   unsigned long ret, pfn, flags;
-   struct zonelist *zonelist;
-   struct zone *zone;
-   struct zoneref *z;
-
-   zonelist = node_zonelist(nid, gfp_mask);
-   for_each_zone_zonelist_nodemask(zone, z, zonelist, gfp_zone(gfp_mask), 
nodemask) {
-   spin_lock_irqsave(&zone->lock, flags);
+   unsigned long nr_pages = 1UL << huge_page_order(h);
 
-   pfn = ALIGN(zone->zone_start_pfn, nr_pages);
-   while (zone_spans_last_pfn(zone, pfn, nr_pages)) {
-   if (pfn_range_valid_gigantic(zone, pfn, nr_pages)) {
-   /*
-* We release the zone lock here because
-* alloc_contig_range() will also lock the zone
-* at some point. If there's an allocation
-* spinning on this lock, it may win the race
-* and cause alloc_con

[PATCH 07/15] dt-bindings: thermal: tsens: Convert over to a yaml schema

2019-10-16 Thread Amit Kucheria
Older IP only supports the 'uplow' interrupt, but newer IP supports
'uplow' and 'critical' interrupts. Document interrupt support in the
tsens driver by converting over to a YAML schema.

Suggested-by: Stephen Boyd 
Signed-off-by: Amit Kucheria 
Reviewed-by: Rob Herring 
---
 .../bindings/thermal/qcom-tsens.txt   |  55 --
 .../bindings/thermal/qcom-tsens.yaml  | 168 ++
 MAINTAINERS   |   1 +
 3 files changed, 169 insertions(+), 55 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/thermal/qcom-tsens.txt
 create mode 100644 Documentation/devicetree/bindings/thermal/qcom-tsens.yaml

diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.txt 
b/Documentation/devicetree/bindings/thermal/qcom-tsens.txt
deleted file mode 100644
index 673cc1831ee9..
--- a/Documentation/devicetree/bindings/thermal/qcom-tsens.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-* QCOM SoC Temperature Sensor (TSENS)
-
-Required properties:
-- compatible:
-  Must be one of the following:
-- "qcom,msm8916-tsens" (MSM8916)
-- "qcom,msm8974-tsens" (MSM8974)
-- "qcom,msm8996-tsens" (MSM8996)
-- "qcom,qcs404-tsens", "qcom,tsens-v1" (QCS404)
-- "qcom,msm8998-tsens", "qcom,tsens-v2" (MSM8998)
-- "qcom,sdm845-tsens", "qcom,tsens-v2" (SDM845)
-  The generic "qcom,tsens-v2" property must be used as a fallback for any SoC
-  with version 2 of the TSENS IP. MSM8996 is the only exception because the
-  generic property did not exist when support was added.
-  Similarly, the generic "qcom,tsens-v1" property must be used as a fallback 
for
-  any SoC with version 1 of the TSENS IP.
-
-- reg: Address range of the thermal registers.
-  New platforms containing v2.x.y of the TSENS IP must specify the SROT and TM
-  register spaces separately, with order being TM before SROT.
-  See Example 2, below.
-
-- #thermal-sensor-cells : Should be 1. See ./thermal.txt for a description.
-- #qcom,sensors: Number of sensors in tsens block
-- Refer to Documentation/devicetree/bindings/nvmem/nvmem.txt to know how to 
specify
-nvmem cells
-
-Example 1 (legacy support before a fallback tsens-v2 property was introduced):
-tsens: thermal-sensor@90 {
-   compatible = "qcom,msm8916-tsens";
-   reg = <0x4a8000 0x2000>;
-   nvmem-cells = <&tsens_caldata>, <&tsens_calsel>;
-   nvmem-cell-names = "caldata", "calsel";
-   #thermal-sensor-cells = <1>;
-   };
-
-Example 2 (for any platform containing v2 of the TSENS IP):
-tsens0: thermal-sensor@c263000 {
-   compatible = "qcom,sdm845-tsens", "qcom,tsens-v2";
-   reg = <0xc263000 0x1ff>, /* TM */
-   <0xc222000 0x1ff>; /* SROT */
-   #qcom,sensors = <13>;
-   #thermal-sensor-cells = <1>;
-   };
-
-Example 3 (for any platform containing v1 of the TSENS IP):
-tsens: thermal-sensor@4a9000 {
-   compatible = "qcom,qcs404-tsens", "qcom,tsens-v1";
-   reg = <0x004a9000 0x1000>, /* TM */
- <0x004a8000 0x1000>; /* SROT */
-   nvmem-cells = <&tsens_caldata>;
-   nvmem-cell-names = "calib";
-   #qcom,sensors = <10>;
-   #thermal-sensor-cells = <1>;
-   };
diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml 
b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
new file mode 100644
index ..23afc7bf5a44
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
@@ -0,0 +1,168 @@
+# SPDX-License-Identifier: (GPL-2.0 OR MIT)
+# Copyright 2019 Linaro Ltd.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/thermal/qcom-tsens.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: QCOM SoC Temperature Sensor (TSENS)
+
+maintainers:
+  - Amit Kucheria 
+
+description: |
+  QCOM SoCs have TSENS IP to allow temperature measurement. There are currently
+  three distinct major versions of the IP that is supported by a single driver.
+  The IP versions are named v0.1, v1 and v2 in the driver, where v0.1 captures
+  everything before v1 when there was no versioning information.
+
+properties:
+  compatible:
+oneOf:
+  - description: v0.1 of TSENS
+items:
+  - enum:
+  - qcom,msm8916-tsens
+  - qcom,msm8974-tsens
+  - const: qcom,tsens-v0_1
+
+  - description: v1 of TSENS
+items:
+  - enum:
+  - qcom,qcs404-tsens
+  - const: qcom,tsens-v1
+
+  - description: v2 of TSENS
+items:
+  - enum:
+  - qcom,msm8996-tsens
+  - qcom,msm8998-tsens
+  - qcom,sdm845-tsens
+  - const: qcom,tsens-v2
+
+  reg:
+maxItems: 2
+items:
+  - description: TM registers
+  - description: SROT registers
+
+  nvmem-cells:
+minItems: 1
+maxItems: 2
+description:
+  Reference to 

[PATCH] RISC-V: fix virtual address overlapped in FIXADDR_START and VMEMMAP_START

2019-10-16 Thread greentime . hu
From: Greentime Hu 

This patch fixes the virtual address layout in pgtable.h.
The virtual address of FIXADDR_START and VMEMMAP_START should not be overlapped.
These addresses will be existed at the same time in Linux kernel that they can't
be overlapped.

Fixes: d95f1a542c3d ("RISC-V: Implement sparsemem")
Signed-off-by: Greentime Hu 
---
 arch/riscv/include/asm/pgtable.h | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 4f4162d90586..b927fb4ecf1c 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -87,14 +87,6 @@ extern pgd_t swapper_pg_dir[];
 #define VMALLOC_END  (PAGE_OFFSET - 1)
 #define VMALLOC_START(PAGE_OFFSET - VMALLOC_SIZE)
 
-#define FIXADDR_TOP  VMALLOC_START
-#ifdef CONFIG_64BIT
-#define FIXADDR_SIZE PMD_SIZE
-#else
-#define FIXADDR_SIZE PGDIR_SIZE
-#endif
-#define FIXADDR_START(FIXADDR_TOP - FIXADDR_SIZE)
-
 /*
  * Roughly size the vmemmap space to be large enough to fit enough
  * struct pages to map half the virtual address space. Then
@@ -108,6 +100,14 @@ extern pgd_t swapper_pg_dir[];
 
 #define vmemmap((struct page *)VMEMMAP_START)
 
+#define FIXADDR_TOP  (VMEMMAP_START)
+#ifdef CONFIG_64BIT
+#define FIXADDR_SIZE PMD_SIZE
+#else
+#define FIXADDR_SIZE PGDIR_SIZE
+#endif
+#define FIXADDR_START(FIXADDR_TOP - FIXADDR_SIZE)
+
 /*
  * ZERO_PAGE is a global shared page that is always zero,
  * used for zero-mapped memory areas, etc.
-- 
2.17.1



[PATCH 02/15] drivers: thermal: tsens: Simplify code flow in tsens_probe

2019-10-16 Thread Amit Kucheria
Move platform_set_drvdata up to avoid an extra 'if (ret)' check after
the call to tsens_register.

Signed-off-by: Amit Kucheria 
Reviewed-by: Stephen Boyd 
Reviewed-by: Daniel Lezcano 
---
 drivers/thermal/qcom/tsens.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index 6ed687a6e53c..542a7f8c3d96 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -149,6 +149,8 @@ static int tsens_probe(struct platform_device *pdev)
priv->feat = data->feat;
priv->fields = data->fields;
 
+   platform_set_drvdata(pdev, priv);
+
if (!priv->ops || !priv->ops->init || !priv->ops->get_temp)
return -EINVAL;
 
@@ -167,11 +169,7 @@ static int tsens_probe(struct platform_device *pdev)
}
}
 
-   ret = tsens_register(priv);
-
-   platform_set_drvdata(pdev, priv);
-
-   return ret;
+   return tsens_register(priv);
 }
 
 static int tsens_remove(struct platform_device *pdev)
-- 
2.17.1



[PATCH 03/15] drivers: thermal: tsens: Add __func__ identifier to debug statements

2019-10-16 Thread Amit Kucheria
Printing the function name when enabling debugging makes logs easier to
read.

Signed-off-by: Amit Kucheria 
Reviewed-by: Stephen Boyd 
Reviewed-by: Daniel Lezcano 
---
 drivers/thermal/qcom/tsens-common.c | 8 
 drivers/thermal/qcom/tsens.c| 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/thermal/qcom/tsens-common.c 
b/drivers/thermal/qcom/tsens-common.c
index c037bdf92c66..7437bfe196e5 100644
--- a/drivers/thermal/qcom/tsens-common.c
+++ b/drivers/thermal/qcom/tsens-common.c
@@ -42,8 +42,8 @@ void compute_intercept_slope(struct tsens_priv *priv, u32 *p1,
 
for (i = 0; i < priv->num_sensors; i++) {
dev_dbg(priv->dev,
-   "sensor%d - data_point1:%#x data_point2:%#x\n",
-   i, p1[i], p2[i]);
+   "%s: sensor%d - data_point1:%#x data_point2:%#x\n",
+   __func__, i, p1[i], p2[i]);
 
priv->sensor[i].slope = SLOPE_DEFAULT;
if (mode == TWO_PT_CALIB) {
@@ -60,7 +60,7 @@ void compute_intercept_slope(struct tsens_priv *priv, u32 *p1,
priv->sensor[i].offset = (p1[i] * SLOPE_FACTOR) -
(CAL_DEGC_PT1 *
priv->sensor[i].slope);
-   dev_dbg(priv->dev, "offset:%d\n", priv->sensor[i].offset);
+   dev_dbg(priv->dev, "%s: offset:%d\n", __func__, 
priv->sensor[i].offset);
}
 }
 
@@ -209,7 +209,7 @@ int __init init_common(struct tsens_priv *priv)
if (ret)
goto err_put_device;
if (!enabled) {
-   dev_err(dev, "tsens device is not enabled\n");
+   dev_err(dev, "%s: device not enabled\n", __func__);
ret = -ENODEV;
goto err_put_device;
}
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index 542a7f8c3d96..06c6bbd69a1a 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -127,7 +127,7 @@ static int tsens_probe(struct platform_device *pdev)
of_property_read_u32(np, "#qcom,sensors", &num_sensors);
 
if (num_sensors <= 0) {
-   dev_err(dev, "invalid number of sensors\n");
+   dev_err(dev, "%s: invalid number of sensors\n", __func__);
return -EINVAL;
}
 
@@ -156,7 +156,7 @@ static int tsens_probe(struct platform_device *pdev)
 
ret = priv->ops->init(priv);
if (ret < 0) {
-   dev_err(dev, "tsens init failed\n");
+   dev_err(dev, "%s: init failed\n", __func__);
return ret;
}
 
@@ -164,7 +164,7 @@ static int tsens_probe(struct platform_device *pdev)
ret = priv->ops->calibrate(priv);
if (ret < 0) {
if (ret != -EPROBE_DEFER)
-   dev_err(dev, "tsens calibration failed\n");
+   dev_err(dev, "%s: calibration failed\n", 
__func__);
return ret;
}
}
-- 
2.17.1



[PATCH 12/15] arm: dts: msm8974: thermal: Add interrupt support

2019-10-16 Thread Amit Kucheria
Register upper-lower interrupt for the tsens controller.

Signed-off-by: Amit Kucheria 
Tested-by: Brian Masney 
---
 arch/arm/boot/dts/qcom-msm8974.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi 
b/arch/arm/boot/dts/qcom-msm8974.dtsi
index 33c534370fd5..c1a3a7d7161c 100644
--- a/arch/arm/boot/dts/qcom-msm8974.dtsi
+++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
@@ -531,6 +531,8 @@
nvmem-cells = <&tsens_calib>, <&tsens_backup>;
nvmem-cell-names = "calib", "calib_backup";
#qcom,sensors = <11>;
+   interrupts = ;
+   interrupt-names = "uplow";
#thermal-sensor-cells = <1>;
};
 
-- 
2.17.1



[PATCH 00/15] thermal: qcom: tsens: Add interrupt support

2019-10-16 Thread Amit Kucheria
Hi Thermal and MSM maintainers,

I believe this series is now ready to be merged. The DT bindings and driver
changes should go through the thermal tree and the changes to the DT files
themselves should go through the MSM tree. There is no hard ordering
dependency because we're adding a new property to the driver. It would help
to soak in linux-next for a few weeks to catch anything on kernelci.org.

Regards,
Amit

Changes since v4:
- Change to of-thermal core[1] to force interrupts w/o changing polling-delay DT
  parameter
- Corresponding changes to DT files to remove the hunks setting the values
  to 0
- Collected reviews and acks

Changes since v3:
- Fix up the YAML definitions based on Rob's review

Changes since v2:
- Addressed Stephen's review comment
- Moved the dt-bindings to yaml (This throws up some new warnings in various 
QCOM
devicetrees. I'll send out a separate series to fix them up)
- Collected reviews and acks
- Added the dt-bindings to MAINTAINERS

Changes since v1:
- Collected reviews and acks
- Addressed Stephen's review comments (hopefully I got them all).
- Completely removed critical interrupt infrastructure from this series.
  Will post that separately.
- Fixed a bug in sign-extension of temperature.
- Fixed DT bindings to use the name of the interrupt e.g. "uplow" and use
  platform_get_irq_byname().

Add interrupt support to TSENS. The first 6 patches are general fixes and
cleanups to the driver before interrupt support is introduced.

[1] 
https://lore.kernel.org/linux-arm-msm/1b53ef537203e629328285b4597a09e4a586d688.1571181041.git.amit.kuche...@linaro.org/

Amit Kucheria (15):
  drivers: thermal: tsens: Get rid of id field in tsens_sensor
  drivers: thermal: tsens: Simplify code flow in tsens_probe
  drivers: thermal: tsens: Add __func__ identifier to debug statements
  drivers: thermal: tsens: Add debugfs support
  arm: dts: msm8974: thermal: Add thermal zones for each sensor
  arm64: dts: msm8916: thermal: Fixup HW ids for cpu sensors
  dt-bindings: thermal: tsens: Convert over to a yaml schema
  arm64: dts: sdm845: thermal: Add interrupt support
  arm64: dts: msm8996: thermal: Add interrupt support
  arm64: dts: msm8998: thermal: Add interrupt support
  arm64: dts: qcs404: thermal: Add interrupt support
  arm: dts: msm8974: thermal: Add interrupt support
  arm64: dts: msm8916: thermal: Add interrupt support
  drivers: thermal: tsens: Create function to return sign-extended
temperature
  drivers: thermal: tsens: Add interrupt support

 .../bindings/thermal/qcom-tsens.txt   |  55 --
 .../bindings/thermal/qcom-tsens.yaml  | 168 ++
 MAINTAINERS   |   1 +
 arch/arm/boot/dts/qcom-msm8974.dtsi   |  92 +++
 arch/arm64/boot/dts/qcom/msm8916.dtsi |   6 +-
 arch/arm64/boot/dts/qcom/msm8996.dtsi |   4 +
 arch/arm64/boot/dts/qcom/msm8998.dtsi |   6 +-
 arch/arm64/boot/dts/qcom/qcs404.dtsi  |   2 +
 arch/arm64/boot/dts/qcom/sdm845.dtsi  |   4 +
 drivers/thermal/qcom/tsens-8960.c |   4 +-
 drivers/thermal/qcom/tsens-common.c   | 529 --
 drivers/thermal/qcom/tsens-v0_1.c |  11 +
 drivers/thermal/qcom/tsens-v1.c   |  29 +
 drivers/thermal/qcom/tsens-v2.c   |  13 +
 drivers/thermal/qcom/tsens.c  |  58 +-
 drivers/thermal/qcom/tsens.h  | 286 --
 16 files changed, 1102 insertions(+), 166 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/thermal/qcom-tsens.txt
 create mode 100644 Documentation/devicetree/bindings/thermal/qcom-tsens.yaml

-- 
2.17.1



[PATCH 11/15] arm64: dts: qcs404: thermal: Add interrupt support

2019-10-16 Thread Amit Kucheria
Register upper-lower interrupt for the tsens controller.

Signed-off-by: Amit Kucheria 
---
 arch/arm64/boot/dts/qcom/qcs404.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/qcs404.dtsi 
b/arch/arm64/boot/dts/qcom/qcs404.dtsi
index a97eeb4569c0..b6a4e6073936 100644
--- a/arch/arm64/boot/dts/qcom/qcs404.dtsi
+++ b/arch/arm64/boot/dts/qcom/qcs404.dtsi
@@ -290,6 +290,8 @@
nvmem-cells = <&tsens_caldata>;
nvmem-cell-names = "calib";
#qcom,sensors = <10>;
+   interrupts = ;
+   interrupt-names = "uplow";
#thermal-sensor-cells = <1>;
};
 
-- 
2.17.1



[PATCH 01/15] drivers: thermal: tsens: Get rid of id field in tsens_sensor

2019-10-16 Thread Amit Kucheria
There are two fields - id and hw_id - to track what sensor an action was
to performed on. This was because the sensors connected to a TSENS IP
might not be contiguous i.e. 1, 2, 4, 5 with 3 being skipped.

This causes confusion in the code which uses hw_id sometimes and id
other times (tsens_get_temp, tsens_get_trend).

Switch to only using the hw_id field to track the physical ID of the
sensor. When we iterate through all the sensors connected to an IP
block, we use an index i to loop through the list of sensors, and then
return the actual hw_id that is registered on that index.

Signed-off-by: Amit Kucheria 
Reviewed-by: Stephen Boyd 
Reviewed-by: Daniel Lezcano 
---
 drivers/thermal/qcom/tsens-8960.c   |  4 ++--
 drivers/thermal/qcom/tsens-common.c | 16 +---
 drivers/thermal/qcom/tsens.c| 11 +--
 drivers/thermal/qcom/tsens.h| 10 --
 4 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/drivers/thermal/qcom/tsens-8960.c 
b/drivers/thermal/qcom/tsens-8960.c
index e46a4e3f25c4..fb77acb8d13b 100644
--- a/drivers/thermal/qcom/tsens-8960.c
+++ b/drivers/thermal/qcom/tsens-8960.c
@@ -245,11 +245,11 @@ static inline int code_to_mdegC(u32 adc_code, const 
struct tsens_sensor *s)
return adc_code * slope + offset;
 }
 
-static int get_temp_8960(struct tsens_priv *priv, int id, int *temp)
+static int get_temp_8960(struct tsens_sensor *s, int *temp)
 {
int ret;
u32 code, trdy;
-   const struct tsens_sensor *s = &priv->sensor[id];
+   struct tsens_priv *priv = s->priv;
unsigned long timeout;
 
timeout = jiffies + usecs_to_jiffies(TIMEOUT_US);
diff --git a/drivers/thermal/qcom/tsens-common.c 
b/drivers/thermal/qcom/tsens-common.c
index 528df8801254..c037bdf92c66 100644
--- a/drivers/thermal/qcom/tsens-common.c
+++ b/drivers/thermal/qcom/tsens-common.c
@@ -83,11 +83,12 @@ static inline int code_to_degc(u32 adc_code, const struct 
tsens_sensor *s)
return degc;
 }
 
-int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp)
+int get_temp_tsens_valid(struct tsens_sensor *s, int *temp)
 {
-   struct tsens_sensor *s = &priv->sensor[i];
-   u32 temp_idx = LAST_TEMP_0 + s->hw_id;
-   u32 valid_idx = VALID_0 + s->hw_id;
+   struct tsens_priv *priv = s->priv;
+   int hw_id = s->hw_id;
+   u32 temp_idx = LAST_TEMP_0 + hw_id;
+   u32 valid_idx = VALID_0 + hw_id;
u32 last_temp = 0, valid, mask;
int ret;
 
@@ -123,12 +124,13 @@ int get_temp_tsens_valid(struct tsens_priv *priv, int i, 
int *temp)
return 0;
 }
 
-int get_temp_common(struct tsens_priv *priv, int i, int *temp)
+int get_temp_common(struct tsens_sensor *s, int *temp)
 {
-   struct tsens_sensor *s = &priv->sensor[i];
+   struct tsens_priv *priv = s->priv;
+   int hw_id = s->hw_id;
int last_temp = 0, ret;
 
-   ret = regmap_field_read(priv->rf[LAST_TEMP_0 + s->hw_id], &last_temp);
+   ret = regmap_field_read(priv->rf[LAST_TEMP_0 + hw_id], &last_temp);
if (ret)
return ret;
 
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index 0627d8615c30..6ed687a6e53c 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -14,19 +14,19 @@
 
 static int tsens_get_temp(void *data, int *temp)
 {
-   const struct tsens_sensor *s = data;
+   struct tsens_sensor *s = data;
struct tsens_priv *priv = s->priv;
 
-   return priv->ops->get_temp(priv, s->id, temp);
+   return priv->ops->get_temp(s, temp);
 }
 
 static int tsens_get_trend(void *data, int trip, enum thermal_trend *trend)
 {
-   const struct tsens_sensor *s = data;
+   struct tsens_sensor *s = data;
struct tsens_priv *priv = s->priv;
 
if (priv->ops->get_trend)
-   return priv->ops->get_trend(priv, s->id, trend);
+   return priv->ops->get_trend(s, trend);
 
return -ENOTSUPP;
 }
@@ -86,8 +86,7 @@ static int tsens_register(struct tsens_priv *priv)
 
for (i = 0;  i < priv->num_sensors; i++) {
priv->sensor[i].priv = priv;
-   priv->sensor[i].id = i;
-   tzd = devm_thermal_zone_of_sensor_register(priv->dev, i,
+   tzd = devm_thermal_zone_of_sensor_register(priv->dev, 
priv->sensor[i].hw_id,
   &priv->sensor[i],
   &tsens_of_ops);
if (IS_ERR(tzd))
diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h
index b89083b61c38..84e5447c5686 100644
--- a/drivers/thermal/qcom/tsens.h
+++ b/drivers/thermal/qcom/tsens.h
@@ -32,7 +32,6 @@ enum tsens_ver {
  * @priv: tsens device instance that this sensor is connected to
  * @tzd: pointer to the thermal zone that this sensor is in
  * @offset: offset of temperature adjustment curve
- * @id: Sensor ID
  * @hw_id: HW ID can be used in case of platform-spec

[PATCH 13/15] arm64: dts: msm8916: thermal: Add interrupt support

2019-10-16 Thread Amit Kucheria
Register upper-lower interrupt for the tsens controller.

Signed-off-by: Amit Kucheria 
---
 arch/arm64/boot/dts/qcom/msm8916.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi 
b/arch/arm64/boot/dts/qcom/msm8916.dtsi
index 8686e101905c..807f86a4535e 100644
--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
@@ -816,6 +816,8 @@
nvmem-cells = <&tsens_caldata>, <&tsens_calsel>;
nvmem-cell-names = "calib", "calib_sel";
#qcom,sensors = <5>;
+   interrupts = ;
+   interrupt-names = "uplow";
#thermal-sensor-cells = <1>;
};
 
-- 
2.17.1



[PATCH 08/15] arm64: dts: sdm845: thermal: Add interrupt support

2019-10-16 Thread Amit Kucheria
Register upper-lower interrupts for each of the two tsens controllers.

Signed-off-by: Amit Kucheria 
Reviewed-by: Stephen Boyd 
---
 arch/arm64/boot/dts/qcom/sdm845.dtsi | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi 
b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index f406a4340b05..0990d5761860 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -2950,6 +2950,8 @@
reg = <0 0x0c263000 0 0x1ff>, /* TM */
  <0 0x0c222000 0 0x1ff>; /* SROT */
#qcom,sensors = <13>;
+   interrupts = ;
+   interrupt-names = "uplow";
#thermal-sensor-cells = <1>;
};
 
@@ -2958,6 +2960,8 @@
reg = <0 0x0c265000 0 0x1ff>, /* TM */
  <0 0x0c223000 0 0x1ff>; /* SROT */
#qcom,sensors = <8>;
+   interrupts = ;
+   interrupt-names = "uplow";
#thermal-sensor-cells = <1>;
};
 
-- 
2.17.1



[PATCH 05/15] arm: dts: msm8974: thermal: Add thermal zones for each sensor

2019-10-16 Thread Amit Kucheria
msm8974 has 11 sensors connected to a single TSENS IP. Define a thermal
zone for each of those sensors to expose the temperature of each zone.

Signed-off-by: Amit Kucheria 
Tested-by: Brian Masney 
Reviewed-by: Stephen Boyd 
---
 arch/arm/boot/dts/qcom-msm8974.dtsi | 90 +
 1 file changed, 90 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi 
b/arch/arm/boot/dts/qcom-msm8974.dtsi
index 369e58f64145..33c534370fd5 100644
--- a/arch/arm/boot/dts/qcom-msm8974.dtsi
+++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
@@ -217,6 +217,96 @@
};
};
};
+
+   q6-dsp-thermal {
+   polling-delay-passive = <250>;
+   polling-delay = <1000>;
+
+   thermal-sensors = <&tsens 1>;
+
+   trips {
+   q6_dsp_alert0: trip-point0 {
+   temperature = <9>;
+   hysteresis = <2000>;
+   type = "hot";
+   };
+   };
+   };
+
+   modemtx-thermal {
+   polling-delay-passive = <250>;
+   polling-delay = <1000>;
+
+   thermal-sensors = <&tsens 2>;
+
+   trips {
+   modemtx_alert0: trip-point0 {
+   temperature = <9>;
+   hysteresis = <2000>;
+   type = "hot";
+   };
+   };
+   };
+
+   video-thermal {
+   polling-delay-passive = <250>;
+   polling-delay = <1000>;
+
+   thermal-sensors = <&tsens 3>;
+
+   trips {
+   video_alert0: trip-point0 {
+   temperature = <95000>;
+   hysteresis = <2000>;
+   type = "hot";
+   };
+   };
+   };
+
+   wlan-thermal {
+   polling-delay-passive = <250>;
+   polling-delay = <1000>;
+
+   thermal-sensors = <&tsens 4>;
+
+   trips {
+   wlan_alert0: trip-point0 {
+   temperature = <105000>;
+   hysteresis = <2000>;
+   type = "hot";
+   };
+   };
+   };
+
+   gpu-thermal-top {
+   polling-delay-passive = <250>;
+   polling-delay = <1000>;
+
+   thermal-sensors = <&tsens 9>;
+
+   trips {
+   gpu1_alert0: trip-point0 {
+   temperature = <9>;
+   hysteresis = <2000>;
+   type = "hot";
+   };
+   };
+   };
+
+   gpu-thermal-bottom {
+   polling-delay-passive = <250>;
+   polling-delay = <1000>;
+
+   thermal-sensors = <&tsens 10>;
+
+   trips {
+   gpu2_alert0: trip-point0 {
+   temperature = <9>;
+   hysteresis = <2000>;
+   type = "hot";
+   };
+   };
+   };
};
 
cpu-pmu {
-- 
2.17.1



[PATCH 09/15] arm64: dts: msm8996: thermal: Add interrupt support

2019-10-16 Thread Amit Kucheria
Register upper-lower interrupts for each of the two tsens controllers.

Signed-off-by: Amit Kucheria 
---
 arch/arm64/boot/dts/qcom/msm8996.dtsi | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi 
b/arch/arm64/boot/dts/qcom/msm8996.dtsi
index 87f4d9c1b0d4..4ca2e7b44559 100644
--- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
@@ -591,6 +591,8 @@
reg = <0x4a9000 0x1000>, /* TM */
  <0x4a8000 0x1000>; /* SROT */
#qcom,sensors = <13>;
+   interrupts = ;
+   interrupt-names = "uplow";
#thermal-sensor-cells = <1>;
};
 
@@ -599,6 +601,8 @@
reg = <0x4ad000 0x1000>, /* TM */
  <0x4ac000 0x1000>; /* SROT */
#qcom,sensors = <8>;
+   interrupts = ;
+   interrupt-names = "uplow";
#thermal-sensor-cells = <1>;
};
 
-- 
2.17.1



[PATCH 15/15] drivers: thermal: tsens: Add interrupt support

2019-10-16 Thread Amit Kucheria
Depending on the IP version, TSENS supports upper, lower and critical
threshold interrupts. We only add support for upper and lower threshold
interrupts for now.

TSENSv2 has an irq [status|clear|mask] bit tuple for each sensor while
earlier versions only have a single bit per sensor to denote status and
clear. These differences are handled transparently by the interrupt
handler. At each interrupt, we reprogram the new upper and lower threshold
in the .set_trip callback.

Signed-off-by: Amit Kucheria 
Reviewed-by: Stephen Boyd 
---
 drivers/thermal/qcom/tsens-common.c | 377 ++--
 drivers/thermal/qcom/tsens-v0_1.c   |  11 +
 drivers/thermal/qcom/tsens-v1.c |  29 +++
 drivers/thermal/qcom/tsens-v2.c |  13 +
 drivers/thermal/qcom/tsens.c|  31 ++-
 drivers/thermal/qcom/tsens.h| 270 
 6 files changed, 669 insertions(+), 62 deletions(-)

diff --git a/drivers/thermal/qcom/tsens-common.c 
b/drivers/thermal/qcom/tsens-common.c
index c34a1a26ce29..03bf1b8133ea 100644
--- a/drivers/thermal/qcom/tsens-common.c
+++ b/drivers/thermal/qcom/tsens-common.c
@@ -13,6 +13,31 @@
 #include 
 #include "tsens.h"
 
+/**
+ * struct tsens_irq_data - IRQ status and temperature violations
+ * @up_viol:upper threshold violated
+ * @up_thresh:  upper threshold temperature value
+ * @up_irq_mask:mask register for upper threshold irqs
+ * @up_irq_clear:   clear register for uppper threshold irqs
+ * @low_viol:   lower threshold violated
+ * @low_thresh: lower threshold temperature value
+ * @low_irq_mask:   mask register for lower threshold irqs
+ * @low_irq_clear:  clear register for lower threshold irqs
+ *
+ * Structure containing data about temperature threshold settings and
+ * irq status if they were violated.
+ */
+struct tsens_irq_data {
+   u32 up_viol;
+   int up_thresh;
+   u32 up_irq_mask;
+   u32 up_irq_clear;
+   u32 low_viol;
+   int low_thresh;
+   u32 low_irq_mask;
+   u32 low_irq_clear;
+};
+
 char *qfprom_read(struct device *dev, const char *cname)
 {
struct nvmem_cell *cell;
@@ -65,6 +90,14 @@ void compute_intercept_slope(struct tsens_priv *priv, u32 
*p1,
}
 }
 
+static inline u32 degc_to_code(int degc, const struct tsens_sensor *s)
+{
+   u64 code = (degc * s->slope + s->offset) / SLOPE_FACTOR;
+
+   pr_debug("%s: raw_code: 0x%llx, degc:%d\n", __func__, code, degc);
+   return clamp_val(code, THRESHOLD_MIN_ADC_CODE, THRESHOLD_MAX_ADC_CODE);
+}
+
 static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s)
 {
int degc, num, den;
@@ -117,6 +150,313 @@ static int tsens_hw_to_mC(struct tsens_sensor *s, int 
field)
return sign_extend32(temp, resolution) * 100;
 }
 
+/**
+ * tsens_mC_to_hw - Convert temperature to hardware register value
+ * @s: Pointer to sensor struct
+ * @temp: temperature in milliCelsius to be programmed to hardware
+ *
+ * This function outputs the value to be written to hardware in ADC code
+ * or deciCelsius depending on IP version.
+ *
+ * Return: ADC code or temperature in deciCelsius.
+ */
+static int tsens_mC_to_hw(struct tsens_sensor *s, int temp)
+{
+   struct tsens_priv *priv = s->priv;
+
+   /* milliC to adc code */
+   if (priv->feat->adc)
+   return degc_to_code(temp / 1000, s);
+
+   /* milliC to deciC */
+   return temp / 100;
+}
+
+static inline enum tsens_ver tsens_version(struct tsens_priv *priv)
+{
+   return priv->feat->ver_major;
+}
+
+static void tsens_set_interrupt_v1(struct tsens_priv *priv, u32 hw_id,
+  enum tsens_irq_type irq_type, bool enable)
+{
+   u32 index;
+
+   switch (irq_type) {
+   case UPPER:
+   index = UP_INT_CLEAR_0 + hw_id;
+   break;
+   case LOWER:
+   index = LOW_INT_CLEAR_0 + hw_id;
+   break;
+   }
+   regmap_field_write(priv->rf[index], enable ? 0 : 1);
+}
+
+static void tsens_set_interrupt_v2(struct tsens_priv *priv, u32 hw_id,
+  enum tsens_irq_type irq_type, bool enable)
+{
+   u32 index_mask, index_clear;
+
+   /*
+* To enable the interrupt flag for a sensor:
+*- clear the mask bit
+* To disable the interrupt flag for a sensor:
+*- Mask further interrupts for this sensor
+*- Write 1 followed by 0 to clear the interrupt
+*/
+   switch (irq_type) {
+   case UPPER:
+   index_mask  = UP_INT_MASK_0 + hw_id;
+   index_clear = UP_INT_CLEAR_0 + hw_id;
+   break;
+   case LOWER:
+   index_mask  = LOW_INT_MASK_0 + hw_id;
+   index_clear = LOW_INT_CLEAR_0 + hw_id;
+   break;
+   }
+
+   if (enable) {
+   regmap_field_write(priv->rf[index_mask], 0);
+   } else {
+   regmap_field_write(priv->rf[index_mask],  1);
+   reg

[PATCH 14/15] drivers: thermal: tsens: Create function to return sign-extended temperature

2019-10-16 Thread Amit Kucheria
Hide the details of how to convert values read from TSENS HW to mCelsius
behind a function. All versions of the IP can be supported as a result.

Signed-off-by: Amit Kucheria 
Reviewed-by: Stephen Boyd 
---
 drivers/thermal/qcom/tsens-common.c | 49 -
 1 file changed, 35 insertions(+), 14 deletions(-)

diff --git a/drivers/thermal/qcom/tsens-common.c 
b/drivers/thermal/qcom/tsens-common.c
index ea2c46cc6a66..c34a1a26ce29 100644
--- a/drivers/thermal/qcom/tsens-common.c
+++ b/drivers/thermal/qcom/tsens-common.c
@@ -84,13 +84,46 @@ static inline int code_to_degc(u32 adc_code, const struct 
tsens_sensor *s)
return degc;
 }
 
+/**
+ * tsens_hw_to_mC - Return sign-extended temperature in mCelsius.
+ * @s: Pointer to sensor struct
+ * @field: Index into regmap_field array pointing to temperature data
+ *
+ * This function handles temperature returned in ADC code or deciCelsius
+ * depending on IP version.
+ *
+ * Return: Temperature in milliCelsius on success, a negative errno will
+ * be returned in error cases
+ */
+static int tsens_hw_to_mC(struct tsens_sensor *s, int field)
+{
+   struct tsens_priv *priv = s->priv;
+   u32 resolution;
+   u32 temp = 0;
+   int ret;
+
+   resolution = priv->fields[LAST_TEMP_0].msb -
+   priv->fields[LAST_TEMP_0].lsb;
+
+   ret = regmap_field_read(priv->rf[field], &temp);
+   if (ret)
+   return ret;
+
+   /* Convert temperature from ADC code to milliCelsius */
+   if (priv->feat->adc)
+   return code_to_degc(temp, s) * 1000;
+
+   /* deciCelsius -> milliCelsius along with sign extension */
+   return sign_extend32(temp, resolution) * 100;
+}
+
 int get_temp_tsens_valid(struct tsens_sensor *s, int *temp)
 {
struct tsens_priv *priv = s->priv;
int hw_id = s->hw_id;
u32 temp_idx = LAST_TEMP_0 + hw_id;
u32 valid_idx = VALID_0 + hw_id;
-   u32 last_temp = 0, valid, mask;
+   u32 valid;
int ret;
 
ret = regmap_field_read(priv->rf[valid_idx], &valid);
@@ -108,19 +141,7 @@ int get_temp_tsens_valid(struct tsens_sensor *s, int *temp)
}
 
/* Valid bit is set, OK to read the temperature */
-   ret = regmap_field_read(priv->rf[temp_idx], &last_temp);
-   if (ret)
-   return ret;
-
-   if (priv->feat->adc) {
-   /* Convert temperature from ADC code to milliCelsius */
-   *temp = code_to_degc(last_temp, s) * 1000;
-   } else {
-   mask = GENMASK(priv->fields[LAST_TEMP_0].msb,
-  priv->fields[LAST_TEMP_0].lsb);
-   /* Convert temperature from deciCelsius to milliCelsius */
-   *temp = sign_extend32(last_temp, fls(mask) - 1) * 100;
-   }
+   *temp = tsens_hw_to_mC(s, temp_idx);
 
return 0;
 }
-- 
2.17.1



Re: [PATCH] KVM: X86: Make fpu allocation a common function

2019-10-16 Thread Paolo Bonzini
On 16/10/19 03:52, Xiaoyao Li wrote:
>>
>> user_fpu could be made percpu too...  That would save a bit of memory
>> for each vCPU.  I'm holding on Xiaoyao's patch because a lot of the code
>> he's touching would go away then.
> 
> Sorry, I don't get clear your attitude.
> Do you mean the generic common function is not so better that I'd better
> to implement the percpu solution?

I wanted some time to give further thought to the percpu user_fpu idea.
 But kvm_load_guest_fpu and kvm_put_guest_fpu are not part of vcpu_load,
so it would not be so easy.  I'll just apply your patch now.

Paolo


[PATCH 10/15] arm64: dts: msm8998: thermal: Add interrupt support

2019-10-16 Thread Amit Kucheria
Register upper-lower interrupts for each of the two tsens controllers.

Signed-off-by: Amit Kucheria 
---
 arch/arm64/boot/dts/qcom/msm8998.dtsi | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/msm8998.dtsi 
b/arch/arm64/boot/dts/qcom/msm8998.dtsi
index c6f81431983e..489d631a9610 100644
--- a/arch/arm64/boot/dts/qcom/msm8998.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8998.dtsi
@@ -816,8 +816,9 @@
compatible = "qcom,msm8998-tsens", "qcom,tsens-v2";
reg = <0x010ab000 0x1000>, /* TM */
  <0x010aa000 0x1000>; /* SROT */
-
#qcom,sensors = <14>;
+   interrupts = ;
+   interrupt-names = "uplow";
#thermal-sensor-cells = <1>;
};
 
@@ -825,8 +826,9 @@
compatible = "qcom,msm8998-tsens", "qcom,tsens-v2";
reg = <0x010ae000 0x1000>, /* TM */
  <0x010ad000 0x1000>; /* SROT */
-
#qcom,sensors = <8>;
+   interrupts = ;
+   interrupt-names = "uplow";
#thermal-sensor-cells = <1>;
};
 
-- 
2.17.1



Re: [PATCH] arm64: defconfig: Enable Qualcomm CPUfreq HW driver

2019-10-16 Thread Amit Kucheria
On Sat, Oct 12, 2019 at 5:14 AM Bjorn Andersson
 wrote:
>
> The Qualcomm CPUfreq HW provides CPU voltage and frequency scaling on
> many modern Qualcomm SoCs. Enable the driver for this hardware block to
> enable this functionality on the SDM845 platform.
>
> Signed-off-by: Bjorn Andersson 

You beat me to it. :-)

Acked-by: Amit Kucheria 

> ---
>  arch/arm64/configs/defconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
> index dea051a64257..45e55dfe1ee4 100644
> --- a/arch/arm64/configs/defconfig
> +++ b/arch/arm64/configs/defconfig
> @@ -85,6 +85,7 @@ CONFIG_ACPI_CPPC_CPUFREQ=m
>  CONFIG_ARM_ARMADA_37XX_CPUFREQ=y
>  CONFIG_ARM_SCPI_CPUFREQ=y
>  CONFIG_ARM_IMX_CPUFREQ_DT=m
> +CONFIG_ARM_QCOM_CPUFREQ_HW=y
>  CONFIG_ARM_RASPBERRYPI_CPUFREQ=m
>  CONFIG_ARM_TEGRA186_CPUFREQ=y
>  CONFIG_ARM_SCPI_PROTOCOL=y
> --
> 2.23.0
>


[PATCH 3/4] mm/thp: allow drop THP from page cache

2019-10-16 Thread Song Liu
From: "Kirill A. Shutemov" 

Once a THP is added to the page cache, it cannot be dropped via
/proc/sys/vm/drop_caches. Fix this issue with proper handling in
invalidate_mapping_pages() and __remove_mapping().

Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Signed-off-by: Kirill A. Shutemov 
Tested-by: Song Liu 
Signed-off-by: Song Liu 
---
 mm/truncate.c | 12 
 mm/vmscan.c   |  3 ++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/mm/truncate.c b/mm/truncate.c
index 8563339041f6..dd9ebc1da356 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -592,6 +592,16 @@ unsigned long invalidate_mapping_pages(struct 
address_space *mapping,
unlock_page(page);
continue;
}
+
+   /* Take a pin outside pagevec */
+   get_page(page);
+
+   /*
+* Drop extra pins before trying to invalidate
+* the huge page.
+*/
+   pagevec_remove_exceptionals(&pvec);
+   pagevec_release(&pvec);
}
 
ret = invalidate_inode_page(page);
@@ -602,6 +612,8 @@ unsigned long invalidate_mapping_pages(struct address_space 
*mapping,
 */
if (!ret)
deactivate_file_page(page);
+   if (PageTransHuge(page))
+   put_page(page);
count += ret;
}
pagevec_remove_exceptionals(&pvec);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index c6659bb758a4..1d80a188ad4a 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -932,7 +932,8 @@ static int __remove_mapping(struct address_space *mapping, 
struct page *page,
 * Note that if SetPageDirty is always performed via set_page_dirty,
 * and thus under the i_pages lock, then this ordering is not required.
 */
-   if (unlikely(PageTransHuge(page)) && PageSwapCache(page))
+   if (unlikely(PageTransHuge(page)) &&
+   (PageSwapCache(page) || !PageSwapBacked(page)))
refcount = 1 + HPAGE_PMD_NR;
else
refcount = 2;
-- 
2.17.1



[PATCH 2/4] mm/thp: fix node page state in split_huge_page_to_list()

2019-10-16 Thread Song Liu
From: "Kirill A. Shutemov" 

Make sure split_huge_page_to_list() handle the state of shmem THP and
file THP properly.

Fixes: 60fbf0ab5da1 ("mm,thp: stats for file backed THP")
Signed-off-by: Kirill A. Shutemov 
Tested-by: Song Liu 
Signed-off-by: Song Liu 
---
 mm/huge_memory.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index c5cb6dcd6c69..13cc93785006 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2789,8 +2789,13 @@ int split_huge_page_to_list(struct page *page, struct 
list_head *list)
ds_queue->split_queue_len--;
list_del(page_deferred_list(head));
}
-   if (mapping)
-   __dec_node_page_state(page, NR_SHMEM_THPS);
+   if (mapping) {
+   if (PageSwapBacked(page))
+   __dec_node_page_state(page, NR_SHMEM_THPS);
+   else
+   __dec_node_page_state(page, NR_FILE_THPS);
+   }
+
spin_unlock(&ds_queue->split_queue_lock);
__split_huge_page(page, list, end, flags);
if (PageSwapCache(head)) {
-- 
2.17.1



[PATCH 4/4] uprobe: only do FOLL_SPLIT_PMD for uprobe register

2019-10-16 Thread Song Liu
Attaching uprobe to text section in THP splits the PMD mapped page table
into PTE mapped entries. On uprobe detach, we would like to regroup PMD
mapped page table entry to regain performance benefit of THP.

However, the regroup is broken For perf_event based trace_uprobe. This is
because perf_event based trace_uprobe calls uprobe_unregister twice on
close: first in TRACE_REG_PERF_CLOSE, then in TRACE_REG_PERF_UNREGISTER.
The second call will split the PMD mapped page table entry, which is not
the desired behavior.

Fix this by only use FOLL_SPLIT_PMD for uprobe register case.

Also add a WARN() to confirm uprobe unregister never work on huge pages.

Fixes: 5a52c9df62b4 ("uprobe: use FOLL_SPLIT_PMD instead of FOLL_SPLIT")
Cc: Kirill A. Shutemov 
Cc: Srikar Dronamraju 
Cc: Oleg Nesterov 
Signed-off-by: Song Liu 
---
 kernel/events/uprobes.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 94d38a39d72e..d7a556cc589e 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -474,14 +474,17 @@ int uprobe_write_opcode(struct arch_uprobe *auprobe, 
struct mm_struct *mm,
struct vm_area_struct *vma;
int ret, is_register, ref_ctr_updated = 0;
bool orig_page_huge = false;
+   unsigned int gup_flags = FOLL_FORCE;
 
is_register = is_swbp_insn(&opcode);
uprobe = container_of(auprobe, struct uprobe, arch);
 
 retry:
+   if (is_register)
+   gup_flags |= FOLL_SPLIT_PMD;
/* Read the page with vaddr into memory */
-   ret = get_user_pages_remote(NULL, mm, vaddr, 1,
-   FOLL_FORCE | FOLL_SPLIT_PMD, &old_page, &vma, NULL);
+   ret = get_user_pages_remote(NULL, mm, vaddr, 1, gup_flags,
+   &old_page, &vma, NULL);
if (ret <= 0)
return ret;
 
@@ -489,6 +492,9 @@ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct 
mm_struct *mm,
if (ret <= 0)
goto put_old;
 
+   WARN(!is_register && PageCompound(old_page),
+"uprobe unregister should never work on compound page\n");
+
/* We are going to replace instruction, update ref_ctr. */
if (!ref_ctr_updated && uprobe->ref_ctr_offset) {
ret = update_ref_ctr(uprobe, mm, is_register ? 1 : -1);
-- 
2.17.1



[PATCH 1/4] proc/meminfo: fix output alignment

2019-10-16 Thread Song Liu
From: "Kirill A. Shutemov" 

Add extra space for FileHugePages and FilePmdMapped, so the output is
aligned with other rows.

Fixes: 60fbf0ab5da1 ("mm,thp: stats for file backed THP")
Signed-off-by: Kirill A. Shutemov 
Tested-by: Song Liu 
Signed-off-by: Song Liu 
---
 fs/proc/meminfo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index ac9247371871..8c1f1bb1a5ce 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -132,9 +132,9 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
global_node_page_state(NR_SHMEM_THPS) * HPAGE_PMD_NR);
show_val_kb(m, "ShmemPmdMapped: ",
global_node_page_state(NR_SHMEM_PMDMAPPED) * HPAGE_PMD_NR);
-   show_val_kb(m, "FileHugePages: ",
+   show_val_kb(m, "FileHugePages:  ",
global_node_page_state(NR_FILE_THPS) * HPAGE_PMD_NR);
-   show_val_kb(m, "FilePmdMapped: ",
+   show_val_kb(m, "FilePmdMapped:  ",
global_node_page_state(NR_FILE_PMDMAPPED) * HPAGE_PMD_NR);
 #endif
 
-- 
2.17.1



[PATCH 0/4] Fixes for THP in page cache

2019-10-16 Thread Song Liu
This set includes a few fixes for THP in page cache. They are based on
Linus's master branch.

Thanks,
Song

Kirill A. Shutemov (3):
  proc/meminfo: fix output alignment
  mm/thp: fix node page state in split_huge_page_to_list()
  mm/thp: allow drop THP from page cache

Song Liu (1):
  uprobe: only do FOLL_SPLIT_PMD for uprobe register

 fs/proc/meminfo.c   |  4 ++--
 kernel/events/uprobes.c | 10 --
 mm/huge_memory.c|  9 +++--
 mm/truncate.c   | 12 
 mm/vmscan.c |  3 ++-
 5 files changed, 31 insertions(+), 7 deletions(-)

--
2.17.1


Re: [PATCH 06/34] csky: Use CONFIG_PREEMPTION

2019-10-16 Thread Sebastian Andrzej Siewior
On 2019-10-16 07:29:34 [+0800], Guo Ren wrote:
> Could CONFIG_PREEMPT_RT be supported in csky ? Any arch backend porting ?

It could. HIGH_RES_TIMERS is useful and IRQ_FORCED_THREADING is
required. You already have PREEMPT(ION) which is good. Then you would
have to try and my guess would be that some of spinlock_t vs
raw_spinlock_t could require changes but we should have lockdep support
for that which would make things easier.

Sebastian


Re: [PATCH] xtensa: implement arch_dma_coherent_to_pfn

2019-10-16 Thread Max Filippov
Hi Christoph,

On Wed, Oct 16, 2019 at 12:08 AM Christoph Hellwig  wrote:
> On Tue, Oct 15, 2019 at 02:25:26PM -0700, Max Filippov wrote:
> > Add trivial implementation for arch_dma_coherent_to_pfn.
> > This change enables communication with PCI ALSA devices through mmapped
> > buffers.
>
> This looks fine, although I'd much rather convert xtensa to the
> generic DMA remap / uncached segment support.

Thanks for the review.

> Do you want this fix for 5.4?  If so please queue it up ASAP so that
> I can do the proper thing for 5.5.  If you don't need it that urgent
> I'd rather go straight to the generic code.

There's no rush, I'll keep my version privately and will switch to the
generic version once it's available.

-- 
Thanks.
-- Max


Re: [PATCH] bus: moxtet: declare moxtet_bus_type

2019-10-16 Thread Christoph Hellwig
On Wed, Oct 16, 2019 at 08:34:06AM +0100, Ben Dooks wrote:
> On 15/10/2019 17:32, Christoph Hellwig wrote:
> > On Tue, Oct 15, 2019 at 01:25:35PM +0100, Ben Dooks wrote:
> > > The moxtet_bus_type object is exported from the bus
> > > driver, but not declared. Add a declaration for use
> > > and to silence the following warning:
> > 
> > The symbol can be marked static instead.
> 
> Then it would have to be un-exported as it's listed as
> EXPORT_SYMBOL_GPL(moxtet_bus_type);

Yes, once you mark it static you should also remove the export.


Re: [PATCH] pwm: sun4i: Fix incorrect calculation of duty_cycle/period

2019-10-16 Thread Thierry Reding
On Mon, Oct 14, 2019 at 03:53:03PM +0200, meg...@megous.com wrote:
> From: Ondrej Jirman 
> 
> Since 5.4-rc1, pwm_apply_state calls ->get_state after ->apply
> if available, and this revealed an issue with integer precision
> when calculating duty_cycle and period for the currently set
> state in ->get_state callback.
> 
> This issue manifested in broken backlight on several Allwinner
> based devices.
> 
> Previously this worked, because ->apply updated the passed state
> directly.
> 
> Fixes: deb9c462f4e53 ("pwm: sun4i: Don't update the state for the caller of 
> pwm_apply_state")
> Signed-off-by: Ondrej Jirman 
> ---
>  drivers/pwm/pwm-sun4i.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Thierry

> diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
> index 6f5840a1a82d..05273725a9ff 100644
> --- a/drivers/pwm/pwm-sun4i.c
> +++ b/drivers/pwm/pwm-sun4i.c
> @@ -137,10 +137,10 @@ static void sun4i_pwm_get_state(struct pwm_chip *chip,
>  
>   val = sun4i_pwm_readl(sun4i_pwm, PWM_CH_PRD(pwm->hwpwm));
>  
> - tmp = prescaler * NSEC_PER_SEC * PWM_REG_DTY(val);
> + tmp = (u64)prescaler * NSEC_PER_SEC * PWM_REG_DTY(val);
>   state->duty_cycle = DIV_ROUND_CLOSEST_ULL(tmp, clk_rate);
>  
> - tmp = prescaler * NSEC_PER_SEC * PWM_REG_PRD(val);
> + tmp = (u64)prescaler * NSEC_PER_SEC * PWM_REG_PRD(val);
>   state->period = DIV_ROUND_CLOSEST_ULL(tmp, clk_rate);
>  }
>  
> -- 
> 2.23.0
> 


signature.asc
Description: PGP signature


Re: [PATCH 1/1] pwm: Convert period and duty cycle to u64

2019-10-16 Thread Thierry Reding
On Tue, Oct 15, 2019 at 07:11:39PM -0700, Guru Das Srinagesh wrote:
> Because period and duty cycle are defined as ints with units of
> nanoseconds, the maximum time duration that can be set is limited to
> ~2.147 seconds. Change their definitions to u64 so that higher durations
> may be set.
> 
> Signed-off-by: Guru Das Srinagesh 
> ---
>  drivers/pwm/core.c  |  4 ++--
>  drivers/pwm/sysfs.c | 10 +-
>  include/linux/pwm.h | 16 
>  3 files changed, 15 insertions(+), 15 deletions(-)

Applied, thanks.

Thierry

> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 6ad51aa..dc79c03 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -1163,8 +1163,8 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct 
> seq_file *s)
>   if (state.enabled)
>   seq_puts(s, " enabled");
>  
> - seq_printf(s, " period: %u ns", state.period);
> - seq_printf(s, " duty: %u ns", state.duty_cycle);
> + seq_printf(s, " period: %llu ns", state.period);
> + seq_printf(s, " duty: %llu ns", state.duty_cycle);
>   seq_printf(s, " polarity: %s",
>  state.polarity ? "inverse" : "normal");
>  
> diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c
> index 2389b86..3fb1610 100644
> --- a/drivers/pwm/sysfs.c
> +++ b/drivers/pwm/sysfs.c
> @@ -42,7 +42,7 @@ static ssize_t period_show(struct device *child,
>  
>   pwm_get_state(pwm, &state);
>  
> - return sprintf(buf, "%u\n", state.period);
> + return sprintf(buf, "%llu\n", state.period);
>  }
>  
>  static ssize_t period_store(struct device *child,
> @@ -52,10 +52,10 @@ static ssize_t period_store(struct device *child,
>   struct pwm_export *export = child_to_pwm_export(child);
>   struct pwm_device *pwm = export->pwm;
>   struct pwm_state state;
> - unsigned int val;
> + u64 val;
>   int ret;
>  
> - ret = kstrtouint(buf, 0, &val);
> + ret = kstrtou64(buf, 0, &val);
>   if (ret)
>   return ret;
>  
> @@ -77,7 +77,7 @@ static ssize_t duty_cycle_show(struct device *child,
>  
>   pwm_get_state(pwm, &state);
>  
> - return sprintf(buf, "%u\n", state.duty_cycle);
> + return sprintf(buf, "%llu\n", state.duty_cycle);
>  }
>  
>  static ssize_t duty_cycle_store(struct device *child,
> @@ -212,7 +212,7 @@ static ssize_t capture_show(struct device *child,
>   if (ret)
>   return ret;
>  
> - return sprintf(buf, "%u %u\n", result.period, result.duty_cycle);
> + return sprintf(buf, "%llu %llu\n", result.period, result.duty_cycle);
>  }
>  
>  static DEVICE_ATTR_RW(period);
> diff --git a/include/linux/pwm.h b/include/linux/pwm.h
> index b2c9c46..1efdd63 100644
> --- a/include/linux/pwm.h
> +++ b/include/linux/pwm.h
> @@ -39,7 +39,7 @@ enum pwm_polarity {
>   * current PWM hardware state.
>   */
>  struct pwm_args {
> - unsigned int period;
> + u64 period;
>   enum pwm_polarity polarity;
>  };
>  
> @@ -56,8 +56,8 @@ enum {
>   * @enabled: PWM enabled status
>   */
>  struct pwm_state {
> - unsigned int period;
> - unsigned int duty_cycle;
> + u64 period;
> + u64 duty_cycle;
>   enum pwm_polarity polarity;
>   bool enabled;
>  };
> @@ -105,13 +105,13 @@ static inline bool pwm_is_enabled(const struct 
> pwm_device *pwm)
>   return state.enabled;
>  }
>  
> -static inline void pwm_set_period(struct pwm_device *pwm, unsigned int 
> period)
> +static inline void pwm_set_period(struct pwm_device *pwm, u64 period)
>  {
>   if (pwm)
>   pwm->state.period = period;
>  }
>  
> -static inline unsigned int pwm_get_period(const struct pwm_device *pwm)
> +static inline u64 pwm_get_period(const struct pwm_device *pwm)
>  {
>   struct pwm_state state;
>  
> @@ -126,7 +126,7 @@ static inline void pwm_set_duty_cycle(struct pwm_device 
> *pwm, unsigned int duty)
>   pwm->state.duty_cycle = duty;
>  }
>  
> -static inline unsigned int pwm_get_duty_cycle(const struct pwm_device *pwm)
> +static inline u64 pwm_get_duty_cycle(const struct pwm_device *pwm)
>  {
>   struct pwm_state state;
>  
> @@ -308,8 +308,8 @@ struct pwm_chip {
>   * @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
>   */
>  struct pwm_capture {
> - unsigned int period;
> - unsigned int duty_cycle;
> + u64 period;
> + u64 duty_cycle;
>  };
>  
>  #if IS_ENABLED(CONFIG_PWM)
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 


signature.asc
Description: PGP signature


Re: [PATCH v3 5/6] x86/ftrace: Use text_poke()

2019-10-16 Thread Peter Zijlstra
> which are not compatible with livepatching. GCC upstream now has
> -flive-patching option, which disables all those interfering optimizations.

Which, IIRC, has a significant performance impact and should thus really
not be used...

If distros ship that crap, I'm going to laugh at them the next time they
want a single digit performance improvement because *important*.


[PATCH] staging: rtl8723bs: remove an redundant null check before kfree()

2019-10-16 Thread zhong jiang
kfree() has taken null pointer into account. hence it is safe to remove
the unnecessary check.

Signed-off-by: zhong jiang 
---
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c 
b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 7011c2a..4597f4f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -2210,8 +2210,7 @@ void rtw_free_hwxmits(struct adapter *padapter)
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
 
hwxmits = pxmitpriv->hwxmits;
-   if (hwxmits)
-   kfree(hwxmits);
+   kfree(hwxmits);
 }
 
 void rtw_init_hwxmits(struct hw_xmit *phwxmit, sint entry)
-- 
1.7.12.4



Re: [PATCH 1/5] KPC2000: kpc2000_spi.c: Fix style issues (line length)

2019-10-16 Thread
On Fri, Oct 11, 2019 at 08:32:19AM +0200, Greg KH wrote:
> On Thu, Oct 10, 2019 at 10:51:51PM -0700, Chandra Annamaneni wrote:
> > Resoved: "WARNING: line over 80 characters" from checkpatch.pl
> 
> Please put "staging:" in your subject line, makes it easier to sort and
> handle.  It should look something like:
>   staging: kpc2000_spi: fix line length issues
> 
> Looks a lot cleaner, right?
> 
> > 
> > Signed-off-by: Chandra Annamaneni 
> > ---
> >  drivers/staging/kpc2000/kpc2000_spi.c | 20 ++--
> >  1 file changed, 10 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
> > b/drivers/staging/kpc2000/kpc2000_spi.c
> > index 3be33c450cab..81d79b116ce0 100644
> > --- a/drivers/staging/kpc2000/kpc2000_spi.c
> > +++ b/drivers/staging/kpc2000/kpc2000_spi.c
> > @@ -30,19 +30,19 @@
> >  #include "kpc.h"
> >  
> >  static struct mtd_partition p2kr0_spi0_parts[] = {
> > -   { .name = "SLOT_0", .size = 7798784,.offset = 0,
> > },
> > -   { .name = "SLOT_1", .size = 7798784,.offset = 
> > MTDPART_OFS_NXTBLK},
> > -   { .name = "SLOT_2", .size = 7798784,.offset = 
> > MTDPART_OFS_NXTBLK},
> > -   { .name = "SLOT_3", .size = 7798784,.offset = 
> > MTDPART_OFS_NXTBLK},
> > -   { .name = "CS0_EXTRA",  .size = MTDPART_SIZ_FULL,   .offset = 
> > MTDPART_OFS_NXTBLK},
> > +   { .name = "SLOT_0",  .size = 7798784,  .offset = 0,},
> > +   { .name = "SLOT_1",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
> > +   { .name = "SLOT_2",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
> > +   { .name = "SLOT_3",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
> > +   { .name = "CS0_EXTRA",  .size = MTDPART_SIZ_FULL,  .offset = 
> > MTDPART_OFS_NXTBLK},
> 
> Why did you pick 2 spaces here as a random choice of padding?  That's
> very odd, please don't.
> 
> Either leave this alone (as it lines everything up nicely), or only use
> one space.  I would suggest just leaving it alone.
> 
> thanks,
> 
> greg k-h

I am going to leave it as is at your and Dan C's suggestion. 

Thanks!
Chandra



Re: [PATCH v3 2/3] bpf: use copy_struct_from_user() in bpf_prog_get_info_by_fd()

2019-10-16 Thread Christian Brauner
On Tue, Oct 15, 2019 at 10:25:49PM -0700, Alexei Starovoitov wrote:
> On Wed, Oct 16, 2019 at 05:44:31AM +0200, Christian Brauner wrote:
> > In v5.4-rc2 we added a new helper (cf. [1]) copy_struct_from_user().
> > This helper is intended for all codepaths that copy structs from
> > userspace that are versioned by size. bpf_prog_get_info_by_fd() does
> > exactly what copy_struct_from_user() is doing.
> > Note that copy_struct_from_user() is calling min() already. So
> > technically, the min_t() call could go. But the info_len is used further
> > below so leave it.
> > 
> > [1]: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper")
> > Cc: Alexei Starovoitov 
> > Cc: Daniel Borkmann 
> > Cc: b...@vger.kernel.org
> > Acked-by: Aleksa Sarai 
> > Signed-off-by: Christian Brauner 
> > ---
> > /* v1 */
> > Link: 
> > https://lore.kernel.org/r/20191009160907.10981-3-christian.brau...@ubuntu.com
> > 
> > /* v2 */
> > Link: 
> > https://lore.kernel.org/r/20191016004138.24845-3-christian.brau...@ubuntu.com
> > - Alexei Starovoitov :
> >   - remove unneeded initialization
> > 
> > /* v3 */
> > unchanged
> > ---
> >  kernel/bpf/syscall.c | 9 +++--
> >  1 file changed, 3 insertions(+), 6 deletions(-)
> > 
> > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> > index 40edcaeccd71..151447f314ca 100644
> > --- a/kernel/bpf/syscall.c
> > +++ b/kernel/bpf/syscall.c
> > @@ -2306,20 +2306,17 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog 
> > *prog,
> >union bpf_attr __user *uattr)
> >  {
> > struct bpf_prog_info __user *uinfo = u64_to_user_ptr(attr->info.info);
> > -   struct bpf_prog_info info = {};
> > +   struct bpf_prog_info info;
> > u32 info_len = attr->info.info_len;
> > struct bpf_prog_stats stats;
> > char __user *uinsns;
> > u32 ulen;
> > int err;
> >  
> > -   err = bpf_check_uarg_tail_zero(uinfo, sizeof(info), info_len);
> > +   info_len = min_t(u32, sizeof(info), info_len);
> > +   err = copy_struct_from_user(&info, sizeof(info), uinfo, info_len);
> 
> really?! min?!
> Frankly I'm disappointed in quality of these patches.
> Especially considering it's v3.
> 
> Just live the code alone.

Oh, I didn't see that part. I didn't know that this would upset
you that much. Sure, I can leave the code alone. Or I try to fix this
up. If you're not happy with you can just ignore this.

Christian


Re: [PATCH 09/12] iomap: lift the xfs writeback code to iomap

2019-10-16 Thread Christoph Hellwig
On Tue, Oct 15, 2019 at 11:40:40AM -0700, Darrick J. Wong wrote:
> > +   if (unlikely(error && !quiet)) {
> > +   printk_ratelimited(KERN_ERR
> > +   "%s: writeback error on sector %llu",
> > +   inode->i_sb->s_id, start);
> 
> Ugh, /this/ message.  It's pretty annoying how it doesn't tell you which
> file or where in that file the write was lost.

Sure, feel free to improve it in a follow on patch.

> 
> I want to send in a patch atop your series to fix this, though I'm a
> also little inclined to want to keep the message inside XFS.
> 
> Thoughts?

I don't see a sensible way to keep it in the file system, and I also
don't really see what that would buy us.  I'd rather use the same
message for all iomap using file systems rather than having slightly
different error reporting for each of them.
inside the iomap callstack.


Re: [PATCH 3/6] drivers: firmware: psci: Register with kernel restart handler

2019-10-16 Thread Stefan Agner
On 2019-10-15 16:51, Thierry Reding wrote:
> From: Guenter Roeck 
> 
> Register with kernel restart handler instead of setting arm_pm_restart
> directly. This enables support for replacing the PSCI restart handler
> with a different handler if necessary for a specific board.
> 
> Select a priority of 129 to indicate a higher than default priority, but
> keep it as low as possible since PSCI reset is known to fail on some
> boards.
> 
> Acked-by: Arnd Bergmann 
> Reviewed-by: Wolfram Sang 
> Tested-by: Wolfram Sang 
> Signed-off-by: Guenter Roeck 
> Acked-by: Lorenzo Pieralisi 
> Signed-off-by: Thierry Reding 

Looks good to me! And helps also in my case, a board which has a broken
PSCI reset capability.

Reviewed-by: Stefan Agner 

--
Stefan

> ---
>  drivers/firmware/psci/psci.c | 12 ++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
> index 84f4ff351c62..a41c6ba043a2 100644
> --- a/drivers/firmware/psci/psci.c
> +++ b/drivers/firmware/psci/psci.c
> @@ -250,7 +250,8 @@ static int get_set_conduit_method(struct device_node *np)
>   return 0;
>  }
>  
> -static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
> +static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
> +   void *data)
>  {
>   if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
>   psci_system_reset2_supported) {
> @@ -263,8 +264,15 @@ static void psci_sys_reset(enum reboot_mode
> reboot_mode, const char *cmd)
>   } else {
>   invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
>   }
> +
> + return NOTIFY_DONE;
>  }
>  
> +static struct notifier_block psci_sys_reset_nb = {
> + .notifier_call = psci_sys_reset,
> + .priority = 129,
> +};
> +
>  static void psci_sys_poweroff(void)
>  {
>   invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
> @@ -431,7 +439,7 @@ static void __init psci_0_2_set_functions(void)
>  
>   psci_ops.migrate_info_type = psci_migrate_info_type;
>  
> - arm_pm_restart = psci_sys_reset;
> + register_restart_handler(&psci_sys_reset_nb);
>  
>   pm_power_off = psci_sys_poweroff;
>  }


Re: [RFC PATCH 03/21] pipe: Use head and tail pointers for the ring, not cursor and length

2019-10-16 Thread Rasmus Villemoes
On 15/10/2019 23.48, David Howells wrote:
> Convert pipes to use head and tail pointers for the buffer ring rather than
> pointer and length as the latter requires two atomic ops to update (or a
> combined op) whereas the former only requires one.
> 
>  (1) The head pointer is the point at which production occurs and points to
>  the slot in which the next buffer will be placed.  This is equivalent
>  to pipe->curbuf + pipe->nrbufs.
> 
>  The head pointer belongs to the write-side.
> 
>  (2) The tail pointer is the point at which consumption occurs.  It points
>  to the next slot to be consumed.  This is equivalent to pipe->curbuf.
> 
>  The tail pointer belongs to the read-side.
> 
>  (3) head and tail are allowed to run to UINT_MAX and wrap naturally.  They
>  are only masked off when the array is being accessed, e.g.:
> 
>   pipe->bufs[head & mask]
> 
>  This means that it is not necessary to have a dead slot in the ring as
>  head == tail isn't ambiguous.
> 
>  (4) The ring is empty if "head == tail".
> 
>  (5) The occupancy of the ring is "head - tail".
> 
>  (6) The number of free slots in the ring is "(tail + pipe->ring_size) -
>  head".

Seems an odd way of writing pipe->ring_size - (head - tail) ; i.e.
obviously #free slots is #size minus #occupancy.

>  (7) The ring is full if "head >= (tail + pipe->ring_size)", which can also
>  be written as "head - tail >= pipe->ring_size".
>

No it cannot, it _must_ be written in the latter form. Assuming
sizeof(int)==1 for simplicity, consider ring_size = 16, tail = 240.
Regardless whether head is 240, 241, ..., 255, 0, tail + ring_size wraps
to 0, so the former expression states the ring is full in all cases.

Better spell out somewhere that while head and tail are free-running, at
any point in time they satisfy the invariant head - tail <= pipe_size
(and also 0 <= head - tail, but that's a tautology for unsigned
ints...). Then it's a matter of taste if one wants to write "full" as
head-tail == pipe_size or head-tail >= pipe_size.

> Also split pipe->buffers into pipe->ring_size (which indicates the size of the
> ring) and pipe->max_usage (which restricts the amount of ring that write() is
> allowed to fill).  This allows for a pipe that is both writable by the kernel
> notification facility and by userspace, allowing plenty of ring space for
> notifications to be added whilst preventing userspace from being able to use
> up too much buffer space.

That seems like something that should be added in a separate patch -
adding ->max_usage and switching appropriate users of ->ring_size over,
so it's more clear where you're using one or the other.

> @@ -1949,8 +1950,12 @@ static ssize_t fuse_dev_splice_write(struct 
> pipe_inode_info *pipe,
>  
>   pipe_lock(pipe);
>  
> - bufs = kvmalloc_array(pipe->nrbufs, sizeof(struct pipe_buffer),
> -   GFP_KERNEL);
> + head = pipe->head;
> + tail = pipe->tail;
> + mask = pipe->ring_size - 1;
> + count = head - tail;
> +
> + bufs = kvmalloc_array(count, sizeof(struct pipe_buffer), GFP_KERNEL);
>   if (!bufs) {
>   pipe_unlock(pipe);
>   return -ENOMEM;
> @@ -1958,8 +1963,8 @@ static ssize_t fuse_dev_splice_write(struct 
> pipe_inode_info *pipe,
>  
>   nbuf = 0;
>   rem = 0;
> - for (idx = 0; idx < pipe->nrbufs && rem < len; idx++)
> - rem += pipe->bufs[(pipe->curbuf + idx) & (pipe->buffers - 
> 1)].len;
> + for (idx = tail; idx < head && rem < len; idx++)
> + rem += pipe->bufs[idx & mask].len;
>  
>   ret = -EINVAL;
>   if (rem < len)
> @@ -1970,16 +1975,16 @@ static ssize_t fuse_dev_splice_write(struct 
> pipe_inode_info *pipe,
>   struct pipe_buffer *ibuf;
>   struct pipe_buffer *obuf;
>  
> - BUG_ON(nbuf >= pipe->buffers);
> - BUG_ON(!pipe->nrbufs);
> - ibuf = &pipe->bufs[pipe->curbuf];
> + BUG_ON(nbuf >= pipe->ring_size);
> + BUG_ON(tail == head);
> + ibuf = &pipe->bufs[tail];

I don't see where tail gets masked between tail = pipe->tail; above and
here, but I may be missing it. In any case, how about seeding head and
tail with something like 1<<20 when creating the pipe so bugs like that
are hit more quickly.

> @@ -515,17 +525,19 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
>  static long pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long 
> arg)
>  {
>   struct pipe_inode_info *pipe = filp->private_data;
> - int count, buf, nrbufs;
> + int count, head, tail, mask;
>  
>   switch (cmd) {
>   case FIONREAD:
>   __pipe_lock(pipe);
>   count = 0;
> - buf = pipe->curbuf;
> - nrbufs = pipe->nrbufs;
> - while (--nrbufs >= 0) {
> - count += pipe->bufs[buf].len;
> - 

Re: [PATCH] KVM: X86: Make fpu allocation a common function

2019-10-16 Thread Xiaoyao Li

On 10/16/2019 3:35 PM, Paolo Bonzini wrote:

On 16/10/19 03:52, Xiaoyao Li wrote:


user_fpu could be made percpu too...  That would save a bit of memory
for each vCPU.  I'm holding on Xiaoyao's patch because a lot of the code
he's touching would go away then.


Sorry, I don't get clear your attitude.
Do you mean the generic common function is not so better that I'd better
to implement the percpu solution?


I wanted some time to give further thought to the percpu user_fpu idea.
  But kvm_load_guest_fpu and kvm_put_guest_fpu are not part of vcpu_load,
so it would not be so easy.  I'll just apply your patch now.


Got it, thanks.

BTW, could you have a look at the series I sent yesterday to refactor 
the vcpu creation flow, which is inspired partly by this issue. Any 
comment and suggestion is welcomed since I don't want to waste time on 
wrong direction.




Re: [PATCH 03/34] powerpc: Use CONFIG_PREEMPTION

2019-10-16 Thread Sebastian Andrzej Siewior
On 2019-10-16 06:57:48 [+0200], Christophe Leroy wrote:
> 
> 
> Le 15/10/2019 à 21:17, Sebastian Andrzej Siewior a écrit :
> > From: Thomas Gleixner 
> > 
> > CONFIG_PREEMPTION is selected by CONFIG_PREEMPT and by CONFIG_PREEMPT_RT.
> > Both PREEMPT and PREEMPT_RT require the same functionality which today
> > depends on CONFIG_PREEMPT.
> > 
> > Switch the entry code over to use CONFIG_PREEMPTION. Add PREEMPT_RT
> > output in __die().
> 
> powerpc doesn't select ARCH_SUPPORTS_RT, so this change is useless as
> CONFIG_PREEMPT_RT cannot be selected.

No it is not. It makes it possible for PowerPC to select it one day and
I have patches for it today. Also, if other ARCH copies code from
PowerPC it will copy the correct thing (as in distinguish between the
flavour PREEMPT and the functionality PREEMPTION).

> > diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
> > index 82f43535e6867..23d2f20be4f2e 100644
> > --- a/arch/powerpc/kernel/traps.c
> > +++ b/arch/powerpc/kernel/traps.c
> > @@ -252,14 +252,19 @@ NOKPROBE_SYMBOL(oops_end);
> >   static int __die(const char *str, struct pt_regs *regs, long err)
> >   {
> > +   const char *pr = "";
> > +
> 
> Please follow the same approach as already existing. Don't add a local var
> for that.

I would leave it to the maintainer to comment on that and decide which
one they want. My eyes find it more readable and the compiles does not
create more code.

> > printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
> > +   if (IS_ENABLED(CONFIG_PREEMPTION))
> > +   pr = IS_ENABLED(CONFIG_PREEMPT_RT) ? " PREEMPT_RT" : " PREEMPT";
> > +
> 
> drop
> 
> > printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s%s %s\n",
> 
> Add one %s
> 
> >IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
> >PAGE_SIZE / 1024,
> >early_radix_enabled() ? " MMU=Radix" : "",
> >early_mmu_has_feature(MMU_FTR_HPTE_TABLE) ? " MMU=Hash" : "",
> > -  IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
> 
> Replace by:   IS_ENABLED(CONFIG_PREEMPTION) ? " PREEMPT" : ""
> 
> > +  pr,
> 
> add something like: IS_ENABLED(CONFIG_PREEMPT_RT) ? "_RT" : ""

this on the other hand will create more code which is not strictly
required.

> >IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
> >IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" __stringify(NR_CPUS)) : "",
> >debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",
> > 
> 
> Christophe

Sebastian


Re: [PATCH 09/12] iomap: lift the xfs writeback code to iomap

2019-10-16 Thread Christoph Hellwig
On Wed, Oct 16, 2019 at 09:07:21AM +1100, Dave Chinner wrote:
> > +   trace_iomap_releasepage(page->mapping->host, page, 0, 0);
> > +
> > /*
> >  * mm accommodates an old ext3 case where clean pages might not have had
> >  * the dirty bit cleared. Thus, it can send actual dirty pages to
> > @@ -483,6 +488,8 @@ EXPORT_SYMBOL_GPL(iomap_releasepage);
> >  void
> >  iomap_invalidatepage(struct page *page, unsigned int offset, unsigned int 
> > len)
> >  {
> > +   trace_iomap_invalidatepage(page->mapping->host, page, offset, len);
> > +
> 
> These tracepoints should be split out into a separate patch like
> the readpage(s) tracepoints. Maybe just lift all the non-writeback
> ones in a single patch...

I guess that makes sense.  Initially I didn't want to duplicate the
trace definition as it is shared with the writeback tracepoints,
but in the overall scheme of things that doesn't really matter.

> > +iomap_finish_page_writeback(struct inode *inode, struct bio_vec *bvec,
> > +   int error)
> > +{
> > +   struct iomap_page *iop = to_iomap_page(bvec->bv_page);
> > +
> > +   if (error) {
> > +   SetPageError(bvec->bv_page);
> > +   mapping_set_error(inode->i_mapping, -EIO);
> > +   }
> > +
> > +   WARN_ON_ONCE(i_blocksize(inode) < PAGE_SIZE && !iop);
> > +   WARN_ON_ONCE(iop && atomic_read(&iop->write_count) <= 0);
> > +
> > +   if (!iop || atomic_dec_and_test(&iop->write_count))
> > +   end_page_writeback(bvec->bv_page);
> > +}
> 
> Can we just pass the struct page into this function?

I'd rather not change calling conventions in code just moved over for
no good reason.  That being said I agree with passing a page, so I'll
just throw in a follow on patch like I did for iomap_ioend_compare
cleanup.

> 
> .
> 
> > +/*
> > + * Submit the bio for an ioend. We are passed an ioend with a bio attached 
> > to
> > + * it, and we submit that bio. The ioend may be used for multiple bio
> > + * submissions, so we only want to allocate an append transaction for the 
> > ioend
> > + * once.  In the case of multiple bio submission, each bio will take an IO
> 
> This needs to be changed to describe what wpc->ops->submit_ioend()
> is used for rather than what XFS might use this hook for.

True.  The real documentation now is in the header near the ops defintion,
but I'll update this one to make more sense as well.

> > +static int
> > +iomap_submit_ioend(struct iomap_writepage_ctx *wpc, struct iomap_ioend 
> > *ioend,
> > +   int error)
> > +{
> > +   ioend->io_bio->bi_private = ioend;
> > +   ioend->io_bio->bi_end_io = iomap_writepage_end_bio;
> > +
> > +   if (wpc->ops->submit_ioend)
> > +   error = wpc->ops->submit_ioend(ioend, error);
> 
> I'm not sure that "submit_ioend" is the best name for this method,
> as it is a pre-bio-submission hook, not an actual IO submission
> method. "prepare_ioend_for_submit" is more descriptive, but probably
> too long. wpc->ops->prepare_submit(ioend, error) reads pretty well,
> though...

Not a huge fan of that name either, but Brian complained.  Let's hold
a popular vote for a name and see if we have a winner.

As for the grammar comments - all this is copied over as-is.  I'll add
another patch to fix that up.



Re: [PATCH v5 11/14] software node: move small properties inline when copying

2019-10-16 Thread Andy Shevchenko
On Tue, Oct 15, 2019 at 11:25:53AM -0700, Dmitry Torokhov wrote:
> On Tue, Oct 15, 2019 at 03:20:28PM +0300, Andy Shevchenko wrote:
> > On Fri, Oct 11, 2019 at 04:07:18PM -0700, Dmitry Torokhov wrote:
> > > When copying/duplicating set of properties, move smaller properties that
> > > were stored separately directly inside property entry structures. We can
> > > move:
> > > 
> > > - up to 8 bytes from U8 arrays
> > > - up to 4 words
> > > - up to 2 double words
> > > - one U64 value
> > > - one or 2 strings.
> > 
> > Can you show where you extract such values?
> 
> the "value" union's largest member is u64, which is 8 bytes. Strings are
> pointers, so on 32-bit arches you can stuff 2 pointers into 8 bytes,
> while on 64-bits you have space for only one.
> 
> > 
> > > + if (!dst->is_inline && dst->length <= sizeof(dst->value)) {
> > > + /* We have an opportunity to move the data inline */
> > > + const void *tmp = dst->pointer;
> > > +
> > 
> > > + memcpy(&dst->value, tmp, dst->length);
> > 
> > ...because this is strange trick.
> 
> Not sure what is so strange about it. You just take data that is stored
> separately and move it into the structure, provided that it is not too
> big (i.e. it does not exceed sizeof(value union) size).

You store a value as union, but going to read as a member of union?
I'm pretty sure it breaks standard rules.

-- 
With Best Regards,
Andy Shevchenko




[PATCH] perf jevents: Fix resource leak in process_mapfile()

2019-10-16 Thread Yunfeng Ye
There are memory leaks and file descriptor resource leaks in
process_mapfile().

Fix this by adding free() and fclose() on the error paths.

Fixes: 80eeb67fe577 ("perf jevents: Program to convert JSON file")
Signed-off-by: Yunfeng Ye 
---
 tools/perf/pmu-events/jevents.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index e2837260ca4d..6e60d4cff592 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -758,6 +758,7 @@ static int process_mapfile(FILE *outfp, char *fpath)
char *line, *p;
int line_num;
char *tblname;
+   int ret = 0;

pr_info("%s: Processing mapfile %s\n", prog, fpath);

@@ -769,6 +770,7 @@ static int process_mapfile(FILE *outfp, char *fpath)
if (!mapfp) {
pr_info("%s: Error %s opening %s\n", prog, strerror(errno),
fpath);
+   free(line);
return -1;
}

@@ -795,7 +797,8 @@ static int process_mapfile(FILE *outfp, char *fpath)
/* TODO Deal with lines longer than 16K */
pr_info("%s: Mapfile %s: line %d too long, aborting\n",
prog, fpath, line_num);
-   return -1;
+   ret = -1;
+   goto out;
}
line[strlen(line)-1] = '\0';

@@ -825,7 +828,9 @@ static int process_mapfile(FILE *outfp, char *fpath)

 out:
print_mapping_table_suffix(outfp);
-   return 0;
+   fclose(mapfp);
+   free(line);
+   return ret;
 }

 /*
-- 
2.7.4.3



[PATCH 3/4] staging: KPC2000: kpc2000_spi.c: Fix style issues (alignment)

2019-10-16 Thread Chandra Annamaneni
Resolved: "CHECK: Alignment should match open parenthesis" from checkpatch

Signed-off-by: Chandra Annamaneni 
---
Previous versions of these patches were not split into different 
patches, did not have different patch numbers and did not have the
keyword staging.
 drivers/staging/kpc2000/kpc2000_spi.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index 929136cdc3e1..24de8d63f504 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -313,19 +313,19 @@ kp_spi_transfer_one_message(struct spi_master *master, 
struct spi_message *m)
if (transfer->speed_hz > KP_SPI_CLK ||
(len && !(rx_buf || tx_buf))) {
dev_dbg(kpspi->dev, "  transfer: %d Hz, %d %s%s, %d 
bpw\n",
-   transfer->speed_hz,
-   len,
-   tx_buf ? "tx" : "",
-   rx_buf ? "rx" : "",
-   transfer->bits_per_word);
+   transfer->speed_hz,
+   len,
+   tx_buf ? "tx" : "",
+   rx_buf ? "rx" : "",
+   transfer->bits_per_word);
dev_dbg(kpspi->dev, "  transfer -EINVAL\n");
return -EINVAL;
}
if (transfer->speed_hz &&
transfer->speed_hz < (KP_SPI_CLK >> 15)) {
dev_dbg(kpspi->dev, "speed_hz %d below minimum %d Hz\n",
-   transfer->speed_hz,
-   KP_SPI_CLK >> 15);
+   transfer->speed_hz,
+   KP_SPI_CLK >> 15);
dev_dbg(kpspi->dev, "  speed_hz -EINVAL\n");
return -EINVAL;
}
-- 
2.20.1



[PATCH 2/4] staging: KPC2000: kpc2000_spi.c: Fix style issues (alignment)

2019-10-16 Thread Chandra Annamaneni
Resolved: "CHECK: Alignment should match open parenthesis" from checkpatch

Signed-off-by: Chandra Annamaneni 
---
Previous versions of these patches were not split into different 
patches, did not have different patch numbers and did not have the
keyword staging.
 drivers/staging/kpc2000/kpc2000_spi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index 5712a88c8788..929136cdc3e1 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -226,8 +226,7 @@ kp_spi_txrx_pio(struct spi_device *spidev, struct 
spi_transfer *transfer)
kp_spi_write_reg(cs, KP_SPI_REG_TXDATA, val);
processed++;
}
-   }
-   else if (rx) {
+   } else if (rx) {
for (i = 0 ; i < c ; i++) {
char test = 0;
 
-- 
2.20.1



[PATCH 4/4] staging: KPC2000: kpc2000_spi.c: Fix style issues (Unnecessary parenthesis)

2019-10-16 Thread Chandra Annamaneni
Resolved: CHECK: Unnecessary parentheses around table[i]

Signed-off-by: Chandra Annamaneni 
---
Previous versions of these patches were not split into different 
patches, did not have different patch numbers and did not have the
keyword staging.
 drivers/staging/kpc2000/kpc2000_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index 24de8d63f504..8becf972af9c 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -476,7 +476,7 @@ kp_spi_probe(struct platform_device *pldev)
/* register the slave boards */
 #define NEW_SPI_DEVICE_FROM_BOARD_INFO_TABLE(table) \
for (i = 0 ; i < ARRAY_SIZE(table) ; i++) { \
-   spi_new_device(master, &(table[i])); \
+   spi_new_device(master, &table[i]); \
}
 
switch ((drvdata->card_id & 0x) >> 16) {
-- 
2.20.1



Re: [PATCH v3 5/6] x86/ftrace: Use text_poke()

2019-10-16 Thread Peter Zijlstra
On Tue, Oct 15, 2019 at 06:27:05PM -0400, Steven Rostedt wrote:

> (7) Seventh session, titled "klp-convert and livepatch relocations", was led
> by Joe Lawrence.
> 
> Joe started the session with problem statement: accessing non exported / 
> static
> symbols from inside the patch module. One possible workardound is manually via
> kallsyms. Second workaround is klp-convert, which actually creates proper
> relocations inside the livepatch module from the symbol database during the
> final .ko link.
> Currently module loader looks for special livepatch relocations and resolves
> those during runtime; kernel support for these relocations have so far been
> added for x86 only. Special livepatch relocations are supported and processed
> also on other architectures. Special quirks/sections are not yet supported.
> Plus klp-convert would still be needed even with late module patching update.
> vmlinux or modules could have ambiguous static symbols.
> 
> It turns out that the features / bugs below have to be resolved before we
> can claim the klp-convert support for relocation complete:
> - handle all the corner cases (jump labels, static keys, ...) properly and
>   have a good regression tests in place

I suppose all the patches in this series-of-series here will make life
harder for KLP, static_call() and 2 byte jumps etc..

> - one day we might (or might not) add support for out-of-tree modules 
> which
>   need klp-convert
> - BFD bug 24456 (multiple relocations to the same .text section)




[PATCH 1/4] staging: KPC2000: kpc2000_spi.c: Fix style issues (missing blank line)

2019-10-16 Thread Chandra Annamaneni
Resolved: "CHECK: Please use a blank line after.." from checkpatch.pl

Signed-off-by: Chandra Annamaneni 
---
Previous versions of these patches were not split into different 
patches, did not have different patch numbers and did not have the
keyword staging.
 drivers/staging/kpc2000/kpc2000_spi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index 6ba94b0131da..5712a88c8788 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -50,6 +50,7 @@ static struct flash_platform_data p2kr0_spi0_pdata = {
.nr_parts = ARRAY_SIZE(p2kr0_spi0_parts),
.parts =p2kr0_spi0_parts,
 };
+
 static struct flash_platform_data p2kr0_spi1_pdata = {
.name = "SPI1",
.nr_parts = ARRAY_SIZE(p2kr0_spi1_parts),
-- 
2.20.1



Re: [PATCH] RISC-V: fix virtual address overlapped in FIXADDR_START and VMEMMAP_START

2019-10-16 Thread Anup Patel
On Wed, Oct 16, 2019 at 1:04 PM  wrote:
>
> From: Greentime Hu 
>
> This patch fixes the virtual address layout in pgtable.h.
> The virtual address of FIXADDR_START and VMEMMAP_START should not be 
> overlapped.
> These addresses will be existed at the same time in Linux kernel that they 
> can't
> be overlapped.
>
> Fixes: d95f1a542c3d ("RISC-V: Implement sparsemem")
> Signed-off-by: Greentime Hu 
> ---
>  arch/riscv/include/asm/pgtable.h | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/arch/riscv/include/asm/pgtable.h 
> b/arch/riscv/include/asm/pgtable.h
> index 4f4162d90586..b927fb4ecf1c 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -87,14 +87,6 @@ extern pgd_t swapper_pg_dir[];
>  #define VMALLOC_END  (PAGE_OFFSET - 1)
>  #define VMALLOC_START(PAGE_OFFSET - VMALLOC_SIZE)
>
> -#define FIXADDR_TOP  VMALLOC_START
> -#ifdef CONFIG_64BIT
> -#define FIXADDR_SIZE PMD_SIZE
> -#else
> -#define FIXADDR_SIZE PGDIR_SIZE
> -#endif
> -#define FIXADDR_START(FIXADDR_TOP - FIXADDR_SIZE)
> -
>  /*
>   * Roughly size the vmemmap space to be large enough to fit enough
>   * struct pages to map half the virtual address space. Then
> @@ -108,6 +100,14 @@ extern pgd_t swapper_pg_dir[];
>
>  #define vmemmap((struct page *)VMEMMAP_START)
>
> +#define FIXADDR_TOP  (VMEMMAP_START)
> +#ifdef CONFIG_64BIT
> +#define FIXADDR_SIZE PMD_SIZE
> +#else
> +#define FIXADDR_SIZE PGDIR_SIZE
> +#endif
> +#define FIXADDR_START(FIXADDR_TOP - FIXADDR_SIZE)
> +
>  /*
>   * ZERO_PAGE is a global shared page that is always zero,
>   * used for zero-mapped memory areas, etc.
> --
> 2.17.1
>

Looks good to me.

Reviewed-by: Anup Patel 

Regards,
Anup


Re: [PATCH 2/2] arm64: dts: sc7180: Add minimal dts/dtsi files for SC7180 soc

2019-10-16 Thread Taniya Das

Hi Vinod,

On 10/16/2019 10:55 AM, Vinod Koul wrote:

On 15-10-19, 16:03, Rajendra Nayak wrote:


+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+,
+,
+;
+   };
+
+   clocks {


Can we have these sorted alphabetically please


+   xo_board: xo-board {
+   compatible = "fixed-clock";
+   clock-frequency = <3840>;
+   clock-output-names = "xo_board";
+   #clock-cells = <0>;
+   };
+
+   sleep_clk: sleep-clk {
+   compatible = "fixed-clock";
+   clock-frequency = <32764>;
+   clock-output-names = "sleep_clk";
+   #clock-cells = <0>;
+   };
+
+   bi_tcxo: bi_tcxo {


why is this a clock defined here? Isnt this gcc clock?



This is a RPMH-controlled clock and not from GCC. It is the parent clock 
for GCC RCGs/PLLs.


Once the RPMH clock support is added these would be removed.


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

--


Re: [PATCH v5 05/14] software node: clean up property_copy_string_array()

2019-10-16 Thread Andy Shevchenko
On Tue, Oct 15, 2019 at 11:12:11AM -0700, Dmitry Torokhov wrote:
> On Tue, Oct 15, 2019 at 03:07:26PM +0300, Andy Shevchenko wrote:
> > On Fri, Oct 11, 2019 at 04:07:12PM -0700, Dmitry Torokhov wrote:
> > > Because property_copy_string_array() stores the newly allocated pointer 
> > > in the
> > > destination property, we have an awkward code in 
> > > property_entry_copy_data()
> > > where we fetch the new pointer from dst.
> > 
> > I don't see a problem in this function.
> > 
> > Rather 'awkward code' is a result of use property_set_pointer() which 
> > relies on
> > data type.
> 
> No, the awkwardness is that we set the pointer once in
> property_copy_string_array(), then fetch it in
> property_entry_copy_data() only to set it again via
> property_set_pointer().

Yes, since property_set_pointer is called independently
on the type of the value.


> This is confising and awkward and I believe it
> is cleaner for property_copy_string_array() to give a pointer to a copy
> of a string array, and then property_entry_copy_data() use it when
> handling the destination structure.

We probably need a 3rd opinion here.

-- 
With Best Regards,
Andy Shevchenko




[ANNOUNCE] Call for Sessions - linux.conf.au 2020 Kernel Miniconf

2019-10-16 Thread Andrew Donnellan

LCA2020 Kernel Miniconf - Gold Coast, Queensland, Australia - 2020-01-14


**

LCA Kernel Miniconf submissions open!

Submissions close: 2019-12-08 (early submissions until 2019-11-17)

Submissions: https://linux.conf.au/proposals/submit/kernel-miniconf/

More info: https://lca-kernel.ozlabs.org/2020-cfs.html

**

linux.conf.au 2020 will be held at the Gold Coast Convention and 
Exhibition Centre, from 13-17 January 2020. The Kernel Miniconf is 
returning once again to discuss all things kernel.


The Kernel Miniconf is a single-day miniconf track about everything 
related to the kernel and low-level systems programming.


The Kernel Miniconf will focus on a variety of kernel-related topics - 
technical presentations on up-and-coming kernel developments, the future 
direction of the kernel, and kernel development community and process 
matters. Past Kernel Miniconfs have included technical talks on topics 
such as memory management, RCU, scheduling and filesystems, as well as 
talks on Linux kernel community topics such as licensing and Linux 
kernel development process.


We invite submissions on anything related to kernel and low-level 
systems programming. We welcome submissions from developers of all 
levels of experience in the kernel community, covering a broad range of 
topics. The focus of the miniconf will primarily be on Linux, however 
non-Linux talks of sufficient interest to a primarily Linux audience 
will be considered.


Early Close Date: 2019-11-17, midnight Anywhere on Earth (UTC-12)
Final Close Date: 2019-12-08, midnight Anywhere on Earth (UTC-12)
Submissions: https://linux.conf.au/proposals/submit/kernel-miniconf/

** For more information: http://lca-kernel.ozlabs.org/2020-cfs.html **

--
Andrew Donnellan  OzLabs, ADL Canberra
a...@linux.ibm.com IBM Australia Limited



Re: [PATCH 10/34] m68k/coldfire: Use CONFIG_PREEMPTION

2019-10-16 Thread Sebastian Andrzej Siewior
On 2019-10-16 10:50:41 [+1000], Greg Ungerer wrote:
> Hi Sebastian,
Hi Greg,

> On 16/10/19 5:17 am, Sebastian Andrzej Siewior wrote:
> > From: Thomas Gleixner 
> > 
> > CONFIG_PREEMPTION is selected by CONFIG_PREEMPT and by CONFIG_PREEMPT_RT.
> > Both PREEMPT and PREEMPT_RT require the same functionality which today
> > depends on CONFIG_PREEMPT.
> > 
> > Switch the entry code over to use CONFIG_PREEMPTION.
> > 
> > Cc: Greg Ungerer 
> 
> Acked-by: Greg Ungerer 

Thank you.

> Do you want me to take this via the m68knommu git tree?
> Or are you taking the whole series via some other tree?

It is up to you. You have all the dependencies so you can either add it
to your -next branch or leave it and we will pick it up for you.

> Regards
> Greg

Sebastian


Re: [PATCH] mm, soft-offline: convert parameter to pfn

2019-10-16 Thread David Hildenbrand

On 16.10.19 09:09, Naoya Horiguchi wrote:

Hi,

I wrote a simple cleanup for parameter of soft_offline_page(),
based on thread https://lkml.org/lkml/2019/10/11/57.

I know that we need more cleanup on hwpoison-inject, but I think
that will be mentioned in re-write patchset Oscar is preparing now.
So let me shared only this part as a separate one now.

Thanks,
Naoya Horiguchi
---
From: Naoya Horiguchi 
Date: Wed, 16 Oct 2019 15:49:00 +0900
Subject: [PATCH] mm, soft-offline: convert parameter to pfn

Currently soft_offline_page() receives struct page, and its sibling
memory_failure() receives pfn. This discrepancy looks weird and makes
precheck on pfn validity tricky. So let's align them.

Signed-off-by: Naoya Horiguchi 
---
  drivers/base/memory.c | 2 +-
  include/linux/mm.h| 2 +-
  mm/madvise.c  | 2 +-
  mm/memory-failure.c   | 8 
  4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index e5485c22ef77..04e469c82852 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -540,7 +540,7 @@ static ssize_t soft_offline_page_store(struct device *dev,
pfn >>= PAGE_SHIFT;
if (!pfn_valid(pfn))
return -ENXIO;
-   ret = soft_offline_page(pfn_to_page(pfn));
+   ret = soft_offline_page(pfn);
return ret == 0 ? count : ret;
  }
  
diff --git a/include/linux/mm.h b/include/linux/mm.h

index 3eba26324ff1..0a452020edf5 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2783,7 +2783,7 @@ extern int sysctl_memory_failure_early_kill;
  extern int sysctl_memory_failure_recovery;
  extern void shake_page(struct page *p, int access);
  extern atomic_long_t num_poisoned_pages __read_mostly;
-extern int soft_offline_page(struct page *page);
+extern int soft_offline_page(unsigned long pfn);
  
  
  /*

diff --git a/mm/madvise.c b/mm/madvise.c
index fd221b610b52..df198d1e5e2e 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -893,7 +893,7 @@ static int madvise_inject_error(int behavior,
if (behavior == MADV_SOFT_OFFLINE) {
pr_info("Soft offlining pfn %#lx at process virtual address 
%#lx\n",
 pfn, start);
-   ret = soft_offline_page(page);
+   ret = soft_offline_page(pfn);
if (ret)
return ret;
} else {
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 4f16e0a7e7cc..eb4fd5e8d5e1 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1514,7 +1514,7 @@ static void memory_failure_work_func(struct work_struct 
*work)
if (!gotten)
break;
if (entry.flags & MF_SOFT_OFFLINE)
-   soft_offline_page(pfn_to_page(entry.pfn));
+   soft_offline_page(entry.pfn);
else
memory_failure(entry.pfn, entry.flags);
}
@@ -1822,7 +1822,7 @@ static int soft_offline_free_page(struct page *page)
  
  /**

   * soft_offline_page - Soft offline a page.
- * @page: page to offline
+ * @pfn: pfn to soft-offline
   *
   * Returns 0 on success, otherwise negated errno.
   *
@@ -1841,10 +1841,10 @@ static int soft_offline_free_page(struct page *page)
   * This is not a 100% solution for all memory, but tries to be
   * ``good enough'' for the majority of memory.
   */
-int soft_offline_page(struct page *page)
+int soft_offline_page(unsigned long pfn)
  {
int ret;
-   unsigned long pfn = page_to_pfn(page);
+   struct page *page = pfn_to_page(pfn);
  
  	if (is_zone_device_page(page)) {

pr_debug_ratelimited("soft_offline: %#lx page is device page\n",



I think you should rebase that patch on linux-next (where the  
pfn_to_online_page() check is in place). I assume you'll want to move  
the pfn_to_online_page() check into soft_offline_page() then as well?


--

Thanks,

David / dhildenb


RE: [PATCH 2/2] virtio_ring: Use DMA API if memory is encrypted

2019-10-16 Thread Ram Pai
On Tue, Oct 15, 2019 at 09:35:01AM +0200, Christoph Hellwig wrote:
> On Fri, Oct 11, 2019 at 06:25:19PM -0700, Ram Pai wrote:
> > From: Thiago Jung Bauermann 
> > 
> > Normally, virtio enables DMA API with VIRTIO_F_IOMMU_PLATFORM, which must
> > be set by both device and guest driver. However, as a hack, when DMA API
> > returns physical addresses, guest driver can use the DMA API; even though
> > device does not set VIRTIO_F_IOMMU_PLATFORM and just uses physical
> > addresses.
> 
> Sorry, but this is a complete bullshit hack.  Driver must always use
> the DMA API if they do DMA, and if virtio devices use physical addresses
> that needs to be returned through the platform firmware interfaces for
> the dma setup.  If you don't do that yet (which based on previous
> informations you don't), you need to fix it, and we can then quirk
> old implementations that already are out in the field.
> 
> In other words: we finally need to fix that virtio mess and not pile
> hacks on top of hacks.

So force all virtio devices to use DMA API, except when
VIRTIO_F_IOMMU_PLATFORM is not enabled?

Any help detailing the idea, will enable us fix this issue once for all.

Will something like below work? It removes the prior hacks, and
always uses DMA API; except when VIRTIO_F_IOMMU_PLATFORM is not enabled.

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index c8be1c4..b593d3d 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -240,22 +240,10 @@ static inline bool virtqueue_use_indirect(struct 
virtqueue *_vq,
 
 static bool vring_use_dma_api(struct virtio_device *vdev)
 {
-   if (!virtio_has_iommu_quirk(vdev))
-   return true;
-
-   /* Otherwise, we are left to guess. */
-   /*
-* In theory, it's possible to have a buggy QEMU-supposed
-* emulated Q35 IOMMU and Xen enabled at the same time.  On
-* such a configuration, virtio has never worked and will
-* not work without an even larger kludge.  Instead, enable
-* the DMA API if we're a Xen guest, which at least allows
-* all of the sensible Xen configurations to work correctly.
-*/
-   if (xen_domain())
-   return true;
+   if (virtio_has_iommu_quirk(vdev))
+   return false;
 
-   return false;
+   return true;
 }
 
 size_t virtio_max_dma_size(struct virtio_device *vdev)


-- 
Ram Pai



Re: [PATCH] RISC-V: fix virtual address overlapped in FIXADDR_START and VMEMMAP_START

2019-10-16 Thread Andreas Schwab
On Okt 16 2019, greentime...@sifive.com wrote:

> From: Greentime Hu 
>
> This patch fixes the virtual address layout in pgtable.h.
> The virtual address of FIXADDR_START and VMEMMAP_START should not be 
> overlapped.
> These addresses will be existed at the same time in Linux kernel that they 
> can't
> be overlapped.

s/be existed/exist/
s/be overlapped/overlap/

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


Re: [PATCH v5 10/14] software node: rename is_array to is_inline

2019-10-16 Thread Andy Shevchenko
On Tue, Oct 15, 2019 at 11:22:06AM -0700, Dmitry Torokhov wrote:
> On Mon, Oct 14, 2019 at 10:37:20AM +0300, Andy Shevchenko wrote:
> > On Fri, Oct 11, 2019 at 04:07:17PM -0700, Dmitry Torokhov wrote:
> > > We do not need a special flag to know if we are dealing with an array,
> > > as we can get that data from ratio between element length and the data
> > > size, however we do need a flag to know whether the data is stored
> > > directly inside property_entry or separately.
> > 
> > > - if (prop->is_array)
> > > + if (!prop->is_inline)
> > 
> > > - if (p->is_array) {
> > > + if (!p->is_inline) {
> > 
> > > - if (src->is_array) {
> > > + if (!src->is_inline) {
> > 
> > May we have positive conditionals instead?
> 
> I was trying to limit the context churn. I can definitely change
> property_get_pointer(), but the other 2 I think are better in the
> current form.
> 
> > 
> > > + * @is_inline: True when the property value is stored directly in
> > 
> > I think word 'directly' is superfluous here.
> > Or, perhaps, 'stored directly' -> 'embedded'
> 
> I'm OK with "embedded".
> 
> > 
> > > + * &struct property_entry instance.
> > 
> > > + * @pointer: Pointer to the property when it is stored separately from
> > > + * the &struct property_entry instance.
> > 
> > 'separately from' -> 'outside' ?
> 
> Umm, I think I prefer "separately" actually.
> 
> > 
> > > + * @value: Value of the property when it is stored inline.
> > 
> > 'stored inline' -> 'embedded in the &struct...' ?
> 
> I was trying to have a link "stored inline" -> "is_inline".
> 
> Do we want to change the flag to be "is_embedded"?

In dictionaries I have

embedded <-> unilateral
inline <-> ???

Perhaps native speaker can jump in and help here.

My point is to be consistent in the terms we are using.

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH 00/15] thermal: qcom: tsens: Add interrupt support

2019-10-16 Thread Daniel Lezcano
On 16/10/2019 09:33, Amit Kucheria wrote:
> Hi Thermal and MSM maintainers,
> 
> I believe this series is now ready to be merged. The DT bindings and driver
> changes should go through the thermal tree and the changes to the DT files
> themselves should go through the MSM tree. There is no hard ordering
> dependency because we're adding a new property to the driver. It would help
> to soak in linux-next for a few weeks to catch anything on kernelci.org.

So the ones going to thermal are:

1-7, 14, 15 right ?

> Changes since v4:
> - Change to of-thermal core[1] to force interrupts w/o changing polling-delay 
> DT
>   parameter
> - Corresponding changes to DT files to remove the hunks setting the values
>   to 0
> - Collected reviews and acks
> 
> Changes since v3:
> - Fix up the YAML definitions based on Rob's review
> 
> Changes since v2:
> - Addressed Stephen's review comment
> - Moved the dt-bindings to yaml (This throws up some new warnings in various 
> QCOM
> devicetrees. I'll send out a separate series to fix them up)
> - Collected reviews and acks
> - Added the dt-bindings to MAINTAINERS
> 
> Changes since v1:
> - Collected reviews and acks
> - Addressed Stephen's review comments (hopefully I got them all).
> - Completely removed critical interrupt infrastructure from this series.
>   Will post that separately.
> - Fixed a bug in sign-extension of temperature.
> - Fixed DT bindings to use the name of the interrupt e.g. "uplow" and use
>   platform_get_irq_byname().
> 
> Add interrupt support to TSENS. The first 6 patches are general fixes and
> cleanups to the driver before interrupt support is introduced.
> 
> [1] 
> https://lore.kernel.org/linux-arm-msm/1b53ef537203e629328285b4597a09e4a586d688.1571181041.git.amit.kuche...@linaro.org/
> 
> Amit Kucheria (15):
>   drivers: thermal: tsens: Get rid of id field in tsens_sensor
>   drivers: thermal: tsens: Simplify code flow in tsens_probe
>   drivers: thermal: tsens: Add __func__ identifier to debug statements
>   drivers: thermal: tsens: Add debugfs support
>   arm: dts: msm8974: thermal: Add thermal zones for each sensor
>   arm64: dts: msm8916: thermal: Fixup HW ids for cpu sensors
>   dt-bindings: thermal: tsens: Convert over to a yaml schema
>   arm64: dts: sdm845: thermal: Add interrupt support
>   arm64: dts: msm8996: thermal: Add interrupt support
>   arm64: dts: msm8998: thermal: Add interrupt support
>   arm64: dts: qcs404: thermal: Add interrupt support
>   arm: dts: msm8974: thermal: Add interrupt support
>   arm64: dts: msm8916: thermal: Add interrupt support
>   drivers: thermal: tsens: Create function to return sign-extended
> temperature
>   drivers: thermal: tsens: Add interrupt support
> 
>  .../bindings/thermal/qcom-tsens.txt   |  55 --
>  .../bindings/thermal/qcom-tsens.yaml  | 168 ++
>  MAINTAINERS   |   1 +
>  arch/arm/boot/dts/qcom-msm8974.dtsi   |  92 +++
>  arch/arm64/boot/dts/qcom/msm8916.dtsi |   6 +-
>  arch/arm64/boot/dts/qcom/msm8996.dtsi |   4 +
>  arch/arm64/boot/dts/qcom/msm8998.dtsi |   6 +-
>  arch/arm64/boot/dts/qcom/qcs404.dtsi  |   2 +
>  arch/arm64/boot/dts/qcom/sdm845.dtsi  |   4 +
>  drivers/thermal/qcom/tsens-8960.c |   4 +-
>  drivers/thermal/qcom/tsens-common.c   | 529 --
>  drivers/thermal/qcom/tsens-v0_1.c |  11 +
>  drivers/thermal/qcom/tsens-v1.c   |  29 +
>  drivers/thermal/qcom/tsens-v2.c   |  13 +
>  drivers/thermal/qcom/tsens.c  |  58 +-
>  drivers/thermal/qcom/tsens.h  | 286 --
>  16 files changed, 1102 insertions(+), 166 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/thermal/qcom-tsens.txt
>  create mode 100644 Documentation/devicetree/bindings/thermal/qcom-tsens.yaml
> 


-- 
  Linaro.org │ Open source software for ARM SoCs

Follow Linaro:   Facebook |
 Twitter |
 Blog



Re: [PATCH v5 13/14] platform/x86: intel_cht_int33fe: use inline reference properties

2019-10-16 Thread Andy Shevchenko
On Fri, Oct 11, 2019 at 04:07:20PM -0700, Dmitry Torokhov wrote:
> Now that static device properties allow defining reference properties
> together with all other types of properties, instead of managing them
> separately, let's adjust the driver.
> 

Acked-by: Andy Shevchenko 

as an idea, whatever implementation we will settle on.

> Signed-off-by: Dmitry Torokhov 
> ---
>  drivers/platform/x86/intel_cht_int33fe.c | 81 
>  1 file changed, 41 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel_cht_int33fe.c 
> b/drivers/platform/x86/intel_cht_int33fe.c
> index 1d5d877b9582..4177c5424931 100644
> --- a/drivers/platform/x86/intel_cht_int33fe.c
> +++ b/drivers/platform/x86/intel_cht_int33fe.c
> @@ -46,30 +46,6 @@ struct cht_int33fe_data {
>   struct fwnode_handle *dp;
>  };
>  
> -static const struct software_node nodes[];
> -
> -static const struct software_node_ref_args pi3usb30532_ref = {
> - &nodes[INT33FE_NODE_PI3USB30532]
> -};
> -
> -static const struct software_node_ref_args dp_ref = {
> - &nodes[INT33FE_NODE_DISPLAYPORT]
> -};
> -
> -static struct software_node_ref_args mux_ref;
> -
> -static const struct software_node_reference usb_connector_refs[] = {
> - { "orientation-switch", 1, &pi3usb30532_ref},
> - { "mode-switch", 1, &pi3usb30532_ref},
> - { "displayport", 1, &dp_ref},
> - { }
> -};
> -
> -static const struct software_node_reference fusb302_refs[] = {
> - { "usb-role-switch", 1, &mux_ref},
> - { }
> -};
> -
>  /*
>   * Grrr I severly dislike buggy BIOS-es. At least one BIOS enumerates
>   * the max17047 both through the INT33FE ACPI device (it is right there
> @@ -105,8 +81,18 @@ static const struct property_entry max17047_props[] = {
>   { }
>  };
>  
> +/*
> + * We are not using inline property here because those are constant,
> + * and we need to adjust this one at runtime to point to real
> + * software node.
> + */
> +static struct software_node_ref_args fusb302_mux_refs[] = {
> + { .node = NULL },
> +};
> +
>  static const struct property_entry fusb302_props[] = {
>   PROPERTY_ENTRY_STRING("linux,extcon-name", "cht_wcove_pwrsrc"),
> + PROPERTY_ENTRY_REF_ARRAY("usb-role-switch", fusb302_mux_refs),
>   { }
>  };
>  
> @@ -122,6 +108,8 @@ static const u32 snk_pdo[] = {
>   PDO_VAR(5000, 12000, 3000),
>  };
>  
> +static const struct software_node nodes[];
> +
>  static const struct property_entry usb_connector_props[] = {
>   PROPERTY_ENTRY_STRING("data-role", "dual"),
>   PROPERTY_ENTRY_STRING("power-role", "dual"),
> @@ -129,15 +117,21 @@ static const struct property_entry 
> usb_connector_props[] = {
>   PROPERTY_ENTRY_U32_ARRAY("source-pdos", src_pdo),
>   PROPERTY_ENTRY_U32_ARRAY("sink-pdos", snk_pdo),
>   PROPERTY_ENTRY_U32("op-sink-microwatt", 250),
> + PROPERTY_ENTRY_REF("orientation-switch",
> +&nodes[INT33FE_NODE_PI3USB30532]),
> + PROPERTY_ENTRY_REF("mode-switch",
> +&nodes[INT33FE_NODE_PI3USB30532]),
> + PROPERTY_ENTRY_REF("displayport",
> +&nodes[INT33FE_NODE_DISPLAYPORT]),
>   { }
>  };
>  
>  static const struct software_node nodes[] = {
> - { "fusb302", NULL, fusb302_props, fusb302_refs },
> + { "fusb302", NULL, fusb302_props },
>   { "max17047", NULL, max17047_props },
>   { "pi3usb30532" },
>   { "displayport" },
> - { "connector", &nodes[0], usb_connector_props, usb_connector_refs },
> + { "connector", &nodes[0], usb_connector_props },
>   { }
>  };
>  
> @@ -173,9 +167,10 @@ static void cht_int33fe_remove_nodes(struct 
> cht_int33fe_data *data)
>  {
>   software_node_unregister_nodes(nodes);
>  
> - if (mux_ref.node) {
> - fwnode_handle_put(software_node_fwnode(mux_ref.node));
> - mux_ref.node = NULL;
> + if (fusb302_mux_refs[0].node) {
> + fwnode_handle_put(
> + software_node_fwnode(fusb302_mux_refs[0].node));
> + fusb302_mux_refs[0].node = NULL;
>   }
>  
>   if (data->dp) {
> @@ -187,25 +182,31 @@ static void cht_int33fe_remove_nodes(struct 
> cht_int33fe_data *data)
>  
>  static int cht_int33fe_add_nodes(struct cht_int33fe_data *data)
>  {
> + const struct software_node *mux_ref_node;
>   int ret;
>  
> - ret = software_node_register_nodes(nodes);
> - if (ret)
> - return ret;
> -
> - /* The devices that are not created in this driver need extra steps. */
> -
>   /*
>* There is no ACPI device node for the USB role mux, so we need to wait
>* until the mux driver has created software node for the mux device.
>* It means we depend on the mux driver. This function will return
>* -EPROBE_DEFER until the mux device is registered.
>*/
> - mux_ref.node = software_node_find_by_name(NULL, "intel-xhci-usb-sw");
> - if (!mux_ref.node) {
> - ret = -

Re: [PATCH v5 00/14] software node: add support for reference properties

2019-10-16 Thread Andy Shevchenko
On Mon, Oct 14, 2019 at 04:57:47PM -0700, Dmitry Torokhov wrote:
> On Mon, Oct 14, 2019 at 10:38:37AM +0300, Andy Shevchenko wrote:
> > On Fri, Oct 11, 2019 at 04:07:07PM -0700, Dmitry Torokhov wrote:
> > > These series implement "references" properties for software nodes as true
> > > properties, instead of managing them completely separately.
> > > 
> > > The first 10 patches are generic cleanups and consolidation and
> > > unification of the existing code; patch #11 implements moving of small
> > > properties inline when copying property entries; patch #12 implements
> > > PROPERTY_ENTRY_REF() and friends; patch #13 converts the user of
> > > references to the property syntax, and patch #14 removes the remains of
> > > references as entities that are managed separately.
> > 
> > Can we get some test cases?
> 
> Something like this? (I'll beef it up if we decide KUnit is OK for
> this).

As a starter, yes.

-- 
With Best Regards,
Andy Shevchenko




[PATCH] [V2] PCI: sysfs: remove pci_bridge_groups and pcie_dev_groups

2019-10-16 Thread Ben Dooks (Codethink)
From: Ben Dooks 

The pci_bridge_groups and pcie_dev_groups objects are
not exported and not used at-all, so remove them to
fix the following warnings from sparse:

drivers/pci/pci-sysfs.c:1546:30: warning: symbol 'pci_bridge_groups' was not 
declared. Should it be static?
drivers/pci/pci-sysfs.c:1555:30: warning: symbol 'pcie_dev_groups' was not 
declared. Should it be static?

Also remove the unused pci_bridge_group and pcie_dev_group
as they are not used any more.

Signed-off-by: Ben Dooks 
---
Cc: Bjorn Helgaas 
Cc: linux-...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

fixup - more unused pci bits
---
 drivers/pci/pci-sysfs.c | 18 --
 1 file changed, 18 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 793412954529..eaffb477c5bf 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1539,24 +1539,6 @@ const struct attribute_group *pci_dev_groups[] = {
NULL,
 };
 
-static const struct attribute_group pci_bridge_group = {
-   .attrs = pci_bridge_attrs,
-};
-
-const struct attribute_group *pci_bridge_groups[] = {
-   &pci_bridge_group,
-   NULL,
-};
-
-static const struct attribute_group pcie_dev_group = {
-   .attrs = pcie_dev_attrs,
-};
-
-const struct attribute_group *pcie_dev_groups[] = {
-   &pcie_dev_group,
-   NULL,
-};
-
 static const struct attribute_group pci_dev_hp_attr_group = {
.attrs = pci_dev_hp_attrs,
.is_visible = pci_dev_hp_attrs_are_visible,
-- 
2.23.0



Re: [PATCH v6 1/7] ASoC: sun4i-i2s: Move channel select offset

2019-10-16 Thread Maxime Ripard
On Wed, Oct 16, 2019 at 09:07:34AM +0200, codekip...@gmail.com wrote:
> From: Marcus Cooper 
>
> On the newer SoCs the offset is used to set the mode of the
> connection. As it is to be used elsewhere then it makes sense
> to move it to the main structure.

Elsewhere where, and to do what?

Maxime


signature.asc
Description: PGP signature


Re: [PATCH] PCI: sysfs: remove pci_bridge_groups and pcie_dev_groups

2019-10-16 Thread Ben Dooks

On 16/10/2019 07:28, Christoph Hellwig wrote:

On Tue, Oct 15, 2019 at 03:00:59PM +0100, Ben Dooks wrote:

The pci_bridge_groups and pcie_dev_groups objects are
not exported and not used at-all, so remove them to
fix the following warnings from sparse:

drivers/pci/pci-sysfs.c:1546:30: warning: symbol 'pci_bridge_groups' was not 
declared. Should it be static?
drivers/pci/pci-sysfs.c:1555:30: warning: symbol 'pcie_dev_groups' was not 
declared. Should it be static?


But now pci_bridge_group is unused, and if you remove that the
attributes, etc..


Ok, thanks for spotting, i've removed those too.

I've no idea why we're not getting compiler warnings for this.


--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html


Re: [PATCH] arm64: defconfig: Enable Qualcomm pseudo rng

2019-10-16 Thread Vinod Koul
On 11-10-19, 16:50, Bjorn Andersson wrote:
> Most Qualcomm platforms contain a pseudo random number generator
> hardware block. Enable the driver for this block.

This enabled and loads the driver, but doesn't enable the usage.

We also need CONFIG_CRYPTO_RNG2 but that gets selected so that part is
fine. For userspace we need CONFIG_CRYPTO_USER_API_RNG to be added so
that kernel exports interface to users. So can you add that as well.

Thanks
> 
> Signed-off-by: Bjorn Andersson 
> ---
>  arch/arm64/configs/defconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
> index a5953b0b382d..688c8f200034 100644
> --- a/arch/arm64/configs/defconfig
> +++ b/arch/arm64/configs/defconfig
> @@ -855,6 +855,7 @@ CONFIG_NLS_ISO8859_1=y
>  CONFIG_SECURITY=y
>  CONFIG_CRYPTO_ECHAINIV=y
>  CONFIG_CRYPTO_ANSI_CPRNG=y
> +CONFIG_CRYPTO_DEV_QCOM_RNG=m
>  CONFIG_DMA_CMA=y
>  CONFIG_CMA_SIZE_MBYTES=32
>  CONFIG_PRINTK_TIME=y
> -- 
> 2.23.0

-- 
~Vinod


  1   2   3   4   5   6   7   8   9   10   >