Re: [PATCH v3 2/5] mtd: spi-nor: cadence-quadspi: add a delay in write sequence

2017-09-24 Thread Vignesh R


On 9/24/2017 5:29 PM, Marek Vasut wrote:
> On 09/24/2017 12:59 PM, Vignesh R wrote:
>> As per 66AK2G02 TRM[1] SPRUHY8F section 11.15.5.3 Indirect Access
>> Controller programming sequence, a delay equal to couple of QSPI master
>> clock(~5ns) is required after setting CQSPI_REG_INDIRECTWR_START bit and
>> writing data to the flash. Introduce a quirk flag CQSPI_NEEDS_WR_DELAY
>> to handle this and set this flag for TI 66AK2G SoC.
>>
>> [1]http://www.ti.com/lit/ug/spruhy8f/spruhy8f.pdf
>>
>> Signed-off-by: Vignesh R 
> 
> Is this TI specific or is this controller property ? I wouldn't be
> surprised of the later ...

I am not sure, there is no generic public documentation by cadence for
this IP. TI TRM clearly states this delay is required and I have
verified it practically that this delay is indeed needed.
But current user of this IP, socfpga does not seem to mention anything
about it. So, I guess its TI specific quirk.

> 
>> ---
>>
>> v3:
>> Fix build warnings reported by kbuild test bot.
>>
>>  drivers/mtd/spi-nor/cadence-quadspi.c | 27 ++-
>>  1 file changed, 26 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c 
>> b/drivers/mtd/spi-nor/cadence-quadspi.c
>> index 53c7d8e0327a..5cd5d6f7303f 100644
>> --- a/drivers/mtd/spi-nor/cadence-quadspi.c
>> +++ b/drivers/mtd/spi-nor/cadence-quadspi.c
>> @@ -38,6 +38,9 @@
>>  #define CQSPI_NAME  "cadence-qspi"
>>  #define CQSPI_MAX_CHIPSELECT16
>>  
>> +/* Quirks */
>> +#define CQSPI_NEEDS_WR_DELAYBIT(0)
>> +
>>  struct cqspi_st;
>>  
>>  struct cqspi_flash_pdata {
>> @@ -76,6 +79,7 @@ struct cqspi_st {
>>  u32 fifo_depth;
>>  u32 fifo_width;
>>  u32 trigger_address;
>> +u32 wr_delay;
>>  struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT];
>>  };
>>  
>> @@ -608,6 +612,15 @@ static int cqspi_indirect_write_execute(struct spi_nor 
>> *nor,
>>  reinit_completion(&cqspi->transfer_complete);
>>  writel(CQSPI_REG_INDIRECTWR_START_MASK,
>> reg_base + CQSPI_REG_INDIRECTWR);
>> +/*
>> + * As per 66AK2G02 TRM SPRUHY8F section 11.15.5.3 Indirect Access
>> + * Controller programming sequence, couple of cycles of
>> + * QSPI_REF_CLK delay is required for the above bit to
>> + * be internally synchronized by the QSPI module. Provide 5
>> + * cycles of delay.
>> + */
>> +if (cqspi->wr_delay)
>> +ndelay(cqspi->wr_delay);
>>  
>>  while (remaining > 0) {
>>  write_bytes = remaining > page_size ? page_size : remaining;
>> @@ -1156,6 +1169,7 @@ static int cqspi_probe(struct platform_device *pdev)
>>  struct cqspi_st *cqspi;
>>  struct resource *res;
>>  struct resource *res_ahb;
>> +unsigned long data;
>>  int ret;
>>  int irq;
>>  
>> @@ -1213,6 +1227,10 @@ static int cqspi_probe(struct platform_device *pdev)
>>  }
>>  
>>  cqspi->master_ref_clk_hz = clk_get_rate(cqspi->clk);
>> +data  = (unsigned long)of_device_get_match_data(dev);
>> +if (data & CQSPI_NEEDS_WR_DELAY)
>> +cqspi->wr_delay = 5 * DIV_ROUND_UP(NSEC_PER_SEC,
>> +   cqspi->master_ref_clk_hz);
>>  
>>  ret = devm_request_irq(dev, irq, cqspi_irq_handler, 0,
>> pdev->name, cqspi);
>> @@ -1284,7 +1302,14 @@ static const struct dev_pm_ops cqspi__dev_pm_ops = {
>>  #endif
>>  
>>  static const struct of_device_id cqspi_dt_ids[] = {
>> -{.compatible = "cdns,qspi-nor",},
>> +{
>> +.compatible = "cdns,qspi-nor",
>> +.data = (void *)0,
>> +},
>> +{
>> +.compatible = "ti,k2g-qspi",
>> +.data = (void *)CQSPI_NEEDS_WR_DELAY,
>> +},
>>  { /* end of table */ }
>>  };
>>  
>>
> 
> 


Re: [PATCH 3/3] iio: trigger: stm32-timer: enable clock when in master mode

2017-09-24 Thread Jonathan Cameron
On Mon, 18 Sep 2017 12:05:32 +0200
Fabrice Gasnier  wrote:

> Clock should be enabled as soon as using master mode, even before
> enabling timer. Or, this may provoke bad behavior on the other end
> (slave timer). Then, introduce 'clk_enabled' flag, instead of relying
> on CR1 EN bit, to keep track of clock being enabled.
> Propagate this anywhere else in the driver.
> 
> Also add 'remove' routine to stop timer and disable clock in case it
> has been left enabled.

This last bit leaves us open to some nasty race conditions I think.
I'm not sure of a clean way to avoid them, but turning this off
before we remove the userspace interfaces doesn't strike me as a good
idea!

More detail inline.

Jonathan

> 
> Signed-off-by: Fabrice Gasnier 
> ---
>  drivers/iio/trigger/stm32-timer-trigger.c | 60 
> +--
>  1 file changed, 42 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/iio/trigger/stm32-timer-trigger.c 
> b/drivers/iio/trigger/stm32-timer-trigger.c
> index eb212f8c..5a6509c 100644
> --- a/drivers/iio/trigger/stm32-timer-trigger.c
> +++ b/drivers/iio/trigger/stm32-timer-trigger.c
> @@ -79,6 +79,7 @@ struct stm32_timer_trigger {
>   struct device *dev;
>   struct regmap *regmap;
>   struct clk *clk;
> + bool clk_enabled;
>   u32 max_arr;
>   const void *triggers;
>   const void *valids;
> @@ -106,7 +107,7 @@ static int stm32_timer_start(struct stm32_timer_trigger 
> *priv,
>  {
>   unsigned long long prd, div;
>   int prescaler = 0;
> - u32 ccer, cr1;
> + u32 ccer;
>  
>   /* Period and prescaler values depends of clock rate */
>   div = (unsigned long long)clk_get_rate(priv->clk);
> @@ -136,9 +137,10 @@ static int stm32_timer_start(struct stm32_timer_trigger 
> *priv,
>   if (ccer & TIM_CCER_CCXE)
>   return -EBUSY;
>  
> - regmap_read(priv->regmap, TIM_CR1, &cr1);
> - if (!(cr1 & TIM_CR1_CEN))
> + if (!priv->clk_enabled) {
> + priv->clk_enabled = true;
>   clk_enable(priv->clk);
> + }
>  
>   regmap_write(priv->regmap, TIM_PSC, prescaler);
>   regmap_write(priv->regmap, TIM_ARR, prd - 1);
> @@ -163,16 +165,12 @@ static int stm32_timer_start(struct stm32_timer_trigger 
> *priv,
>  
>  static void stm32_timer_stop(struct stm32_timer_trigger *priv)
>  {
> - u32 ccer, cr1;
> + u32 ccer;
>  
>   regmap_read(priv->regmap, TIM_CCER, &ccer);
>   if (ccer & TIM_CCER_CCXE)
>   return;
>  
> - regmap_read(priv->regmap, TIM_CR1, &cr1);
> - if (cr1 & TIM_CR1_CEN)
> - clk_disable(priv->clk);
> -
>   /* Stop timer */
>   regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE, 0);
>   regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN, 0);
> @@ -181,6 +179,11 @@ static void stm32_timer_stop(struct stm32_timer_trigger 
> *priv)
>  
>   /* Make sure that registers are updated */
>   regmap_update_bits(priv->regmap, TIM_EGR, TIM_EGR_UG, TIM_EGR_UG);
> +
> + if (priv->clk_enabled) {
> + priv->clk_enabled = false;
> + clk_disable(priv->clk);
> + }
>  }
>  
>  static ssize_t stm32_tt_store_frequency(struct device *dev,
> @@ -295,6 +298,11 @@ static ssize_t stm32_tt_store_master_mode(struct device 
> *dev,
>   for (i = 0; i <= master_mode_max; i++) {
>   if (!strncmp(master_mode_table[i], buf,
>strlen(master_mode_table[i]))) {
> + if (!priv->clk_enabled) {
> + /* Clock should be enabled first */
> + priv->clk_enabled = true;
> + clk_enable(priv->clk);
> + }
>   regmap_update_bits(priv->regmap, TIM_CR2, mask,
>  i << shift);
>   /* Make sure that registers are updated */
> @@ -438,7 +446,6 @@ static int stm32_counter_write_raw(struct iio_dev 
> *indio_dev,
>  int val, int val2, long mask)
>  {
>   struct stm32_timer_trigger *priv = iio_priv(indio_dev);
> - u32 dat;
>  
>   switch (mask) {
>   case IIO_CHAN_INFO_RAW:
> @@ -450,17 +457,19 @@ static int stm32_counter_write_raw(struct iio_dev 
> *indio_dev,
>  
>   case IIO_CHAN_INFO_ENABLE:
>   if (val) {
> - regmap_read(priv->regmap, TIM_CR1, &dat);
> - if (!(dat & TIM_CR1_CEN))
> + if (!priv->clk_enabled) {
> + priv->clk_enabled = true;
>   clk_enable(priv->clk);
> + }
>   regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN,
>  TIM_CR1_CEN);
>   } else {
> - regmap_read(priv->regmap, TIM_CR1, &dat);
>   regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN,
>  

Product Enquiry

2017-09-24 Thread Carol Merck
Hello,

We recently visited your website and we are interested in your models, We will 
like to make an order from your list of products. However, we would like to see 
your company's latest catalogs with the; minimum order quantity, delivery 
time/FOB, payment terms etc. Official order placement will follow as soon as 
possible. 

Awaiting your prompt reply.


Thanks and best regards,

Carol Merck
Purchasing Manager


Re: [PATCH v3 5/5] mtd: spi-nor: cadence-quadspi: Add runtime PM support

2017-09-24 Thread Marek Vasut
On 09/24/2017 12:59 PM, Vignesh R wrote:
> Add pm_runtime* calls to cadence-quadspi driver. This is required to
> switch on QSPI power domain on TI 66AK2G SoC during probe.
> 
> Signed-off-by: Vignesh R 

Are you planning to add some more fine-grained PM control later?

> ---
>  drivers/mtd/spi-nor/cadence-quadspi.c | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c 
> b/drivers/mtd/spi-nor/cadence-quadspi.c
> index d9629e8f4798..2c8e6226d267 100644
> --- a/drivers/mtd/spi-nor/cadence-quadspi.c
> +++ b/drivers/mtd/spi-nor/cadence-quadspi.c
> @@ -31,6 +31,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -1224,6 +1225,13 @@ static int cqspi_probe(struct platform_device *pdev)
>   return -ENXIO;
>   }
>  
> + pm_runtime_enable(&pdev->dev);
> + ret = pm_runtime_get_sync(&pdev->dev);
> + if (ret < 0) {
> + pm_runtime_put_noidle(&pdev->dev);
> + return ret;
> + }
> +
>   ret = clk_prepare_enable(cqspi->clk);
>   if (ret) {
>   dev_err(dev, "Cannot enable QSPI clock.\n");
> @@ -1275,6 +1283,9 @@ static int cqspi_remove(struct platform_device *pdev)
>  
>   clk_disable_unprepare(cqspi->clk);
>  
> + pm_runtime_put_sync(&pdev->dev);
> + pm_runtime_disable(&pdev->dev);
> +
>   return 0;
>  }
>  
> 


-- 
Best regards,
Marek Vasut


Re: [PATCH v3 2/5] mtd: spi-nor: cadence-quadspi: add a delay in write sequence

2017-09-24 Thread Marek Vasut
On 09/24/2017 12:59 PM, Vignesh R wrote:
> As per 66AK2G02 TRM[1] SPRUHY8F section 11.15.5.3 Indirect Access
> Controller programming sequence, a delay equal to couple of QSPI master
> clock(~5ns) is required after setting CQSPI_REG_INDIRECTWR_START bit and
> writing data to the flash. Introduce a quirk flag CQSPI_NEEDS_WR_DELAY
> to handle this and set this flag for TI 66AK2G SoC.
> 
> [1]http://www.ti.com/lit/ug/spruhy8f/spruhy8f.pdf
> 
> Signed-off-by: Vignesh R 

Is this TI specific or is this controller property ? I wouldn't be
surprised of the later ...

> ---
> 
> v3:
> Fix build warnings reported by kbuild test bot.
> 
>  drivers/mtd/spi-nor/cadence-quadspi.c | 27 ++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c 
> b/drivers/mtd/spi-nor/cadence-quadspi.c
> index 53c7d8e0327a..5cd5d6f7303f 100644
> --- a/drivers/mtd/spi-nor/cadence-quadspi.c
> +++ b/drivers/mtd/spi-nor/cadence-quadspi.c
> @@ -38,6 +38,9 @@
>  #define CQSPI_NAME   "cadence-qspi"
>  #define CQSPI_MAX_CHIPSELECT 16
>  
> +/* Quirks */
> +#define CQSPI_NEEDS_WR_DELAY BIT(0)
> +
>  struct cqspi_st;
>  
>  struct cqspi_flash_pdata {
> @@ -76,6 +79,7 @@ struct cqspi_st {
>   u32 fifo_depth;
>   u32 fifo_width;
>   u32 trigger_address;
> + u32 wr_delay;
>   struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT];
>  };
>  
> @@ -608,6 +612,15 @@ static int cqspi_indirect_write_execute(struct spi_nor 
> *nor,
>   reinit_completion(&cqspi->transfer_complete);
>   writel(CQSPI_REG_INDIRECTWR_START_MASK,
>  reg_base + CQSPI_REG_INDIRECTWR);
> + /*
> +  * As per 66AK2G02 TRM SPRUHY8F section 11.15.5.3 Indirect Access
> +  * Controller programming sequence, couple of cycles of
> +  * QSPI_REF_CLK delay is required for the above bit to
> +  * be internally synchronized by the QSPI module. Provide 5
> +  * cycles of delay.
> +  */
> + if (cqspi->wr_delay)
> + ndelay(cqspi->wr_delay);
>  
>   while (remaining > 0) {
>   write_bytes = remaining > page_size ? page_size : remaining;
> @@ -1156,6 +1169,7 @@ static int cqspi_probe(struct platform_device *pdev)
>   struct cqspi_st *cqspi;
>   struct resource *res;
>   struct resource *res_ahb;
> + unsigned long data;
>   int ret;
>   int irq;
>  
> @@ -1213,6 +1227,10 @@ static int cqspi_probe(struct platform_device *pdev)
>   }
>  
>   cqspi->master_ref_clk_hz = clk_get_rate(cqspi->clk);
> + data  = (unsigned long)of_device_get_match_data(dev);
> + if (data & CQSPI_NEEDS_WR_DELAY)
> + cqspi->wr_delay = 5 * DIV_ROUND_UP(NSEC_PER_SEC,
> +cqspi->master_ref_clk_hz);
>  
>   ret = devm_request_irq(dev, irq, cqspi_irq_handler, 0,
>  pdev->name, cqspi);
> @@ -1284,7 +1302,14 @@ static const struct dev_pm_ops cqspi__dev_pm_ops = {
>  #endif
>  
>  static const struct of_device_id cqspi_dt_ids[] = {
> - {.compatible = "cdns,qspi-nor",},
> + {
> + .compatible = "cdns,qspi-nor",
> + .data = (void *)0,
> + },
> + {
> + .compatible = "ti,k2g-qspi",
> + .data = (void *)CQSPI_NEEDS_WR_DELAY,
> + },
>   { /* end of table */ }
>  };
>  
> 


-- 
Best regards,
Marek Vasut


[PATCH] net: bcm63xx_enet: Use setup_timer and mod_timer

2017-09-24 Thread Himanshu Jha
Use setup_timer and mod_timer API instead of structure assignments.

This is done using Coccinelle and semantic patch used
for this as follows:

@@
expression x,y,z,a,b;
@@

-init_timer (&x);
+setup_timer (&x, y, z);
+mod_timer (&a, b);
-x.function = y;
-x.data = z;
-x.expires = b;
-add_timer(&a);

Signed-off-by: Himanshu Jha 
---
 drivers/net/ethernet/broadcom/bcm63xx_enet.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c 
b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index f8f..c6221f0 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -2331,11 +2331,8 @@ static int bcm_enetsw_open(struct net_device *dev)
}
 
/* start phy polling timer */
-   init_timer(&priv->swphy_poll);
-   priv->swphy_poll.function = swphy_poll_timer;
-   priv->swphy_poll.data = (unsigned long)priv;
-   priv->swphy_poll.expires = jiffies;
-   add_timer(&priv->swphy_poll);
+   setup_timer(&priv->swphy_poll, swphy_poll_timer, (unsigned long)priv);
+   mod_timer(&priv->swphy_poll, jiffies);
return 0;
 
 out:
-- 
2.7.4



Re: [PATCH 2/3] iio: trigger: stm32-timer: fix a corner case to write preset

2017-09-24 Thread Jonathan Cameron
On Mon, 18 Sep 2017 12:05:31 +0200
Fabrice Gasnier  wrote:

> Balance timer start routine that sets ARPE: clear it in stop routine.
> This fixes a corner case, when timer is used successively as trigger
> (with sampling_frequency start/stop routines), then as a counter
> (with preset).
> 
> Fixes: 93fbe91b5521 ("iio: Add STM32 timer trigger driver")
> 
> Signed-off-by: Fabrice Gasnier 

Applied to the fixes-togreg-post-rc1 branch of iio.git and
marked for stable.

Thanks,

Jonathan
> ---
>  drivers/iio/trigger/stm32-timer-trigger.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/trigger/stm32-timer-trigger.c 
> b/drivers/iio/trigger/stm32-timer-trigger.c
> index 34cc25b..eb212f8c 100644
> --- a/drivers/iio/trigger/stm32-timer-trigger.c
> +++ b/drivers/iio/trigger/stm32-timer-trigger.c
> @@ -174,6 +174,7 @@ static void stm32_timer_stop(struct stm32_timer_trigger 
> *priv)
>   clk_disable(priv->clk);
>  
>   /* Stop timer */
> + regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE, 0);
>   regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN, 0);
>   regmap_write(priv->regmap, TIM_PSC, 0);
>   regmap_write(priv->regmap, TIM_ARR, 0);



Re: [PATCH 1/3] iio: trigger: stm32-timer: preset shouldn't be buffered

2017-09-24 Thread Jonathan Cameron
On Mon, 18 Sep 2017 12:05:30 +0200
Fabrice Gasnier  wrote:

> Currently, setting preset value (ARR) will update directly 'Auto reload
> value' only on 1st write access. But then, ARPE is set. This makes
> ARR a shadow register. Preset value should be updated upon each
> write request: ensure ARPE is 0. This fixes successive writes to
> preset attribute.
> 
> Fixes: 4adec7da0536 ("iio: stm32 trigger: Add quadrature encoder device")
> 
> Signed-off-by: Fabrice Gasnier 

Applied to the fixes-togreg-post-rc1 branch of iio.git and marked
for stable.

Thanks,

Jonathan

> ---
>  drivers/iio/trigger/stm32-timer-trigger.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/trigger/stm32-timer-trigger.c 
> b/drivers/iio/trigger/stm32-timer-trigger.c
> index 9b90534..34cc25b 100644
> --- a/drivers/iio/trigger/stm32-timer-trigger.c
> +++ b/drivers/iio/trigger/stm32-timer-trigger.c
> @@ -715,8 +715,9 @@ static ssize_t stm32_count_set_preset(struct iio_dev 
> *indio_dev,
>   if (ret)
>   return ret;
>  
> + /* TIMx_ARR register shouldn't be buffered (ARPE=0) */
> + regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE, 0);
>   regmap_write(priv->regmap, TIM_ARR, preset);
> - regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE, TIM_CR1_ARPE);
>  
>   return len;
>  }



Re: [PATCH 3/3] iio: adc: twl4030: Return an error if we can not enable the vusb3v1 regulator in 'twl4030_madc_probe()'

2017-09-24 Thread Jonathan Cameron
On Sat, 23 Sep 2017 08:06:20 +0200
Christophe JAILLET  wrote:

> If we can not enable the regulator, go through the error handling path
> instead of silently continuing.
> 
> Fixes: 7cc97d77ee8a ("iio: adc: twl4030: Fix ADC[3:6] readings")
> Signed-off-by: Christophe JAILLET 

Applied to the fixes-togreg-post-rc1 branch of iio.git.

I haven't explicitly marked this one for stable as it isn't broken
as such, just inconsistent.

Thanks,

Jonathan
> ---
> This patch is highly speculative.
> I don't find logical to return an error if we don't find the 'vusb3v1'
> regulator, but continue if we find it, but can't enable it.
> Returning an error if both cases (i.e. failing 'devm_regulator_get()' or
> 'regulator_enable)' seems the usual pattern in all the .probe functions
> with a 'regulator_enable()' call have looked at (~ 10 of them taken
> randomly)
> ---
>  drivers/iio/adc/twl4030-madc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
> index 32db23d9a483..e3cfb91bffc6 100644
> --- a/drivers/iio/adc/twl4030-madc.c
> +++ b/drivers/iio/adc/twl4030-madc.c
> @@ -893,8 +893,10 @@ static int twl4030_madc_probe(struct platform_device 
> *pdev)
>   }
>  
>   ret = regulator_enable(madc->usb3v1);
> - if (ret)
> + if (ret) {
>   dev_err(madc->dev, "could not enable 3v1 bias regulator\n");
> + goto err_i2c;
> + }
>  
>   ret = iio_device_register(iio_dev);
>   if (ret) {



Re: [PATCH 2/3] iio: adc: twl4030: Disable the vusb3v1 rugulator in the error handling path of 'twl4030_madc_probe()'

2017-09-24 Thread Jonathan Cameron
On Sat, 23 Sep 2017 08:06:19 +0200
Christophe JAILLET  wrote:

> Commit 7cc97d77ee8a has introduced a call to 'regulator_disable()' in the
> .remove function.
> So we should also have such a call in the .probe function in case of
> error after a successful 'regulator_enable()' call.
> 
> Add a new label for that and use it.
> 
> Fixes: 7cc97d77ee8a ("iio: adc: twl4030: Fix ADC[3:6] readings")
> Signed-off-by: Christophe JAILLET 

Applied to the fixes-togreg-post-rc1 branch of iio.git and marked
for stable.

Thanks,

Jonathan
> ---
>  drivers/iio/adc/twl4030-madc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
> index 80ab2ed70b85..32db23d9a483 100644
> --- a/drivers/iio/adc/twl4030-madc.c
> +++ b/drivers/iio/adc/twl4030-madc.c
> @@ -899,11 +899,13 @@ static int twl4030_madc_probe(struct platform_device 
> *pdev)
>   ret = iio_device_register(iio_dev);
>   if (ret) {
>   dev_err(&pdev->dev, "could not register iio device\n");
> - goto err_i2c;
> + goto err_usb3v1;
>   }
>  
>   return 0;
>  
> +err_usb3v1:
> + regulator_disable(madc->usb3v1);
>  err_i2c:
>   twl4030_madc_set_current_generator(madc, 0, 0);
>  err_current_generator:



[PATCH] s390/sclp: Use setup_timer and mod_timer

2017-09-24 Thread Himanshu Jha
Use setup_timer and mod_timer API instead of structure assignments.

This is done using Coccinelle and semantic patch used
for this as follows:

@@
expression x,y,z,a,b;
@@

-init_timer (&x);
+setup_timer (&x, y, z);
+mod_timer (&a, b);
-x.function = y;
-x.data = z;
-x.expires = b;
-add_timer(&a);

Signed-off-by: Himanshu Jha 
---
 drivers/s390/char/sclp_con.c | 7 ++-
 drivers/s390/char/sclp_tty.c | 7 ++-
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/s390/char/sclp_con.c b/drivers/s390/char/sclp_con.c
index 6037bc8..9b5ac8f 100644
--- a/drivers/s390/char/sclp_con.c
+++ b/drivers/s390/char/sclp_con.c
@@ -210,11 +210,8 @@ sclp_console_write(struct console *console, const char 
*message,
/* Setup timer to output current console buffer after 1/10 second */
if (sclp_conbuf != NULL && sclp_chars_in_buffer(sclp_conbuf) != 0 &&
!timer_pending(&sclp_con_timer)) {
-   init_timer(&sclp_con_timer);
-   sclp_con_timer.function = sclp_console_timeout;
-   sclp_con_timer.data = 0UL;
-   sclp_con_timer.expires = jiffies + HZ/10;
-   add_timer(&sclp_con_timer);
+   setup_timer(&sclp_con_timer, sclp_console_timeout, 0UL);
+   mod_timer(&sclp_con_timer, jiffies + HZ / 10);
}
 out:
spin_unlock_irqrestore(&sclp_con_lock, flags);
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
index 236b736..469487e 100644
--- a/drivers/s390/char/sclp_tty.c
+++ b/drivers/s390/char/sclp_tty.c
@@ -217,11 +217,8 @@ static int sclp_tty_write_string(const unsigned char *str, 
int count, int may_fa
/* Setup timer to output current console buffer after 1/10 second */
if (sclp_ttybuf && sclp_chars_in_buffer(sclp_ttybuf) &&
!timer_pending(&sclp_tty_timer)) {
-   init_timer(&sclp_tty_timer);
-   sclp_tty_timer.function = sclp_tty_timeout;
-   sclp_tty_timer.data = 0UL;
-   sclp_tty_timer.expires = jiffies + HZ/10;
-   add_timer(&sclp_tty_timer);
+   setup_timer(&sclp_tty_timer, sclp_tty_timeout, 0UL);
+   mod_timer(&sclp_tty_timer, jiffies + HZ / 10);
}
spin_unlock_irqrestore(&sclp_tty_lock, flags);
 out:
-- 
2.7.4



Re: [PATCH 1/3] iio: adc: twl4030: Fix an error handling path in 'twl4030_madc_probe()'

2017-09-24 Thread Jonathan Cameron
On Sat, 23 Sep 2017 08:06:18 +0200
Christophe JAILLET  wrote:

> If 'devm_regulator_get()' fails, we should go through the existing error
> handling path instead of returning directly, as done is all the other
> error handling paths in this function.
> 
> Fixes: 7cc97d77ee8a ("iio: adc: twl4030: Fix ADC[3:6] readings")
> Signed-off-by: Christophe JAILLET 
Applied to the fixes-togreg-post-rc1 branch of iio.git and marked
for stable. 

Thanks,

Jonathan
> ---
>  drivers/iio/adc/twl4030-madc.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
> index 1edd99f0c5e5..80ab2ed70b85 100644
> --- a/drivers/iio/adc/twl4030-madc.c
> +++ b/drivers/iio/adc/twl4030-madc.c
> @@ -887,8 +887,10 @@ static int twl4030_madc_probe(struct platform_device 
> *pdev)
>  
>   /* Enable 3v1 bias regulator for MADC[3:6] */
>   madc->usb3v1 = devm_regulator_get(madc->dev, "vusb3v1");
> - if (IS_ERR(madc->usb3v1))
> - return -ENODEV;
> + if (IS_ERR(madc->usb3v1)) {
> + ret = -ENODEV;
> + goto err_i2c;
> + }
>  
>   ret = regulator_enable(madc->usb3v1);
>   if (ret)



[PATCH] IB/qib: Use setup_timer and mod_timer

2017-09-24 Thread Himanshu Jha
Use setup_timer and mod_timer API instead of structure assignments.

This is done using Coccinelle and semantic patch used
for this as follows:

@@
expression x,y,z,a,b;
@@

-init_timer (&x);
+setup_timer (&x, y, z);
+mod_timer (&a, b);
-x.function = y;
-x.data = z;
-x.expires = b;
-add_timer(&a);

Signed-off-by: Himanshu Jha 
---
 drivers/infiniband/hw/qib/qib_driver.c |  8 +++-
 drivers/infiniband/hw/qib/qib_mad.c| 10 --
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_driver.c 
b/drivers/infiniband/hw/qib/qib_driver.c
index 719906a..2314e8a 100644
--- a/drivers/infiniband/hw/qib/qib_driver.c
+++ b/drivers/infiniband/hw/qib/qib_driver.c
@@ -735,11 +735,9 @@ void qib_set_led_override(struct qib_pportdata *ppd, 
unsigned int val)
 */
if (atomic_inc_return(&ppd->led_override_timer_active) == 1) {
/* Need to start timer */
-   init_timer(&ppd->led_override_timer);
-   ppd->led_override_timer.function = qib_run_led_override;
-   ppd->led_override_timer.data = (unsigned long) ppd;
-   ppd->led_override_timer.expires = jiffies + 1;
-   add_timer(&ppd->led_override_timer);
+   setup_timer(&ppd->led_override_timer, qib_run_led_override,
+   (unsigned long)ppd);
+   mod_timer(&ppd->led_override_timer, jiffies + 1);
} else {
if (ppd->led_override_vals[0] || ppd->led_override_vals[1])
mod_timer(&ppd->led_override_timer, jiffies + 1);
diff --git a/drivers/infiniband/hw/qib/qib_mad.c 
b/drivers/infiniband/hw/qib/qib_mad.c
index 82d9da9..1237952 100644
--- a/drivers/infiniband/hw/qib/qib_mad.c
+++ b/drivers/infiniband/hw/qib/qib_mad.c
@@ -2478,12 +2478,10 @@ void qib_notify_create_mad_agent(struct rvt_dev_info 
*rdi, int port_idx)
 
/* Initialize xmit_wait structure */
dd->pport[port_idx].cong_stats.counter = 0;
-   init_timer(&dd->pport[port_idx].cong_stats.timer);
-   dd->pport[port_idx].cong_stats.timer.function = xmit_wait_timer_func;
-   dd->pport[port_idx].cong_stats.timer.data =
-   (unsigned long)(&dd->pport[port_idx]);
-   dd->pport[port_idx].cong_stats.timer.expires = 0;
-   add_timer(&dd->pport[port_idx].cong_stats.timer);
+   setup_timer(&dd->pport[port_idx].cong_stats.timer,
+   xmit_wait_timer_func,
+   (unsigned long)(&dd->pport[port_idx]));
+   mod_timer(&dd->pport[port_idx].cong_stats.timer, 0);
 }
 
 void qib_notify_free_mad_agent(struct rvt_dev_info *rdi, int port_idx)
-- 
2.7.4



Re: [PATCH net-next 10/10] net: hns3: Add mqprio support when interacting with network stack

2017-09-24 Thread Jiri Pirko
Sat, Sep 23, 2017 at 02:47:20AM CEST, linyunsh...@huawei.com wrote:
>Hi, Jiri
>
>On 2017/9/23 0:03, Jiri Pirko wrote:
>> Fri, Sep 22, 2017 at 04:11:51PM CEST, linyunsh...@huawei.com wrote:
>>> Hi, Jiri
>>>
> - if (!tc) {
> + if (if_running) {
> + (void)hns3_nic_net_stop(netdev);
> + msleep(100);
> + }
> +
> + ret = (kinfo->dcb_ops && kinfo->dcb_ops->>setup_tc) ?
> + kinfo->dcb_ops->setup_tc(h, tc, prio_tc) : ->EOPNOTSUPP;
>>>
 This is most odd. Why do you call dcb_ops from >ndo_setup_tc callback?
 Why are you mixing this together? prio->tc mapping >can be done
 directly in dcbnl
>>>
>>> Here is what we do in dcb_ops->setup_tc:
>>> Firstly, if current tc num is different from the tc num
>>> that user provide, then we setup the queues for each
>>> tc.
>>>
>>> Secondly, we tell hardware the pri to tc mapping that
>>> the stack is using. In rx direction, our hardware need
>>> that mapping to put different packet into different tc'
>>> queues according to the priority of the packet, then
>>> rss decides which specific queue in the tc should the
>>> packet goto.
>>>
>>> By mixing, I suppose you meant why we need the
>>> pri to tc infomation?
>> 
>> by mixing, I mean what I wrote. You are calling dcb_ops callback from
>> ndo_setup_tc callback. So you are mixing DCBNL subsystem and TC
>> subsystem. Why? Why do you need sch_mqprio? Why DCBNL is not enough for
>> all?
>
>When using lldptool, dcbnl is involved.
>
>But when using tc qdisc, dcbbl is not involved, below is the a few key
>call graph in the kernel when tc qdisc cmd is executed.
>
>cmd:
>tc qdisc add dev eth0 root handle 1:0 mqprio num_tc 4 map 1 2 3 3 1 3 1 1 hw 1
>
>call graph:
>rtnetlink_rcv_msg -> tc_modify_qdisc -> qdisc_create -> mqprio_init ->
>hns3_nic_setup_tc
>
>When hns3_nic_setup_tc is called, we need to know how many tc num and
>prio_tc mapping from the tc_mqprio_qopt which is provided in the paramter
>in the ndo_setup_tc function, and dcb_ops is the our hardware specific
>method to setup the tc related parameter to the hardware, so this is why
>we call dcb_ops callback in ndo_setup_tc callback.
>
>I hope this will answer your question, thanks for your time.

Okay. I understand that you have a usecase for mqprio mapping offload
without lldptool being involved. Ok. I believe it is wrong to call dcb_ops
from tc callback. You should have a generic layer inside the driver and
call it from both dcb_ops and tc callbacks.

Also, what happens If I run lldptool concurrently with mqprio? Who wins
and is going to configure the mapping?


>
>> 
>> 
>> 
>>> I hope I did not misunderstand your question, thanks
>>> for your time reviewing.
>> 
>> .
>> 
>


[GIT PULL] x86 fixes

2017-09-24 Thread Ingo Molnar
Linus,

Please pull the latest x86-urgent-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
x86-urgent-for-linus

   # HEAD: f5caf621ee357279e759c0911daf6d55c7d36f03 x86/asm: Fix inline asm 
call constraints for Clang

Another round of CR3/PCID related fixes (I think this addresses all but one of 
the 
known problems with PCID support), an objtool fix plus a Clang fix that 
(finally) 
solves all Clang quirks to build a bootable x86 kernel as-is.


  out-of-topic modifications in x86-urgent-for-linus:
  -
  tools/objtool/check.c  # 0d0970eef3b0: objtool: Handle another 
GCC 

 Thanks,

Ingo

-->
Andy Lutomirski (4):
  x86/mm: Factor out CR3-building code
  x86/mm/64: Stop using CR3.PCID == 0 in ASID-aware code
  x86/mm/32: Move setup_clear_cpu_cap(X86_FEATURE_PCID) earlier
  x86/mm/32: Load a sane CR3 before cpu_init() on secondary CPUs

Josh Poimboeuf (2):
  objtool: Handle another GCC stack pointer adjustment bug
  x86/asm: Fix inline asm call constraints for Clang


 arch/x86/include/asm/alternative.h   |  3 +-
 arch/x86/include/asm/asm.h   | 11 ++
 arch/x86/include/asm/mmu_context.h   | 32 +++---
 arch/x86/include/asm/mshyperv.h  | 10 +++---
 arch/x86/include/asm/paravirt_types.h| 14 
 arch/x86/include/asm/preempt.h   | 15 +++--
 arch/x86/include/asm/processor.h |  6 ++--
 arch/x86/include/asm/rwsem.h |  4 +--
 arch/x86/include/asm/uaccess.h   |  4 +--
 arch/x86/include/asm/xen/hypercall.h |  5 ++-
 arch/x86/kernel/cpu/bugs.c   |  8 -
 arch/x86/kernel/cpu/common.c |  8 +
 arch/x86/kernel/smpboot.c| 13 +++
 arch/x86/kvm/emulate.c   |  3 +-
 arch/x86/kvm/vmx.c   |  3 +-
 arch/x86/mm/fault.c  |  3 +-
 arch/x86/mm/tlb.c| 11 +++---
 tools/objtool/Documentation/stack-validation.txt |  6 ++--
 tools/objtool/arch/x86/decode.c  |  6 ++--
 tools/objtool/check.c| 43 
 20 files changed, 122 insertions(+), 86 deletions(-)

diff --git a/arch/x86/include/asm/alternative.h 
b/arch/x86/include/asm/alternative.h
index 1b020381ab38..c096624137ae 100644
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -218,10 +218,9 @@ static inline int alternatives_text_reserved(void *start, 
void *end)
 #define alternative_call_2(oldfunc, newfunc1, feature1, newfunc2, feature2,   \
   output, input...)  \
 {\
-   register void *__sp asm(_ASM_SP); \
asm volatile (ALTERNATIVE_2("call %P[old]", "call %P[new1]", feature1,\
"call %P[new2]", feature2)\
-   : output, "+r" (__sp) \
+   : output, ASM_CALL_CONSTRAINT \
: [old] "i" (oldfunc), [new1] "i" (newfunc1), \
  [new2] "i" (newfunc2), ## input);   \
 }
diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h
index 676ee5807d86..c1eadbaf1115 100644
--- a/arch/x86/include/asm/asm.h
+++ b/arch/x86/include/asm/asm.h
@@ -132,4 +132,15 @@
 /* For C file, we already have NOKPROBE_SYMBOL macro */
 #endif
 
+#ifndef __ASSEMBLY__
+/*
+ * This output constraint should be used for any inline asm which has a "call"
+ * instruction.  Otherwise the asm may be inserted before the frame pointer
+ * gets set up by the containing function.  If you forget to do this, objtool
+ * may print a "call without frame pointer save/setup" warning.
+ */
+register unsigned int __asm_call_sp asm("esp");
+#define ASM_CALL_CONSTRAINT "+r" (__asm_call_sp)
+#endif
+
 #endif /* _ASM_X86_ASM_H */
diff --git a/arch/x86/include/asm/mmu_context.h 
b/arch/x86/include/asm/mmu_context.h
index 7ae318c340d9..c120b5db178a 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -286,6 +286,32 @@ static inline bool arch_vma_access_permitted(struct 
vm_area_struct *vma,
return __pkru_allows_pkey(vma_pkey(vma), write);
 }
 
+/*
+ * If PCID is on, ASID-aware code paths put the ASID+1 into the PCID
+ * bits.  This serves two purposes.  It prevents a nasty situation in
+ * which PCID-unaware code saves CR3, loads some other value (with PCID
+ * == 0), and then restores CR3, thus corrupting the TLB for ASID 0 if
+ * the saved ASID was nonzero.  It also means that any bugs involving
+ * lo

[GIT PULL] timer fix

2017-09-24 Thread Ingo Molnar
Linus,

Please pull the latest timers-urgent-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
timers-urgent-for-linus

   # HEAD: 8fce3dc5c5d6f6301f67311fa79f333902b58cea clocksource/integrator: Fix 
section mismatch warning

A clocksource driver section mismatch fix.

 Thanks,

Ingo

-->
Arnd Bergmann (1):
  clocksource/integrator: Fix section mismatch warning


 drivers/clocksource/timer-integrator-ap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/timer-integrator-ap.c 
b/drivers/clocksource/timer-integrator-ap.c
index 2ff64d9d4fb3..62d24690ba02 100644
--- a/drivers/clocksource/timer-integrator-ap.c
+++ b/drivers/clocksource/timer-integrator-ap.c
@@ -36,8 +36,8 @@ static u64 notrace integrator_read_sched_clock(void)
return -readl(sched_clk_base + TIMER_VALUE);
 }
 
-static int integrator_clocksource_init(unsigned long inrate,
-  void __iomem *base)
+static int __init integrator_clocksource_init(unsigned long inrate,
+ void __iomem *base)
 {
u32 ctrl = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC;
unsigned long rate = inrate;


[GIT PULL] IRQ fixes

2017-09-24 Thread Ingo Molnar
Linus,

Please pull the latest irq-urgent-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
irq-urgent-for-linus

   # HEAD: cf00ab842eec7cd4923a3f0f3b5ddcead9b11306 Merge tag 'irqchip-4.14-2' 
of git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms into 
irq/urgent

Three irqchip driver fixes, and an affinity mask helper function bug fix 
affecting 
x86.

 Thanks,

Ingo

-->
Arnd Bergmann (1):
  irqchip/gic-v4: Fix building with ancient gcc

Paul Burton (1):
  irqchip.mips-gic: Fix shared interrupt mask writes

Thomas Gleixner (1):
  Revert "genirq: Restrict effective affinity to interrupts actually using 
it"

zijun_hu (1):
  irqchip/gic-v3: Iterate over possible CPUs by for_each_possible_cpu()


 drivers/irqchip/irq-gic-v3.c   |  8 
 drivers/irqchip/irq-gic-v4.c   | 12 +---
 drivers/irqchip/irq-mips-gic.c |  6 +++---
 include/linux/irq.h|  5 +
 4 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index 519149ec9053..b5df99c6f680 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -1042,7 +1042,7 @@ static int get_cpu_number(struct device_node *dn)
 {
const __be32 *cell;
u64 hwid;
-   int i;
+   int cpu;
 
cell = of_get_property(dn, "reg", NULL);
if (!cell)
@@ -1056,9 +1056,9 @@ static int get_cpu_number(struct device_node *dn)
if (hwid & ~MPIDR_HWID_BITMASK)
return -1;
 
-   for (i = 0; i < num_possible_cpus(); i++)
-   if (cpu_logical_map(i) == hwid)
-   return i;
+   for_each_possible_cpu(cpu)
+   if (cpu_logical_map(cpu) == hwid)
+   return cpu;
 
return -1;
 }
diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c
index 2370e6d9e603..cd0bcc3b7e33 100644
--- a/drivers/irqchip/irq-gic-v4.c
+++ b/drivers/irqchip/irq-gic-v4.c
@@ -173,7 +173,9 @@ int its_map_vlpi(int irq, struct its_vlpi_map *map)
 {
struct its_cmd_info info = {
.cmd_type = MAP_VLPI,
-   .map  = map,
+   {
+   .map  = map,
+   },
};
 
/*
@@ -189,7 +191,9 @@ int its_get_vlpi(int irq, struct its_vlpi_map *map)
 {
struct its_cmd_info info = {
.cmd_type = GET_VLPI,
-   .map  = map,
+   {
+   .map  = map,
+   },
};
 
return irq_set_vcpu_affinity(irq, &info);
@@ -205,7 +209,9 @@ int its_prop_update_vlpi(int irq, u8 config, bool inv)
 {
struct its_cmd_info info = {
.cmd_type = inv ? PROP_UPDATE_AND_INV_VLPI : PROP_UPDATE_VLPI,
-   .config   = config,
+   {
+   .config   = config,
+   },
};
 
return irq_set_vcpu_affinity(irq, &info);
diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
index 6e52a88bbd9e..40159ac12ac8 100644
--- a/drivers/irqchip/irq-mips-gic.c
+++ b/drivers/irqchip/irq-mips-gic.c
@@ -169,7 +169,7 @@ static void gic_mask_irq(struct irq_data *d)
 {
unsigned int intr = GIC_HWIRQ_TO_SHARED(d->hwirq);
 
-   write_gic_rmask(BIT(intr));
+   write_gic_rmask(intr);
gic_clear_pcpu_masks(intr);
 }
 
@@ -179,7 +179,7 @@ static void gic_unmask_irq(struct irq_data *d)
unsigned int intr = GIC_HWIRQ_TO_SHARED(d->hwirq);
unsigned int cpu;
 
-   write_gic_smask(BIT(intr));
+   write_gic_smask(intr);
 
gic_clear_pcpu_masks(intr);
cpu = cpumask_first_and(affinity, cpu_online_mask);
@@ -767,7 +767,7 @@ static int __init gic_of_init(struct device_node *node,
for (i = 0; i < gic_shared_intrs; i++) {
change_gic_pol(i, GIC_POL_ACTIVE_HIGH);
change_gic_trig(i, GIC_TRIG_LEVEL);
-   write_gic_rmask(BIT(i));
+   write_gic_rmask(i);
}
 
for (i = 0; i < gic_vpes; i++) {
diff --git a/include/linux/irq.h b/include/linux/irq.h
index b99a784635ff..d4728bf6a537 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -783,10 +783,7 @@ static inline struct cpumask 
*irq_data_get_affinity_mask(struct irq_data *d)
 static inline
 struct cpumask *irq_data_get_effective_affinity_mask(struct irq_data *d)
 {
-   if (!cpumask_empty(d->common->effective_affinity))
-   return d->common->effective_affinity;
-
-   return d->common->affinity;
+   return d->common->effective_affinity;
 }
 static inline void irq_data_update_effective_affinity(struct irq_data *d,
  const struct cpumask *m)


[GIT PULL] syscall-return address-limit checking fixes

2017-09-24 Thread Ingo Molnar
Linus,

Please pull the latest core-urgent-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
core-urgent-for-linus

   # HEAD: a2048e34d4655c06d31400646ae495bbfeb16b27 arm64/syscalls: Move 
address limit check in loop

This fixes a number of bugs in the address-limit (USER_DS) checks that got 
introduced in the merge window, (mostly) affecting the ARM and ARM64 platforms.

 Thanks,

Ingo

-->
Thomas Garnier (4):
  syscalls: Use CHECK_DATA_CORRUPTION for addr_limit_user_check
  Revert "arm/syscalls: Check address limit on user-mode return"
  arm/syscalls: Optimize address limit check
  arm64/syscalls: Move address limit check in loop


 arch/arm/include/asm/thread_info.h | 15 ++-
 arch/arm/include/asm/uaccess.h |  2 --
 arch/arm/kernel/entry-common.S | 20 +---
 arch/arm/kernel/signal.c   | 10 ++
 arch/arm64/kernel/signal.c |  6 +++---
 include/linux/syscalls.h   | 12 
 6 files changed, 36 insertions(+), 29 deletions(-)

diff --git a/arch/arm/include/asm/thread_info.h 
b/arch/arm/include/asm/thread_info.h
index 1d468b527b7b..776757d1604a 100644
--- a/arch/arm/include/asm/thread_info.h
+++ b/arch/arm/include/asm/thread_info.h
@@ -139,11 +139,10 @@ extern int vfp_restore_user_hwstate(struct user_vfp 
__user *,
 #define TIF_NEED_RESCHED   1   /* rescheduling necessary */
 #define TIF_NOTIFY_RESUME  2   /* callback before returning to user */
 #define TIF_UPROBE 3   /* breakpointed or singlestepping */
-#define TIF_FSCHECK4   /* Check FS is USER_DS on return */
-#define TIF_SYSCALL_TRACE  5   /* syscall trace active */
-#define TIF_SYSCALL_AUDIT  6   /* syscall auditing active */
-#define TIF_SYSCALL_TRACEPOINT 7   /* syscall tracepoint instrumentation */
-#define TIF_SECCOMP8   /* seccomp syscall filtering active */
+#define TIF_SYSCALL_TRACE  4   /* syscall trace active */
+#define TIF_SYSCALL_AUDIT  5   /* syscall auditing active */
+#define TIF_SYSCALL_TRACEPOINT 6   /* syscall tracepoint instrumentation */
+#define TIF_SECCOMP7   /* seccomp syscall filtering active */
 
 #define TIF_NOHZ   12  /* in adaptive nohz mode */
 #define TIF_USING_IWMMXT   17
@@ -154,7 +153,6 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user 
*,
 #define _TIF_NEED_RESCHED  (1 << TIF_NEED_RESCHED)
 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
 #define _TIF_UPROBE(1 << TIF_UPROBE)
-#define _TIF_FSCHECK   (1 << TIF_FSCHECK)
 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
 #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
 #define _TIF_SYSCALL_TRACEPOINT(1 << TIF_SYSCALL_TRACEPOINT)
@@ -168,9 +166,8 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user 
*,
 /*
  * Change these and you break ASM code in entry-common.S
  */
-#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING |  \
-_TIF_NOTIFY_RESUME | _TIF_UPROBE | \
-_TIF_FSCHECK)
+#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
+_TIF_NOTIFY_RESUME | _TIF_UPROBE)
 
 #endif /* __KERNEL__ */
 #endif /* __ASM_ARM_THREAD_INFO_H */
diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index 87936dd5d151..0bf2347495f1 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -70,8 +70,6 @@ static inline void set_fs(mm_segment_t fs)
 {
current_thread_info()->addr_limit = fs;
modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
-   /* On user-mode return, check fs is correct */
-   set_thread_flag(TIF_FSCHECK);
 }
 
 #define segment_eq(a, b)   ((a) == (b))
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index ca3614dc6938..99c908226065 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #ifdef CONFIG_AEABI
 #include 
 #endif
@@ -48,12 +49,14 @@ saved_pc.reqlr
  UNWIND(.fnstart   )
  UNWIND(.cantunwind)
disable_irq_notrace @ disable interrupts
+   ldr r2, [tsk, #TI_ADDR_LIMIT]
+   cmp r2, #TASK_SIZE
+   blneaddr_limit_check_failed
ldr r1, [tsk, #TI_FLAGS]@ re-check for syscall tracing
-   tst r1, #_TIF_SYSCALL_WORK
-   bne fast_work_pending
-   tst r1, #_TIF_WORK_MASK
+   tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
bne fast_work_pending
 
+
/* perform architecture specific actions before user return */
arch_ret_to_user r1, lr
 
@@ -76,16 +79,16 @@ ENDPROC(ret_fast_syscall)
  UNWIND(.cantunwind)
str r0, [sp, #S_R0 + 

[PATCH v2 4/4] Make all print functions receive the fp argument, and opens a dump file in process_event.

2017-09-24 Thread yuzhoujian
Signed-off-by: yuzhoujian 
---
 tools/perf/builtin-script.c | 401 
 1 file changed, 217 insertions(+), 184 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 271dfc4..4891719 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -57,6 +57,8 @@
 static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
 static struct perf_stat_config stat_config;
 static int max_blocks;
+static FILE*per_event_dump_file;
+static const char  *file_name;
 
 unsigned int scripting_max_stack = PERF_MAX_STACK_DEPTH;
 
@@ -501,7 +503,7 @@ static int perf_session__check_output_opt(struct 
perf_session *session)
 }
 
 static void fprint_sample_iregs(struct perf_sample *sample,
- struct perf_event_attr *attr, FILE *fp __maybe_unused)
+ struct perf_event_attr *attr, FILE *fp)
 {
struct regs_dump *regs = &sample->intr_regs;
uint64_t mask = attr->sample_regs_intr;
@@ -512,12 +514,12 @@ static void fprint_sample_iregs(struct perf_sample 
*sample,
 
for_each_set_bit(r, (unsigned long *) &mask, sizeof(mask) * 8) {
u64 val = regs->regs[i++];
-   fprintf(stdout, "%5s:0x%"PRIx64" ", perf_reg_name(r), val);
+   fprintf(fp, "%5s:0x%"PRIx64" ", perf_reg_name(r), val);
}
 }
 
 static void fprint_sample_uregs(struct perf_sample *sample,
- struct perf_event_attr *attr, FILE *fp __maybe_unused)
+ struct perf_event_attr *attr, FILE *fp)
 {
struct regs_dump *regs = &sample->user_regs;
uint64_t mask = attr->sample_regs_user;
@@ -526,17 +528,17 @@ static void fprint_sample_uregs(struct perf_sample 
*sample,
if (!regs || !regs->regs)
return;
 
-   fprintf(stdout, " ABI:%" PRIu64 " ", regs->abi);
+   fprintf(fp, " ABI:%" PRIu64 " ", regs->abi);
 
for_each_set_bit(r, (unsigned long *) &mask, sizeof(mask) * 8) {
u64 val = regs->regs[i++];
-   fprintf(stdout, "%5s:0x%"PRIx64" ", perf_reg_name(r), val);
+   fprintf(fp, "%5s:0x%"PRIx64" ", perf_reg_name(r), val);
}
 }
 
 static void fprint_sample_start(struct perf_sample *sample,
   struct thread *thread,
-  struct perf_evsel *evsel, FILE *fp 
__maybe_unused)
+  struct perf_evsel *evsel, FILE *fp)
 {
struct perf_event_attr *attr = &evsel->attr;
unsigned long secs;
@@ -544,25 +546,25 @@ static void fprint_sample_start(struct perf_sample 
*sample,
 
if (PRINT_FIELD(COMM)) {
if (latency_format)
-   fprintf(stdout, "%8.8s ", thread__comm_str(thread));
+   fprintf(fp, "%8.8s ", thread__comm_str(thread));
else if (PRINT_FIELD(IP) && symbol_conf.use_callchain)
-   fprintf(stdout, "%s ", thread__comm_str(thread));
+   fprintf(fp, "%s ", thread__comm_str(thread));
else
-   fprintf(stdout, "%16s ", thread__comm_str(thread));
+   fprintf(fp, "%16s ", thread__comm_str(thread));
}
 
if (PRINT_FIELD(PID) && PRINT_FIELD(TID))
-   fprintf(stdout, "%5d/%-5d ", sample->pid, sample->tid);
+   fprintf(fp, "%5d/%-5d ", sample->pid, sample->tid);
else if (PRINT_FIELD(PID))
-   fprintf(stdout, "%5d ", sample->pid);
+   fprintf(fp, "%5d ", sample->pid);
else if (PRINT_FIELD(TID))
-   fprintf(stdout, "%5d ", sample->tid);
+   fprintf(fp, "%5d ", sample->tid);
 
if (PRINT_FIELD(CPU)) {
if (latency_format)
-   fprintf(stdout, "%3d ", sample->cpu);
+   fprintf(fp, "%3d ", sample->cpu);
else
-   fprintf(stdout, "[%03d] ", sample->cpu);
+   fprintf(fp, "[%03d] ", sample->cpu);
}
 
if (PRINT_FIELD(TIME)) {
@@ -571,11 +573,11 @@ static void fprint_sample_start(struct perf_sample 
*sample,
nsecs -= secs * NSEC_PER_SEC;
 
if (nanosecs)
-   fprintf(stdout, "%5lu.%09llu: ", secs, nsecs);
+   fprintf(fp, "%5lu.%09llu: ", secs, nsecs);
else {
char sample_time[32];
timestamp__scnprintf_usec(sample->time, sample_time, 
sizeof(sample_time));
-   fprintf(stdout, "%12s: ", sample_time);
+   fprintf(fp, "%12s: ", sample_time);
}
}
 }
@@ -592,7 +594,7 @@ static void fprint_sample_start(struct perf_sample *sample,
 static void fprint_sample_brstack(struct perf_sample *sample,
 struct thread *thread,

[PATCH v2 1/4] Add a new element for the struct perf_tool, and add the --per-event-dump option for perf script

2017-09-24 Thread yuzhoujian
Signed-off-by: yuzhoujian 
---
 tools/perf/builtin-script.c | 3 +++
 tools/perf/util/tool.h  | 1 +
 2 files changed, 4 insertions(+)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 9092de0..936af8b 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -2729,6 +2729,7 @@ int cmd_script(int argc, const char **argv)
.cpu_map = process_cpu_map_event,
.ordered_events  = true,
.ordering_requires_timestamps = true,
+   .per_event_dump = false,
},
};
struct perf_data_file file = {
@@ -2799,6 +2800,8 @@ int cmd_script(int argc, const char **argv)
"Show context switch events (if recorded)"),
OPT_BOOLEAN('\0', "show-namespace-events", 
&script.show_namespace_events,
"Show namespace events (if recorded)"),
+   OPT_BOOLEAN('\0', "per-event-dump", &script.tool.per_event_dump,
+   "print trace output to files named by the monitored 
events"),
OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
OPT_INTEGER(0, "max-blocks", &max_blocks,
"Maximum number of code blocks to dump with brstackinsn"),
diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h
index d549e50..ad40931 100644
--- a/tools/perf/util/tool.h
+++ b/tools/perf/util/tool.h
@@ -75,6 +75,7 @@ struct perf_tool {
boolordered_events;
boolordering_requires_timestamps;
boolnamespace_events;
+   boolper_event_dump;
enum show_feature_header show_feat_hdr;
 };
 
-- 
1.8.3.1



[PATCH v2 2/4] Add fp argument to print functions

2017-09-24 Thread yuzhoujian
Signed-off-by: yuzhoujian 
---
 tools/perf/builtin-script.c | 190 +++-
 1 file changed, 100 insertions(+), 90 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 936af8b..065bea7 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -500,8 +500,8 @@ static int perf_session__check_output_opt(struct 
perf_session *session)
return 0;
 }
 
-static void print_sample_iregs(struct perf_sample *sample,
- struct perf_event_attr *attr)
+static void fprint_sample_iregs(struct perf_sample *sample,
+ struct perf_event_attr *attr, FILE *fp __maybe_unused)
 {
struct regs_dump *regs = &sample->intr_regs;
uint64_t mask = attr->sample_regs_intr;
@@ -516,8 +516,8 @@ static void print_sample_iregs(struct perf_sample *sample,
}
 }
 
-static void print_sample_uregs(struct perf_sample *sample,
- struct perf_event_attr *attr)
+static void fprint_sample_uregs(struct perf_sample *sample,
+ struct perf_event_attr *attr, FILE *fp __maybe_unused)
 {
struct regs_dump *regs = &sample->user_regs;
uint64_t mask = attr->sample_regs_user;
@@ -534,9 +534,9 @@ static void print_sample_uregs(struct perf_sample *sample,
}
 }
 
-static void print_sample_start(struct perf_sample *sample,
+static void fprint_sample_start(struct perf_sample *sample,
   struct thread *thread,
-  struct perf_evsel *evsel)
+  struct perf_evsel *evsel, FILE *fp 
__maybe_unused)
 {
struct perf_event_attr *attr = &evsel->attr;
unsigned long secs;
@@ -589,9 +589,10 @@ static void print_sample_start(struct perf_sample *sample,
return br->flags.predicted ? 'P' : 'M';
 }
 
-static void print_sample_brstack(struct perf_sample *sample,
+static void fprint_sample_brstack(struct perf_sample *sample,
 struct thread *thread,
-struct perf_event_attr *attr)
+struct perf_event_attr *attr,
+FILE *fp __maybe_unused)
 {
struct branch_stack *br = sample->branch_stack;
struct addr_location alf, alt;
@@ -633,9 +634,10 @@ static void print_sample_brstack(struct perf_sample 
*sample,
}
 }
 
-static void print_sample_brstacksym(struct perf_sample *sample,
+static void fprint_sample_brstacksym(struct perf_sample *sample,
struct thread *thread,
-   struct perf_event_attr *attr)
+   struct perf_event_attr *attr,
+   FILE *fp __maybe_unused)
 {
struct branch_stack *br = sample->branch_stack;
struct addr_location alf, alt;
@@ -680,9 +682,10 @@ static void print_sample_brstacksym(struct perf_sample 
*sample,
}
 }
 
-static void print_sample_brstackoff(struct perf_sample *sample,
+static void fprint_sample_brstackoff(struct perf_sample *sample,
struct thread *thread,
-   struct perf_event_attr *attr)
+   struct perf_event_attr *attr,
+   FILE *fp __maybe_unused)
 {
struct branch_stack *br = sample->branch_stack;
struct addr_location alf, alt;
@@ -789,9 +792,9 @@ static int grab_bb(u8 *buffer, u64 start, u64 end,
return len;
 }
 
-static void print_jump(uint64_t ip, struct branch_entry *en,
+static void fprint_jump(uint64_t ip, struct branch_entry *en,
   struct perf_insn *x, u8 *inbuf, int len,
-  int insn)
+  int insn, FILE *fp __maybe_unused)
 {
printf("\t%016" PRIx64 "\t%-30s\t#%s%s%s%s",
   ip,
@@ -808,9 +811,10 @@ static void print_jump(uint64_t ip, struct branch_entry 
*en,
putchar('\n');
 }
 
-static void print_ip_sym(struct thread *thread, u8 cpumode, int cpu,
+static void fprint_ip_sym(struct thread *thread, u8 cpumode, int cpu,
 uint64_t addr, struct symbol **lastsym,
-struct perf_event_attr *attr)
+struct perf_event_attr *attr,
+FILE *fp __maybe_unused)
 {
struct addr_location al;
int off;
@@ -846,10 +850,11 @@ static void print_ip_sym(struct thread *thread, u8 
cpumode, int cpu,
*lastsym = al.sym;
 }
 
-static void print_sample_brstackinsn(struct perf_sample *sample,
+static void fprint_sample_brstackinsn(struct perf_sample *sample,
 struct thread *thread,
 struct perf_event_attr *attr,
-struct machine *machine)
+struct machine *ma

[PATCH v2 3/4] Replace printf with fprintf for all print functions

2017-09-24 Thread yuzhoujian
Signed-off-by: yuzhoujian 
---
 tools/perf/builtin-script.c | 178 ++--
 1 file changed, 89 insertions(+), 89 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 065bea7..271dfc4 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -512,7 +512,7 @@ static void fprint_sample_iregs(struct perf_sample *sample,
 
for_each_set_bit(r, (unsigned long *) &mask, sizeof(mask) * 8) {
u64 val = regs->regs[i++];
-   printf("%5s:0x%"PRIx64" ", perf_reg_name(r), val);
+   fprintf(stdout, "%5s:0x%"PRIx64" ", perf_reg_name(r), val);
}
 }
 
@@ -526,11 +526,11 @@ static void fprint_sample_uregs(struct perf_sample 
*sample,
if (!regs || !regs->regs)
return;
 
-   printf(" ABI:%" PRIu64 " ", regs->abi);
+   fprintf(stdout, " ABI:%" PRIu64 " ", regs->abi);
 
for_each_set_bit(r, (unsigned long *) &mask, sizeof(mask) * 8) {
u64 val = regs->regs[i++];
-   printf("%5s:0x%"PRIx64" ", perf_reg_name(r), val);
+   fprintf(stdout, "%5s:0x%"PRIx64" ", perf_reg_name(r), val);
}
 }
 
@@ -544,25 +544,25 @@ static void fprint_sample_start(struct perf_sample 
*sample,
 
if (PRINT_FIELD(COMM)) {
if (latency_format)
-   printf("%8.8s ", thread__comm_str(thread));
+   fprintf(stdout, "%8.8s ", thread__comm_str(thread));
else if (PRINT_FIELD(IP) && symbol_conf.use_callchain)
-   printf("%s ", thread__comm_str(thread));
+   fprintf(stdout, "%s ", thread__comm_str(thread));
else
-   printf("%16s ", thread__comm_str(thread));
+   fprintf(stdout, "%16s ", thread__comm_str(thread));
}
 
if (PRINT_FIELD(PID) && PRINT_FIELD(TID))
-   printf("%5d/%-5d ", sample->pid, sample->tid);
+   fprintf(stdout, "%5d/%-5d ", sample->pid, sample->tid);
else if (PRINT_FIELD(PID))
-   printf("%5d ", sample->pid);
+   fprintf(stdout, "%5d ", sample->pid);
else if (PRINT_FIELD(TID))
-   printf("%5d ", sample->tid);
+   fprintf(stdout, "%5d ", sample->tid);
 
if (PRINT_FIELD(CPU)) {
if (latency_format)
-   printf("%3d ", sample->cpu);
+   fprintf(stdout, "%3d ", sample->cpu);
else
-   printf("[%03d] ", sample->cpu);
+   fprintf(stdout, "[%03d] ", sample->cpu);
}
 
if (PRINT_FIELD(TIME)) {
@@ -571,11 +571,11 @@ static void fprint_sample_start(struct perf_sample 
*sample,
nsecs -= secs * NSEC_PER_SEC;
 
if (nanosecs)
-   printf("%5lu.%09llu: ", secs, nsecs);
+   fprintf(stdout, "%5lu.%09llu: ", secs, nsecs);
else {
char sample_time[32];
timestamp__scnprintf_usec(sample->time, sample_time, 
sizeof(sample_time));
-   printf("%12s: ", sample_time);
+   fprintf(stdout, "%12s: ", sample_time);
}
}
 }
@@ -612,21 +612,21 @@ static void fprint_sample_brstack(struct perf_sample 
*sample,
thread__find_addr_map(thread, sample->cpumode, 
MAP__FUNCTION, to, &alt);
}
 
-   printf("0x%"PRIx64, from);
+   fprintf(stdout, "0x%"PRIx64, from);
if (PRINT_FIELD(DSO)) {
-   printf("(");
+   fprintf(stdout, "(");
map__fprintf_dsoname(alf.map, stdout);
-   printf(")");
+   fprintf(stdout, ")");
}
 
-   printf("/0x%"PRIx64, to);
+   fprintf(stdout, "/0x%"PRIx64, to);
if (PRINT_FIELD(DSO)) {
-   printf("(");
+   fprintf(stdout, "(");
map__fprintf_dsoname(alt.map, stdout);
-   printf(")");
+   fprintf(stdout, ")");
}
 
-   printf("/%c/%c/%c/%d ",
+   fprintf(stdout, "/%c/%c/%c/%d ",
mispred_str( br->entries + i),
br->entries[i].flags.in_tx? 'X' : '-',
br->entries[i].flags.abort? 'A' : '-',
@@ -663,18 +663,18 @@ static void fprint_sample_brstacksym(struct perf_sample 
*sample,
 
symbol__fprintf_symname_offs(alf.sym, &alf, stdout);
if (PRINT_FIELD(DSO)) {
-   printf("(");
+   fprintf(stdout, "(");
map__fprintf_dsoname(alf.map, stdout);
-   printf(")");
+   fprintf(stdout, ")"

[PATCH v2 0/4] perf script: Add script per-event-dump support

2017-09-24 Thread yuzhoujian
Introduce a new option to print trace output to files named by the
monitored events and update perf-script documentation accordingly.

 Shown below is output of perf script command with the newly introduced
 option.

 $perf record -e cycles -e cs -ag -- sleep 10
 $perf script --per-event-dump
 $ls /
 perf.data-script-dump-cycles.txt perf.data-script-dump-cs.txt

 Without per-event-dump support, drawing flamegraphs for different events
 is really hard. You can only monitor one event at a time for perf record.
 Using this option, we can get the trace output files named by the monitored
 events, and could draw flamegraphs according to the event's name.

yuzhoujian (4):
  Add a new element for the struct perf_tool, and add the
--per-event-dump option for perf script
  Add fp argument to print functions
  Replace printf with fprintf for all print functions
  Make all print functions receive the fp argument, and opens a dump
file in process_event.

changes in v2:
- remove the set of script.tool.per_event_dump variable.
- add the __maybe_unused attribute for the fp argument in the second 
patch.
- remove the fp_selection_helper function for setting the fp argument.
- split the original second patch(Makes all those related functions 
receive the FILE pointer) to two patches.
- modify the file name of per-event-dump to -script-dump-.txt

 tools/perf/builtin-script.c | 452 
 tools/perf/util/tool.h  |   1 +
 2 files changed, 250 insertions(+), 203 deletions(-)

-- 
1.8.3.1



Re: 9f4835fb96 ("x86/fpu: Tighten validation of user-supplied .."): Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

2017-09-24 Thread Ingo Molnar

* kernel test robot  wrote:

> Greetings,
> 
> 0day kernel testing robot got the below dmesg and the first bad commit is
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git WIP.x86/fpu
> 
> commit 9f4835fb965d8eea7e608d0cb62c246c804dec90
> Author: Eric Biggers 
> AuthorDate: Fri Sep 22 10:41:55 2017 -0700
> Commit: Ingo Molnar 
> CommitDate: Sat Sep 23 11:02:00 2017 +0200
> 
> x86/fpu: Tighten validation of user-supplied xstate_header

Would it be possible to re-start this bisection, now that I've split up the 
commit 
into 10 more obvious patches?

My guess is that it's one of these two that is the bad commit:

  3deb4cca945b: x86/fpu: Copy the full header in copy_user_to_xstate()
  cfbd048cce44: x86/fpu: Copy the full state_header in copy_kernel_to_xstate()

... but it could be some of the others as well.

Thanks,

Ingo


[tip:x86/asm] x86/asm: Remove unnecessary \n\t in front of CC_SET() from asm templates

2017-09-24 Thread tip-bot for Uros Bizjak
Commit-ID:  3c52b5c64326d9dcfee4e10611c53ec1b1b20675
Gitweb: http://git.kernel.org/tip/3c52b5c64326d9dcfee4e10611c53ec1b1b20675
Author: Uros Bizjak 
AuthorDate: Wed, 6 Sep 2017 17:18:08 +0200
Committer:  Ingo Molnar 
CommitDate: Sun, 24 Sep 2017 11:19:01 +0200

x86/asm: Remove unnecessary \n\t in front of CC_SET() from asm templates

There is no need for \n\t in front of CC_SET(), as the macro already includes 
these two.

Signed-off-by: Uros Bizjak 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/20170906151808.5634-1-ubiz...@gmail.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/archrandom.h |  8 
 arch/x86/include/asm/bitops.h | 10 +-
 arch/x86/include/asm/percpu.h |  2 +-
 arch/x86/include/asm/rmwcc.h  |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/x86/include/asm/archrandom.h 
b/arch/x86/include/asm/archrandom.h
index 5b0579a..3ac991d 100644
--- a/arch/x86/include/asm/archrandom.h
+++ b/arch/x86/include/asm/archrandom.h
@@ -45,7 +45,7 @@ static inline bool rdrand_long(unsigned long *v)
bool ok;
unsigned int retry = RDRAND_RETRY_LOOPS;
do {
-   asm volatile(RDRAND_LONG "\n\t"
+   asm volatile(RDRAND_LONG
 CC_SET(c)
 : CC_OUT(c) (ok), "=a" (*v));
if (ok)
@@ -59,7 +59,7 @@ static inline bool rdrand_int(unsigned int *v)
bool ok;
unsigned int retry = RDRAND_RETRY_LOOPS;
do {
-   asm volatile(RDRAND_INT "\n\t"
+   asm volatile(RDRAND_INT
 CC_SET(c)
 : CC_OUT(c) (ok), "=a" (*v));
if (ok)
@@ -71,7 +71,7 @@ static inline bool rdrand_int(unsigned int *v)
 static inline bool rdseed_long(unsigned long *v)
 {
bool ok;
-   asm volatile(RDSEED_LONG "\n\t"
+   asm volatile(RDSEED_LONG
 CC_SET(c)
 : CC_OUT(c) (ok), "=a" (*v));
return ok;
@@ -80,7 +80,7 @@ static inline bool rdseed_long(unsigned long *v)
 static inline bool rdseed_int(unsigned int *v)
 {
bool ok;
-   asm volatile(RDSEED_INT "\n\t"
+   asm volatile(RDSEED_INT
 CC_SET(c)
 : CC_OUT(c) (ok), "=a" (*v));
return ok;
diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index 8540227..8cee8db 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -142,7 +142,7 @@ static __always_inline void __clear_bit(long nr, volatile 
unsigned long *addr)
 static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, 
volatile unsigned long *addr)
 {
bool negative;
-   asm volatile(LOCK_PREFIX "andb %2,%1\n\t"
+   asm volatile(LOCK_PREFIX "andb %2,%1"
CC_SET(s)
: CC_OUT(s) (negative), ADDR
: "ir" ((char) ~(1 << nr)) : "memory");
@@ -245,7 +245,7 @@ static __always_inline bool __test_and_set_bit(long nr, 
volatile unsigned long *
 {
bool oldbit;
 
-   asm("bts %2,%1\n\t"
+   asm("bts %2,%1"
CC_SET(c)
: CC_OUT(c) (oldbit), ADDR
: "Ir" (nr));
@@ -285,7 +285,7 @@ static __always_inline bool __test_and_clear_bit(long nr, 
volatile unsigned long
 {
bool oldbit;
 
-   asm volatile("btr %2,%1\n\t"
+   asm volatile("btr %2,%1"
 CC_SET(c)
 : CC_OUT(c) (oldbit), ADDR
 : "Ir" (nr));
@@ -297,7 +297,7 @@ static __always_inline bool __test_and_change_bit(long nr, 
volatile unsigned lon
 {
bool oldbit;
 
-   asm volatile("btc %2,%1\n\t"
+   asm volatile("btc %2,%1"
 CC_SET(c)
 : CC_OUT(c) (oldbit), ADDR
 : "Ir" (nr) : "memory");
@@ -328,7 +328,7 @@ static __always_inline bool variable_test_bit(long nr, 
volatile const unsigned l
 {
bool oldbit;
 
-   asm volatile("bt %2,%1\n\t"
+   asm volatile("bt %2,%1"
 CC_SET(c)
 : CC_OUT(c) (oldbit)
 : "m" (*(unsigned long *)addr), "Ir" (nr));
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 9fa0360..b21a475 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -525,7 +525,7 @@ static inline bool x86_this_cpu_variable_test_bit(int nr,
 {
bool oldbit;
 
-   asm volatile("bt "__percpu_arg(2)",%1\n\t"
+   asm volatile("bt "__percpu_arg(2)",%1"
CC_SET(c)
: CC_OUT(c) (oldbit)
: "m" (*(unsigned long __percpu *)addr), "Ir" (nr));
diff --git a/arch/x86/include/asm/rmwcc.h b/arch/x86/include/asm/rmwcc.h
index 045f992..0c411c8 100644
--- a/arch/x86/include/asm/rmwcc.h
+++ b/arch/x86/include/asm/rmwcc.h
@@ -28,7 +28,7 @@ cc_label: 

[PATCH 01/10] x86/fpu: Introduce validate_xstate_header()

2017-09-24 Thread Ingo Molnar
From: Eric Biggers 

Move validation of user-supplied xstate_header into a helper function,
in preparation of calling it from both the ptrace and sigreturn syscall
paths.

The new function also considers it to be an error if *any* reserved bits
are set, whereas before we were just clearing most of them silently.

This should reduce the chance of bugs that fail to correctly validate
user-supplied XSAVE areas.  It also will expose any broken userspace
programs that set the other reserved bits; this is desirable because
such programs will lose compatibility with future CPUs and kernels if
those bits are ever used for anything.  (There shouldn't be any such
programs, and in fact in the case where the compacted format is in use
we were already validating xfeatures.  But you never know...)

Signed-off-by: Eric Biggers 
Cc: Andy Lutomirski 
Cc: Dave Hansen 
Cc: Dmitry Vyukov 
Cc: Fenghua Yu 
Cc: Kees Cook 
Cc: Kevin Hao 
Cc: Linus Torvalds 
Cc: Michael Halcrow 
Cc: Oleg Nesterov 
Cc: Peter Zijlstra 
Cc: Rik van Riel 
Cc: Thomas Gleixner 
Cc: Wanpeng Li 
Cc: Yu-cheng Yu 
Cc: kernel-harden...@lists.openwall.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/fpu/xstate.h |  4 
 arch/x86/kernel/fpu/xstate.c  | 24 
 2 files changed, 28 insertions(+)

diff --git a/arch/x86/include/asm/fpu/xstate.h 
b/arch/x86/include/asm/fpu/xstate.h
index 579ac2358e63..83fee2469eb7 100644
--- a/arch/x86/include/asm/fpu/xstate.h
+++ b/arch/x86/include/asm/fpu/xstate.h
@@ -52,4 +52,8 @@ int copy_xstate_to_kernel(void *kbuf, struct xregs_state 
*xsave, unsigned int of
 int copy_xstate_to_user(void __user *ubuf, struct xregs_state *xsave, unsigned 
int offset, unsigned int size);
 int copy_kernel_to_xstate(struct xregs_state *xsave, const void *kbuf);
 int copy_user_to_xstate(struct xregs_state *xsave, const void __user *ubuf);
+
+/* Validate an xstate header supplied by userspace (ptrace or sigreturn) */
+extern int validate_xstate_header(const struct xstate_header *hdr);
+
 #endif
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 703e76d027ee..2427aeea33b5 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -483,6 +483,30 @@ int using_compacted_format(void)
return boot_cpu_has(X86_FEATURE_XSAVES);
 }
 
+/* Validate an xstate header supplied by userspace (ptrace or sigreturn) */
+int validate_xstate_header(const struct xstate_header *hdr)
+{
+   /* No unknown or supervisor features may be set */
+   if (hdr->xfeatures & (~xfeatures_mask | XFEATURE_MASK_SUPERVISOR))
+   return -EINVAL;
+
+   /* Userspace must use the uncompacted format */
+   if (hdr->xcomp_bv)
+   return -EINVAL;
+
+   /*
+* If 'reserved' is shrunken to add a new field, make sure to validate
+* that new field here!
+*/
+   BUILD_BUG_ON(sizeof(hdr->reserved) != 48);
+
+   /* No reserved bits may be set */
+   if (memchr_inv(hdr->reserved, 0, sizeof(hdr->reserved)))
+   return -EINVAL;
+
+   return 0;
+}
+
 static void __xstate_dump_leaves(void)
 {
int i;
-- 
2.11.0



[PATCH 03/10] x86/fpu: Use validate_xstate_header() to validate the xstate_header in sanitize_restored_xstate()

2017-09-24 Thread Ingo Molnar
From: Eric Biggers 

Tighten the checks in sanitize_restored_xstate().

Signed-off-by: Eric Biggers 
Cc: Andy Lutomirski 
Cc: Dave Hansen 
Cc: Dmitry Vyukov 
Cc: Fenghua Yu 
Cc: Kees Cook 
Cc: Kevin Hao 
Cc: Linus Torvalds 
Cc: Michael Halcrow 
Cc: Oleg Nesterov 
Cc: Peter Zijlstra 
Cc: Rik van Riel 
Cc: Thomas Gleixner 
Cc: Wanpeng Li 
Cc: Yu-cheng Yu 
Cc: kernel-harden...@lists.openwall.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/fpu/signal.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
index 1ef1b228b9fd..afe54247cf27 100644
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -214,8 +214,11 @@ sanitize_restored_xstate(struct task_struct *tsk,
struct xstate_header *header = &xsave->header;
 
if (use_xsave()) {
-   /* These bits must be zero. */
-   memset(header->reserved, 0, 48);
+   /*
+* Note: we don't need to zero the reserved bits in the
+* xstate_header here because we either didn't copy them at all,
+* or we checked earlier that they aren't set.
+*/
 
/*
 * Init the state that is not present in the memory
@@ -224,7 +227,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
if (fx_only)
header->xfeatures = XFEATURE_MASK_FPSSE;
else
-   header->xfeatures &= (xfeatures_mask & xfeatures);
+   header->xfeatures &= xfeatures;
}
 
if (use_fxsr()) {
@@ -308,7 +311,7 @@ static int __fpu__restore_sig(void __user *buf, void __user 
*buf_fx, int size)
/*
 * For 32-bit frames with fxstate, copy the user state to the
 * thread's fpu state, reconstruct fxstate from the fsave
-* header. Sanitize the copied state etc.
+* header. Validate and sanitize the copied state.
 */
struct fpu *fpu = &tsk->thread.fpu;
struct user_i387_ia32_struct env;
@@ -328,10 +331,8 @@ static int __fpu__restore_sig(void __user *buf, void 
__user *buf_fx, int size)
err = copy_user_to_xstate(&fpu->state.xsave, buf_fx);
} else {
err = __copy_from_user(&fpu->state.xsave, buf_fx, 
state_size);
-
-   /* xcomp_bv must be 0 when using uncompacted format */
-   if (!err && fpu->state.xsave.header.xcomp_bv)
-   err = -EINVAL;
+   if (!err)
+   err = 
validate_xstate_header(&fpu->state.xsave.header);
}
 
if (err || __copy_from_user(&env, buf, sizeof(env))) {
-- 
2.11.0



[PATCH 04/10] x86/fpu: Copy the full state_header in copy_kernel_to_xstate()

2017-09-24 Thread Ingo Molnar
From: Eric Biggers 

This is in preparation to verify the full xstate header as supplied by 
user-space.

Signed-off-by: Eric Biggers 
Cc: Andy Lutomirski 
Cc: Dave Hansen 
Cc: Dmitry Vyukov 
Cc: Fenghua Yu 
Cc: Kees Cook 
Cc: Kevin Hao 
Cc: Linus Torvalds 
Cc: Michael Halcrow 
Cc: Oleg Nesterov 
Cc: Peter Zijlstra 
Cc: Rik van Riel 
Cc: Thomas Gleixner 
Cc: Wanpeng Li 
Cc: Yu-cheng Yu 
Cc: kernel-harden...@lists.openwall.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/fpu/xstate.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 2427aeea33b5..02591b96bb25 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -1148,11 +1148,13 @@ int copy_kernel_to_xstate(struct xregs_state *xsave, 
const void *kbuf)
int i;
u64 xfeatures;
u64 allowed_features;
+   struct xstate_header hdr;
 
offset = offsetof(struct xregs_state, header);
-   size = sizeof(xfeatures);
+   size = sizeof(hdr);
 
-   memcpy(&xfeatures, kbuf + offset, size);
+   memcpy(&hdr, kbuf + offset, size);
+   xfeatures = hdr.xfeatures;
 
/*
 * Reject if the user sets any disabled or supervisor features:
-- 
2.11.0



[PATCH 07/10] x86/fpu: Copy the full header in copy_user_to_xstate()

2017-09-24 Thread Ingo Molnar
From: Eric Biggers 

This is in preparation to verify the full xstate header as supplied by 
user-space.

Signed-off-by: Eric Biggers 
Cc: Andy Lutomirski 
Cc: Dave Hansen 
Cc: Dmitry Vyukov 
Cc: Fenghua Yu 
Cc: Kees Cook 
Cc: Kevin Hao 
Cc: Linus Torvalds 
Cc: Michael Halcrow 
Cc: Oleg Nesterov 
Cc: Peter Zijlstra 
Cc: Rik van Riel 
Cc: Thomas Gleixner 
Cc: Wanpeng Li 
Cc: Yu-cheng Yu 
Cc: kernel-harden...@lists.openwall.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/fpu/xstate.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 325db7850335..0cd7b73c25e8 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -1199,13 +1199,16 @@ int copy_user_to_xstate(struct xregs_state *xsave, 
const void __user *ubuf)
int i;
u64 xfeatures;
u64 allowed_features;
+   struct xstate_header hdr;
 
offset = offsetof(struct xregs_state, header);
-   size = sizeof(xfeatures);
+   size = sizeof(hdr);
 
-   if (__copy_from_user(&xfeatures, ubuf + offset, size))
+   if (__copy_from_user(&hdr, ubuf + offset, size))
return -EFAULT;
 
+   xfeatures = hdr.xfeatures;
+
/*
 * Reject if the user sets any disabled or supervisor features:
 */
-- 
2.11.0



[PATCH 06/10] x86/fpu: Use validate_xstate_header() to validate the xstate_header in copy_kernel_to_xstate()

2017-09-24 Thread Ingo Molnar
From: Eric Biggers 

Tighten the checks in copy_kernel_to_xstate().

Signed-off-by: Eric Biggers 
Cc: Andy Lutomirski 
Cc: Dave Hansen 
Cc: Dmitry Vyukov 
Cc: Fenghua Yu 
Cc: Kees Cook 
Cc: Kevin Hao 
Cc: Linus Torvalds 
Cc: Michael Halcrow 
Cc: Oleg Nesterov 
Cc: Peter Zijlstra 
Cc: Rik van Riel 
Cc: Thomas Gleixner 
Cc: Wanpeng Li 
Cc: Yu-cheng Yu 
Cc: kernel-harden...@lists.openwall.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/fpu/xstate.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index c97c4a9db52a..325db7850335 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -1138,15 +1138,12 @@ int copy_xstate_to_user(void __user *ubuf, struct 
xregs_state *xsave, unsigned i
 
 /*
  * Convert from a ptrace standard-format kernel buffer to kernel XSAVES format
- * and copy to the target thread. This is called from xstateregs_set() and
- * there we check the CPU has XSAVES and a whole standard-sized buffer
- * exists.
+ * and copy to the target thread. This is called from xstateregs_set().
  */
 int copy_kernel_to_xstate(struct xregs_state *xsave, const void *kbuf)
 {
unsigned int offset, size;
int i;
-   u64 allowed_features;
struct xstate_header hdr;
 
offset = offsetof(struct xregs_state, header);
@@ -1154,12 +1151,7 @@ int copy_kernel_to_xstate(struct xregs_state *xsave, 
const void *kbuf)
 
memcpy(&hdr, kbuf + offset, size);
 
-   /*
-* Reject if the user sets any disabled or supervisor features:
-*/
-   allowed_features = xfeatures_mask & ~XFEATURE_MASK_SUPERVISOR;
-
-   if (hdr.xfeatures & ~allowed_features)
+   if (validate_xstate_header(&hdr))
return -EINVAL;
 
for (i = 0; i < XFEATURE_MAX; i++) {
-- 
2.11.0



[PATCH 08/10] x86/fpu: Eliminate the 'xfeatures' local variable in copy_user_to_xstate()

2017-09-24 Thread Ingo Molnar
From: Eric Biggers 

We now have this field in hdr.xfeatures.

Signed-off-by: Eric Biggers 
Cc: Andy Lutomirski 
Cc: Dave Hansen 
Cc: Dmitry Vyukov 
Cc: Fenghua Yu 
Cc: Kees Cook 
Cc: Kevin Hao 
Cc: Linus Torvalds 
Cc: Michael Halcrow 
Cc: Oleg Nesterov 
Cc: Peter Zijlstra 
Cc: Rik van Riel 
Cc: Thomas Gleixner 
Cc: Wanpeng Li 
Cc: Yu-cheng Yu 
Cc: kernel-harden...@lists.openwall.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/fpu/xstate.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 0cd7b73c25e8..b6d78b78b5c2 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -1197,7 +1197,6 @@ int copy_user_to_xstate(struct xregs_state *xsave, const 
void __user *ubuf)
 {
unsigned int offset, size;
int i;
-   u64 xfeatures;
u64 allowed_features;
struct xstate_header hdr;
 
@@ -1207,20 +1206,18 @@ int copy_user_to_xstate(struct xregs_state *xsave, 
const void __user *ubuf)
if (__copy_from_user(&hdr, ubuf + offset, size))
return -EFAULT;
 
-   xfeatures = hdr.xfeatures;
-
/*
 * Reject if the user sets any disabled or supervisor features:
 */
allowed_features = xfeatures_mask & ~XFEATURE_MASK_SUPERVISOR;
 
-   if (xfeatures & ~allowed_features)
+   if (hdr.xfeatures & ~allowed_features)
return -EINVAL;
 
for (i = 0; i < XFEATURE_MAX; i++) {
u64 mask = ((u64)1 << i);
 
-   if (xfeatures & mask) {
+   if (hdr.xfeatures & mask) {
void *dst = __raw_xsave_addr(xsave, 1 << i);
 
offset = xstate_offsets[i];
@@ -1231,7 +1228,7 @@ int copy_user_to_xstate(struct xregs_state *xsave, const 
void __user *ubuf)
}
}
 
-   if (xfeatures_mxcsr_quirk(xfeatures)) {
+   if (xfeatures_mxcsr_quirk(hdr.xfeatures)) {
offset = offsetof(struct fxregs_state, mxcsr);
size = MXCSR_AND_FLAGS_SIZE;
if (__copy_from_user(&xsave->i387.mxcsr, ubuf + offset, size))
@@ -1247,7 +1244,7 @@ int copy_user_to_xstate(struct xregs_state *xsave, const 
void __user *ubuf)
/*
 * Add back in the features that came in from userspace:
 */
-   xsave->header.xfeatures |= xfeatures;
+   xsave->header.xfeatures |= hdr.xfeatures;
 
return 0;
 }
-- 
2.11.0



[PATCH v3 2/5] mtd: spi-nor: cadence-quadspi: add a delay in write sequence

2017-09-24 Thread Vignesh R
As per 66AK2G02 TRM[1] SPRUHY8F section 11.15.5.3 Indirect Access
Controller programming sequence, a delay equal to couple of QSPI master
clock(~5ns) is required after setting CQSPI_REG_INDIRECTWR_START bit and
writing data to the flash. Introduce a quirk flag CQSPI_NEEDS_WR_DELAY
to handle this and set this flag for TI 66AK2G SoC.

[1]http://www.ti.com/lit/ug/spruhy8f/spruhy8f.pdf

Signed-off-by: Vignesh R 
---

v3:
Fix build warnings reported by kbuild test bot.

 drivers/mtd/spi-nor/cadence-quadspi.c | 27 ++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c 
b/drivers/mtd/spi-nor/cadence-quadspi.c
index 53c7d8e0327a..5cd5d6f7303f 100644
--- a/drivers/mtd/spi-nor/cadence-quadspi.c
+++ b/drivers/mtd/spi-nor/cadence-quadspi.c
@@ -38,6 +38,9 @@
 #define CQSPI_NAME "cadence-qspi"
 #define CQSPI_MAX_CHIPSELECT   16
 
+/* Quirks */
+#define CQSPI_NEEDS_WR_DELAY   BIT(0)
+
 struct cqspi_st;
 
 struct cqspi_flash_pdata {
@@ -76,6 +79,7 @@ struct cqspi_st {
u32 fifo_depth;
u32 fifo_width;
u32 trigger_address;
+   u32 wr_delay;
struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT];
 };
 
@@ -608,6 +612,15 @@ static int cqspi_indirect_write_execute(struct spi_nor 
*nor,
reinit_completion(&cqspi->transfer_complete);
writel(CQSPI_REG_INDIRECTWR_START_MASK,
   reg_base + CQSPI_REG_INDIRECTWR);
+   /*
+* As per 66AK2G02 TRM SPRUHY8F section 11.15.5.3 Indirect Access
+* Controller programming sequence, couple of cycles of
+* QSPI_REF_CLK delay is required for the above bit to
+* be internally synchronized by the QSPI module. Provide 5
+* cycles of delay.
+*/
+   if (cqspi->wr_delay)
+   ndelay(cqspi->wr_delay);
 
while (remaining > 0) {
write_bytes = remaining > page_size ? page_size : remaining;
@@ -1156,6 +1169,7 @@ static int cqspi_probe(struct platform_device *pdev)
struct cqspi_st *cqspi;
struct resource *res;
struct resource *res_ahb;
+   unsigned long data;
int ret;
int irq;
 
@@ -1213,6 +1227,10 @@ static int cqspi_probe(struct platform_device *pdev)
}
 
cqspi->master_ref_clk_hz = clk_get_rate(cqspi->clk);
+   data  = (unsigned long)of_device_get_match_data(dev);
+   if (data & CQSPI_NEEDS_WR_DELAY)
+   cqspi->wr_delay = 5 * DIV_ROUND_UP(NSEC_PER_SEC,
+  cqspi->master_ref_clk_hz);
 
ret = devm_request_irq(dev, irq, cqspi_irq_handler, 0,
   pdev->name, cqspi);
@@ -1284,7 +1302,14 @@ static const struct dev_pm_ops cqspi__dev_pm_ops = {
 #endif
 
 static const struct of_device_id cqspi_dt_ids[] = {
-   {.compatible = "cdns,qspi-nor",},
+   {
+   .compatible = "cdns,qspi-nor",
+   .data = (void *)0,
+   },
+   {
+   .compatible = "ti,k2g-qspi",
+   .data = (void *)CQSPI_NEEDS_WR_DELAY,
+   },
{ /* end of table */ }
 };
 
-- 
2.14.1



[PATCH v3 0/5] K2G: Add QSPI support

2017-09-24 Thread Vignesh R
This series adds support for Cadence QSPI IP present in TI's 66AK2G SoC.
The patches enhance the existing cadence-quadspi driver to support
loopback clock circuit, pm_runtime support and tweaks for 66AK2G SoC.

Change log:

v3:
* Fix build warnings reported by kbuild test bot.

Resend:
* Rebase to latest linux-next.
* Collect Acked-bys

v2:
* Drop DT patches. Will be sent as separate series as requested by
 maintainer.
* Split binding docs into separate patches.
* Address comments by Rob Herring.


Vignesh R (5):
  mtd: spi-nor: cadence-quadspi: Add TI 66AK2G SoC specific compatible
  mtd: spi-nor: cadence-quadspi: add a delay in write sequence
  mtd: spi-nor: cadence-quadspi: Add new binding to enable loop-back
circuit
  mtd: spi-nor: cadence-quadspi: Add support to enable loop-back clock
circuit
  mtd: spi-nor: cadence-quadspi: Add runtime PM support

 .../devicetree/bindings/mtd/cadence-quadspi.txt|  7 +++-
 drivers/mtd/spi-nor/cadence-quadspi.c  | 46 --
 2 files changed, 49 insertions(+), 4 deletions(-)

-- 
2.14.1



[PATCH v3 3/5] mtd: spi-nor: cadence-quadspi: Add new binding to enable loop-back circuit

2017-09-24 Thread Vignesh R
Cadence QSPI IP has a adapted loop-back circuit which can be enabled by
setting BYPASS field to 0 in READCAPTURE register. It enables use of
QSPI return clock to latch the data rather than the internal QSPI
reference clock. For high speed operations, adapted loop-back circuit
using QSPI return clock helps to increase data valid window.

Add DT parameter cdns,rclk-en to help enable adapted loop-back circuit
for boards which do have QSPI return clock provided. Update binding
documentation for the same.

Signed-off-by: Vignesh R 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/mtd/cadence-quadspi.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt 
b/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
index 7dbe3bd9ac56..bb2075df9b38 100644
--- a/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
+++ b/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
@@ -16,6 +16,9 @@ Required properties:
 
 Optional properties:
 - cdns,is-decoded-cs : Flag to indicate whether decoder is used or not.
+- cdns,rclk-en : Flag to indicate that QSPI return clock is used to latch
+  the read data rather than the QSPI clock. Make sure that QSPI return
+  clock is populated on the board before using this property.
 
 Optional subnodes:
 Subnodes of the Cadence Quad SPI controller are spi slave nodes with additional
-- 
2.14.1



[PATCH v3 4/5] mtd: spi-nor: cadence-quadspi: Add support to enable loop-back clock circuit

2017-09-24 Thread Vignesh R
Cadence QSPI IP has a adapted loop-back circuit which can be enabled by
setting BYPASS field to 0 in READCAPTURE register. It enables use of
QSPI return clock to latch the data rather than the internal QSPI
reference clock. For high speed operations, adapted loop-back circuit
using QSPI return clock helps to increase data valid window.

Based on DT parameter cdns,rclk-en enable adapted loop-back circuit
for boards which do have QSPI return clock provided.
This patch also modifies cqspi_readdata_capture() function's bypass
parameter to bool to match how its used in the function.

Signed-off-by: Vignesh R 
---
 drivers/mtd/spi-nor/cadence-quadspi.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c 
b/drivers/mtd/spi-nor/cadence-quadspi.c
index 5cd5d6f7303f..d9629e8f4798 100644
--- a/drivers/mtd/spi-nor/cadence-quadspi.c
+++ b/drivers/mtd/spi-nor/cadence-quadspi.c
@@ -78,6 +78,7 @@ struct cqspi_st {
boolis_decoded_cs;
u32 fifo_depth;
u32 fifo_width;
+   boolrclk_en;
u32 trigger_address;
u32 wr_delay;
struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT];
@@ -788,7 +789,7 @@ static void cqspi_config_baudrate_div(struct cqspi_st 
*cqspi)
 }
 
 static void cqspi_readdata_capture(struct cqspi_st *cqspi,
-  const unsigned int bypass,
+  const bool bypass,
   const unsigned int delay)
 {
void __iomem *reg_base = cqspi->iobase;
@@ -852,7 +853,8 @@ static void cqspi_configure(struct spi_nor *nor)
cqspi->sclk = sclk;
cqspi_config_baudrate_div(cqspi);
cqspi_delay(nor);
-   cqspi_readdata_capture(cqspi, 1, f_pdata->read_delay);
+   cqspi_readdata_capture(cqspi, !cqspi->rclk_en,
+  f_pdata->read_delay);
}
 
if (switch_cs || switch_ck)
@@ -1049,6 +1051,8 @@ static int cqspi_of_get_pdata(struct platform_device 
*pdev)
return -ENXIO;
}
 
+   cqspi->rclk_en = of_property_read_bool(np, "cdns,rclk-en");
+
return 0;
 }
 
-- 
2.14.1



[PATCH v3 5/5] mtd: spi-nor: cadence-quadspi: Add runtime PM support

2017-09-24 Thread Vignesh R
Add pm_runtime* calls to cadence-quadspi driver. This is required to
switch on QSPI power domain on TI 66AK2G SoC during probe.

Signed-off-by: Vignesh R 
---
 drivers/mtd/spi-nor/cadence-quadspi.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c 
b/drivers/mtd/spi-nor/cadence-quadspi.c
index d9629e8f4798..2c8e6226d267 100644
--- a/drivers/mtd/spi-nor/cadence-quadspi.c
+++ b/drivers/mtd/spi-nor/cadence-quadspi.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1224,6 +1225,13 @@ static int cqspi_probe(struct platform_device *pdev)
return -ENXIO;
}
 
+   pm_runtime_enable(&pdev->dev);
+   ret = pm_runtime_get_sync(&pdev->dev);
+   if (ret < 0) {
+   pm_runtime_put_noidle(&pdev->dev);
+   return ret;
+   }
+
ret = clk_prepare_enable(cqspi->clk);
if (ret) {
dev_err(dev, "Cannot enable QSPI clock.\n");
@@ -1275,6 +1283,9 @@ static int cqspi_remove(struct platform_device *pdev)
 
clk_disable_unprepare(cqspi->clk);
 
+   pm_runtime_put_sync(&pdev->dev);
+   pm_runtime_disable(&pdev->dev);
+
return 0;
 }
 
-- 
2.14.1



[PATCH v3 1/5] mtd: spi-nor: cadence-quadspi: Add TI 66AK2G SoC specific compatible

2017-09-24 Thread Vignesh R
Update binding documentation to add a new compatible for TI 66AK2G SoC,
to handle TI SoC specific quirks in the driver.

Signed-off-by: Vignesh R 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/mtd/cadence-quadspi.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt 
b/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
index f248056da24c..7dbe3bd9ac56 100644
--- a/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
+++ b/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
@@ -1,7 +1,9 @@
 * Cadence Quad SPI controller
 
 Required properties:
-- compatible : Should be "cdns,qspi-nor".
+- compatible : should be one of the following:
+   Generic default - "cdns,qspi-nor".
+   For TI 66AK2G SoC - "ti,k2g-qspi", "cdns,qspi-nor".
 - reg : Contains two entries, each of which is a tuple consisting of a
physical address and length. The first entry is the address and
length of the controller register set. The second entry is the
-- 
2.14.1



[PATCH 10/10] x86/fpu: Use using_compacted_format() instead of open coded X86_FEATURE_XSAVES

2017-09-24 Thread Ingo Molnar
From: Eric Biggers 

Signed-off-by: Eric Biggers 
Cc: Andy Lutomirski 
Cc: Dave Hansen 
Cc: Dmitry Vyukov 
Cc: Fenghua Yu 
Cc: Kees Cook 
Cc: Kevin Hao 
Cc: Linus Torvalds 
Cc: Michael Halcrow 
Cc: Oleg Nesterov 
Cc: Peter Zijlstra 
Cc: Rik van Riel 
Cc: Thomas Gleixner 
Cc: Wanpeng Li 
Cc: Yu-cheng Yu 
Cc: kernel-harden...@lists.openwall.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/fpu/regset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/fpu/regset.c b/arch/x86/kernel/fpu/regset.c
index b831d5b9de99..3ea151372389 100644
--- a/arch/x86/kernel/fpu/regset.c
+++ b/arch/x86/kernel/fpu/regset.c
@@ -134,7 +134,7 @@ int xstateregs_set(struct task_struct *target, const struct 
user_regset *regset,
 
fpu__prepare_write(fpu);
 
-   if (boot_cpu_has(X86_FEATURE_XSAVES)) {
+   if (using_compacted_format()) {
if (kbuf)
ret = copy_kernel_to_xstate(xsave, kbuf);
else
-- 
2.11.0



[PATCH 05/10] x86/fpu: Eliminate the 'xfeatures' local variable in copy_kernel_to_xstate()

2017-09-24 Thread Ingo Molnar
From: Eric Biggers 

We have this information in the xstate_header.

Signed-off-by: Eric Biggers 
Cc: Andy Lutomirski 
Cc: Dave Hansen 
Cc: Dmitry Vyukov 
Cc: Fenghua Yu 
Cc: Kees Cook 
Cc: Kevin Hao 
Cc: Linus Torvalds 
Cc: Michael Halcrow 
Cc: Oleg Nesterov 
Cc: Peter Zijlstra 
Cc: Rik van Riel 
Cc: Thomas Gleixner 
Cc: Wanpeng Li 
Cc: Yu-cheng Yu 
Cc: kernel-harden...@lists.openwall.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/fpu/xstate.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 02591b96bb25..c97c4a9db52a 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -1146,7 +1146,6 @@ int copy_kernel_to_xstate(struct xregs_state *xsave, 
const void *kbuf)
 {
unsigned int offset, size;
int i;
-   u64 xfeatures;
u64 allowed_features;
struct xstate_header hdr;
 
@@ -1154,20 +1153,19 @@ int copy_kernel_to_xstate(struct xregs_state *xsave, 
const void *kbuf)
size = sizeof(hdr);
 
memcpy(&hdr, kbuf + offset, size);
-   xfeatures = hdr.xfeatures;
 
/*
 * Reject if the user sets any disabled or supervisor features:
 */
allowed_features = xfeatures_mask & ~XFEATURE_MASK_SUPERVISOR;
 
-   if (xfeatures & ~allowed_features)
+   if (hdr.xfeatures & ~allowed_features)
return -EINVAL;
 
for (i = 0; i < XFEATURE_MAX; i++) {
u64 mask = ((u64)1 << i);
 
-   if (xfeatures & mask) {
+   if (hdr.xfeatures & mask) {
void *dst = __raw_xsave_addr(xsave, 1 << i);
 
offset = xstate_offsets[i];
@@ -1177,7 +1175,7 @@ int copy_kernel_to_xstate(struct xregs_state *xsave, 
const void *kbuf)
}
}
 
-   if (xfeatures_mxcsr_quirk(xfeatures)) {
+   if (xfeatures_mxcsr_quirk(hdr.xfeatures)) {
offset = offsetof(struct fxregs_state, mxcsr);
size = MXCSR_AND_FLAGS_SIZE;
memcpy(&xsave->i387.mxcsr, kbuf + offset, size);
@@ -1192,7 +1190,7 @@ int copy_kernel_to_xstate(struct xregs_state *xsave, 
const void *kbuf)
/*
 * Add back in the features that came in from userspace:
 */
-   xsave->header.xfeatures |= xfeatures;
+   xsave->header.xfeatures |= hdr.xfeatures;
 
return 0;
 }
-- 
2.11.0



[PATCH 09/10] x86/fpu: Use validate_xstate_header() to validate the xstate_header in copy_user_to_xstate()

2017-09-24 Thread Ingo Molnar
From: Eric Biggers 

Tighten the checks in copy_user_to_xstate().

Signed-off-by: Eric Biggers 
Cc: Andy Lutomirski 
Cc: Dave Hansen 
Cc: Dmitry Vyukov 
Cc: Fenghua Yu 
Cc: Kees Cook 
Cc: Kevin Hao 
Cc: Linus Torvalds 
Cc: Michael Halcrow 
Cc: Oleg Nesterov 
Cc: Peter Zijlstra 
Cc: Rik van Riel 
Cc: Thomas Gleixner 
Cc: Wanpeng Li 
Cc: Yu-cheng Yu 
Cc: kernel-harden...@lists.openwall.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/fpu/xstate.c | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index b6d78b78b5c2..f1d5476c9022 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -1188,16 +1188,15 @@ int copy_kernel_to_xstate(struct xregs_state *xsave, 
const void *kbuf)
 }
 
 /*
- * Convert from a ptrace standard-format user-space buffer to kernel XSAVES 
format
- * and copy to the target thread. This is called from xstateregs_set() and
- * there we check the CPU has XSAVES and a whole standard-sized buffer
- * exists.
+ * Convert from a ptrace or sigreturn standard-format user-space buffer to
+ * kernel XSAVES format and copy to the target thread. This is called from
+ * xstateregs_set(), as well as potentially from the sigreturn() and
+ * rt_sigreturn() system calls.
  */
 int copy_user_to_xstate(struct xregs_state *xsave, const void __user *ubuf)
 {
unsigned int offset, size;
int i;
-   u64 allowed_features;
struct xstate_header hdr;
 
offset = offsetof(struct xregs_state, header);
@@ -1206,12 +1205,7 @@ int copy_user_to_xstate(struct xregs_state *xsave, const 
void __user *ubuf)
if (__copy_from_user(&hdr, ubuf + offset, size))
return -EFAULT;
 
-   /*
-* Reject if the user sets any disabled or supervisor features:
-*/
-   allowed_features = xfeatures_mask & ~XFEATURE_MASK_SUPERVISOR;
-
-   if (hdr.xfeatures & ~allowed_features)
+   if (validate_xstate_header(&hdr))
return -EINVAL;
 
for (i = 0; i < XFEATURE_MAX; i++) {
-- 
2.11.0



[PATCH 02/10] x86/fpu: Use validate_xstate_header() to validate the xstate_header in xstateregs_set()

2017-09-24 Thread Ingo Molnar
From: Eric Biggers 

Tighten the checks in xstateregs_set().

Signed-off-by: Eric Biggers 
Cc: Andy Lutomirski 
Cc: Dave Hansen 
Cc: Dmitry Vyukov 
Cc: Fenghua Yu 
Cc: Kees Cook 
Cc: Kevin Hao 
Cc: Linus Torvalds 
Cc: Michael Halcrow 
Cc: Oleg Nesterov 
Cc: Peter Zijlstra 
Cc: Rik van Riel 
Cc: Thomas Gleixner 
Cc: Wanpeng Li 
Cc: Yu-cheng Yu 
Cc: kernel-harden...@lists.openwall.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/kernel/fpu/regset.c | 19 ++-
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/fpu/regset.c b/arch/x86/kernel/fpu/regset.c
index ee8d2f049818..b831d5b9de99 100644
--- a/arch/x86/kernel/fpu/regset.c
+++ b/arch/x86/kernel/fpu/regset.c
@@ -141,27 +141,20 @@ int xstateregs_set(struct task_struct *target, const 
struct user_regset *regset,
ret = copy_user_to_xstate(xsave, ubuf);
} else {
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, xsave, 0, 
-1);
-
-   /* xcomp_bv must be 0 when using uncompacted format */
-   if (!ret && xsave->header.xcomp_bv)
-   ret = -EINVAL;
+   if (!ret)
+   ret = validate_xstate_header(&xsave->header);
}
 
/*
-* In case of failure, mark all states as init:
-*/
-   if (ret)
-   fpstate_init(&fpu->state);
-
-   /*
 * mxcsr reserved bits must be masked to zero for security reasons.
 */
xsave->i387.mxcsr &= mxcsr_feature_mask;
-   xsave->header.xfeatures &= xfeatures_mask;
+
/*
-* These bits must be zero.
+* In case of failure, mark all states as init:
 */
-   memset(&xsave->header.reserved, 0, 48);
+   if (ret)
+   fpstate_init(&fpu->state);
 
return ret;
 }
-- 
2.11.0



[PATCH 00/10] x86/fpu: Split up "x86/fpu: Tighten validation of user-supplied xstate_header"

2017-09-24 Thread Ingo Molnar
As mentioned before, the patch was too big and too complex, and I've split it
up into 10 smaller, bisectable patches:

Eric Biggers (10):
  x86/fpu: Introduce validate_xstate_header()
  x86/fpu: Use validate_xstate_header() to validate the xstate_header in 
xstateregs_set()
  x86/fpu: Use validate_xstate_header() to validate the xstate_header in 
sanitize_restored_xstate()
  x86/fpu: Copy the full state_header in copy_kernel_to_xstate()
  x86/fpu: Eliminate the 'xfeatures' local variable in copy_kernel_to_xstate()
  x86/fpu: Use validate_xstate_header() to validate the xstate_header in 
copy_kernel_to_xstate()
  x86/fpu: Copy the full header in copy_user_to_xstate()
  x86/fpu: Eliminate the 'xfeatures' local variable in copy_user_to_xstate()
  x86/fpu: Use validate_xstate_header() to validate the xstate_header in 
copy_user_to_xstate()
  x86/fpu: Use using_compacted_format() instead of open coded X86_FEATURE_XSAVES

 arch/x86/include/asm/fpu/xstate.h |  4 
 arch/x86/kernel/fpu/regset.c  | 21 ++---
 arch/x86/kernel/fpu/signal.c  | 17 ++---
 arch/x86/kernel/fpu/xstate.c  | 76 
+--
 4 files changed, 63 insertions(+), 55 deletions(-)

I kept the attribution in place, because the end result is almost the same.

Below is the interdiff from the original version, I uninlined 
validate_xstate_header(),
because it's way too large to be inlined everywhere, plus I removed a couple of
spurious "!= 0" patterns.

The latest x86/fpu bits can be found in -tip:

git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git master
git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git WIP.x86/fpu

Thanks,

Ingo

===
 include/asm/fpu/xstate.h |   23 +--
 kernel/fpu/xstate.c  |   28 ++--
 2 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/arch/x86/include/asm/fpu/xstate.h 
b/arch/x86/include/asm/fpu/xstate.h
index 3d79d0ee4d30..83fee2469eb7 100644
--- a/arch/x86/include/asm/fpu/xstate.h
+++ b/arch/x86/include/asm/fpu/xstate.h
@@ -54,27 +54,6 @@ int copy_kernel_to_xstate(struct xregs_state *xsave, const 
void *kbuf);
 int copy_user_to_xstate(struct xregs_state *xsave, const void __user *ubuf);
 
 /* Validate an xstate header supplied by userspace (ptrace or sigreturn) */
-static inline int validate_xstate_header(const struct xstate_header *hdr)
-{
-   /* No unknown or supervisor features may be set */
-   if (hdr->xfeatures & (~xfeatures_mask | XFEATURE_MASK_SUPERVISOR))
-   return -EINVAL;
-
-   /* Userspace must use the uncompacted format */
-   if (hdr->xcomp_bv)
-   return -EINVAL;
-
-   /*
-* If 'reserved' is shrunken to add a new field, make sure to validate
-* that new field here!
-*/
-   BUILD_BUG_ON(sizeof(hdr->reserved) != 48);
-
-   /* No reserved bits may be set */
-   if (memchr_inv(hdr->reserved, 0, sizeof(hdr->reserved)))
-   return -EINVAL;
-
-   return 0;
-}
+extern int validate_xstate_header(const struct xstate_header *hdr);
 
 #endif
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 7ebd1a0811b6..f1d5476c9022 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -483,6 +483,30 @@ int using_compacted_format(void)
return boot_cpu_has(X86_FEATURE_XSAVES);
 }
 
+/* Validate an xstate header supplied by userspace (ptrace or sigreturn) */
+int validate_xstate_header(const struct xstate_header *hdr)
+{
+   /* No unknown or supervisor features may be set */
+   if (hdr->xfeatures & (~xfeatures_mask | XFEATURE_MASK_SUPERVISOR))
+   return -EINVAL;
+
+   /* Userspace must use the uncompacted format */
+   if (hdr->xcomp_bv)
+   return -EINVAL;
+
+   /*
+* If 'reserved' is shrunken to add a new field, make sure to validate
+* that new field here!
+*/
+   BUILD_BUG_ON(sizeof(hdr->reserved) != 48);
+
+   /* No reserved bits may be set */
+   if (memchr_inv(hdr->reserved, 0, sizeof(hdr->reserved)))
+   return -EINVAL;
+
+   return 0;
+}
+
 static void __xstate_dump_leaves(void)
 {
int i;
@@ -1127,7 +1151,7 @@ int copy_kernel_to_xstate(struct xregs_state *xsave, 
const void *kbuf)
 
memcpy(&hdr, kbuf + offset, size);
 
-   if (validate_xstate_header(&hdr) != 0)
+   if (validate_xstate_header(&hdr))
return -EINVAL;
 
for (i = 0; i < XFEATURE_MAX; i++) {
@@ -1181,7 +1205,7 @@ int copy_user_to_xstate(struct xregs_state *xsave, const 
void __user *ubuf)
if (__copy_from_user(&hdr, ubuf + offset, size))
return -EFAULT;
 
-   if (validate_xstate_header(&hdr) != 0)
+   if (validate_xstate_header(&hdr))
return -EINVAL;
 
for (i = 0; i < XFEATURE_MAX; i++) {


[PATCH] rpmsg: Allow RPMSG_VIRTIO to be enabled via menuconfig or defconfig

2017-09-24 Thread Anup Patel
Currently, RPMSG_VIRTIO can only be enabled if some other kconfig
option selects it. This does not allow it to be enabled for
virtualized systems where Virtio RPMSG is available over Virtio
MMIO or PCI transport.

This patch updates RPMSG_VIRTIO kconfig option so that we can
enable the VirtIO RPMSG driver via menuconfig or defconfig.

Signed-off-by: Anup Patel 
---
 drivers/rpmsg/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig
index 0fe6eac..7e29b30 100644
--- a/drivers/rpmsg/Kconfig
+++ b/drivers/rpmsg/Kconfig
@@ -47,7 +47,7 @@ config RPMSG_QCOM_SMD
  platforms.
 
 config RPMSG_VIRTIO
-   tristate
+   tristate "Virtio RPMSG bus driver"
select RPMSG
select VIRTIO
 
-- 
2.7.4



Re: [PATCH 1/6] [media] omap_vout: Delete an error message for a failed memory allocation in omap_vout_create_video_devices()

2017-09-24 Thread Joe Perches
On Sun, 2017-09-24 at 12:22 +0200, SF Markus Elfring wrote:
> Omit an extra message for a memory allocation failure in this function.
[]
> diff --git a/drivers/media/platform/omap/omap_vout.c 
> b/drivers/media/platform/omap/omap_vout.c
[]
> @@ -1948,7 +1948,5 @@ static int __init omap_vout_create_video_devices(struct 
> platform_device *pdev)
> - if (!vout) {
> - dev_err(&pdev->dev, ": could not allocate memory\n");
> + if (!vout)
>   return -ENOMEM;
> - }
>  
>   vout->vid = k;
>   vid_dev->vouts[k] = vout;

Use normal patch styles.
Fix your tools before you send any more patches.


[PATCH 6/6] [media] omap_vout: Delete two unnecessary variable initialisations in omap_vout_probe()

2017-09-24 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 24 Sep 2017 11:33:39 +0200

The variables "dssdev" and "vid_dev" will eventually be set
to appropriate pointers a bit later.
Thus omit the explicit initialisations at the beginning.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/omap/omap_vout.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/omap/omap_vout.c 
b/drivers/media/platform/omap/omap_vout.c
index f446a37064f4..0efcea820007 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -2075,9 +2075,9 @@ static int __init omap_vout_probe(struct platform_device 
*pdev)
 {
int ret = 0, i;
struct omap_overlay *ovl;
-   struct omap_dss_device *dssdev = NULL;
+   struct omap_dss_device *dssdev;
struct omap_dss_device *def_display;
-   struct omap2video_device *vid_dev = NULL;
+   struct omap2video_device *vid_dev;
 
if (omapdss_is_initialized() == false)
return -EPROBE_DEFER;
-- 
2.14.1



[PATCH 5/6] [media] omap_vout: Delete an unnecessary variable initialisation in omap_vout_open()

2017-09-24 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 24 Sep 2017 11:20:11 +0200

The local variable "vout" is reassigned by a statement at the beginning.
Thus omit the explicit initialisation.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/omap/omap_vout.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/omap/omap_vout.c 
b/drivers/media/platform/omap/omap_vout.c
index 71b77426271e..f446a37064f4 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -1001,7 +1001,7 @@ static int omap_vout_release(struct file *file)
 static int omap_vout_open(struct file *file)
 {
struct videobuf_queue *q;
-   struct omap_vout_device *vout = NULL;
+   struct omap_vout_device *vout;
 
vout = video_drvdata(file);
if (!vout)
-- 
2.14.1



[PATCH 4/6] [media] omap_vout: Fix a possible null pointer dereference in omap_vout_open()

2017-09-24 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 24 Sep 2017 11:00:57 +0200

Move a debug message so that a null pointer access can not happen
for the variable "vout" in this function.

Fixes: 5c7ab6348e7b3fcca2b8ee548306c774472971e2 ("V4L/DVB: V4L2: Add support 
for OMAP2/3 V4L2 display driver on top of DSS2")

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/omap/omap_vout.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/omap/omap_vout.c 
b/drivers/media/platform/omap/omap_vout.c
index 2b55a8ebd1ad..71b77426271e 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -1004,11 +1004,11 @@ static int omap_vout_open(struct file *file)
struct omap_vout_device *vout = NULL;
 
vout = video_drvdata(file);
-   v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
-
if (!vout)
return -ENODEV;
 
+   v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
+
/* for now, we only support single open */
if (vout->opened)
return -EBUSY;
-- 
2.14.1



[PATCH 3/6] [media] omap_vout: Adjust a null pointer check in two functions

2017-09-24 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 24 Sep 2017 10:30:29 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/omap/omap_vout.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/omap/omap_vout.c 
b/drivers/media/platform/omap/omap_vout.c
index 4a4d171ca573..2b55a8ebd1ad 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -1006,7 +1006,7 @@ static int omap_vout_open(struct file *file)
vout = video_drvdata(file);
v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
 
-   if (vout == NULL)
+   if (!vout)
return -ENODEV;
 
/* for now, we only support single open */
@@ -2095,7 +2095,7 @@ static int __init omap_vout_probe(struct platform_device 
*pdev)
}
 
vid_dev = kzalloc(sizeof(*vid_dev), GFP_KERNEL);
-   if (vid_dev == NULL) {
+   if (!vid_dev) {
ret = -ENOMEM;
goto err_dss_init;
}
-- 
2.14.1



radeon_get_bios: BUG: unable to handle kernel paging request

2017-09-24 Thread Thomas Meyer
Hi,

while trying to resurrect my old Macbook as an 32 bit kernel testing device,
I think someone broke the radeon driver on this first generation pure EFI boot
Macbook.

My guess would be that the introduction of the vga_switcheroo code did break the
radeon_get_bios functionality.

I will try again without radeon_atrm_get_bios and radeon_acpi_vfct_bios.

kind regards
thomas

[0.00] Linux version 4.14.0-rc1+ (thomas@maria) (gcc version 7.1.1 
20170622 (Red Hat 7.1.1-3) (GCC)) #7 SMP Sun Sep 24 07:16:00 CEST 2017
[0.00] Disabled fast string operations
[0.00] x86/fpu: x87 FPU will use FXSAVE
[0.00] e820: BIOS-provided physical RAM map:
[0.00] BIOS-e820: [mem 0x-0x0008efff] usable
[0.00] BIOS-e820: [mem 0x0008f000-0x0008] ACPI NVS
[0.00] BIOS-e820: [mem 0x0009-0x0009] usable
[0.00] BIOS-e820: [mem 0x0010-0x7f0c7fff] usable
[0.00] BIOS-e820: [mem 0x7f0c8000-0x7f2c8fff] ACPI NVS
[0.00] BIOS-e820: [mem 0x7f2c9000-0x7fe4afff] usable
[0.00] BIOS-e820: [mem 0x7fe4b000-0x7fe6efff] reserved
[0.00] BIOS-e820: [mem 0x7fe6f000-0x7fe7efff] usable
[0.00] BIOS-e820: [mem 0x7fe7f000-0x7feaafff] reserved
[0.00] BIOS-e820: [mem 0x7feab000-0x7feb1fff] usable
[0.00] BIOS-e820: [mem 0x7feb2000-0x7feb6fff] ACPI data
[0.00] BIOS-e820: [mem 0x7feb7000-0x7feb8fff] usable
[0.00] BIOS-e820: [mem 0x7feb9000-0x7feeefff] ACPI NVS
[0.00] BIOS-e820: [mem 0x7feef000-0x7fefefff] ACPI data
[0.00] BIOS-e820: [mem 0x7feff000-0x7fef] reserved
[0.00] BIOS-e820: [mem 0xe00f8000-0xe00f8fff] reserved
[0.00] BIOS-e820: [mem 0xfed1c000-0xfed1] reserved
[0.00] BIOS-e820: [mem 0xfffb-0xfffd] reserved
[0.00] Notice: NX (Execute Disable) protection cannot be enabled: 
non-PAE kernel!
[0.00] e820: update [mem 0x7bf6f010-0x7bf7ea3b] usable ==> usable
[0.00] e820: update [mem 0x7bf6f010-0x7bf7ea3b] usable ==> usable
[0.00] extended physical RAM map:
[0.00] reserve setup_data: [mem 0x-0x0008efff] 
usable
[0.00] reserve setup_data: [mem 0x0008f000-0x0008] 
ACPI NVS
[0.00] reserve setup_data: [mem 0x0009-0x0009] 
usable
[0.00] reserve setup_data: [mem 0x0010-0x7bf6f00f] 
usable
[0.00] reserve setup_data: [mem 0x7bf6f010-0x7bf7ea3b] 
usable
[0.00] reserve setup_data: [mem 0x7bf7ea3c-0x7f0c7fff] 
usable
[0.00] reserve setup_data: [mem 0x7f0c8000-0x7f2c8fff] 
ACPI NVS
[0.00] reserve setup_data: [mem 0x7f2c9000-0x7fe4afff] 
usable
[0.00] reserve setup_data: [mem 0x7fe4b000-0x7fe6efff] 
reserved
[0.00] reserve setup_data: [mem 0x7fe6f000-0x7fe7efff] 
usable
[0.00] reserve setup_data: [mem 0x7fe7f000-0x7feaafff] 
reserved
[0.00] reserve setup_data: [mem 0x7feab000-0x7feb1fff] 
usable
[0.00] reserve setup_data: [mem 0x7feb2000-0x7feb6fff] 
ACPI data
[0.00] reserve setup_data: [mem 0x7feb7000-0x7feb8fff] 
usable
[0.00] reserve setup_data: [mem 0x7feb9000-0x7feeefff] 
ACPI NVS
[0.00] reserve setup_data: [mem 0x7feef000-0x7fefefff] 
ACPI data
[0.00] reserve setup_data: [mem 0x7feff000-0x7fef] 
reserved
[0.00] reserve setup_data: [mem 0xe00f8000-0xe00f8fff] 
reserved
[0.00] reserve setup_data: [mem 0xfed1c000-0xfed1] 
reserved
[0.00] reserve setup_data: [mem 0xfffb-0xfffd] 
reserved
[0.00] efi: EFI v1.10 by Apple
[0.00] efi:  ACPI=0x7fefd000  ACPI 2.0=0x7fefd014  SMBIOS=0x7feba000 
[0.00] random: fast init done
[0.00] SMBIOS 2.4 present.
[0.00] DMI: Apple Computer, Inc. MacBookPro1,1/Mac-F425BEC8, BIOS
MBP11.88Z.0055.B08.0610121325 10/12/06
[0.00] tsc: Fast TSC calibration using PIT
[0.00] e820: update [mem 0x-0x0fff] usable ==> reserved
[0.00] e820: remove [mem 0x000a-0x000f] usable
[0.00] e820: last_pfn = 0x7feb9 max_arch_pfn = 0x10
[0.00] MTRR default type: uncachable
[0.00] MTRR fixed ranges enabled:
[0.00]   0-9 write-back
[0.00]   A-B uncachable
[0.00]   C-C write-protect
[0.00]   D-D uncachable
[0.00]   E-F write-protect
[0.00] M

[PATCH 2/6] [media] omap_vout: Improve a size determination in two functions

2017-09-24 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 24 Sep 2017 10:18:26 +0200

Replace the specification of data structures by variable references
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/omap/omap_vout.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/omap/omap_vout.c 
b/drivers/media/platform/omap/omap_vout.c
index aebc1e628ac5..4a4d171ca573 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -1943,8 +1943,7 @@ static int __init omap_vout_create_video_devices(struct 
platform_device *pdev)
struct omap2video_device, v4l2_dev);
 
for (k = 0; k < pdev->num_resources; k++) {
-
-   vout = kzalloc(sizeof(struct omap_vout_device), GFP_KERNEL);
+   vout = kzalloc(sizeof(*vout), GFP_KERNEL);
if (!vout)
return -ENOMEM;
 
@@ -2095,7 +2094,7 @@ static int __init omap_vout_probe(struct platform_device 
*pdev)
goto err_dss_init;
}
 
-   vid_dev = kzalloc(sizeof(struct omap2video_device), GFP_KERNEL);
+   vid_dev = kzalloc(sizeof(*vid_dev), GFP_KERNEL);
if (vid_dev == NULL) {
ret = -ENOMEM;
goto err_dss_init;
-- 
2.14.1



[PATCH 1/6] [media] omap_vout: Delete an error message for a failed memory allocation in omap_vout_create_video_devices()

2017-09-24 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 24 Sep 2017 10:08:22 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/omap/omap_vout.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/platform/omap/omap_vout.c 
b/drivers/media/platform/omap/omap_vout.c
index 4d29860d27b4..aebc1e628ac5 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -1948,7 +1948,5 @@ static int __init omap_vout_create_video_devices(struct 
platform_device *pdev)
-   if (!vout) {
-   dev_err(&pdev->dev, ": could not allocate memory\n");
+   if (!vout)
return -ENOMEM;
-   }
 
vout->vid = k;
vid_dev->vouts[k] = vout;
-- 
2.14.1



[PATCH 0/6] [media] omap_vout: Adjustments for three function implementations

2017-09-24 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 24 Sep 2017 12:06:54 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (6):
  Delete an error message for a failed memory allocation in 
omap_vout_create_video_devices()
  Improve a size determination in two functions
  Adjust a null pointer check in two functions
  Fix a possible null pointer dereference in omap_vout_open()
  Delete an unnecessary variable initialisation in omap_vout_open()
  Delete two unnecessary variable initialisations in omap_vout_probe()

 drivers/media/platform/omap/omap_vout.c | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

-- 
2.14.1



Re: [PATCH] sparc64: mmu_context: Add missing include files

2017-09-24 Thread Oded Gabbay
On Sun, Sep 10, 2017 at 11:44 PM, Guenter Roeck  wrote:
> Fix the following build errors.
>
> In file included from arch/sparc/include/asm/mmu_context.h:4:0,
>  from include/linux/mmu_context.h:4,
>  from drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h:29,
>  from drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c:23:
> arch/sparc/include/asm/mmu_context_64.h:22:37: error:
> unknown type name 'per_cpu_secondary_mm'
>
> arch/sparc/include/asm/mmu_context_64.h: In function 'switch_mm':
> arch/sparc/include/asm/mmu_context_64.h:79:2: error:
> implicit declaration of function 'smp_processor_id'
>
> Fixes: 70539bd79500 ("drm/amd: Update MEC HQD loading code for KFD")
> Signed-off-by: Guenter Roeck 
> ---
> "Exposed-by:" instead of "Fixes:" might be more appropriate.
>
>  arch/sparc/include/asm/mmu_context_64.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/arch/sparc/include/asm/mmu_context_64.h 
> b/arch/sparc/include/asm/mmu_context_64.h
> index 87841d687f8d..a34315e1f0ed 100644
> --- a/arch/sparc/include/asm/mmu_context_64.h
> +++ b/arch/sparc/include/asm/mmu_context_64.h
> @@ -7,9 +7,11 @@
>
>  #include 
>  #include 
> +#include 
>
>  #include 
>  #include 
> +#include 
>
>  static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct 
> *tsk)
>  {
> --
> 2.7.4
>


This patch is:
Acked-by: Oded Gabbay 


HI David,
Could you please pick-up this patch for -rc3/4 ?
We constantly get kbuild error reports due to this issue.

Thanks,
Oded


Re: 9f4835fb96 ("x86/fpu: Tighten validation of user-supplied .."): Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

2017-09-24 Thread Ingo Molnar

* kernel test robot  wrote:

> Greetings,
> 
> 0day kernel testing robot got the below dmesg and the first bad commit is
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git WIP.x86/fpu
> 
> commit 9f4835fb965d8eea7e608d0cb62c246c804dec90
> Author: Eric Biggers 
> AuthorDate: Fri Sep 22 10:41:55 2017 -0700
> Commit: Ingo Molnar 
> CommitDate: Sat Sep 23 11:02:00 2017 +0200
> 
> x86/fpu: Tighten validation of user-supplied xstate_header

So unfortunately the crash log was not extracted properly by the bot, so we 
only 
know the subject line:

   Kernel panic - not syncing: Attempted to kill init! exitcode=0x000b

One possibility would be for this memcpy() in copy_kernel_to_xstate() to cause 
the 
crash:

memcpy(&hdr, kbuf + offset, size);

where 'size' increased from:


size = sizeof(xfeatures);

which was 8 bytes, to:

size = sizeof(hdr);

which is 64 bytes.

What guarantees that 'kbuf + offset + size-1' is still within the kbuf buffer? 
AFAICS 'kbuf' gets validated with fpu_user_xstate_size.

... I might be barking up the wrong tree, but I don't see this guaranteed, at 
least not in any obvious way.

In hindsight, I think we need to split up this commit:

  x86/fpu: Tighten validation of user-supplied xstate_header

Into at least 5-6 parts (!), as it's way too large and risky.

Here is the split-up I'd suggest:

1)

Introduce the new validate_xstate_header() function - without actually using it.

2)

Change xstateregs_set() to use validate_xstate_header() and change the behavior 
of 
reserved bits. Since this impacts the ABI we better have this as a standalone, 
bisectable patch.

3)

Change sanitize_restored_xstate() to use the new validate_xstate_header().

4)

Change copy_kernel_to_xstate() to introduce the new on-kernel-stack header 
copy, 
but don't yet update the rest of the code, just initialize 'xfeatures' from the 
header copy and leave the rest unchanged.

5)

Fix copy_kernel_to_xstate() to now use the header properly, pass it to 
validate_xstate_header() and get rid of the 'xfeatures' local variable, etc.
  
6)

Also, while this change looks correct but it's unrelated and spurious:
 
-   if (boot_cpu_has(X86_FEATURE_XSAVES)) {
+   if (using_compacted_format()) {

and using_compacted_format() is a stupidly global function that adds overhead 
unnecessarily:

int using_compacted_format(void)
{
return boot_cpu_has(X86_FEATURE_XSAVES);
}

It should be a static inline instead.

Thanks,

Ingo


Re: [PATCH] firmware: dmi_scan: Drop dmi_initialized

2017-09-24 Thread Ingo Molnar

* Jean Delvare  wrote:

> Hi Ingo,
> 
> On Sat, 23 Sep 2017 12:50:31 +0200, Ingo Molnar wrote:
> > * Jean Delvare  wrote:
> > 
> > > I don't think it makes sense to check for a possible bad
> > > initialization order at run time on every system when it is all
> > > decided at build time.
> > > 
> > > A more efficient way to make sure developers do not introduce new
> > > calls to dmi_check_system() too early in the initialization sequence
> > > is to simply document the expected call order. That way, developers
> > > have a chance to get it right immediately, without having to
> > > test-boot their kernel, wonder why it does not work, and parse the
> > > kernel logs for a warning message. And we get rid of the run-time
> > > performance penalty as a nice side effect.  
> > 
> > Huh? Initialization ordering requirements are very opaque,
> 
> They were. Now they are very documented.
> 
> > and by removing the debug check any such bugs are actively hidden. How
> > is documentation supposed to uncover such bugs once they happen?
> 
> You are looking at it the wrong way around. Documentation is how they
> do not happen in the first place.

That expectation, as a general statement, is very naive and contrary to 
experience: documentation is fine for one layer of defense to prevent bugs, but 
_when_ they happen and a bug slips through, documentation does not help 
anymore, 
because the dependencies in the _code_ are opaque and non-obvious ...

For example during the early SMP efforts of Linux we used to document lock 
dependencies as well, but once the kernel had more than a dozen spinlocks we 
periodically ran into deadlocks and the whole design became unmaintainable 
quickly. So we have lockdep in addition to documentation.

> You hit this problem once, 9 years ago. You thought it would have been easier 
> to 
> debug if there was a warning, and you added it.

I did not just 'think' it would have been easier to debug, I wasted time on 
that 
bug and a warning would have helped so I added it. That was and remains 
objectively true.

While I expect most such warnings to never see any public email lists (because 
once a developer triggers it it gets fixed without the bug ever getting 
triggered 
by others), yet searching for "dmi check: not initialized yet" still finds a 
couple of incidents where real or potential bugs were found by this init 
dependency check, such as:

   
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-September/289347.html

or this:

   https://www.spinics.net/lists/linux-acpi/msg28698.html

... so this warning actually helped a number of kernel developers to not
waste time on the opaque dependency. This is a warning that was added due
to an _actual category of bugs_, which has been triggered subsequently as
well, so it's not a frivolous warning by any meaning.

> [...] It was one way to solve the problem but I claim it was not the best.
> 
> What I expect from developers calling a function they aren't familiar
> with is to read its documentation first. That's the very reason why we
> spend time writing the documentation. They should not just call the
> function, boot and see if it works or not. Software engineering vs.
> trial and error.

This statement is breathtaking in its ignorance :-(

> > So NAK.
> 
> This was FYI. I maintain this subsystem, and you did not convince me. I also 
> can't see a general trend of implementing what you suggest in the rest of the 
> kernel. Thankfully.

I find the arrogance displayed here breathtaking as well - the last thing we 
need 
is for firmware interfacing kernel code to become _more_ fragile.

This was and continues to be a useful warning - but what worries me even more 
is 
not just the removal of the warning, but the false and technically invalid 
justifications under which it is removed...

For those reasons I maintain my NAK:

  Nacked-by: Ingo Molnar 

Thanks,

Ingo


[char-misc 1/2] mei: always use domain runtime pm callbacks.

2017-09-24 Thread Tomas Winkler
From: Alexander Usyskin 

This patch fixes a regression caused by the new changes
in the run wake handlers, pci_dev_run_wake() return true
when wake is possible from the software perspective
not whether it is actually enabled.

The mei devices that support D0i3 are no longer receiving an interrupt
after entering runtime suspend state and will stall.

MEI maps runtime suspend/resume to its own defined
power gating (PG) states, (D0i3 or other depending on generation),
hence we need to go around the native PCI runtime service which
eventually brings the device into D3cold/hot state,
but the mei devices cannot wake up from D3 unlike from D0i3/PG state,
which keeps irq running.
To get around PCI device native runtime pm,
MEI uses runtime pm domain handlers which take precedence.

Cc:  #4.13+
Cc: Rafael J. Wysocki 
Signed-off-by: Alexander Usyskin 
Signed-off-by: Tomas Winkler 
---
 drivers/misc/mei/pci-me.c  | 21 +++--
 drivers/misc/mei/pci-txe.c | 30 +++---
 2 files changed, 22 insertions(+), 29 deletions(-)

diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index 4ff40d319676..630757a4b36a 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -226,12 +226,15 @@ static int mei_me_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
pdev->dev_flags |= PCI_DEV_FLAGS_NEEDS_RESUME;
 
/*
-   * For not wake-able HW runtime pm framework
-   * can't be used on pci device level.
-   * Use domain runtime pm callbacks instead.
-   */
-   if (!pci_dev_run_wake(pdev))
-   mei_me_set_pm_domain(dev);
+* ME maps runtime suspend/resume to D0i states,
+* hence we need to go around native PCI runtime service which
+* eventually brings the device into D3cold/hot state,
+* but the mei device cannot wake up from D3 unlike from D0i3.
+* To get around the PCI device native runtime pm,
+* ME uses runtime pm domain handlers which take precedence
+* over the driver's pm handlers.
+*/
+   mei_me_set_pm_domain(dev);
 
if (mei_pg_is_enabled(dev))
pm_runtime_put_noidle(&pdev->dev);
@@ -271,8 +274,7 @@ static void mei_me_shutdown(struct pci_dev *pdev)
dev_dbg(&pdev->dev, "shutdown\n");
mei_stop(dev);
 
-   if (!pci_dev_run_wake(pdev))
-   mei_me_unset_pm_domain(dev);
+   mei_me_unset_pm_domain(dev);
 
mei_disable_interrupts(dev);
free_irq(pdev->irq, dev);
@@ -300,8 +302,7 @@ static void mei_me_remove(struct pci_dev *pdev)
dev_dbg(&pdev->dev, "stop\n");
mei_stop(dev);
 
-   if (!pci_dev_run_wake(pdev))
-   mei_me_unset_pm_domain(dev);
+   mei_me_unset_pm_domain(dev);
 
mei_disable_interrupts(dev);
 
diff --git a/drivers/misc/mei/pci-txe.c b/drivers/misc/mei/pci-txe.c
index e38a5f144373..0566f9bfa7de 100644
--- a/drivers/misc/mei/pci-txe.c
+++ b/drivers/misc/mei/pci-txe.c
@@ -144,12 +144,14 @@ static int mei_txe_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
pdev->dev_flags |= PCI_DEV_FLAGS_NEEDS_RESUME;
 
/*
-   * For not wake-able HW runtime pm framework
-   * can't be used on pci device level.
-   * Use domain runtime pm callbacks instead.
-   */
-   if (!pci_dev_run_wake(pdev))
-   mei_txe_set_pm_domain(dev);
+* TXE maps runtime suspend/resume to own power gating states,
+* hence we need to go around native PCI runtime service which
+* eventually brings the device into D3cold/hot state.
+* But the TXE device cannot wake up from D3 unlike from own
+* power gating. To get around PCI device native runtime pm,
+* TXE uses runtime pm domain handlers which take precedence.
+*/
+   mei_txe_set_pm_domain(dev);
 
pm_runtime_put_noidle(&pdev->dev);
 
@@ -186,8 +188,7 @@ static void mei_txe_shutdown(struct pci_dev *pdev)
dev_dbg(&pdev->dev, "shutdown\n");
mei_stop(dev);
 
-   if (!pci_dev_run_wake(pdev))
-   mei_txe_unset_pm_domain(dev);
+   mei_txe_unset_pm_domain(dev);
 
mei_disable_interrupts(dev);
free_irq(pdev->irq, dev);
@@ -215,8 +216,7 @@ static void mei_txe_remove(struct pci_dev *pdev)
 
mei_stop(dev);
 
-   if (!pci_dev_run_wake(pdev))
-   mei_txe_unset_pm_domain(dev);
+   mei_txe_unset_pm_domain(dev);
 
mei_disable_interrupts(dev);
free_irq(pdev->irq, dev);
@@ -318,15 +318,7 @@ static int mei_txe_pm_runtime_suspend(struct device 
*device)
else
ret = -EAGAIN;
 
-   /*
-* If everything is okay we're about to enter PCI low
-* power state (D3) therefor we need to disable the
-* interrupts towards host.
-* However if device is not wakeable we do not enter
-* D-low state and we need to keep the interrupt kicking
-*/
-   if (!ret

[char-misc 0/2] mei updates for 4.14-rc2

2017-09-24 Thread Tomas Winkler
Hello Greg, here are updates for 4.14-rc2 containing:

A regression fix that hit us in 4.13,
unfortunately we haven't spotted it during the 4.13 cycle.

A new device id, for Gemini Lake SoC. This particular patch doesn't
apply cleanly to stable kernels so I will post separated backport patches 
for 4.4 and newer kernel versions.

Alexander Usyskin (1):
  mei: always use domain runtime pm callbacks.

Tomas Winkler (1):
  mei: me: add gemini lake devices id

 drivers/misc/mei/hw-me-regs.h |  2 ++
 drivers/misc/mei/pci-me.c | 23 +--
 drivers/misc/mei/pci-txe.c| 30 +++---
 3 files changed, 26 insertions(+), 29 deletions(-)

-- 
2.9.5



[char-misc 2/2] mei: me: add gemini lake devices id

2017-09-24 Thread Tomas Winkler
Add Gemini Lake (GLK) device id.

Signed-off-by: Tomas Winkler 
---
 drivers/misc/mei/hw-me-regs.h | 2 ++
 drivers/misc/mei/pci-me.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/drivers/misc/mei/hw-me-regs.h b/drivers/misc/mei/hw-me-regs.h
index c8307e8b4c16..0baf530d 100644
--- a/drivers/misc/mei/hw-me-regs.h
+++ b/drivers/misc/mei/hw-me-regs.h
@@ -127,6 +127,8 @@
 #define MEI_DEV_ID_BXT_M  0x1A9A  /* Broxton M */
 #define MEI_DEV_ID_APL_I  0x5A9A  /* Apollo Lake I */
 
+#define MEI_DEV_ID_GLK0x319A  /* Gemini Lake */
+
 #define MEI_DEV_ID_KBP0xA2BA  /* Kaby Point */
 #define MEI_DEV_ID_KBP_2  0xA2BB  /* Kaby Point 2 */
 
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index 630757a4b36a..78b3172c8e6e 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -93,6 +93,8 @@ static const struct pci_device_id mei_me_pci_tbl[] = {
{MEI_PCI_DEVICE(MEI_DEV_ID_BXT_M, MEI_ME_PCH8_CFG)},
{MEI_PCI_DEVICE(MEI_DEV_ID_APL_I, MEI_ME_PCH8_CFG)},
 
+   {MEI_PCI_DEVICE(MEI_DEV_ID_GLK, MEI_ME_PCH8_CFG)},
+
{MEI_PCI_DEVICE(MEI_DEV_ID_KBP, MEI_ME_PCH8_CFG)},
{MEI_PCI_DEVICE(MEI_DEV_ID_KBP_2, MEI_ME_PCH8_CFG)},
 
-- 
2.9.5



include/linux/kernel.h:860:32: error: dereferencing pointer to incomplete type 'struct clock_event_device'

2017-09-24 Thread kbuild test robot
Hi Ian,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   cd4175b11685b11c40e31a03e05084cc212b0649
commit: c7acec713d14c6ce8a20154f9dfda258d6bcad3b kernel.h: handle pointers to 
arrays better in container_of()
date:   2 months ago
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout c7acec713d14c6ce8a20154f9dfda258d6bcad3b
# save the attached .config to linux build tree
make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   In file included from drivers/clocksource/timer-of.c:25:0:
   drivers/clocksource/timer-of.h:35:28: error: field 'clkevt' has incomplete 
type
 struct clock_event_device clkevt;
   ^~
   In file included from include/linux/err.h:4:0,
from include/linux/clk.h:15,
from drivers/clocksource/timer-of.c:18:
   drivers/clocksource/timer-of.h: In function 'to_timer_of':
>> include/linux/kernel.h:860:32: error: dereferencing pointer to incomplete 
>> type 'struct clock_event_device'
 BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
   ^~
   include/linux/compiler.h:517:19: note: in definition of macro 
'__compiletime_assert'
  bool __cond = !(condition);\
  ^
   include/linux/compiler.h:537:2: note: in expansion of macro 
'_compiletime_assert'
 _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
 ^~~
   include/linux/build_bug.h:46:37: note: in expansion of macro 
'compiletime_assert'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~
   include/linux/kernel.h:860:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
 BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
 ^~~~
   include/linux/kernel.h:860:20: note: in expansion of macro '__same_type'
 BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
   ^~~
   drivers/clocksource/timer-of.h:44:9: note: in expansion of macro 
'container_of'
 return container_of(clkevt, struct timer_of, clkevt);
^~~~
--
   In file included from drivers//clocksource/timer-of.c:25:0:
   drivers//clocksource/timer-of.h:35:28: error: field 'clkevt' has incomplete 
type
 struct clock_event_device clkevt;
   ^~
   In file included from include/linux/err.h:4:0,
from include/linux/clk.h:15,
from drivers//clocksource/timer-of.c:18:
   drivers//clocksource/timer-of.h: In function 'to_timer_of':
>> include/linux/kernel.h:860:32: error: dereferencing pointer to incomplete 
>> type 'struct clock_event_device'
 BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
   ^~
   include/linux/compiler.h:517:19: note: in definition of macro 
'__compiletime_assert'
  bool __cond = !(condition);\
  ^
   include/linux/compiler.h:537:2: note: in expansion of macro 
'_compiletime_assert'
 _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
 ^~~
   include/linux/build_bug.h:46:37: note: in expansion of macro 
'compiletime_assert'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~
   include/linux/kernel.h:860:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
 BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
 ^~~~
   include/linux/kernel.h:860:20: note: in expansion of macro '__same_type'
 BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
   ^~~
   drivers//clocksource/timer-of.h:44:9: note: in expansion of macro 
'container_of'
 return container_of(clkevt, struct timer_of, clkevt);
^~~~

vim +860 include/linux/kernel.h

   843  
   844  
   845  /*
   846   * swap - swap value of @a and @b
   847   */
   848  #define swap(a, b) \
   849  do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
   850  
   851  /**
   852   * container_of - cast a member of a structure out to the containing 
structure
   853   * @ptr:the pointer to the member.
   854   * @type:   the type of the container struct this is embedded in.
   855   * @member: the name of the member within the struct.
   856   *
   857   */
   858  #define container_of(ptr, type, member) ({  
\
   859  void *__mptr = (void *)(ptr);   
\
 > 860  BUILD_BUG_ON_MSG

Re: [PATCH] Fix C++ kernel in include/linux/mtd/mtd.h

2017-09-24 Thread Richard Weinberger
Am Sonntag, 24. September 2017, 10:20:06 CEST schrieb Boris Brezillon:
> On Sat, 23 Sep 2017 23:10:26 +0200
> 
> Marek Vasut  wrote:
> > On 09/23/2017 10:13 PM, Pavel Machek wrote:
> > > C++ comments look wrong in kernel tree. Fix one.
> > 
> > AFAIR they are now (sadly) accepted, but this patch works for me.
> 
> Works for me too. Here is my
> 
> Acked-by: Boris Brezillon 
> 
> > Would be nice if trivial could pick it.
> 
> Hm, I'd recommend not doing that, otherwise we might end up with a
> conflict if a patch modify something in this area.

Let's carry it via MTD.
BTW: Shouldn't it be s/kernel/comment/ in the subject line?

Thanks,
//richard


Re: [PATCH] Fix C++ kernel in include/linux/mtd/mtd.h

2017-09-24 Thread Boris Brezillon
On Sat, 23 Sep 2017 23:10:26 +0200
Marek Vasut  wrote:

> On 09/23/2017 10:13 PM, Pavel Machek wrote:
> > C++ comments look wrong in kernel tree. Fix one.  
> 
> AFAIR they are now (sadly) accepted, but this patch works for me.

Works for me too. Here is my

Acked-by: Boris Brezillon 

> Would be nice if trivial could pick it.

Hm, I'd recommend not doing that, otherwise we might end up with a
conflict if a patch modify something in this area.

> 
> > Signed-off-by: Pavel Machek 
> > 
> > diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> > index 6cd0f6b..849543f1 100644
> > --- a/include/linux/mtd/mtd.h
> > +++ b/include/linux/mtd/mtd.h
> > @@ -267,7 +267,7 @@ struct mtd_info {
> >  */
> > unsigned int bitflip_threshold;
> >  
> > -   // Kernel-only stuff starts here.
> > +   /* Kernel-only stuff starts here. */
> > const char *name;
> > int index;
> >  
> >   
> 
> 



[PATCH v3] block: consider merge of segments when merge bio into rq

2017-09-24 Thread Jianchao Wang
When account the nr_phys_segments during merging bios into rq,
only consider segments merging in individual bio but not all
the bios in a rq. This leads to the bigger nr_phys_segments of
rq than the real one when the segments of bios in rq are
contiguous and mergeable. The nr_phys_segments of rq will exceed
max_segmets of q and stop merging while the sectors of rq maybe
far away from the max_sectors of q.

In practice, the merging will stop due to max_segmets limit while
the segments in the rq are contiguous and mergeable during the
mkfs.ext4 workload on my local. This could be harmful to the
performance of sequential operations.

To fix it, consider the segments merge when account nr_phys_segments
of rq during merging bio into rq. Decrease the nr_phys_segments of rq
by 1 when the adjacent segments in bio and rq are contiguous and
mergeable. Consequently get more fully merging and better performance
in sequential operations. In addition, it could eliminate the wasting of
scatterlist structure.

On my local mkfs.ext4 workload, the final size of rq issued raise from
168 sectors (max_segmets is 168) to 2560 sectors (max_sector_kb is 1280).

Change since v2:
Merge the duplicate code of segments merging check in
ll_front/back_merge_fn() together into ll_new_hw_segment().

Change since v1:
Add more comment to elaborate how this issue found and result after
apply the patch.

Signed-off-by: Jianchao Wang 
---
 block/blk-merge.c | 49 +++--
 1 file changed, 35 insertions(+), 14 deletions(-)

diff --git a/block/blk-merge.c b/block/blk-merge.c
index aa524ca..8dacedb 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -474,28 +474,50 @@ EXPORT_SYMBOL(blk_rq_map_sg);
 
 static inline int ll_new_hw_segment(struct request_queue *q,
struct request *req,
-   struct bio *bio)
+   struct bio *bio,
+   bool at_head)
 {
-   int nr_phys_segs = bio_phys_segments(q, bio);
+   unsigned int seg_size;
+   int total_nr_phys_segs;
+   bool contig;
 
-   if (req->nr_phys_segments + nr_phys_segs > queue_max_segments(q))
+   if (blk_integrity_merge_bio(q, req, bio) == false)
goto no_merge;
 
-   if (blk_integrity_merge_bio(q, req, bio) == false)
+   total_nr_phys_segs = req->nr_phys_segments + bio_phys_segments(q, bio);
+   if (at_head) {
+   seg_size = bio->bi_seg_back_size + req->bio->bi_seg_front_size;
+   contig = blk_phys_contig_segment(q, bio, req->bio);
+   } else {
+   seg_size = req->biotail->bi_seg_back_size + 
bio->bi_seg_front_size;
+   contig = blk_phys_contig_segment(q, req->biotail, bio);
+   }
+   if (contig)
+   total_nr_phys_segs--;
+
+   if (unlikely(total_nr_phys_segs > queue_max_segments(q)))
goto no_merge;
 
-   /*
-* This will form the start of a new hw segment.  Bump both
-* counters.
-*/
-   req->nr_phys_segments += nr_phys_segs;
-   return 1;
+   if (contig) {
+   if (at_head) {
+   if (bio->bi_phys_segments == 1)
+   bio->bi_seg_front_size = seg_size;
+   if (req->nr_phys_segments == 1)
+   req->biotail->bi_seg_back_size = seg_size;
+   } else {
+   if (req->nr_phys_segments == 1)
+   req->bio->bi_seg_front_size = seg_size;
+   if (bio->bi_phys_segments == 1)
+   bio->bi_seg_back_size = seg_size;
+   }
+   }
 
+   req->nr_phys_segments = total_nr_phys_segs;
+   return 1;
 no_merge:
req_set_nomerge(q, req);
return 0;
 }
-
 int ll_back_merge_fn(struct request_queue *q, struct request *req,
 struct bio *bio)
 {
@@ -514,13 +536,12 @@ int ll_back_merge_fn(struct request_queue *q, struct 
request *req,
if (!bio_flagged(bio, BIO_SEG_VALID))
blk_recount_segments(q, bio);
 
-   return ll_new_hw_segment(q, req, bio);
+   return ll_new_hw_segment(q, req, bio, false);
 }
 
 int ll_front_merge_fn(struct request_queue *q, struct request *req,
  struct bio *bio)
 {
-
if (req_gap_front_merge(req, bio))
return 0;
if (blk_integrity_rq(req) &&
@@ -536,7 +557,7 @@ int ll_front_merge_fn(struct request_queue *q, struct 
request *req,
if (!bio_flagged(req->bio, BIO_SEG_VALID))
blk_recount_segments(q, req->bio);
 
-   return ll_new_hw_segment(q, req, bio);
+   return ll_new_hw_segment(q, req, bio, true);
 }
 
 /*
-- 
2.7.4



Re: [PATCH V3 1/1] clk: bulk: add of_clk_bulk_get()

2017-09-24 Thread Geert Uytterhoeven
On Sun, Sep 24, 2017 at 4:06 AM, kbuild test robot  wrote:
> [auto build test ERROR on clk/clk-next]
> [also build test ERROR on v4.14-rc1 next-20170922]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
>
> url:
> https://github.com/0day-ci/linux/commits/Dong-Aisheng/clk-bulk-add-of_clk_bulk_get/20170921-203645
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
> config: sh-apsh4a3a_defconfig (attached as .config)
> compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
> reproduce:
> wget 
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=sh
>
> All errors (new ones prefixed by >>):
>
>In file included from arch/sh/kernel/setup.c:28:0:
>>> include/linux/clk.h:689:12: error: 'of_clk_bulk_get' defined but not used 
>>> [-Werror=unused-function]
> static int of_clk_bulk_get(struct device_node *np, int num_clks,
>^~~
>cc1: all warnings being treated as errors
>
> vim +/of_clk_bulk_get +689 include/linux/clk.h
>
>681
>682  #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK)
>683  int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,
>684   struct clk_bulk_data *clks);
>685  struct clk *of_clk_get(struct device_node *np, int index);
>686  struct clk *of_clk_get_by_name(struct device_node *np, const char 
> *name);
>687  struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec);
>688  #else
>  > 689  static int of_clk_bulk_get(struct device_node *np, int num_clks,

static inline

>690 struct clk_bulk_data *clks)
>691  {
>692  return -ENOENT;
>693  }
>694

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[PATCH v6 1/2] media:imx274 device tree binding file

2017-09-24 Thread Leon Luo
The binding file for imx274 CMOS sensor V4l2 driver

Signed-off-by: Leon Luo 
---
v6:
 - no changes
v5:
 - add 'port' and 'endpoint' information
v4:
 - no changes
v3:
 - remove redundant properties and references
 - document 'reg' property
v2:
 - no changes
---
 .../devicetree/bindings/media/i2c/imx274.txt   | 33 ++
 1 file changed, 33 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/imx274.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/imx274.txt 
b/Documentation/devicetree/bindings/media/i2c/imx274.txt
new file mode 100644
index ..80f2e89568e1
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/imx274.txt
@@ -0,0 +1,33 @@
+* Sony 1/2.5-Inch 8.51Mp CMOS Digital Image Sensor
+
+The Sony imx274 is a 1/2.5-inch CMOS active pixel digital image sensor with
+an active array size of 3864H x 2202V. It is programmable through I2C
+interface. The I2C address is fixed to 0x1a as per sensor data sheet.
+Image data is sent through MIPI CSI-2, which is configured as 4 lanes
+at 1440 Mbps.
+
+
+Required Properties:
+- compatible: value should be "sony,imx274" for imx274 sensor
+- reg: I2C bus address of the device
+
+Optional Properties:
+- reset-gpios: Sensor reset GPIO
+
+The imx274 device node should contain one 'port' child node with
+an 'endpoint' subnode. For further reading on port node refer to
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Example:
+   sensor@1a {
+   compatible = "sony,imx274";
+   reg = <0x1a>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reset-gpios = <&gpio_sensor 0 0>;
+   port {
+   sensor_out: endpoint {
+   remote-endpoint = <&csiss_in>;
+   };
+   };
+   };
-- 
2.14.0.rc1



[PATCH v6 2/2] media:imx274 V4l2 driver for Sony imx274 CMOS sensor

2017-09-24 Thread Leon Luo
The imx274 is a Sony CMOS image sensor that has 1/2.5 image size.
It supports up to 3840x2160 (4K) 60fps, 1080p 120fps. The interface
is 4-lane MIPI CSI-2 running at 1.44Gbps each.

This driver has been tested on Xilinx ZCU102 platform with a Leopard
LI-IMX274MIPI-FMC camera board.

Support for the following features:
-Resolutions: 3840x2160, 1920x1080, 1280x720
-Frame rate: 3840x2160 : 5 – 60fps
1920x1080 : 5 – 120fps
1280x720 : 5 – 120fps
-Exposure time: 16 – (frame interval) micro-seconds
-Gain: 1x - 180x
-VFLIP: enable/disabledrivers/media/i2c/imx274.c
-Test pattern: 12 test patterns

Signed-off-by: Leon Luo 
Tested-by: Sören Brinkmann 
---
v6:
- remove media/v4l2-image-sizes.h from include header
- make the header file alphabetical order
- remove fmt->pad check in imx274_get_fmt,
  the V4L2 subdev framework does it already
- change 'struct reg_8 *regs' to 'struct reg_8 regs[n]',
  where n is the exact numbers needed for this function
- move MODULE_DEVICE_TABLE(of, imx274_of_id_table); closer
  to imx274_of_id_table definition
- remove return check of imx274_write_table in imx274_remove,
  because it should remove all resources even i2c fails here
- move imx274_load_default before v4l2_async_register_subdev
v5:
 - no changes
v4:
 - use 32-bit data type to avoid __divdi3 compile error for i386
 - clean up OR together error codes
v3:
 - clean up header files
 - use struct directly instead of alias #define
 - use v4l2_ctrl_s_ctrl instead of v4l2_s_ctrl
 - revise debug output
 - move static helpers closer to their call site
 - don't OR toegether error codes
 - use closest valid gain value instead of erroring out
 - assigne lock to the control handler and omit explicit locking
 - acquire mutex lock for imx274_get_fmt
 - remove format->pad check in imx274_set_fmt since the pad is always 0
 - pass struct v4l2_ctrl pointer in gain/exposure/vlip/test pattern controls
 - remove priv->ctrls.vflip->val = val in imx274_set_vflip()
 - remove priv->ctrls.test_pattern->val = val in imx274_set_test_pattern()
 - remove empty open/close callbacks
 - remove empty core ops
 - add more error labels in probe
 - use v4l2_async_unregister_subdev instead of v4l2_device_unregister_subdev
 - use dynamic debug
 - split start_stream to two steps: imx274_mode_regs() and imx274_start_stream()
   frame rate & exposure can be updated
   between imx274_mode_regs() & imx274_start_stream()

v2:
 - Fix Kconfig to not remove existing options
---
 drivers/media/i2c/Kconfig  |7 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/imx274.c | 1804 
 3 files changed, 1812 insertions(+)
 create mode 100644 drivers/media/i2c/imx274.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 47113774a297..9659849e33a0 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -555,6 +555,13 @@ config VIDEO_APTINA_PLL
 config VIDEO_SMIAPP_PLL
tristate
 
+config VIDEO_IMX274
+   tristate "Sony IMX274 sensor support"
+   depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+   ---help---
+ This is a V4L2 sensor-level driver for the Sony IMX274
+ CMOS image sensor.
+
 config VIDEO_OV2640
tristate "OmniVision OV2640 sensor support"
depends on VIDEO_V4L2 && I2C
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index c843c181dfb9..f8d57e453936 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -92,5 +92,6 @@ obj-$(CONFIG_VIDEO_IR_I2C)  += ir-kbd-i2c.o
 obj-$(CONFIG_VIDEO_ML86V7667)  += ml86v7667.o
 obj-$(CONFIG_VIDEO_OV2659) += ov2659.o
 obj-$(CONFIG_VIDEO_TC358743)   += tc358743.o
+obj-$(CONFIG_VIDEO_IMX274) += imx274.o
 
 obj-$(CONFIG_SDR_MAX2175) += max2175.o
diff --git a/drivers/media/i2c/imx274.c b/drivers/media/i2c/imx274.c
new file mode 100644
index ..924d543682b0
--- /dev/null
+++ b/drivers/media/i2c/imx274.c
@@ -0,0 +1,1804 @@
+/*
+ * imx274.c - IMX274 CMOS Image Sensor driver
+ *
+ * Copyright (C) 2017, Leopard Imaging, Inc.
+ *
+ * Leon Luo 
+ * Edwin Zou 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+/*
+ * See "SHR, SVR Setting" in datasheet
+ */
+#define IMX274_DEFAULT_FRAME_LENGTH(45

Re: (*ABS*+0xbb29b267): multiple definition of `__crc___gcov_merge_add'

2017-09-24 Thread Richard Weinberger
Am Sonntag, 24. September 2017, 08:42:06 CEST schrieb kbuild test robot:
> Hi Thomas,
> 
> FYI, the error/warning still remains.

Thomas' fix will be part of the next pull request.

Thanks,
//richard


Re: [PATCH] staging:ccree Fix avoid externs in .c files

2017-09-24 Thread Gilad Ben-Yossef
On Thu, Sep 21, 2017 at 9:43 AM, Janani Sankara Babu
 wrote:
> This patch solves the warning shown by the checkpatch script
> WARNING: externs should be avoided in .c files

I'm afraid here too the feedback is the same - you are working on the
Linus master tree, therefore you are seeing
things that are already gone from the downstream staging tree.


Thanks,
Gilad


-- 
Gilad Ben-Yossef
Chief Coffee Drinker

"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
 -- Jean-Baptiste Queru


Re: [PATCH] staging:ccree Fix use BIT macro

2017-09-24 Thread Gilad Ben-Yossef
Hi Janani,

On Thu, Sep 21, 2017 at 9:39 AM, Janani Sankara Babu
 wrote:
> This patch is created to solve the following warning shown by the checkpatch
> script Warning: Replace all occurences of (1<
> Signed-off-by: Janani Sankara Babu 

Thank you for the patch - unfortunately, such a fix s already present
in the staging-next tree.

I suggest you base your patches to ccree on that tree as it is the
most current for this driver.

Thanks again,
Gilad


-- 
Gilad Ben-Yossef
Chief Coffee Drinker

"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
 -- Jean-Baptiste Queru


Re: ALSA: bebob: Use common error handling code in snd_bebob_stream_start_duplex()

2017-09-24 Thread SF Markus Elfring
> 668 if (!amdtp_stream_wait_callback(&bebob->tx_stream,
> 669 CALLBACK_TIMEOUT)) {
> 670 amdtp_stream_stop(&bebob->tx_stream);
> 671 amdtp_stream_stop(&bebob->rx_stream);
> 672 break_both_connections(bebob);
> 673 err = -ETIMEDOUT;
> 674 }
> 675 }
> 
> I think it better to apply your solution too in the above to keep code 
> consistency.

How do you think about to adjust this function implementation after the other 
two
update steps from the patch series would be integrated?


> For the other patches, I can find no merit to apply except for reduction
> of the number of characters included in the file.

Would you like to refer to any specific update suggestions for further 
clarification?

Regards,
Markus


<    2   3   4   5   6   7