RE: [PATCH 1/2] net: fec_main: Use platform_get_irq_byname_optional() to avoid error message

2019-10-09 Thread Andy Duan
From: Anson Huang  Sent: Wednesday, October 9, 2019 6:16 PM
> Failed to get irq using name is NOT fatal as driver will use index to get irq
> instead, use platform_get_irq_byname_optional() instead of
> platform_get_irq_byname() to avoid below error message during
> probe:
> 
> [0.819312] fec 30be.ethernet: IRQ int0 not found
> [0.824433] fec 30be.ethernet: IRQ int1 not found
> [0.829539] fec 30be.ethernet: IRQ int2 not found
> 
> Fixes: 7723f4c5ecdb ("driver core: platform: Add an error message to
> platform_get_irq*()")
> Signed-off-by: Anson Huang 

Acked-by: Fugang Duan 

> ---
>  drivers/net/ethernet/freescale/fec_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index d4d4c72..22c01b2 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -3558,7 +3558,7 @@ fec_probe(struct platform_device *pdev)
> 
>   for (i = 0; i < irq_cnt; i++) {
>   snprintf(irq_name, sizeof(irq_name), "int%d", i);
> - irq = platform_get_irq_byname(pdev, irq_name);
> + irq = platform_get_irq_byname_optional(pdev, irq_name);
>   if (irq < 0)
>   irq = platform_get_irq(pdev, i);
>   if (irq < 0) {
> --
> 2.7.4



RE: [PATCH 2/2] net: fec_ptp: Use platform_get_irq_xxx_optional() to avoid error message

2019-10-09 Thread Andy Duan
From: Anson Huang  Sent: Wednesday, October 9, 2019 6:16 PM
> Use platform_get_irq_byname_optional() and platform_get_irq_optional()
> instead of platform_get_irq_byname() and platform_get_irq() for optional
> IRQs to avoid below error message during probe:
> 
> [0.795803] fec 30be.ethernet: IRQ pps not found
> [0.800787] fec 30be.ethernet: IRQ index 3 not found
> 
> Fixes: 7723f4c5ecdb ("driver core: platform: Add an error message to
> platform_get_irq*()")
> Signed-off-by: Anson Huang 

Acked-by: Fugang Duan 
> ---
>  drivers/net/ethernet/freescale/fec_ptp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fec_ptp.c
> b/drivers/net/ethernet/freescale/fec_ptp.c
> index 19e2365..945643c 100644
> --- a/drivers/net/ethernet/freescale/fec_ptp.c
> +++ b/drivers/net/ethernet/freescale/fec_ptp.c
> @@ -600,9 +600,9 @@ void fec_ptp_init(struct platform_device *pdev, int
> irq_idx)
> 
>   INIT_DELAYED_WORK(&fep->time_keep, fec_time_keep);
> 
> - irq = platform_get_irq_byname(pdev, "pps");
> + irq = platform_get_irq_byname_optional(pdev, "pps");
>   if (irq < 0)
> - irq = platform_get_irq(pdev, irq_idx);
> + irq = platform_get_irq_optional(pdev, irq_idx);
>   /* Failure to get an irq is not fatal,
>* only the PTP_CLOCK_PPS clock events should stop
>*/
> --
> 2.7.4



Re: [PATCH v2 03/22] mtd: spi-nor: cadence-quadspi: Fix cqspi_command_read() definition

2019-10-09 Thread Boris Brezillon
On Tue, 24 Sep 2019 07:45:58 +
 wrote:

> From: Tudor Ambarus 
> 
> n_tx was never used, drop it. Replace 'const u8 *txbuf' with 'u8 opcode',
> to comply with the SPI NOR int (*read_reg)() method. The 'const'
> qualifier has no meaning for parameters passed by value, drop it.
> Going furher, the opcode was passed to cqspi_calc_rdreg() and never used,
> drop it.
> 
> Signed-off-by: Tudor Ambarus 

Reviewed-by: Boris Brezillon 

> ---
>  drivers/mtd/spi-nor/cadence-quadspi.c | 15 +++
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c 
> b/drivers/mtd/spi-nor/cadence-quadspi.c
> index ebda612641a4..22008fecd326 100644
> --- a/drivers/mtd/spi-nor/cadence-quadspi.c
> +++ b/drivers/mtd/spi-nor/cadence-quadspi.c
> @@ -285,7 +285,7 @@ static irqreturn_t cqspi_irq_handler(int this_irq, void 
> *dev)
>   return IRQ_HANDLED;
>  }
>  
> -static unsigned int cqspi_calc_rdreg(struct spi_nor *nor, const u8 opcode)
> +static unsigned int cqspi_calc_rdreg(struct spi_nor *nor)
>  {
>   struct cqspi_flash_pdata *f_pdata = nor->priv;
>   u32 rdreg = 0;
> @@ -354,8 +354,7 @@ static int cqspi_exec_flash_cmd(struct cqspi_st *cqspi, 
> unsigned int reg)
>   return cqspi_wait_idle(cqspi);
>  }
>  
> -static int cqspi_command_read(struct spi_nor *nor,
> -   const u8 *txbuf, const unsigned n_tx,
> +static int cqspi_command_read(struct spi_nor *nor, u8 opcode,
> u8 *rxbuf, size_t n_rx)
>  {
>   struct cqspi_flash_pdata *f_pdata = nor->priv;
> @@ -373,9 +372,9 @@ static int cqspi_command_read(struct spi_nor *nor,
>   return -EINVAL;
>   }
>  
> - reg = txbuf[0] << CQSPI_REG_CMDCTRL_OPCODE_LSB;
> + reg = opcode << CQSPI_REG_CMDCTRL_OPCODE_LSB;
>  
> - rdreg = cqspi_calc_rdreg(nor, txbuf[0]);
> + rdreg = cqspi_calc_rdreg(nor);
>   writel(rdreg, reg_base + CQSPI_REG_RD_INSTR);
>  
>   reg |= (0x1 << CQSPI_REG_CMDCTRL_RD_EN_LSB);
> @@ -471,7 +470,7 @@ static int cqspi_read_setup(struct spi_nor *nor)
>   unsigned int reg;
>  
>   reg = nor->read_opcode << CQSPI_REG_RD_INSTR_OPCODE_LSB;
> - reg |= cqspi_calc_rdreg(nor, nor->read_opcode);
> + reg |= cqspi_calc_rdreg(nor);
>  
>   /* Setup dummy clock cycles */
>   dummy_clk = nor->read_dummy;
> @@ -604,7 +603,7 @@ static int cqspi_write_setup(struct spi_nor *nor)
>   /* Set opcode. */
>   reg = nor->program_opcode << CQSPI_REG_WR_INSTR_OPCODE_LSB;
>   writel(reg, reg_base + CQSPI_REG_WR_INSTR);
> - reg = cqspi_calc_rdreg(nor, nor->program_opcode);
> + reg = cqspi_calc_rdreg(nor);
>   writel(reg, reg_base + CQSPI_REG_RD_INSTR);
>  
>   reg = readl(reg_base + CQSPI_REG_SIZE);
> @@ -1087,7 +1086,7 @@ static int cqspi_read_reg(struct spi_nor *nor, u8 
> opcode, u8 *buf, size_t len)
>  
>   ret = cqspi_set_protocol(nor, 0);
>   if (!ret)
> - ret = cqspi_command_read(nor, &opcode, 1, buf, len);
> + ret = cqspi_command_read(nor, opcode, buf, len);
>  
>   return ret;
>  }



Re: [PATCH 2/4] i2c: at91: implement i2c bus recovery

2019-10-09 Thread Ludovic Desroches
On Wed, Oct 09, 2019 at 04:01:47PM +0200, Alexandre Belloni wrote:
> 
> On 09/10/2019 15:55:00+0200, Ludovic Desroches wrote:
> > On Wed, Oct 02, 2019 at 04:46:56PM +0200, Kamel Bouhara wrote:
> > > External E-Mail
> > > 
> > > 
> > > Implement i2c bus recovery when slaves devices might hold SDA low.
> > > In this case re-assign SCL/SDA to gpios and issue 9 dummy clock pulses
> > > until the slave release SDA.
> > > 
> > 
> > Hi Kamel,
> > 
> > Thanks for adding this new feature. As I see patches only for sama5d3 and
> > sama5d4, I assume it has not been tested with a sama5d2, isn't it?
> > 
> 
> I there a point having it on sama5d2 as the controller already supports
> this feature?
> 

Right, I was focused on pinctrl and forget we have this feature
supported by the IP.

> > I doubt it works with a sama5d2 because of the pinctrl. I also wonder if it 
> > can
> > work if we add .strict = true to pinmux_ops which is something plan for the
> > future...
> > 
> 
> I don't see why it wouldn't work with strict as this is switching muxing
> properly instead of using the pins for two functions at the same time.
> 

Not sure devm_gpiod_get won't fail with strict.

Ludovic


Re: [PATCH] cpufreq: Avoid cpufreq_suspend() deadlock on system shutdown

2019-10-09 Thread Viresh Kumar
On 09-10-19, 01:29, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki 
> 
> It is incorrect to set the cpufreq syscore shutdown callback pointer
> to cpufreq_suspend(), because that function cannot be run in the
> syscore stage of system shutdown for two reasons: (a) it may attempt
> to carry out actions depending on devices that have already been shut
> down at that point and (b) the RCU synchronization carried out by it
> may not be able to make progress then.
> 
> The latter issue has been present since commit 45975c7d21a1 ("rcu:
> Define RCU-sched API in terms of RCU for Tree RCU PREEMPT builds"),
> but the former one has always been there regardless.
> 
> Fix that by dropping cpufreq_syscore_ops altogether and making
> device_shutdown() call cpufreq_suspend() directly before shutting
> down devices, which is along the lines of what system-wide power
> management does.
> 
> Fixes: 45975c7d21a1 ("rcu: Define RCU-sched API in terms of RCU for Tree RCU 
> PREEMPT builds")
> Reported-by: Ville Syrjälä 
> Tested-by: Ville Syrjälä 
> Signed-off-by: Rafael J. Wysocki 
> ---
>  drivers/base/core.c   |3 +++
>  drivers/cpufreq/cpufreq.c |   10 --
>  2 files changed, 3 insertions(+), 10 deletions(-)

Acked-by: Viresh Kumar 

-- 
viresh


Re: [PATCH v2 02/22] mtd: spi-nor: Introduce 'struct spi_nor_controller_ops'

2019-10-09 Thread Boris Brezillon
On Tue, 24 Sep 2019 07:45:53 +
 wrote:

> From: Tudor Ambarus 
> 
> Move all SPI NOR controller driver specific ops in a dedicated
> structure. 'struct spi_nor' becomes lighter.
> 
> Use size_t for lengths in 'int (*write_reg)()' and 'int (*read_reg)()'.
> Rename wite/read_buf to buf, the name of the functions are
> suggestive enough. Constify buf in int (*write_reg). Comply with these
> changes in the SPI NOR controller drivers.
> 
> Suggested-by: Boris Brezillon 
> Signed-off-by: Tudor Ambarus 

Reviewed-by: Boris Brezillon 

> ---
>  drivers/mtd/spi-nor/aspeed-smc.c  | 23 ++-
>  drivers/mtd/spi-nor/cadence-quadspi.c | 39 ++
>  drivers/mtd/spi-nor/hisi-sfc.c| 22 +-
>  drivers/mtd/spi-nor/intel-spi.c   | 24 ++-
>  drivers/mtd/spi-nor/mtk-quadspi.c | 25 +++-
>  drivers/mtd/spi-nor/nxp-spifi.c   | 23 +++
>  drivers/mtd/spi-nor/spi-nor.c | 76 
> ---
>  include/linux/mtd/spi-nor.h   | 51 +--
>  8 files changed, 166 insertions(+), 117 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/aspeed-smc.c 
> b/drivers/mtd/spi-nor/aspeed-smc.c
> index 009c1da8574c..2b7cabbb680c 100644
> --- a/drivers/mtd/spi-nor/aspeed-smc.c
> +++ b/drivers/mtd/spi-nor/aspeed-smc.c
> @@ -320,7 +320,8 @@ static void aspeed_smc_unprep(struct spi_nor *nor, enum 
> spi_nor_ops ops)
>   mutex_unlock(&chip->controller->mutex);
>  }
>  
> -static int aspeed_smc_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int 
> len)
> +static int aspeed_smc_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf,
> +size_t len)
>  {
>   struct aspeed_smc_chip *chip = nor->priv;
>  
> @@ -331,8 +332,8 @@ static int aspeed_smc_read_reg(struct spi_nor *nor, u8 
> opcode, u8 *buf, int len)
>   return 0;
>  }
>  
> -static int aspeed_smc_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf,
> - int len)
> +static int aspeed_smc_write_reg(struct spi_nor *nor, u8 opcode, const u8 
> *buf,
> + size_t len)
>  {
>   struct aspeed_smc_chip *chip = nor->priv;
>  
> @@ -746,6 +747,15 @@ static int aspeed_smc_chip_setup_finish(struct 
> aspeed_smc_chip *chip)
>   return 0;
>  }
>  
> +static const struct spi_nor_controller_ops aspeed_smc_controller_ops = {
> + .prepare = aspeed_smc_prep,
> + .unprepare = aspeed_smc_unprep,
> + .read_reg = aspeed_smc_read_reg,
> + .write_reg = aspeed_smc_write_reg,
> + .read = aspeed_smc_read_user,
> + .write = aspeed_smc_write_user,
> +};
> +
>  static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller,
> struct device_node *np, struct resource *r)
>  {
> @@ -805,12 +815,7 @@ static int aspeed_smc_setup_flash(struct 
> aspeed_smc_controller *controller,
>   nor->dev = dev;
>   nor->priv = chip;
>   spi_nor_set_flash_node(nor, child);
> - nor->read = aspeed_smc_read_user;
> - nor->write = aspeed_smc_write_user;
> - nor->read_reg = aspeed_smc_read_reg;
> - nor->write_reg = aspeed_smc_write_reg;
> - nor->prepare = aspeed_smc_prep;
> - nor->unprepare = aspeed_smc_unprep;
> + nor->controller_ops = &aspeed_smc_controller_ops;
>  
>   ret = aspeed_smc_chip_setup_init(chip, r);
>   if (ret)
> diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c 
> b/drivers/mtd/spi-nor/cadence-quadspi.c
> index 7bef63947b29..ebda612641a4 100644
> --- a/drivers/mtd/spi-nor/cadence-quadspi.c
> +++ b/drivers/mtd/spi-nor/cadence-quadspi.c
> @@ -356,18 +356,19 @@ static int cqspi_exec_flash_cmd(struct cqspi_st *cqspi, 
> unsigned int reg)
>  
>  static int cqspi_command_read(struct spi_nor *nor,
> const u8 *txbuf, const unsigned n_tx,
> -   u8 *rxbuf, const unsigned n_rx)
> +   u8 *rxbuf, size_t n_rx)
>  {
>   struct cqspi_flash_pdata *f_pdata = nor->priv;
>   struct cqspi_st *cqspi = f_pdata->cqspi;
>   void __iomem *reg_base = cqspi->iobase;
>   unsigned int rdreg;
>   unsigned int reg;
> - unsigned int read_len;
> + size_t read_len;
>   int status;
>  
>   if (!n_rx || n_rx > CQSPI_STIG_DATA_LEN_MAX || !rxbuf) {
> - dev_err(nor->dev, "Invalid input argument, len %d rxbuf 0x%p\n",
> + dev_err(nor->dev,
> + "Invalid input argument, len %zu rxbuf 0x%p\n",
>   n_rx, rxbuf);
>   return -EINVAL;
>   }
> @@ -404,19 +405,19 @@ static int cqspi_command_read(struct spi_nor *nor,
>  }
>  
>  static int cqspi_command_write(struct spi_nor *nor, const u8 opcode,
> -const u8 *txbuf, const unsigned n_tx)
> +const u8 *txbuf, size_t n_tx)
>  {
>   struct cqspi_flash_pdata *f_pda

Re: Potential NULL pointer deference in RDMA

2019-10-09 Thread Leon Romanovsky
On Wed, Oct 09, 2019 at 09:44:58PM -0700, Yizhuo Zhai wrote:
> Hi All:
> drivers/infiniband/sw/rxe/rxe_verbs.c:
> The function to_rdev() could return NULL, but no caller in this file
> checks the return value but directly dereference them, which seems
> potentially unsafe. Callers include rxe_query_device(),
> rxe_query_port(), rxe_query_pkey(), etc.


All NULL returns in to_r*() function are useless and can be removed.

Thanks
>
>
> --
> Kind Regards,
>
> Yizhuo Zhai
>
> Computer Science, Graduate Student
> University of California, Riverside


Re: [PATCH v2 01/22] mtd: spi-nor: hisi-sfc: Drop nor->erase NULL assignment

2019-10-09 Thread Boris Brezillon
On Tue, 24 Sep 2019 07:45:50 +
 wrote:

> From: Tudor Ambarus 
> 
> The pointer to 'struct spi_nor' is kzalloc'ed above in the code.
> 
> Signed-off-by: Tudor Ambarus 

Reviewed-by: Boris Brezillon 

> ---
>  drivers/mtd/spi-nor/hisi-sfc.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/mtd/spi-nor/hisi-sfc.c b/drivers/mtd/spi-nor/hisi-sfc.c
> index 6dac9dd8bf42..c99ed9cdbf9c 100644
> --- a/drivers/mtd/spi-nor/hisi-sfc.c
> +++ b/drivers/mtd/spi-nor/hisi-sfc.c
> @@ -364,7 +364,6 @@ static int hisi_spi_nor_register(struct device_node *np,
>   nor->write_reg = hisi_spi_nor_write_reg;
>   nor->read = hisi_spi_nor_read;
>   nor->write = hisi_spi_nor_write;
> - nor->erase = NULL;
>   ret = spi_nor_scan(nor, NULL, &hwcaps);
>   if (ret)
>   return ret;



Re: [PATCH] cpufreq/cpufreq_governor: Fix memory leak in cpufreq_dbs_governor_init

2019-10-09 Thread Viresh Kumar
On 09-10-19, 18:26, Navid Emamdoost wrote:
> In the implementation of cpufreq_dbs_governor_init(), dbs_data is
> allocated and later is assigned to governor_data. But before that
> assignment, if gov->init() fails this allocation is not released.
> dbs_data should be released in case if gov->init() failure.
> 
> Fixes: 714a2d9c8792 ("cpufreq: governor: split cpufreq_governor_dbs()")
> Signed-off-by: Navid Emamdoost 
> ---
>  drivers/cpufreq/cpufreq_governor.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/cpufreq_governor.c 
> b/drivers/cpufreq/cpufreq_governor.c
> index 4bb054d0cb43..deb099d36266 100644
> --- a/drivers/cpufreq/cpufreq_governor.c
> +++ b/drivers/cpufreq/cpufreq_governor.c
> @@ -428,8 +428,10 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy 
> *policy)
>   gov_attr_set_init(&dbs_data->attr_set, &policy_dbs->list);
>  
>   ret = gov->init(dbs_data);
> - if (ret)
> + if (ret) {
> + kfree(dbs_data);
>   goto free_policy_dbs_info;

Maybe add another label right before kfree() at the bottom and jump there
instead. We wanted to share code in the error path.

> + }
>  
>   /*
>* The sampling interval should not be less than the transition latency
> -- 
> 2.17.1

-- 
viresh


Re: [PATCH v1 0/2] perf stat: Support --all-kernel and --all-user

2019-10-09 Thread Jin, Yao




On 10/1/2019 10:17 AM, Andi Kleen wrote:

I think it's useful. Makes it easy to do kernel/user break downs.
perf record should support the same.


Don't we have this already with:

[root@quaco ~]# perf stat -e cycles:u,instructions:u,cycles:k,instructions:k -a 
-- sleep 1


This only works for simple cases. Try it for --topdown or multiple -M metrics.

-Andi



Hi Arnaldo, Jiri,

We think it should be very useful if --all-user / --all-kernel can be 
specified together, so that we can get a break down between user and 
kernel easily.


But yes, the patches for supporting this new semantics is much 
complicated than the patch which just follows original perf-record 
behavior. I fully understand this concern.


So if this new semantics can be accepted, that would be very good. But 
if you think the new semantics is too complicated, I'm also fine for 
posting a new patch which just follows the perf-record behavior.


Thanks
Jin Yao


Re: [PATCH v6 06/12] arm/efi: EFI soft reservation to memblock

2019-10-09 Thread Ard Biesheuvel
On Thu, 10 Oct 2019 at 01:19, Dan Williams  wrote:
>
> UEFI 2.8 defines an EFI_MEMORY_SP attribute bit to augment the
> interpretation of the EFI Memory Types as "reserved for a specific
> purpose".
>
> The proposed Linux behavior for specific purpose memory is that it is
> reserved for direct-access (device-dax) by default and not available for
> any kernel usage, not even as an OOM fallback.  Later, through udev
> scripts or another init mechanism, these device-dax claimed ranges can
> be reconfigured and hot-added to the available System-RAM with a unique
> node identifier. This device-dax management scheme implements "soft" in
> the "soft reserved" designation by allowing some or all of the
> reservation to be recovered as typical memory. This policy can be
> disabled at compile-time with CONFIG_EFI_SOFT_RESERVE=n, or runtime with
> efi=nosoftreserve.
>
> For this patch, update the ARM paths that consider
> EFI_CONVENTIONAL_MEMORY to optionally take the EFI_MEMORY_SP attribute
> into account as a reservation indicator. Publish the soft reservation as
> IORES_DESC_SOFT_RESERVED memory, similar to x86.
>
> (Based on an original patch by Ard)
>
> Cc: Will Deacon 
> Cc: Catalin Marinas 
> Cc: Ard Biesheuvel 
> Signed-off-by: Dan Williams 

Reviewed-by: Ard Biesheuvel 

> ---
>  arch/arm64/mm/mmu.c   |2 ++
>  drivers/firmware/efi/arm-init.c   |9 +
>  drivers/firmware/efi/arm-runtime.c|   24 
>  drivers/firmware/efi/libstub/arm32-stub.c |5 +
>  drivers/firmware/efi/libstub/random.c |4 
>  5 files changed, 44 insertions(+)
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 60c929f3683b..2c385fe05fde 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -1061,6 +1061,8 @@ int arch_add_memory(int nid, u64 start, u64 size,
> __create_pgd_mapping(swapper_pg_dir, start, __phys_to_virt(start),
>  size, PAGE_KERNEL, __pgd_pgtable_alloc, flags);
>
> +   memblock_clear_nomap(start, size);
> +
> return __add_pages(nid, start >> PAGE_SHIFT, size >> PAGE_SHIFT,
>restrictions);
>  }
> diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c
> index 311cd349a862..904fa09e6a6b 100644
> --- a/drivers/firmware/efi/arm-init.c
> +++ b/drivers/firmware/efi/arm-init.c
> @@ -163,6 +163,15 @@ static __init int is_usable_memory(efi_memory_desc_t *md)
> case EFI_BOOT_SERVICES_DATA:
> case EFI_CONVENTIONAL_MEMORY:
> case EFI_PERSISTENT_MEMORY:
> +   /*
> +* Special purpose memory is 'soft reserved', which means it
> +* is set aside initially, but can be hotplugged back in or
> +* be assigned to the dax driver after boot.
> +*/
> +   if (efi_soft_reserve_enabled() &&
> +   (md->attribute & EFI_MEMORY_SP))
> +   return false;
> +
> /*
>  * According to the spec, these regions are no longer reserved
>  * after calling ExitBootServices(). However, we can only use
> diff --git a/drivers/firmware/efi/arm-runtime.c 
> b/drivers/firmware/efi/arm-runtime.c
> index e2ac5fa5531b..899b803842bb 100644
> --- a/drivers/firmware/efi/arm-runtime.c
> +++ b/drivers/firmware/efi/arm-runtime.c
> @@ -121,6 +121,30 @@ static int __init arm_enable_runtime_services(void)
> return 0;
> }
>
> +   if (efi_soft_reserve_enabled()) {
> +   efi_memory_desc_t *md;
> +
> +   for_each_efi_memory_desc(md) {
> +   int md_size = md->num_pages << EFI_PAGE_SHIFT;
> +   struct resource *res;
> +
> +   if (!(md->attribute & EFI_MEMORY_SP))
> +   continue;
> +
> +   res = kzalloc(sizeof(*res), GFP_KERNEL);
> +   if (WARN_ON(!res))
> +   break;
> +
> +   res->start  = md->phys_addr;
> +   res->end= md->phys_addr + md_size - 1;
> +   res->name   = "Soft Reserved";
> +   res->flags  = IORESOURCE_MEM;
> +   res->desc   = IORES_DESC_SOFT_RESERVED;
> +
> +   insert_resource(&iomem_resource, res);
> +   }
> +   }
> +
> if (efi_runtime_disabled()) {
> pr_info("EFI runtime services will be disabled.\n");
> return 0;
> diff --git a/drivers/firmware/efi/libstub/arm32-stub.c 
> b/drivers/firmware/efi/libstub/arm32-stub.c
> index e8f7aefb6813..3cd54d2096c6 100644
> --- a/drivers/firmware/efi/libstub/arm32-stub.c
> +++ b/drivers/firmware/efi/libstub/arm32-stub.c
> @@ -146,6 +146,11 @@ static efi_status_t 
> reserve_kernel_base(efi_system_table_t *sys_table_arg,
>

[PATCH] x86/kvm: Fix -Wmissing-prototypes warnings

2019-10-09 Thread Yi Wang
We get two warning when build kernel with W=1:
arch/x86/kernel/kvm.c:872:6: warning: no previous prototype for 
‘arch_haltpoll_enable’ [-Wmissing-prototypes]
arch/x86/kernel/kvm.c:885:6: warning: no previous prototype for 
‘arch_haltpoll_disable’ [-Wmissing-prototypes]

Including the missing head file can fix this.

Signed-off-by: Yi Wang 
---
 arch/x86/kernel/kvm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index e820568..32ef1ee 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static int kvmapf = 1;
 
-- 
1.8.3.1



Re: [PATCH v17 01/14] bitops: Introduce the for_each_set_clump8 macro

2019-10-09 Thread Geert Uytterhoeven
Hi Andy,

On Thu, Oct 10, 2019 at 7:49 AM Andy Shevchenko
 wrote:
> On Thu, Oct 10, 2019 at 5:31 AM Masahiro Yamada
>  wrote:
> > On Thu, Oct 10, 2019 at 3:54 AM Geert Uytterhoeven  
> > wrote:
> > > On Wed, Oct 9, 2019 at 7:09 PM Andy Shevchenko
> > >  wrote:
> > > > On Thu, Oct 10, 2019 at 01:28:08AM +0900, Masahiro Yamada wrote:
> > > > > On Thu, Oct 10, 2019 at 12:27 AM William Breathitt Gray
> > > > >  wrote:
> > > > > >
> > > > > > This macro iterates for each 8-bit group of bits (clump) with set 
> > > > > > bits,
> > > > > > within a bitmap memory region. For each iteration, "start" is set 
> > > > > > to the
> > > > > > bit offset of the found clump, while the respective clump value is
> > > > > > stored to the location pointed by "clump". Additionally, the
> > > > > > bitmap_get_value8 and bitmap_set_value8 functions are introduced to
> > > > > > respectively get and set an 8-bit value in a bitmap memory region.
> > > >
> > > > > Why is the return type "unsigned long" where you know
> > > > > it return the 8-bit value ?
> > > >
> > > > Because bitmap API operates on unsigned long type. This is not only
> > > > consistency, but for sake of flexibility in case we would like to 
> > > > introduce
> > > > more calls like clump16 or so.
> > >
> > > TBH, that doesn't convince me: those functions explicitly take/return an
> > > 8-bit value, and have "8" in their name.  The 8-bit value is never
> > > really related to, retrieved from, or stored in a full "unsigned long"
> > > element of a bitmap, only to/from/in a part (byte) of it.
> > >
> > > Following your rationale, all of iowrite{8,16,32,64}*() should take an
> > > "unsigned long" value, too.
> > >
> >
> > +1
> >
> > Using u8/u16/u32/u64 looks more consistent with other bitmap helpers.
> >
> > void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, unsigned
> > int nbits);
> > void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int 
> > nbits);
> > static inline void bitmap_from_u64(unsigned long *dst, u64 mask);
> >
> >
> >
> > If you want to see more examples from other parts,
>
> Geert's and yours examples both are not related. They are about
> fixed-width properies when we know that is the part of protocol.
> Here we have no protocol which stricts us to the mentioned fixed-width types.

Yes you have: they are functions to store/retrieve an 8-bit value from
the middle of the bitmap, which is reflected in their names ("clump8",
"value8").
The input/output value is clearly separated from the actual bitmap,
which is referenced by the "unsigned long *".

If you add new "value16" functions, they will be intended to store/retrieve
16-bit values.

Besides, if retrieving an 8-bit value requires passing an
"unsigned long *", the caller needs two variables: one unsigned long to
pass the address of, and one u8 to copy the returned value into.

> So, I can tell an opposite, your arguments didn't convince me.
>
> Imagine the function which does an or / and / xor operation on bitmap.
> Now, when I supply unsigned long, I will see
> operations on one type in _one_ function independently of the size.
> Your proposal will make an unneded churn.

Depends on what kind of value you will use to do the logical operation
with the bitmap:
  - Full bitmap => unsigned long * + size,
  - Single bitmap "word" => unsigned long,
  - 8-bit value => u8,
  - 16-bit value => u16

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


Re: Packet gets stuck in NOLOCK pfifo_fast qdisc

2019-10-09 Thread Jonas Bonn

Hi Paolo,

On 09/10/2019 21:14, Paolo Abeni wrote:

On Wed, 2019-10-09 at 08:46 +0200, Jonas Bonn wrote:

Hi,

The lockless pfifo_fast qdisc has an issue with packets getting stuck in
the queue.  What appears to happen is:

i)  Thread 1 holds the 'seqlock' on the qdisc and dequeues packets.
ii)  Thread 1 dequeues the last packet in the queue.
iii)  Thread 1 iterates through the qdisc->dequeue function again and
determines that the queue is empty.

iv)  Thread 2 queues up a packet.  Since 'seqlock' is busy, it just
assumes the packet will be dequeued by whoever is holding the lock.

v)  Thread 1 releases 'seqlock'.

After v), nobody will check if there are packets in the queue until a
new packet is enqueued.  Thereby, the packet enqueued by Thread 2 may be
delayed indefinitely.


I think you are right.

It looks like this possible race is present since the initial lockless
implementation - commit 6b3ba9146fe6 ("net: sched: allow qdiscs to
handle locking")

Anyhow the racing windows looks quite tiny - I never observed that
issue in my tests. Do you have a working reproducer?


Yes, it's reliably reproducible.  We do network latency measurements and 
latency spikes for these packets that get stuck in the queue.




Something alike the following code - completely untested - can possibly
address the issue, but it's a bit rough and I would prefer not adding
additonal complexity to the lockless qdiscs, can you please have a spin
a it?


Your change looks reasonable.  I'll give it a try.




Thanks,

Paolo
---
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index 6a70845bd9ab..65a1c03330d6 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -113,18 +113,23 @@ bool sch_direct_xmit(struct sk_buff *skb, struct Qdisc *q,
 struct net_device *dev, struct netdev_queue *txq,
 spinlock_t *root_lock, bool validate);
  
-void __qdisc_run(struct Qdisc *q);

+int __qdisc_run(struct Qdisc *q);
  
  static inline void qdisc_run(struct Qdisc *q)

  {
+   int quota = 0;
+
if (qdisc_run_begin(q)) {
/* NOLOCK qdisc must check 'state' under the qdisc seqlock
 * to avoid racing with dev_qdisc_reset()
 */
if (!(q->flags & TCQ_F_NOLOCK) ||
likely(!test_bit(__QDISC_STATE_DEACTIVATED, &q->state)))
-   __qdisc_run(q);
+   quota = __qdisc_run(q);
qdisc_run_end(q);
+
+   if (quota > 0 && q->flags & TCQ_F_NOLOCK && q->ops->peek(q))
+   __netif_schedule(q);


Not sure this is relevant, but there's a subtle difference in the way 
that the underlying ptr_ring peeks at the queue head and checks whether 
the queue is empty.


For peek it's:

READ_ONCE(r->queue[r->consumer_head]);

For is_empty it's:

!r->queue[READ_ONCE(r->consumer_head)];

The placement of the READ_ONCE changes here.  I can't get my head around 
whether this difference is significant or not.  If it is, then perhaps 
an is_empty() method is needed on the qdisc_ops...???


/Jonas


Re: [PATCH v4 0/5] Powerpc/Watchpoint: Few important fixes

2019-10-09 Thread Ravi Bangoria




On 10/10/19 10:14 AM, Ravi Bangoria wrote:



@Christophe, Is patch5 works for you on 8xx?



Getting the following :

root@vgoip:~# ./ptrace-hwbreak
test: ptrace-hwbreak
tags: git_version:v5.4-rc2-710-gf0082e173fe4-dirty
PTRACE_SET_DEBUGREG, WO, len: 1: Ok
PTRACE_SET_DEBUGREG, WO, len: 2: Ok
PTRACE_SET_DEBUGREG, WO, len: 4: Ok
PTRACE_SET_DEBUGREG, WO, len: 8: Ok
PTRACE_SET_DEBUGREG, RO, len: 1: Ok
PTRACE_SET_DEBUGREG, RO, len: 2: Ok
PTRACE_SET_DEBUGREG, RO, len: 4: Ok
PTRACE_SET_DEBUGREG, RO, len: 8: Ok
PTRACE_SET_DEBUGREG, RW, len: 1: Ok
PTRACE_SET_DEBUGREG, RW, len: 2: Ok
PTRACE_SET_DEBUGREG, RW, len: 4: Ok
PTRACE_SET_DEBUGREG, RW, len: 8: Ok
PPC_PTRACE_SETHWDEBUG, MODE_EXACT, WO, len: 1: Ok
PPC_PTRACE_SETHWDEBUG, MODE_EXACT, RO, len: 1: Ok
PPC_PTRACE_SETHWDEBUG, MODE_EXACT, RW, len: 1: Ok
PPC_PTRACE_SETHWDEBUG, MODE_RANGE, DW ALIGNED, WO, len: 6: Ok
PPC_PTRACE_SETHWDEBUG, MODE_RANGE, DW ALIGNED, RO, len: 6: Fail
failure: ptrace-hwbreak



Thanks Christophe. I don't have any 8xx box. I checked qemu and it seems
qemu emulation for 8xx is not yet supported. So I can't debug this. Can
you please check why it's failing?


PPC_PTRACE_SETHWDEBUG internally uses DAWR register and probably 8xx does
not emulate DAWR logic, it only uses DABR to emulate double-word watchpoint.
In that case, all testcases that uses PPC_PTRACE_SETHWDEBUG should be
disabled for 8xx. I'll change [PATCH 5] accordingly and resend.

Also, do you think I should fix hw_breakpoint_validate_len() from [PARCH 1]
for 8xx? I re-checked you recent patch* to allow any address range size for
8xx. With that patch, hw_breakpoint_validate_len() won't get called at all
for 8xx.

* Message-Id: 
1ed0de54ce6021fa0fdf50e938365546a4f5e316.1566925030.git.christophe.le...@c-s.fr

-Ravi



Re: Maybe a bug in kernel/irq/chip.c unmask_irq(), device IRQ masked unexpectedly. (re-formated the mail body, sorry)

2019-10-09 Thread Yi Zheng
Hi

   My patch is canceled. I have tested that simple adjustment, the
device IRQ masked unexpectedly. It seems that it is more easily to
occur with that patch.

So, the root cause is not found yet.


[PATCH bpf-next 2/2] bpf/stackmap: fix A-A deadlock in bpf_get_stack()

2019-10-09 Thread Song Liu
bpf stackmap with build-id lookup (BPF_F_STACK_BUILD_ID) can trigger A-A
deadlock on rq_lock():

rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
[...]
Call Trace:
 try_to_wake_up+0x1ad/0x590
 wake_up_q+0x54/0x80
 rwsem_wake+0x8a/0xb0
 bpf_get_stack+0x13c/0x150
 bpf_prog_fbdaf42eded9fe46_on_event+0x5e3/0x1000
 bpf_overflow_handler+0x60/0x100
 __perf_event_overflow+0x4f/0xf0
 perf_swevent_overflow+0x99/0xc0
 ___perf_sw_event+0xe7/0x120
 __schedule+0x47d/0x620
 schedule+0x29/0x90
 futex_wait_queue_me+0xb9/0x110
 futex_wait+0x139/0x230
 do_futex+0x2ac/0xa50
 __x64_sys_futex+0x13c/0x180
 do_syscall_64+0x42/0x100
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

This can be reproduced by:
1. Start a multi-thread program that does parallel mmap() and malloc();
2. taskset the program to 2 CPUs;
3. Attach bpf program to trace_sched_switch and gather stackmap with
   build-id, e.g. with trace.py from bcc tools:
   trace.py -U -p  -s  t:sched:sched_switch

A sample reproducer is attached at the end.

Fix this by checking whether rq_lock is already locked. If so, postpone
the up_read() to irq_work, just like the in_nmi() case.

Fixes: commit 615755a77b24 ("bpf: extend stackmap to save 
binary_build_id+offset instead of address")
Cc: sta...@vger.kernel.org # v4.17+
Cc: Peter Zijlstra 
Cc: Alexei Starovoitov 
Cc: Daniel Borkmann 
Reported-by: Tejun Heo 
Signed-off-by: Song Liu 

Reproducer:
 8< 

char *filename;

void *worker(void *p)
{
void *ptr;
int fd;
char *pptr;

fd = open(filename, O_RDONLY);
if (fd < 0)
return NULL;
while (1) {
struct timespec ts = {0, 1000 + rand() % 2000};

ptr = mmap(NULL, 4096 * 64, PROT_READ, MAP_PRIVATE, fd, 0);
usleep(1);
if (ptr == MAP_FAILED) {
printf("failed to mmap\n");
break;
}
munmap(ptr, 4096 * 64);
usleep(1);
pptr = malloc(1);
usleep(1);
pptr[0] = 1;
usleep(1);
free(pptr);
usleep(1);
nanosleep(&ts, NULL);
}
close(fd);
return NULL;
}

int main(int argc, char *argv[])
{
void *ptr;
int i;
pthread_t threads[THREAD_COUNT];

if (argc < 2)
return 0;

filename = argv[1];

for (i = 0; i < THREAD_COUNT; i++) {
if (pthread_create(threads + i, NULL, worker, NULL)) {
fprintf(stderr, "Error creating thread\n");
return 0;
}
}

for (i = 0; i < THREAD_COUNT; i++)
pthread_join(threads[i], NULL);
return 0;
}
 8< 
---
 kernel/bpf/stackmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
index 052580c33d26..3b278f6b0c3e 100644
--- a/kernel/bpf/stackmap.c
+++ b/kernel/bpf/stackmap.c
@@ -287,7 +287,7 @@ static void stack_map_get_build_id_offset(struct 
bpf_stack_build_id *id_offs,
bool irq_work_busy = false;
struct stack_map_irq_work *work = NULL;

-   if (in_nmi()) {
+   if (in_nmi() || this_rq_is_locked()) {
work = this_cpu_ptr(&up_read_work);
if (work->irq_work.flags & IRQ_WORK_BUSY)
/* cannot queue more up_read, fallback */
--
2.17.1


[PATCH bpf-next 0/2] bpf/stackmap: fix A-A deadlock in bpf_get_stack()

2019-10-09 Thread Song Liu
bpf stackmap with build-id lookup (BPF_F_STACK_BUILD_ID) can trigger A-A
deadlock on rq_lock():

rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
[...]
Call Trace:
 try_to_wake_up+0x1ad/0x590
 wake_up_q+0x54/0x80
 rwsem_wake+0x8a/0xb0
 bpf_get_stack+0x13c/0x150
 bpf_prog_fbdaf42eded9fe46_on_event+0x5e3/0x1000
 bpf_overflow_handler+0x60/0x100
 __perf_event_overflow+0x4f/0xf0
 perf_swevent_overflow+0x99/0xc0
 ___perf_sw_event+0xe7/0x120
 __schedule+0x47d/0x620
 schedule+0x29/0x90
 futex_wait_queue_me+0xb9/0x110
 futex_wait+0x139/0x230
 do_futex+0x2ac/0xa50
 __x64_sys_futex+0x13c/0x180
 do_syscall_64+0x42/0x100
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

For more details on how to reproduce this is error, please refer to 2/2.

Fix this issue by checking a new helper this_rq_is_locked(). If the
rq_lock is already locked, postpone up_read() in irq_work, just like the
in_nmi() case.

Song Liu (2):
  sched: introduce this_rq_is_locked()
  bpf/stackmap: fix A-A deadlock in bpf_get_stack()

 include/linux/sched.h | 1 +
 kernel/bpf/stackmap.c | 2 +-
 kernel/sched/core.c   | 8 
 3 files changed, 10 insertions(+), 1 deletion(-)

--
2.17.1


[PATCH bpf-next 1/2] sched: introduce this_rq_is_locked()

2019-10-09 Thread Song Liu
this_rq_is_locked() is introduced to check whether current CPU is holding
rq_lock(). This will be used in bpf/stackmap.c to decide whether is safe
to call up_read(), which may call rq_lock() for the same CPU.

Fixes: commit 615755a77b24 ("bpf: extend stackmap to save 
binary_build_id+offset instead of address")
Cc: sta...@vger.kernel.org # v4.17+
Cc: Peter Zijlstra 
Cc: Alexei Starovoitov 
Cc: Daniel Borkmann 
Cc: Tejun Heo 
Signed-off-by: Song Liu 
---
 include/linux/sched.h | 1 +
 kernel/sched/core.c   | 8 
 2 files changed, 9 insertions(+)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 2c2e56bd8913..fb0fcbd1b6f6 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1995,4 +1995,5 @@ int sched_trace_rq_cpu(struct rq *rq);

 const struct cpumask *sched_trace_rd_span(struct root_domain *rd);

+bool this_rq_is_locked(void);
 #endif
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7880f4f64d0e..577cbe7c05fc 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -138,6 +138,14 @@ struct rq *task_rq_lock(struct task_struct *p, struct 
rq_flags *rf)
}
 }

+bool this_rq_is_locked(void)
+{
+   struct rq *rq;
+
+   rq = this_rq();
+   return raw_spin_is_locked(&rq->lock);
+}
+
 /*
  * RQ-clock updating methods:
  */
--
2.17.1


Compliments

2019-10-09 Thread Holo Lambert
Dear,

Do you have any project or an on going project which requires funding?
I have an investor with a huge capital who is ready to invest up to
Ten million US dollars upwards.

So I am looking for a trustworthy and reliable partner with a project
investment that can generate a healthy returns on investment. If you
have a good project to sponsor or partner with kindly get back to me
immediately for us to discuss the details.

Regards
Holo Lambert.


Re: [PATCH v4 3/9] mm: pagewalk: Don't split transhuge pmds when a pmd_entry is present

2019-10-09 Thread VMware

On 10/10/19 4:07 AM, Linus Torvalds wrote:

On Wed, Oct 9, 2019 at 6:10 PM Thomas Hellström (VMware)
 wrote:

Your original patch does exactly the same!

Oh, no. You misread my original patch.

Look again.

The logic in my original patch was very different. It said that

  - *if* we have a pmd_entry function, then we obviously call that one.

 And if - after calling the pmd_entry function - we are still a
hugepage, then we skip the pte_entry case entirely.

And part of skipping is obviously "don't split" - but it never had
that "don't split and then call the pte walker" case.

  - and if we *don't* have a pmd_entry function, but we do have a
pte_entry function, then we always split before calling it.

Notice the difference?


From what I can tell, my patch is doing the same. At least that always 
was the intention. To determine whether to skip pte and skip split, your 
patch uses


/* No pte level at all? */
if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd)
|| pmd_devmap(*pmd))
continue;

whereas my patch does

            if (pmd_trans_unstable(pmd))
goto again;
/* Fall through */

which is the same (pmd_trans_unstable() is the same test as you do, but 
not racy). Yes, it's missing the test for pmd_devmap() but I think 
that's an mm bug been discussed elsewhere, and we also rerun because a 
huge / none pmd at this (FALLBACK) point is probably a race and unintended.




But I think the "change pmd_entry to have a sane return code" is a
simpler and more flexible model, and then the pmd_entry code can just
let the pte walker split the pmd if needed.


OK, let's aim for that then.

Thanks,

Thomas




So I liked that part of your patch.

Linus





[PATCH] wdt: bd70528: Trivial function documentation fix

2019-10-09 Thread Matti Vaittinen
The function documentation for the exported  ROHM BD70528 WDG control
functions used old argument names. Fix the names.

Signed-off-by: Matti Vaittinen 
---
 drivers/watchdog/bd70528_wdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/bd70528_wdt.c b/drivers/watchdog/bd70528_wdt.c
index b0152fef4fc7..439f9920978a 100644
--- a/drivers/watchdog/bd70528_wdt.c
+++ b/drivers/watchdog/bd70528_wdt.c
@@ -97,7 +97,7 @@ EXPORT_SYMBOL(bd70528_wdt_set);
 /**
  * bd70528_wdt_lock - take WDT lock
  *
- * @bd70528:   device data for the PMIC instance we want to operate on
+ * @data:  device data for the PMIC instance we want to operate on
  *
  * Lock WDT for arming/disarming in order to avoid race condition caused
  * by WDT state changes initiated by WDT and RTC drivers.
@@ -114,7 +114,7 @@ EXPORT_SYMBOL(bd70528_wdt_lock);
 /**
  * bd70528_wdt_unlock - unlock WDT lock
  *
- * @bd70528:   device data for the PMIC instance we want to operate on
+ * @data:  device data for the PMIC instance we want to operate on
  *
  * Unlock WDT lock which has previously been taken by call to
  * bd70528_wdt_lock.
-- 
2.21.0


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

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


linux-next: Tree for Oct 10

2019-10-09 Thread Stephen Rothwell
Hi all,

Changes since 20191009:

The samsung-krzk tree gained a conflict against Linus' tree.

The tip tree gained a conflict and semantic conflicts against the
drm tree.

Non-merge commits (relative to Linus' tree): 3318
 3518 files changed, 112430 insertions(+), 57856 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" and checkout or reset to the new
master.

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log
files in the Next directory.  Between each merge, the tree was built
with a ppc64_defconfig for powerpc, an allmodconfig for x86_64, a
multi_v7_defconfig for arm and a native build of tools/perf. After
the final fixups (if any), I do an x86_64 modules_install followed by
builds for x86_64 allnoconfig, powerpc allnoconfig (32 and 64 bit),
ppc44x_defconfig, allyesconfig and pseries_le_defconfig and i386, sparc
and sparc64 defconfig. And finally, a simple boot test of the powerpc
pseries_le_defconfig kernel in qemu (with and without kvm enabled).

Below is a summary of the state of the merge.

I am currently merging 314 trees (counting Linus' and 78 trees of bug
fix patches pending for the current merge release).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (8a8c600de5dc Merge tag 'for-linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma)
Merging fixes/master (54ecb8f7028c Linux 5.4-rc1)
Merging kbuild-current/fixes (b8d5e105ebbf scripts: setlocalversion: fix a 
bashism)
Merging arc-current/for-curr (41277ba7eb4e ARC: mm: tlb flush optim: elide 
redundant uTLB invalidates for MMUv3)
Merging arm-current/fixes (5b3efa4f1479 ARM: 8901/1: add a criteria for 
pfn_valid of arm)
Merging arm-soc-fixes/arm/fixes (60c1b3e25728 ARM: multi_v7_defconfig: Fix 
SPI_STM32_QSPI support)
Merging arm64-fixes/for-next/fixes (3e7c93bd04ed arm64: armv8_deprecated: 
Checking return value for memory allocation)
Merging m68k-current/for-linus (0f1979b402df m68k: Remove ioremap_fullcache())
Merging powerpc-fixes/fixes (3439595d5b85 selftests/powerpc: Fix compile error 
on tlbie_test due to newer gcc)
Merging s390-fixes/fixes (da0c9ea146cb Linux 5.4-rc2)
Merging sparc/master (038029c03e21 sparc: remove unneeded uapi/asm/statfs.h)
Merging fscrypt-current/for-stable (ae64f9bd1d36 Linux 4.15-rc2)
Merging net/master (4123f637a512 ip6erspan: remove the incorrect mtu limit for 
ip6erspan)
Merging bpf/master (106c35dda32f selftests/bpf: More compatible nc options in 
test_lwt_ip_encap)
Merging ipsec/master (68ce6688a5ba net: sched: taprio: Fix potential integer 
overflow in taprio_set_picos_per_byte)
Merging netfilter/master (503c9addef61 ptp: fix typo of "mechanism" in Kconfig 
help text)
Merging ipvs/master (503c9addef61 ptp: fix typo of "mechanism" in Kconfig help 
text)
Merging wireless-drivers/master (3aed88373bda Merge tag 
'iwlwifi-for-kalle-2019-10-09' of 
git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-fixes)
Merging mac80211/master (4123f637a512 ip6erspan: remove the incorrect mtu limit 
for ip6erspan)
Merging rdma-fixes/for-rc (0417791536ae RDMA/mlx5: Add missing 
synchronize_srcu() for MW cases)
Merging sound-current/for-linus (130bce3afbbb ALSA: hdac: clear link output 
stream mapping)
Merging sound-asoc-fixes/for-linus (89dfae218794 Merge branch 'asoc-5.4' into 
asoc-linus)
Merging regmap-fixes/for-linus (da0c9ea146cb Linux 5.4-rc2)
Merging regulator-fixes/for-linus (ca32f845a865 Merge branch 'regulator-5.4' 
into regulator-linus)
Merging spi-fixes/for-linus (f4192468460d Merge branch 'spi-5.4' into spi-linus)
Merging pci-current/for-linus (54ecb8f7028c Linux 5.4-rc1)
Merging driver-core.current/driver-core-linus (82af5b660967 sysfs: Fixes 
__BIN_ATTR_WO() macro)
Merging tty.current/tty-linus (fc64f7abbef2 serial: 8250_omap: Fix gpio check 
for auto RTS/CTS)
Merging usb.current/usb-linus (623170ff5971 usb:cdns3: Fix for CV CH9 running 
with g_zero driver.)
Merging usb-gadget-fixes/fixes (4a56a478a525 usb: gadget: mass_storage: Fix 
races between

Re: [PATCH 07/11] vhost: convert vhost_umem_interval_tree to half closed intervals

2019-10-09 Thread Jason Wang



On 2019/10/4 上午4:18, Davidlohr Bueso wrote:

The vhost_umem interval tree really wants [a, b) intervals,
not fully closed as currently. As such convert it to use the
new interval_tree_gen.h, and also rename the 'last' endpoint
in the node to 'end', which both a more suitable name for
the half closed interval and also reduces the chances of some
caller being missed.

Cc: Michael S. Tsirkin" 
Cc: Jason Wang 
Cc: virtualizat...@lists.linux-foundation.org
Signed-off-by: Davidlohr Bueso 
---
  drivers/vhost/vhost.c | 19 +--
  drivers/vhost/vhost.h |  4 ++--
  2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 36ca2cf419bf..80c3cca24dc7 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -28,7 +28,7 @@
  #include 
  #include 
  #include 
-#include 
+#include 
  #include 
  
  #include "vhost.h"

@@ -51,7 +51,7 @@ enum {
  
  INTERVAL_TREE_DEFINE(struct vhost_umem_node,

 rb, __u64, __subtree_last,
-START, LAST, static inline, vhost_umem_interval_tree);
+START, END, static inline, vhost_umem_interval_tree);
  
  #ifdef CONFIG_VHOST_CROSS_ENDIAN_LEGACY

  static void vhost_disable_cross_endian(struct vhost_virtqueue *vq)
@@ -1034,7 +1034,7 @@ static int vhost_new_umem_range(struct vhost_umem *umem,
  
  	node->start = start;

node->size = size;
-   node->last = end;
+   node->end = end;
node->userspace_addr = userspace_addr;
node->perm = perm;
INIT_LIST_HEAD(&node->link);
@@ -1112,7 +1112,7 @@ static int vhost_process_iotlb_msg(struct vhost_dev *dev,
}
vhost_vq_meta_reset(dev);
if (vhost_new_umem_range(dev->iotlb, msg->iova, msg->size,
-msg->iova + msg->size - 1,
+msg->iova + msg->size,
 msg->uaddr, msg->perm)) {
ret = -ENOMEM;
break;
@@ -1126,7 +1126,7 @@ static int vhost_process_iotlb_msg(struct vhost_dev *dev,
}
vhost_vq_meta_reset(dev);
vhost_del_umem_range(dev->iotlb, msg->iova,
-msg->iova + msg->size - 1);
+msg->iova + msg->size);
break;
default:
ret = -EINVAL;
@@ -1320,15 +1320,14 @@ static bool iotlb_access_ok(struct vhost_virtqueue *vq,
  {
const struct vhost_umem_node *node;
struct vhost_umem *umem = vq->iotlb;
-   u64 s = 0, size, orig_addr = addr, last = addr + len - 1;
+   u64 s = 0, size, orig_addr = addr, last = addr + len;
  
  	if (vhost_vq_meta_fetch(vq, addr, len, type))

return true;
  
  	while (len > s) {

node = vhost_umem_interval_tree_iter_first(&umem->umem_tree,
-  addr,
-  last);
+  addr, last);
if (node == NULL || node->start > addr) {
vhost_iotlb_miss(vq, addr, access);
return false;
@@ -1455,7 +1454,7 @@ static long vhost_set_memory(struct vhost_dev *d, struct 
vhost_memory __user *m)
 region->guest_phys_addr,
 region->memory_size,
 region->guest_phys_addr +
-region->memory_size - 1,
+region->memory_size,
 region->userspace_addr,
 VHOST_ACCESS_RW))
goto err;
@@ -2055,7 +2054,7 @@ static int translate_desc(struct vhost_virtqueue *vq, u64 
addr, u32 len,
}
  
  		node = vhost_umem_interval_tree_iter_first(&umem->umem_tree,

-   addr, addr + len - 1);
+  addr, addr + len);
if (node == NULL || node->start > addr) {
if (umem != dev->iotlb) {
ret = -EFAULT;
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index e9ed2722b633..bb36cb9ed5ec 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -53,13 +53,13 @@ struct vhost_log {
  };
  
  #define START(node) ((node)->start)

-#define LAST(node) ((node)->last)
+#define END(node) ((node)->end)
  
  struct vhost_umem_node {

struct rb_node rb;
struct list_head link;
__u64 start;
-   __u64 last;
+   __u64 end;
__u64 size;
__u64 userspace_addr;
__u32 perm;



Reviewed-by: Jason Wang 




Re: [PATCH v17 01/14] bitops: Introduce the for_each_set_clump8 macro

2019-10-09 Thread Andy Shevchenko
On Thu, Oct 10, 2019 at 5:31 AM Masahiro Yamada
 wrote:
> On Thu, Oct 10, 2019 at 3:54 AM Geert Uytterhoeven  
> wrote:
> > On Wed, Oct 9, 2019 at 7:09 PM Andy Shevchenko
> >  wrote:
> > > On Thu, Oct 10, 2019 at 01:28:08AM +0900, Masahiro Yamada wrote:
> > > > On Thu, Oct 10, 2019 at 12:27 AM William Breathitt Gray
> > > >  wrote:
> > > > >
> > > > > This macro iterates for each 8-bit group of bits (clump) with set 
> > > > > bits,
> > > > > within a bitmap memory region. For each iteration, "start" is set to 
> > > > > the
> > > > > bit offset of the found clump, while the respective clump value is
> > > > > stored to the location pointed by "clump". Additionally, the
> > > > > bitmap_get_value8 and bitmap_set_value8 functions are introduced to
> > > > > respectively get and set an 8-bit value in a bitmap memory region.
> > >
> > > > Why is the return type "unsigned long" where you know
> > > > it return the 8-bit value ?
> > >
> > > Because bitmap API operates on unsigned long type. This is not only
> > > consistency, but for sake of flexibility in case we would like to 
> > > introduce
> > > more calls like clump16 or so.
> >
> > TBH, that doesn't convince me: those functions explicitly take/return an
> > 8-bit value, and have "8" in their name.  The 8-bit value is never
> > really related to, retrieved from, or stored in a full "unsigned long"
> > element of a bitmap, only to/from/in a part (byte) of it.
> >
> > Following your rationale, all of iowrite{8,16,32,64}*() should take an
> > "unsigned long" value, too.
> >
>
> +1
>
> Using u8/u16/u32/u64 looks more consistent with other bitmap helpers.
>
> void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, unsigned
> int nbits);
> void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int 
> nbits);
> static inline void bitmap_from_u64(unsigned long *dst, u64 mask);
>
>
>
> If you want to see more examples from other parts,

Geert's and yours examples both are not related. They are about
fixed-width properies when we know that is the part of protocol.
Here we have no protocol which stricts us to the mentioned fixed-width types.

So, I can tell an opposite, your arguments didn't convince me.

Imagine the function which does an or / and / xor operation on bitmap.
Now, when I supply unsigned long, I will see
operations on one type in _one_ function independently of the size.
Your proposal will make an unneded churn.

-- 
With Best Regards,
Andy Shevchenko


Re: Potential NULL pointer deference in spi

2019-10-09 Thread Eric Dumazet



On 10/9/19 10:37 PM, Yizhuo Zhai wrote:
> Hi All:
> 
> drivers/spi/spi.c:
> 
> The function to_spi_device() could return NULL, but some callers
> in this file does not check the return value while directly dereference
> it, which seems potentially unsafe.
> 
> Such callers include spidev_release(),  spi_dev_check(),
> driver_override_store(), etc.
> 
> 


Many of your reports are completely bogus.

I suggest you spend more time before sending such emails to very large audience
and risk being ignored at some point.

Thanks.


Re: [PATCH 2/3] PCI: pciehp: Wait for PDS if in-band presence is disabled

2019-10-09 Thread Andy Shevchenko
On Thu, Oct 10, 2019 at 8:37 AM Andy Shevchenko
 wrote:
> On Wed, Oct 9, 2019 at 11:05 PM Stuart Hayes  wrote:

> > +static void pcie_wait_for_presence(struct pci_dev *pdev)
> > +{
> > +   int timeout = 1250;

> > +   bool pds;

Also this is redundant. Just use the following outside the loop

 if (!retries)
   pc_info(...);

.

> > +   u16 slot_status;
> > +
> > +   while (true) {
> > +   pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, 
> > &slot_status);
> > +   pds = !!(slot_status & PCI_EXP_SLTSTA_PDS);
> > +   if (pds || timeout <= 0)
> > +   break;
> > +   msleep(10);
> > +   timeout -= 10;
> > +   }
>
> Can we avoid infinite loops? They are hard to parse (in most cases,
> and especially when it's a timeout loop)
>
> unsigned int retries = 125; // 1250 ms
>
> do {
>  ...
> } while (--retries);
>
> > +
> > +   if (!pds)
> > +   pci_info(pdev, "Presence Detect state not set in 1250 
> > msec\n");
> > +}
>
> --
> With Best Regards,
> Andy Shevchenko



-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 2/3] PCI: pciehp: Wait for PDS if in-band presence is disabled

2019-10-09 Thread Andy Shevchenko
On Wed, Oct 9, 2019 at 11:05 PM Stuart Hayes  wrote:
>
> From: Alexandru Gagniuc 
>
> When inband presence is disabled, PDS may come up at any time, or not
> at all. PDS being low may indicate that the card is still mating, and
> we could expect contact bounce to bring down the link as well.
>
> It is reasonable to assume that most cards will mate in a hotplug slot
> in about a second. Thus, when we know PDS only reflects out-of-band
> presence, it's worthwhile to wait the extra second or so to make sure
> the card is properly mated before loading the driver, and to prevent
> the hotplug code from disabling a device if the presence detect change
> goes active after the device is enabled.

> +static void pcie_wait_for_presence(struct pci_dev *pdev)
> +{
> +   int timeout = 1250;
> +   bool pds;
> +   u16 slot_status;
> +
> +   while (true) {
> +   pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
> +   pds = !!(slot_status & PCI_EXP_SLTSTA_PDS);
> +   if (pds || timeout <= 0)
> +   break;
> +   msleep(10);
> +   timeout -= 10;
> +   }

Can we avoid infinite loops? They are hard to parse (in most cases,
and especially when it's a timeout loop)

unsigned int retries = 125; // 1250 ms

do {
 ...
} while (--retries);

> +
> +   if (!pds)
> +   pci_info(pdev, "Presence Detect state not set in 1250 
> msec\n");
> +}

-- 
With Best Regards,
Andy Shevchenko


Potential NULL pointer deference in spi

2019-10-09 Thread Yizhuo Zhai
Hi All:

drivers/spi/spi.c:

The function to_spi_device() could return NULL, but some callers
in this file does not check the return value while directly dereference
it, which seems potentially unsafe.

Such callers include spidev_release(),  spi_dev_check(),
driver_override_store(), etc.


-- 
Kind Regards,

Yizhuo Zhai

Computer Science, Graduate Student
University of California, Riverside


[PATCH v4 1/2] powerpc/irq: bring back ksp_limit management in C functions.

2019-10-09 Thread Christophe Leroy
Commit cbc9565ee826 ("powerpc: Remove ksp_limit on ppc64") moved
PPC32 ksp_limit handling in assembly functions call_do_softirq()
and call_do_irq() as they are different for PPC32 and PPC64.

In preparation of replacing these functions by inline assembly,
partialy revert that commit to bring back ksp_limit assignment
in the callers.

To get and set ksp_limit without a forest of #ifdefs CONFIG_PPC32,
use helpers that will void on PPC64.

Signed-off-by: Christophe Leroy 

---
v2: added forward declaration of struct task_struct to avoid build failure.
v3: included linux/sched.h, forward declaration is not enough.
v4: no change
---
 arch/powerpc/include/asm/irq.h | 22 ++
 arch/powerpc/kernel/irq.c  | 14 +-
 arch/powerpc/kernel/misc_32.S  | 14 --
 3 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/include/asm/irq.h b/arch/powerpc/include/asm/irq.h
index 814dfab7e392..0c6469983c66 100644
--- a/arch/powerpc/include/asm/irq.h
+++ b/arch/powerpc/include/asm/irq.h
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -64,5 +65,26 @@ extern void __do_irq(struct pt_regs *regs);
 
 int irq_choose_cpu(const struct cpumask *mask);
 
+#ifdef CONFIG_PPC32
+static inline unsigned long get_ksp_limit(struct task_struct *tsk)
+{
+   return tsk->thread.ksp_limit;
+}
+
+static inline void set_ksp_limit(struct task_struct *tsk, unsigned long limit)
+{
+   tsk->thread.ksp_limit = limit;
+}
+#else
+static inline unsigned long get_ksp_limit(struct task_struct *tsk)
+{
+   return 0;
+}
+
+static inline void set_ksp_limit(struct task_struct *tsk, unsigned long limit)
+{
+}
+#endif
+
 #endif /* _ASM_IRQ_H */
 #endif /* __KERNEL__ */
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 5645bc9cbc09..04204be49577 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -646,6 +646,7 @@ void do_IRQ(struct pt_regs *regs)
 {
struct pt_regs *old_regs = set_irq_regs(regs);
void *cursp, *irqsp, *sirqsp;
+   unsigned long saved_ksp_limit = get_ksp_limit(current);
 
/* Switch to the irq stack to handle this */
cursp = (void *)(current_stack_pointer() & ~(THREAD_SIZE - 1));
@@ -658,9 +659,15 @@ void do_IRQ(struct pt_regs *regs)
set_irq_regs(old_regs);
return;
}
+   /* Adjust the stack limit */
+   set_ksp_limit(current, (unsigned long)irqsp);
+
/* Switch stack and call */
call_do_irq(regs, irqsp);
 
+   /* Restore stack limit */
+   set_ksp_limit(current, saved_ksp_limit);
+
set_irq_regs(old_regs);
 }
 
@@ -681,7 +688,12 @@ void *hardirq_ctx[NR_CPUS] __read_mostly;
 
 void do_softirq_own_stack(void)
 {
-   call_do_softirq(softirq_ctx[smp_processor_id()]);
+   void *irqsp = softirq_ctx[smp_processor_id()];
+   unsigned long saved_ksp_limit = get_ksp_limit(current);
+
+   set_ksp_limit(current, (unsigned long)irqsp);
+   call_do_softirq(irqsp);
+   set_ksp_limit(current, saved_ksp_limit);
 }
 
 irq_hw_number_t virq_to_hw(unsigned int virq)
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 82df4b09e79f..a5422f7782b3 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -33,23 +33,14 @@
 
.text
 
-/*
- * We store the saved ksp_limit in the unused part
- * of the STACK_FRAME_OVERHEAD
- */
 _GLOBAL(call_do_softirq)
mflrr0
stw r0,4(r1)
-   lwz r10,THREAD+KSP_LIMIT(r2)
-   stw r3, THREAD+KSP_LIMIT(r2)
stwur1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r3)
mr  r1,r3
-   stw r10,8(r1)
bl  __do_softirq
-   lwz r10,8(r1)
lwz r1,0(r1)
lwz r0,4(r1)
-   stw r10,THREAD+KSP_LIMIT(r2)
mtlrr0
blr
 
@@ -59,16 +50,11 @@ _GLOBAL(call_do_softirq)
 _GLOBAL(call_do_irq)
mflrr0
stw r0,4(r1)
-   lwz r10,THREAD+KSP_LIMIT(r2)
-   stw r4, THREAD+KSP_LIMIT(r2)
stwur1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r4)
mr  r1,r4
-   stw r10,8(r1)
bl  __do_irq
-   lwz r10,8(r1)
lwz r1,0(r1)
lwz r0,4(r1)
-   stw r10,THREAD+KSP_LIMIT(r2)
mtlrr0
blr
 
-- 
2.13.3



[PATCH v4 2/2] powerpc/irq: inline call_do_irq() and call_do_softirq()

2019-10-09 Thread Christophe Leroy
call_do_irq() and call_do_softirq() are quite similar on PPC32 and
PPC64 and are simple enough to be worth inlining.

Inlining them avoids an mflr/mtlr pair plus a save/reload on stack.

This is inspired from S390 arch. Several other arches do more or
less the same. The way sparc arch does seems odd thought.

Signed-off-by: Christophe Leroy 
Reviewed-by: Segher Boessenkool 

---
v2: no change.
v3: no change.
v4:
- comment reminding the purpose of the inline asm block.
- added r2 as clobbered reg
---
 arch/powerpc/include/asm/irq.h |  2 --
 arch/powerpc/kernel/irq.c  | 32 
 arch/powerpc/kernel/misc_32.S  | 25 -
 arch/powerpc/kernel/misc_64.S  | 22 --
 4 files changed, 32 insertions(+), 49 deletions(-)

diff --git a/arch/powerpc/include/asm/irq.h b/arch/powerpc/include/asm/irq.h
index 0c6469983c66..10476d5283dc 100644
--- a/arch/powerpc/include/asm/irq.h
+++ b/arch/powerpc/include/asm/irq.h
@@ -57,8 +57,6 @@ extern void *mcheckirq_ctx[NR_CPUS];
 extern void *hardirq_ctx[NR_CPUS];
 extern void *softirq_ctx[NR_CPUS];
 
-void call_do_softirq(void *sp);
-void call_do_irq(struct pt_regs *regs, void *sp);
 extern void do_IRQ(struct pt_regs *regs);
 extern void __init init_IRQ(void);
 extern void __do_irq(struct pt_regs *regs);
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 04204be49577..d62fe18405a0 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -642,6 +642,22 @@ void __do_irq(struct pt_regs *regs)
irq_exit();
 }
 
+static inline void call_do_irq(struct pt_regs *regs, void *sp)
+{
+   register unsigned long r3 asm("r3") = (unsigned long)regs;
+
+   /* Temporarily switch r1 to sp, call __do_irq() then restore r1 */
+   asm volatile(
+   "   "PPC_STLU"  1, %2(%1);\n"
+   "   mr  1, %1;\n"
+   "   bl  %3;\n"
+   "   "PPC_LL"1, 0(1);\n" :
+   "+r"(r3) :
+   "b"(sp), "i"(THREAD_SIZE - STACK_FRAME_OVERHEAD), "i"(__do_irq) 
:
+   "lr", "xer", "ctr", "memory", "cr0", "cr1", "cr5", "cr6", "cr7",
+   "r0", "r2", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", 
"r12");
+}
+
 void do_IRQ(struct pt_regs *regs)
 {
struct pt_regs *old_regs = set_irq_regs(regs);
@@ -686,6 +702,22 @@ void *mcheckirq_ctx[NR_CPUS] __read_mostly;
 void *softirq_ctx[NR_CPUS] __read_mostly;
 void *hardirq_ctx[NR_CPUS] __read_mostly;
 
+static inline void call_do_softirq(const void *sp)
+{
+   register unsigned long ret asm("r3");
+
+   /* Temporarily switch r1 to sp, call __do_softirq() then restore r1 */
+   asm volatile(
+   "   "PPC_STLU"  1, %2(%1);\n"
+   "   mr  1, %1;\n"
+   "   bl  %3;\n"
+   "   "PPC_LL"1, 0(1);\n" :
+   "=r"(ret) :
+   "b"(sp), "i"(THREAD_SIZE - STACK_FRAME_OVERHEAD), 
"i"(__do_softirq) :
+   "lr", "xer", "ctr", "memory", "cr0", "cr1", "cr5", "cr6", "cr7",
+   "r0", "r2", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", 
"r12");
+}
+
 void do_softirq_own_stack(void)
 {
void *irqsp = softirq_ctx[smp_processor_id()];
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index a5422f7782b3..307307b57743 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -33,31 +33,6 @@
 
.text
 
-_GLOBAL(call_do_softirq)
-   mflrr0
-   stw r0,4(r1)
-   stwur1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r3)
-   mr  r1,r3
-   bl  __do_softirq
-   lwz r1,0(r1)
-   lwz r0,4(r1)
-   mtlrr0
-   blr
-
-/*
- * void call_do_irq(struct pt_regs *regs, void *sp);
- */
-_GLOBAL(call_do_irq)
-   mflrr0
-   stw r0,4(r1)
-   stwur1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r4)
-   mr  r1,r4
-   bl  __do_irq
-   lwz r1,0(r1)
-   lwz r0,4(r1)
-   mtlrr0
-   blr
-
 /*
  * This returns the high 64 bits of the product of two 64-bit numbers.
  */
diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
index b55a7b4cb543..69fd714a5236 100644
--- a/arch/powerpc/kernel/misc_64.S
+++ b/arch/powerpc/kernel/misc_64.S
@@ -27,28 +27,6 @@
 
.text
 
-_GLOBAL(call_do_softirq)
-   mflrr0
-   std r0,16(r1)
-   stdur1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r3)
-   mr  r1,r3
-   bl  __do_softirq
-   ld  r1,0(r1)
-   ld  r0,16(r1)
-   mtlrr0
-   blr
-
-_GLOBAL(call_do_irq)
-   mflrr0
-   std r0,16(r1)
-   stdur1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r4)
-   mr  r1,r4
-   bl  __do_irq
-   ld  r1,0(r1)
-   ld  r0,16(r1)
-   mtlrr0
-   blr
-
.section".toc","aw"
 PPC64_CACHES:
 

Re: [Outreachy kernel] [PATCH] staging: qlge: Fix multiple assignments warning by splitting the assignement into two each

2019-10-09 Thread Julia Lawall



On Wed, 9 Oct 2019, Joe Perches wrote:

> On Wed, 2019-10-09 at 22:48 +0200, Julia Lawall wrote:
> > On Wed, 9 Oct 2019, Jules Irenge wrote:
> > > Fix multiple assignments warning " check
> > >  issued by checkpatch.pl tool:
> > > "CHECK: multiple assignments should be avoided".
> []
> > > diff --git a/drivers/staging/qlge/qlge_dbg.c 
> > > b/drivers/staging/qlge/qlge_dbg.c
> []
> > > @@ -141,8 +141,10 @@ static int ql_get_serdes_regs(struct ql_adapter 
> > > *qdev,
> > >   u32 *direct_ptr, temp;
> > >   u32 *indirect_ptr;
> > >
> > > - xfi_direct_valid = xfi_indirect_valid = 0;
> > > - xaui_direct_valid = xaui_indirect_valid = 1;
> > > + xfi_indirect_valid = 0;
> > > + xfi_direct_valid = xfi_indirect_valid;
> > > + xaui_indirect_valid = 1;
> > > + xaui_direct_valid = xaui_indirect_valid
> >
> > Despite checkpatch, I think that the original code was easier to
> > understand.
>
> It'd likely be easier to understand if all the
> _valid uses were bool and the ql_get_both_serdes
> _valid arguments were change to bool from
> unsigned int as well.

Indeed, given the names and the values, bool would be much better.

> btw: qlge likely is going to be deleted and not updated.

OK.  Jules, if you want to make this change, you can, but it could be
better to move on to some other driver.

thanks,
julia

>
> ---
>  drivers/staging/qlge/qlge_dbg.c | 22 ++
>  1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
> index 7e16066a3527..90ab37d4c49d 100644
> --- a/drivers/staging/qlge/qlge_dbg.c
> +++ b/drivers/staging/qlge/qlge_dbg.c
> @@ -112,7 +112,7 @@ static int ql_read_serdes_reg(struct ql_adapter *qdev, 
> u32 reg, u32 *data)
>
>  static void ql_get_both_serdes(struct ql_adapter *qdev, u32 addr,
>   u32 *direct_ptr, u32 *indirect_ptr,
> - unsigned int direct_valid, unsigned int indirect_valid)
> + bool direct_valid, bool indirect_valid)
>  {
>   unsigned int status;
>
> @@ -136,14 +136,12 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
>   struct ql_mpi_coredump *mpi_coredump)
>  {
>   int status;
> - unsigned int xfi_direct_valid, xfi_indirect_valid, xaui_direct_valid;
> - unsigned int xaui_indirect_valid, i;
> + bool xfi_direct_valid = false, xfi_indirect_valid = false;
> + bool xaui_direct_valid = true, xaui_indirect_valid = true;
> + unsigned int i;
>   u32 *direct_ptr, temp;
>   u32 *indirect_ptr;
>
> - xfi_direct_valid = xfi_indirect_valid = 0;
> - xaui_direct_valid = xaui_indirect_valid = 1;
> -
>   /* The XAUI needs to be read out per port */
>   status = ql_read_other_func_serdes_reg(qdev,
>   XG_SERDES_XAUI_HSS_PCS_START, &temp);
> @@ -152,7 +150,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
>
>   if ((temp & XG_SERDES_ADDR_XAUI_PWR_DOWN) ==
>   XG_SERDES_ADDR_XAUI_PWR_DOWN)
> - xaui_indirect_valid = 0;
> + xaui_indirect_valid = false;
>
>   status = ql_read_serdes_reg(qdev, XG_SERDES_XAUI_HSS_PCS_START, &temp);
>
> @@ -161,7 +159,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
>
>   if ((temp & XG_SERDES_ADDR_XAUI_PWR_DOWN) ==
>   XG_SERDES_ADDR_XAUI_PWR_DOWN)
> - xaui_direct_valid = 0;
> + xaui_direct_valid = false;
>
>   /*
>* XFI register is shared so only need to read one
> @@ -176,18 +174,18 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev,
>   /* now see if i'm NIC 1 or NIC 2 */
>   if (qdev->func & 1)
>   /* I'm NIC 2, so the indirect (NIC1) xfi is up. */
> - xfi_indirect_valid = 1;
> + xfi_indirect_valid = true;
>   else
> - xfi_direct_valid = 1;
> + xfi_direct_valid = true;
>   }
>   if ((temp & XG_SERDES_ADDR_XFI2_PWR_UP) ==
>   XG_SERDES_ADDR_XFI2_PWR_UP) {
>   /* now see if i'm NIC 1 or NIC 2 */
>   if (qdev->func & 1)
>   /* I'm NIC 2, so the indirect (NIC1) xfi is up. */
> - xfi_direct_valid = 1;
> + xfi_direct_valid = true;
>   else
> - xfi_indirect_valid = 1;
> + xfi_indirect_valid = true;
>   }
>
>   /* Get XAUI_AN register block. */
>
>


Potential NULL pointer deference inata: sata_rcar

2019-10-09 Thread Yizhuo Zhai
Hi All:
In function sata_rcar_bmdma_fill_sg, macro for_each_sg uses sg_next(),
which could return NULL as "sg", however, there's no check before
dereferencing it (in sg_dma_address()), which is potentially unsafe.

-- 
Kind Regards,

Yizhuo Zhai

Computer Science, Graduate Student
University of California, Riverside


Re: [PATCH v2 2/3] ARM: dts: add Netronix E60K02 board common file

2019-10-09 Thread Andreas Kemnade
Hi Jonathan,

On Mon, 7 Oct 2019 00:38:48 +0200
Jonathan Neuschäfer  wrote:

> Thanks for CCing me on this patchset. Nice to see more e-book reader
> related work!
> 
btw. seems that we have a common target, since our ebook readers both
have a tps65185. It seems to be a good idea to comment things on the
i2c busses without proper bindings. That might help to find allies.

I will send a v3 with correct memory, better name for GLED
and the above-mentioned comments.

Regards,
Andreas

> A few comments and questions below.
> 
> On Mon, Sep 30, 2019 at 09:43:31PM +0200, Andreas Kemnade wrote:
> > The Netronix board E60K02 can be found some several Ebook-Readers,
> > at least the Kobo Clara HD and the Tolino Shine 3. The board
> > is equipped with different SoCs requiring different pinmuxes.  
> 
> Do I understand it correctly that i.MX6SL and i.MX6SLL are pin-
> compatible so we can use the same pin numbers and GPIO handles in the
> DT?
> 
> > +   leds {
> > +   compatible = "gpio-leds";
> > +   pinctrl-names = "default";
> > +   pinctrl-0 = <&pinctrl_led>;
> > +
> > +   GLED {  
> 
> What does "GLED" mean? It's not obvious to me.
> What user-visible purpose does this LED have, or where is it on the
> board?
> 
> > +   gpios = <&gpio5 7 GPIO_ACTIVE_LOW>;
> > +   linux,default-trigger = "timer";
> > +   };
> > +   };
> > +
> > +   memory {
> > +   reg = <0x8000 0x8000>;  
> 
> 2 GiB of memory?
> 
> > +   /* Core3_3V3 */  
> 
> What are these labels (Core3_3V3, Core4_1V2, etc.)?
> 
> > +   dcdc2_reg: DCDC2 {
> > +   regulator-name = "DCDC2";
> > +   regulator-always-on;
> > +   regulator-boot-on;
> > +   regulator-state-mem {
> > +   regulator-on-in-suspend;
> > +   regulator-suspend-max-microvolt = 
> > <330>;
> > +   regulator-suspend-min-microvolt = 
> > <330>;
> > +   };
> > +   };  
> 
> 
> Thanks,
> Jonathan Neuschäfer


Re: string.h: Mark 34 functions with __must_check

2019-10-09 Thread Andy Shevchenko
On Wed, Oct 9, 2019 at 11:11 PM Markus Elfring  wrote:
>
> > I'm curious. How many warnings showed up when you applied this patch?
>
> I suggest to take another look at six places in a specific source file
> (for example).
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/test_kasan.c?id=b92a953cb7f727c42a15ac2ea59bf3cf9c39370d#n595

The *test* word must have given you a clue that the code you a looking
at is not an ordinary one.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] USB: core: Fix potental Null Pointer dereference

2019-10-09 Thread Greg Kroah-Hartman
On Wed, Oct 09, 2019 at 06:02:02PM -0700, Yizhuo wrote:
> Inside function usb_device_is_owned(), usb_hub_to_struct_hub()
> could return NULL but there's no check before its dereference,
> which is potentially unsafe.
> 
> Signed-off-by: Yizhuo 
> ---
>  drivers/usb/core/hub.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 236313f41f4a..8d628c8e0c1b 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -1977,7 +1977,7 @@ bool usb_device_is_owned(struct usb_device *udev)
>   if (udev->state == USB_STATE_NOTATTACHED || !udev->parent)
>   return false;
>   hub = usb_hub_to_struct_hub(udev->parent);
> - return !!hub->ports[udev->portnum - 1]->port_owner;
> + return hub && !!hub->ports[udev->portnum - 1]->port_owner;

How can hub ever not be valid?

thanks,

greg k-h


Re: [PATCH v2] mm/page_isolation: fix a deadlock with printk()

2019-10-09 Thread Sergey Senozhatsky
On (10/09/19 16:26), Michal Hocko wrote:
> On Wed 09-10-19 15:56:32, Peter Oberparleiter wrote:
> [...]
> > A generic solution would be preferable from my point of view though,
> > because otherwise each console driver owner would need to ensure that any
> > lock taken in their console.write implementation is never held while
> > memory is allocated/released.
>
> Considering that console.write is called from essentially arbitrary code
> path IIUC then all the locks used in this path should be pretty much
> tail locks or console internal ones without external dependencies.

That's a good expectation, but I guess it's not always the case.

One example might be NET console - net subsystem locks, net device
drivers locks, maybe even some MM locks (skb allocations?).

But even more "commonly used" consoles sometimes break that
expectation. E.g. 8250

serial8250_console_write()
 serial8250_modem_status()
  wake_up_interruptible()

And so on.

-ss


Re: [PATCH v1 0/2] spi: cadence-qspi: Add cadence-qspi support for Intel LGM SoC

2019-10-09 Thread Ramuthevar, Vadivel MuruganX

Hi Vignesh,

On 10/10/2019 12:18 PM, Vignesh Raghavendra wrote:


On 10/10/19 7:04 AM, Ramuthevar, Vadivel MuruganX wrote:

HI Vignesh,

On 17/9/2019 12:50 AM, Vignesh Raghavendra wrote:

Hi,

On 16/09/19 1:08 PM, Ramuthevar,Vadivel MuruganX wrote:

patch 1: Add YAML for cadence-qspi devicetree cdocumentation.
patch 2: cadence-qspi controller driver to support QSPI-NAND flash
using existing spi-nand framework with legacy spi protocol.

Nope, you cannot have two drivers for the same IP (i.e Cadence QSPI)
just to support to different types of SPI memories. This is the reason
why spi_mem_ops was introduced.

Please rewrite this driver over to use spi_mem_ops (instead of using
generic SPI xfers) so that same driver supports both SPI-NOR and
SPI-NAND flashes. Once that's done drivers/mtd/spi-nor/cadence-quadspi.c
can be deleted.

There are few existing examples of spi_mem_ops users in drivers/spi/
(git grep spi_mem_ops) and materials here on how to write such a driver:

[1]
https://bootlin.com/blog/spi-mem-bringing-some-consistency-to-the-spi-memory-ecosystem/

[2] https://www.youtube.com/watch?v=PkWbuLM_gmU

As per Mark Brown and your suggestion,  I have started adapting
cadence-qaudspi driver with spi_mem_ops framework to work
QSPI-NAND/NOR as a generic driver(completely removed the legacy
SPI-XFERS),  is in progress on Intel LGM SoC.
QSPI-IP on Intel LGM  do not have DMA  support and also not part of QSPI
IP, so couldn't able to validate DMA related.
will adapt the DMA things which are existing in cadence-quadspi.c as it is.


Great, appreciate the effort!


currently TI and Altera SoC's use this Cadence-qspi IP , both are not
using DMA as per my understanding (correct me if it is wrong).
confirmed through device tree entry.


TI platforms use DMA to read data from flash in memory mapped mode
(direct access controller) using mem-to-mem DMA channels. Mem-to-mem DMA
channels are requested as and when needed and are not part of DT
description (as they are not bound to a device)

yes, understood now, Thanks!

what is your opinion on DMA related stuff?

Not having DMA support would be a regression. Please keep the DAC + DMA
part as is. I can help you will all the DMA related testing...
Sure, will keep DAC + DMA, as we discussed earlier use QUIRKS to 
differentiate and follow the same.


---
With Regards
Vadivel


Regards
Vignesh


also using macronix(QSPI-NOR)
flash/Micron(QSPI-NAND).
---
With Regards
Vadivel

Ramuthevar Vadivel Murugan (2):
    dt-bindings: spi: Add support for cadence-qspi IP Intel LGM SoC
    spi: cadence-qspi: Add QSPI support for Intel LGM SoC

   .../devicetree/bindings/spi/cadence,qspi-nand.yaml |  84 +++
   drivers/spi/Kconfig    |   9 +
   drivers/spi/Makefile   |   1 +
   drivers/spi/spi-cadence-qspi-apb.c | 644
+
   drivers/spi/spi-cadence-qspi-apb.h | 174 ++
   drivers/spi/spi-cadence-qspi.c | 461
+++
   drivers/spi/spi-cadence-qspi.h |  73 +++
   7 files changed, 1446 insertions(+)
   create mode 100644
Documentation/devicetree/bindings/spi/cadence,qspi-nand.yaml
   create mode 100644 drivers/spi/spi-cadence-qspi-apb.c
   create mode 100644 drivers/spi/spi-cadence-qspi-apb.h
   create mode 100644 drivers/spi/spi-cadence-qspi.c
   create mode 100644 drivers/spi/spi-cadence-qspi.h



Re: [PATCH] rpmsg: glink: Remove channel decouple from rpdev release

2019-10-09 Thread Stephen Boyd
Quoting Chris Lew (2019-10-08 18:33:45)
> If a channel is being rapidly restarted and the kobj release worker is
> busy, there is a chance the the rpdev_release function will run after
> the channel struct itself has been released.
> 
> There should not be a need to decouple the channel from rpdev in the
> rpdev release since that should only happen from the channel close
> commands.
> 
> Signed-off-by: Chris Lew 

Fixes tag? The whole thing sounds broken and probably is still racy in
the face of SMP given that channel->rpdev is tested for "published" or
not. Can you describe the race that you're closing more?



Re: [PATCH] mm/kmemleak: skip late_init if not skip disable

2019-10-09 Thread Murphy Zhou
Hi,

On Wed, Oct 9, 2019 at 12:51 AM Catalin Marinas  wrote:
>
> Hi Murphy,
>
> On Sun, Sep 29, 2019 at 05:56:59PM +0800, Murphy Zhou wrote:
> > Now if DEFAULT_OFF set to y, kmemleak_init will start the cleanup_work
> > workqueue. Then late_init call will set kmemleak_initialized to 1, the
> > cleaup workqueue will try to do cleanup, triggering:
> >
> > [24.738773] 
> > ==
> > [24.742784] BUG: KASAN: global-out-of-bounds in 
> > __kmemleak_do_cleanup+0x166/0x180
>
> I don't think the invocation of kmemleak_do_cleanup() is the issue here.
> It should be safe schedule the clean-up thread in case kmemleak was
> disabled from boot. What you probably hit was a bug in
> __kmemleak_do_cleanup() itself, fixed here:
>
> http://lkml.kernel.org/r/20191004134624.46216-1-catalin.mari...@arm.com
>
> With the above patch, I can no longer trigger the KASan warning.

Got it. Thanks for noticing!

>
> --
> Catalin


Potential NULL pointer deference in iwlwifi: mvm

2019-10-09 Thread Yizhuo Zhai
Hi All:

drivers/net/wireless/intel/iwlwifi/mvm/power.c:

The function iwl_mvm_vif_from_mac80211() could return NULL,
but some callers in this file does not check the return value while
directly dereference it, which seems potentially unsafe.
Such callers include iwl_mvm_update_d0i3_power_mode(),
iwl_mvm_power_configure_uapsd(),
iwl_mvm_power_allow_uapsd(), etc.



-- 
Kind Regards,

Yizhuo Zhai

Computer Science, Graduate Student
University of California, Riverside


Potential NULL pointer deference in mm/memcontrol.c

2019-10-09 Thread Yizhuo Zhai
Hi All:
mm/memcontrol.c:
The function mem_cgroup_from_css() could return NULL, but some callers
in this file
checks the return value but directly dereference it, which seems
potentially unsafe.
Such callers include mem_cgroup_hierarchy_read(),
mem_cgroup_hierarchy_write(), mem_cgroup_read_u64(),
mem_cgroup_reset(), etc.
-- 
Kind Regards,

Yizhuo Zhai

Computer Science, Graduate Student
University of California, Riverside


[PATCH v2 4/4] staging: rtl8723bs: Remove unnecessary blank lines

2019-10-09 Thread Wambui Karuga
Remove multiple blank lines in
drivers/staging/rtl8723bs/core/rtw_mlme.c.
Issues reported by checkpatch.pl as:
CHECK: Please don't use multiple blank lines

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 47 ---
 1 file changed, 47 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 17da4170e861..02bc60d8478f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -208,7 +208,6 @@ void _rtw_free_network(struct   mlme_priv *pmlmepriv, 
struct wlan_network *pnetwor
 
pmlmepriv->num_of_scanned--;
 
-
/* DBG_871X("_rtw_free_network:SSID =%s\n", 
pnetwork->network.Ssid.Ssid); */
 
spin_unlock_bh(&free_queue->lock);
@@ -300,12 +299,8 @@ void rtw_free_network_queue(struct adapter *padapter, u8 
isfreeall)
spin_unlock_bh(&scanned_queue->lock);
 }
 
-
-
-
 sint rtw_if_up(struct adapter *padapter)
 {
-
sint res;
 
if (padapter->bDriverStopped || padapter->bSurpriseRemoved ||
@@ -317,7 +312,6 @@ sint rtw_if_up(struct adapter *padapter)
return res;
 }
 
-
 void rtw_generate_random_ibss(u8 *pibss)
 {
unsigned long curtime = jiffies;
@@ -335,7 +329,6 @@ u8 *rtw_get_capability_from_ie(u8 *ie)
return ie + 8 + 2;
 }
 
-
 u16 rtw_get_capability(struct wlan_bssid_ex *bss)
 {
__le16  val;
@@ -423,7 +416,6 @@ int is_same_network(struct wlan_bssid_ex *src, struct 
wlan_bssid_ex *dst, u8 fea
memcpy((u8 *)&tmps, rtw_get_capability_from_ie(src->IEs), 2);
memcpy((u8 *)&tmpd, rtw_get_capability_from_ie(dst->IEs), 2);
 
-
s_cap = le16_to_cpu(tmps);
d_cap = le16_to_cpu(tmpd);
 
@@ -465,7 +457,6 @@ struct  wlan_network
*rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
 {
struct list_head*plist, *phead;
 
-
struct  wlan_network*pwlan = NULL;
struct  wlan_network*oldest = NULL;
 
@@ -577,12 +568,8 @@ static void update_current_network(struct adapter 
*adapter, struct wlan_bssid_ex
}
 }
 
-
 /*
-
 Caller must hold pmlmepriv->lock first.
-
-
 */
 void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex 
*target)
 {
@@ -623,7 +610,6 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
 
}
 
-
/* If we didn't find a match, then get a new network slot to initialize
 * with this beacon's information */
/* if (phead == plist) { */
@@ -759,7 +745,6 @@ int rtw_is_desired_network(struct adapter *adapter, struct 
wlan_network *pnetwor
}
}
 
-
if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 
0)) {
DBG_871X("desired_encmode: %d, privacy: %d\n", desired_encmode, 
privacy);
bselected = false;
@@ -770,7 +755,6 @@ int rtw_is_desired_network(struct adapter *adapter, struct 
wlan_network *pnetwor
bselected = false;
}
 
-
return bselected;
 }
 
@@ -780,7 +764,6 @@ void rtw_atimdone_event_callback(struct adapter 
*adapter, u8 *pbuf)
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive 
atimdone_event\n"));
 }
 
-
 void rtw_survey_event_callback(struct adapter  *adapter, u8 *pbuf)
 {
u32 len;
@@ -797,7 +780,6 @@ void rtw_survey_event_callback(struct adapter   
*adapter, u8 *pbuf)
return;
}
 
-
spin_lock_bh(&pmlmepriv->lock);
 
/*  update IBSS_network 's timestamp */
@@ -830,8 +812,6 @@ void rtw_survey_event_callback(struct adapter   
*adapter, u8 *pbuf)
spin_unlock_bh(&pmlmepriv->lock);
 }
 
-
-
 void rtw_surveydone_event_callback(struct adapter  *adapter, u8 *pbuf)
 {
u8 timer_cancelled = false;
@@ -862,7 +842,6 @@ void rtw_surveydone_event_callback(struct adapter   
*adapter, u8 *pbuf)
if (timer_cancelled)
_cancel_timer(&pmlmepriv->scan_to_timer, &timer_cancelled);
 
-
spin_lock_bh(&pmlmepriv->lock);
 
rtw_set_signal_stat_timer(&adapter->recvpriv);
@@ -1002,7 +981,6 @@ static void find_network(struct adapter *adapter)
else
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, 
("rtw_free_assoc_resources : pwlan == NULL\n\n"));
 
-
if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) &&
(adapter->stapriv.asoc_sta_count == 1))
rtw_free_network_nolock(adapter, pwlan);
@@ -1181,7 +1159,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
psta->wireless_mode = pmlmeext->cur_wireless_mode;
psta->raid = networktype_to_raid_ex(padapter, psta);
 
-
/* sta mode */
rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true);
 
@@ -1213,7 +1190,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
  

[PATCH v2 3/4] staging: rtl8723bs: Remove comparisons to booleans in conditionals.

2019-10-09 Thread Wambui Karuga
Remove comparisons to true and false in multiple if statements in
drivers/staging/rtl8723bs/core/rtw_mlme.c
Issues reported by checkpatch.pl as:
CHECK: Using comparison to false is error prone
CHECK: Using comparison to true is error prone

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 29 +++
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index b15b761782b8..17da4170e861 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -187,7 +187,7 @@ void _rtw_free_network(struct   mlme_priv *pmlmepriv, 
struct wlan_network *pnetwor
if (!pnetwork)
return;
 
-   if (pnetwork->fixed == true)
+   if (pnetwork->fixed)
return;
 
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) ||
@@ -222,7 +222,7 @@ void _rtw_free_network_nolock(structmlme_priv 
*pmlmepriv, struct wlan_network *
if (!pnetwork)
return;
 
-   if (pnetwork->fixed == true)
+   if (pnetwork->fixed)
return;
 
/* spin_lock_irqsave(&free_queue->lock, irqL); */
@@ -480,7 +480,7 @@ struct  wlan_network
*rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
 
pwlan = LIST_CONTAINOR(plist, struct wlan_network, list);
 
-   if (pwlan->fixed != true) {
+   if (!pwlan->fixed) {
if (oldest == NULL || time_after(oldest->last_scanned, 
pwlan->last_scanned))
oldest = pwlan;
}
@@ -867,7 +867,7 @@ void rtw_surveydone_event_callback(struct adapter   
*adapter, u8 *pbuf)
 
rtw_set_signal_stat_timer(&adapter->recvpriv);
 
-   if (pmlmepriv->to_join == true) {
+   if (pmlmepriv->to_join) {
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
if (check_fwstate(pmlmepriv, _FW_LINKED) == false) {
set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
@@ -1368,7 +1368,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, 
u8 *pbuf)
if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) {
/* s1. find ptarget_wlan */
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-   if (the_same_macaddr == true) {
+   if (the_same_macaddr) {
ptarget_wlan = 
rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
} else {
pcur_wlan = 
rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
@@ -1843,7 +1843,7 @@ static void rtw_auto_scan_handler(struct adapter 
*padapter)
goto exit;
}
 
-   if (pmlmepriv->LinkDetectInfo.bBusyTraffic == true) {
+   if (pmlmepriv->LinkDetectInfo.bBusyTraffic) {
DBG_871X(FUNC_ADPT_FMT" exit BusyTraffic\n", 
FUNC_ADPT_ARG(padapter));
goto exit;
}
@@ -1863,20 +1863,20 @@ void rtw_dynamic_check_timer_handler(struct adapter 
*adapter)
if (!adapter)
return;
 
-   if (adapter->hw_init_completed == false)
+   if (!adapter->hw_init_completed)
return;
 
-   if ((adapter->bDriverStopped == true) || (adapter->bSurpriseRemoved == 
true))
+   if (adapter->bDriverStopped || adapter->bSurpriseRemoved)
return;
 
-   if (adapter->net_closed == true)
+   if (adapter->net_closed)
return;
 
if (is_primary_adapter(adapter))
DBG_871X("IsBtDisabled =%d, IsBtControlLps =%d\n", 
hal_btcoex_IsBtDisabled(adapter), hal_btcoex_IsBtControlLps(adapter));
 
-   if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode == true)
-   && (hal_btcoex_IsBtControlLps(adapter) == false)
+   if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode)
+   && !(hal_btcoex_IsBtControlLps(adapter))
) {
u8 bEnterPS;
 
@@ -2047,7 +2047,7 @@ static int rtw_check_join_candidate(struct mlme_priv *mlme
 
 
/* check bssid, if needed */
-   if (mlme->assoc_by_bssid == true) {
+   if (mlme->assoc_by_bssid) {
if (memcmp(competitor->network.MacAddress, mlme->assoc_bssid, 
ETH_ALEN))
goto exit;
}
@@ -2805,7 +2805,6 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, 
uint ie_len, u8 channe
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
u8 cbw40_enable = 0;
 
-
if (!phtpriv->ht_option)
return;
 
@@ -2815,7 +2814,7 @@ void rtw_update_ht_cap(

[PATCH v2 2/4] staging: rtl8723bs: Remove unnecessary braces for single statements

2019-10-09 Thread Wambui Karuga
Clean up multiple unnecessary braces around single statement blocks in
drivers/staging/rtl8723bs/core/rtw_mlme.c
Issues reported by checkpatch.pl as:
WARNING: braces {} are not necessary for single statement blocks or
WARNING: braces {} are not necessary for any arm of this statement

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 37 ---
 1 file changed, 12 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 7f27287223e8..b15b761782b8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -112,9 +112,8 @@ void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 {
if (pmlmepriv) {
rtw_free_mlme_priv_ie_data(pmlmepriv);
-   if (pmlmepriv->free_bss_buf) {
+   if (pmlmepriv->free_bss_buf)
vfree(pmlmepriv->free_bss_buf);
-   }
}
 }
 
@@ -753,11 +752,10 @@ int rtw_is_desired_network(struct adapter *adapter, 
struct wlan_network *pnetwor
 
if (psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPA2PSK) {
p = rtw_get_ie(pnetwork->network.IEs + 
_BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, (pnetwork->network.IELength - 
_BEACON_IE_OFFSET_));
-   if (p && ie_len > 0) {
+   if (p && ie_len > 0)
bselected = true;
-   } else {
+   else
bselected = false;
-   }
}
}
 
@@ -822,9 +820,8 @@ void rtw_survey_event_callback(struct adapter   
*adapter, u8 *pbuf)
 
/*  lock pmlmepriv->lock when you accessing network_q */
if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) {
-   if (pnetwork->Ssid.Ssid[0] == 0) {
+   if (pnetwork->Ssid.Ssid[0] == 0)
pnetwork->Ssid.SsidLength = 0;
-   }
rtw_add_network(adapter, pnetwork);
}
 
@@ -893,9 +890,8 @@ void rtw_surveydone_event_callback(struct adapter   
*adapter, u8 *pbuf)
 
pmlmepriv->fw_state = 
WIFI_ADHOC_MASTER_STATE;
 
-   if (rtw_createbss_cmd(adapter) != 
_SUCCESS) {
-   RT_TRACE(_module_rtl871x_mlme_c_, 
_drv_err_, ("Error =>rtw_createbss_cmd status FAIL\n"));
-   }
+   if (rtw_createbss_cmd(adapter) != 
_SUCCESS)
+   
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error =>rtw_createbss_cmd status 
FAIL\n"));
 
pmlmepriv->to_join = false;
}
@@ -1166,9 +1162,8 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 
psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress);
-   if (!psta) {
+   if (!psta)
psta = rtw_alloc_stainfo(pstapriv, 
pnetwork->network.MacAddress);
-   }
 
if (psta) { /* update ptarget_sta */
 
@@ -1347,11 +1342,10 @@ void rtw_joinbss_event_prehandle(struct adapter 
*adapter, u8 *pbuf)
rtw_get_encrypt_decrypt_from_registrypriv(adapter);
 
 
-   if (pmlmepriv->assoc_ssid.SsidLength == 0) {
+   if (pmlmepriv->assoc_ssid.SsidLength == 0)
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@   joinbss 
event call back  for Any SSid\n"));
-   } else {
+   else
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@   
rtw_joinbss_event_callback for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid));
-   }
 
the_same_macaddr = !memcmp(pnetwork->network.MacAddress, 
cur_network->network.MacAddress, ETH_ALEN);
 
@@ -1723,13 +1717,8 @@ void rtw_stadel_event_callback(struct adapter *adapter, 
u8 *pbuf)
_clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE);
}
 
-   if (rtw_createbss_cmd(adapter) != _SUCCESS) {
-
+   if (rtw_createbss_cmd(adapter) != _SUCCESS)
RT_TRACE(_module_rtl871x_ioctl_set_c_, 
_drv_err_, ("***Error =>stadel_event_callback: rtw_createbss_cmd status 
FAIL***\n "));
-
-   }
-
-
}
 
}
@@ -1902,9 +1891,8 @@ void rtw_dynamic_check_timer_handler(struct adapter 
*adapter)
}
 
} else {
-   if (is_primary_adapter(adapter)) {
+   if (is_primary_adapter(adapter))
rtw_dynamic_chk_wk_cmd(adapter);
-   }
}
 
/* auto site survey */
@@ -2988,9 +2976,8 @@ void rtw_append_exented_cap(struct adapter *padapter, u8 
*out_i

[PATCH v2 1/4] staging: rtl8723bs: Remove comparisons to NULL in conditionals

2019-10-09 Thread Wambui Karuga
Remove most comparisons to NULL in conditionals in
drivers/staging/rtl8723bs/core/rtw_mlme.c
Issues reported by checkpatch.pl as:
CHECK: Comparison to NULL could be written

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 46 +++
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 0ac7712223af..7f27287223e8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -40,7 +40,7 @@ int   rtw_init_mlme_priv(struct adapter *padapter)
 
pbuf = vzalloc(array_size(MAX_BSS_CNT, sizeof(struct wlan_network)));
 
-   if (pbuf == NULL) {
+   if (!pbuf) {
res = _FAIL;
goto exit;
}
@@ -185,7 +185,7 @@ void _rtw_free_network(struct   mlme_priv *pmlmepriv, 
struct wlan_network *pnetwor
 /* _irqL irqL; */
struct __queue *free_queue = &(pmlmepriv->free_bss_pool);
 
-   if (pnetwork == NULL)
+   if (!pnetwork)
return;
 
if (pnetwork->fixed == true)
@@ -220,7 +220,7 @@ void _rtw_free_network_nolock(structmlme_priv 
*pmlmepriv, struct wlan_network *
 
struct __queue *free_queue = &(pmlmepriv->free_bss_pool);
 
-   if (pnetwork == NULL)
+   if (!pnetwork)
return;
 
if (pnetwork->fixed == true)
@@ -633,7 +633,7 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
/* If there are no more slots, expire the oldest */
/* list_del_init(&oldest->list); */
pnetwork = oldest;
-   if (pnetwork == NULL) {
+   if (!pnetwork) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, 
("\n\n\nsomething wrong here\n\n\n"));
goto exit;
}
@@ -654,7 +654,7 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
 
pnetwork = rtw_alloc_network(pmlmepriv); /*  will 
update scan_time */
 
-   if (pnetwork == NULL) {
+   if (!pnetwork) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, 
("\n\n\nsomething wrong here\n\n\n"));
goto exit;
}
@@ -738,7 +738,7 @@ int rtw_is_desired_network(struct adapter *adapter, struct 
wlan_network *pnetwor
privacy = pnetwork->network.Privacy;
 
if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) {
-   if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, 
pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen) != NULL)
+   if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, 
pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen))
return true;
else
return false;
@@ -1166,7 +1166,7 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 
psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress);
-   if (psta == NULL) {
+   if (!psta) {
psta = rtw_alloc_stainfo(pstapriv, 
pnetwork->network.MacAddress);
}
 
@@ -1413,7 +1413,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, 
u8 *pbuf)
/* s3. find ptarget_sta & update ptarget_sta after 
update cur_network only for station mode */
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == 
true) {
ptarget_sta = 
rtw_joinbss_update_stainfo(adapter, pnetwork);
-   if (ptarget_sta == NULL) {
+   if (!ptarget_sta) {
RT_TRACE(_module_rtl871x_mlme_c_, 
_drv_err_, ("Can't update stainfo when joinbss_event callback\n"));

spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
goto ignore_joinbss_callback;
@@ -1503,7 +1503,7 @@ void rtw_sta_media_status_rpt(struct adapter *adapter, 
struct sta_info *psta, u3
 {
u16 media_status_rpt;
 
-   if (psta == NULL)
+   if (!psta)
return;
 
media_status_rpt = (u16)((psta->mac_id<<8)|mstatus); /*   
MACID|OPMODE:1 connect */
@@ -1561,7 +1561,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, 
u8 *pbuf)
 
/* for AD-HOC mode */
psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr);
-   if (psta != NULL) {
+   if (psta) {
/* the sta have been in sta_info_queue => do nothing */
 
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: 
rtw_stassoc_event_callback: sta has been in sta_ha

[PATCH v2 0/4] staging: rtl8723bs: Style clean-up in rtw_mlme.c

2019-10-09 Thread Wambui Karuga
This patchset addresses multiple style and formatting issues reported by
checkpatch.pl in drivers/staging/rtl8723bs/core/rtw_mlme.c

PATCH v2 of the series corrects the "patchest" mispelling in the
original cover letter and provides a clearer subject line.

Wambui Karuga (4):
  staging: rtl8723bs: Remove comparisons to NULL in conditionals
  staging: rtl8723bs: Remove unnecessary braces for single statements
  staging: rtl8723bs: Remove comparisons to booleans in conditionals.
  staging: rtl8723bs: Remove unnecessary blank lines

 drivers/staging/rtl8723bs/core/rtw_mlme.c | 157 +++---
 1 file changed, 48 insertions(+), 109 deletions(-)

-- 
2.23.0



Potential NULL pointer deference in RDMA

2019-10-09 Thread Yizhuo Zhai
Hi All:
drivers/infiniband/sw/rxe/rxe_verbs.c:
The function to_rdev() could return NULL, but no caller in this file
checks the return value but directly dereference them, which seems
potentially unsafe. Callers include rxe_query_device(),
rxe_query_port(), rxe_query_pkey(), etc.


-- 
Kind Regards,

Yizhuo Zhai

Computer Science, Graduate Student
University of California, Riverside


Re: [PATCH v4 0/5] Powerpc/Watchpoint: Few important fixes

2019-10-09 Thread Ravi Bangoria




@Christophe, Is patch5 works for you on 8xx?



Getting the following :

root@vgoip:~# ./ptrace-hwbreak
test: ptrace-hwbreak
tags: git_version:v5.4-rc2-710-gf0082e173fe4-dirty
PTRACE_SET_DEBUGREG, WO, len: 1: Ok
PTRACE_SET_DEBUGREG, WO, len: 2: Ok
PTRACE_SET_DEBUGREG, WO, len: 4: Ok
PTRACE_SET_DEBUGREG, WO, len: 8: Ok
PTRACE_SET_DEBUGREG, RO, len: 1: Ok
PTRACE_SET_DEBUGREG, RO, len: 2: Ok
PTRACE_SET_DEBUGREG, RO, len: 4: Ok
PTRACE_SET_DEBUGREG, RO, len: 8: Ok
PTRACE_SET_DEBUGREG, RW, len: 1: Ok
PTRACE_SET_DEBUGREG, RW, len: 2: Ok
PTRACE_SET_DEBUGREG, RW, len: 4: Ok
PTRACE_SET_DEBUGREG, RW, len: 8: Ok
PPC_PTRACE_SETHWDEBUG, MODE_EXACT, WO, len: 1: Ok
PPC_PTRACE_SETHWDEBUG, MODE_EXACT, RO, len: 1: Ok
PPC_PTRACE_SETHWDEBUG, MODE_EXACT, RW, len: 1: Ok
PPC_PTRACE_SETHWDEBUG, MODE_RANGE, DW ALIGNED, WO, len: 6: Ok
PPC_PTRACE_SETHWDEBUG, MODE_RANGE, DW ALIGNED, RO, len: 6: Fail
failure: ptrace-hwbreak



Thanks Christophe. I don't have any 8xx box. I checked qemu and it seems
qemu emulation for 8xx is not yet supported. So I can't debug this. Can
you please check why it's failing?

-Ravi



[PATCH] staging: octeon: Fix incorrect type in assignment

2019-10-09 Thread Wambui Karuga
Fix the following warning generated by sparse in
drivers/staging/octeon/ethernet-tx.c:

drivers/staging/octeon/ethernet-tx.c:563:50: warning: incorrect type in 
assignment (different base types)
drivers/staging/octeon/ethernet-tx.c:563:50:expected unsigned short 
[usertype] hw_chksum
drivers/staging/octeon/ethernet-tx.c:563:50:got restricted __wsum 
[usertype] csum

Warning generated by running:
make C=2 CF="-D__CHECK_ENDIAN__" drivers/staging/octeon/

Signed-off-by: Wambui Karuga 
---
 drivers/staging/octeon/octeon-stubs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/octeon/octeon-stubs.h 
b/drivers/staging/octeon/octeon-stubs.h
index 38954b6c89e1..b2e3c72205dd 100644
--- a/drivers/staging/octeon/octeon-stubs.h
+++ b/drivers/staging/octeon/octeon-stubs.h
@@ -123,7 +123,7 @@ union cvmx_pip_wqe_word0 {
struct {
uint64_t next_ptr:40;
uint8_t unused;
-   uint16_t hw_chksum;
+   __wsum hw_chksum;
} cn38xx;
struct {
uint64_t pknd:6;/* 0..5 */
-- 
2.23.0



[PATCH] staging: sm750fb: Potential uninitialized field in "pll"

2019-10-09 Thread Yizhuo
Inside function set_chip_clock(), struct pll is supposed to be
initialized in sm750_calc_pll_value(), if condition
"diff < mini_diff" in sm750_calc_pll_value() cannot be fulfilled,
then some field of pll will not be initialized but used in
function sm750_format_pll_reg(), which is potentially unsafe.

Signed-off-by: Yizhuo 
---
 drivers/staging/sm750fb/ddk750_chip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.c 
b/drivers/staging/sm750fb/ddk750_chip.c
index 5a317cc98a4b..31b3cf9c2d8b 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -55,7 +55,7 @@ static unsigned int get_mxclk_freq(void)
  */
 static void set_chip_clock(unsigned int frequency)
 {
-   struct pll_value pll;
+   struct pll_value pll = {};
unsigned int actual_mx_clk;
 
/* Cheok_0509: For SM750LE, the chip clock is fixed. Nothing to set. */
-- 
2.17.1



Re: [PATCH v1 1/2] pinctrl: Add pinmux & GPIO controller driver for new SoC

2019-10-09 Thread Tanwar, Rahul


Hi Linus,

Thanks for taking time out to review.

On 5/10/2019 4:28 AM, Linus Walleij wrote:
>> +config PINCTRL_EQUILIBRIUM
>> +   tristate "Generic pinctrl and GPIO driver for Intel Lightning 
>> Mountain SoC"
>> +   select PINMUX
>> +   select PINCONF
>> +   select GPIOLIB
>> +   select GPIOLIB_IRQCHIP
> Nice use of the GPIOLIB_IRQCHIP.
>
> Are you sure you can't just use GPIO_GENERIC as well?
> This is almost always usable when you have a register with
> n consecutive bits representing GPIO lines.
>
> Look how we use bgpio_init() in e.g. drivers/gpio/gpio-ftgpio010.c
> to cut down on boilerplate code, and we also get a spinlock
> protection and .get/.set_multiple() implementation for free.

I went through gpio-mmio.c & gpio-ftgpio010.c code. My understanding is
that GPIO_GENERIC can support a max of 64 consecutive bits representing
GPIO lines. We have more than 100 GPIO's and they are spread out across
4 different banks with non consecutive registers i.e. DATA_IN_0~31@offset0x0,
DATA_IN_32~63@offset0x100 and so on. In other words, i think we can not
support memory mapped GPIO controller.

>> +#include 
>> +#include 
> Why do you need these two includes?

Yes, these are redundant. I will remove them. Thanks.

>> +static const struct pin_config pin_cfg_type[] = {
>> +   {"intel,pullup",PINCONF_TYPE_PULL_UP},
>> +   {"intel,pulldown",  PINCONF_TYPE_PULL_DOWN},
>> +   {"intel,drive-current", PINCONF_TYPE_DRIVE_CURRENT},
>> +   {"intel,slew-rate", PINCONF_TYPE_SLEW_RATE},
>> +   {"intel,open-drain",PINCONF_TYPE_OPEN_DRAIN},
>> +   {"intel,output",PINCONF_TYPE_OUTPUT},
>> +};
> So... if we are adding a new driver with a new DT binding,
> why use the made-up "intel," prefixed flags when we have the
> standard DT flags from
> Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
> already handled by the core?

Yes, Andy & Rob have also raised same concerns. I will switch to using
standard DT properties & generic pinconf and remove redundant code.
Thanks.

>> +static inline void eqbr_set_val(void __iomem *addr, u32 offset,
>> +   u32 mask, u32 set, raw_spinlock_t *lock)
>> +{
>> +   u32 val;
>> +   unsigned long flags;
>> +
>> +   raw_spin_lock_irqsave(lock, flags);
>> +   val = readl(addr) & ~(mask << offset);
>> +   writel(val | ((set & mask) << offset), addr);
>> +   raw_spin_unlock_irqrestore(lock, flags);
>> +}
> Mask-and-set is usually achieved with regmap-mmio if you
> dont use GPIO_GENERIC, but I think you can just use
> GPIO_GENERIC. All of these:

As mentioned above, we cannot use GPIO_GENERIC. And there was no specific
reason/motivation for us to use regmap-mmio because most of the driver's
that we referenced were using readl()/write(). Do you recommend us to remove
readl()/writel() and switch to regmap-mmio based design ?

>> +static int intel_eqbr_gpio_get_dir(struct gpio_chip *gc, unsigned int 
>> offset)
>> +static int intel_eqbr_gpio_dir_input(struct gpio_chip *gc, unsigned int 
>> offset)
>> +static int intel_eqbr_gpio_dir_output(struct gpio_chip *gc, unsigned int 
>> offset,
>> +static void intel_eqbr_gpio_set(struct gpio_chip *gc,
>> +   unsigned int offset, int dir)
>> +static int intel_eqbr_gpio_get(struct gpio_chip *gc, unsigned int offset)
> Look very bit-per-bit mapped.
>
>> +static int intel_eqbr_gpio_to_irq(struct gpio_chip *gc, unsigned int offset)
>> +{
>> +   struct intel_gpio_desc *desc = gpiochip_get_data(gc);
> Since struct gpio_desc means a per-line state container
> and struct intel_gpio_desc refers to the whole chip, I think this
> struct should be renamed something like struct eqbr_gpio.

Just to clarify, we have 4 different GPIO banks and each GPIO bank is
implemented as a separate gpio_chip. So we have 4 instances of gpio_desc
each one having its own gpio_chip. What i mean to say is that gpio_desc
is actually not a per-line state container, its a per gpio_chip container.

>> +   unsigned int virq;
>> +
>> +   if (!desc->irq_domain)
>> +   return -ENODEV;
>> +
>> +   virq = irq_find_mapping(desc->irq_domain, offset);
>> +   if (virq)
>> +   return virq;
>> +   else
>> +   return irq_create_mapping(desc->irq_domain, offset);
>> +}
>> +
>> +static int gpiochip_setup(struct device *dev, struct intel_gpio_desc *desc)
>> +{
> (...)
>> +   gc->to_irq  = intel_eqbr_gpio_to_irq;
> You don't need any of this funku stuff. The GPIOLIB_IRQCHIP
> provides default implementations to do all this for you.
> Just look in drivers/gpio/gpio-ftgpio010.c and follow
> the pattern (look how I set up struct gpio_irq_chip using
> *girq etc). If you need anything custom we need some
> special motivation here.

Yes, i checked gpio-ftgpio010.c and agree that this is already handled
under GPIOLIB_IRQCHIP. I will make these

[git pull] dcache_readdir() fixes

2019-10-09 Thread Al Viro
The couple of patches you'd been OK with; no hlist
conversion yet, and cursors are still in the list of children.

The following changes since commit 4d856f72c10ecb060868ed10ff1b1453943fc6c8:

  Linux 5.3 (2019-09-15 14:19:32 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git work.dcache

for you to fetch changes up to 26b6c984338474b7032a3f1ee28e9d7590c225db:

  libfs: take cursors out of list when moving past the end of directory 
(2019-10-09 22:57:30 -0400)


Al Viro (2):
  Fix the locking in dcache_readdir() and friends
  libfs: take cursors out of list when moving past the end of directory

 fs/libfs.c | 137 -
 1 file changed, 71 insertions(+), 66 deletions(-)


Re: [PATCH v1 0/2] spi: cadence-qspi: Add cadence-qspi support for Intel LGM SoC

2019-10-09 Thread Vignesh Raghavendra



On 10/10/19 7:04 AM, Ramuthevar, Vadivel MuruganX wrote:
> HI Vignesh,
> 
> On 17/9/2019 12:50 AM, Vignesh Raghavendra wrote:
>> Hi,
>>
>> On 16/09/19 1:08 PM, Ramuthevar,Vadivel MuruganX wrote:
>>> patch 1: Add YAML for cadence-qspi devicetree cdocumentation.
>>> patch 2: cadence-qspi controller driver to support QSPI-NAND flash
>>> using existing spi-nand framework with legacy spi protocol.
>> Nope, you cannot have two drivers for the same IP (i.e Cadence QSPI)
>> just to support to different types of SPI memories. This is the reason
>> why spi_mem_ops was introduced.
>>
>> Please rewrite this driver over to use spi_mem_ops (instead of using
>> generic SPI xfers) so that same driver supports both SPI-NOR and
>> SPI-NAND flashes. Once that's done drivers/mtd/spi-nor/cadence-quadspi.c
>> can be deleted.
>>
>> There are few existing examples of spi_mem_ops users in drivers/spi/
>> (git grep spi_mem_ops) and materials here on how to write such a driver:
>>
>> [1]
>> https://bootlin.com/blog/spi-mem-bringing-some-consistency-to-the-spi-memory-ecosystem/
>>
>> [2] https://www.youtube.com/watch?v=PkWbuLM_gmU
> As per Mark Brown and your suggestion,  I have started adapting
> cadence-qaudspi driver with spi_mem_ops framework to work
> QSPI-NAND/NOR as a generic driver(completely removed the legacy
> SPI-XFERS),  is in progress on Intel LGM SoC.
> QSPI-IP on Intel LGM  do not have DMA  support and also not part of QSPI
> IP, so couldn't able to validate DMA related.
> will adapt the DMA things which are existing in cadence-quadspi.c as it is.
> 

Great, appreciate the effort!

> currently TI and Altera SoC's use this Cadence-qspi IP , both are not
> using DMA as per my understanding (correct me if it is wrong).
> confirmed through device tree entry.
> 

TI platforms use DMA to read data from flash in memory mapped mode
(direct access controller) using mem-to-mem DMA channels. Mem-to-mem DMA
channels are requested as and when needed and are not part of DT
description (as they are not bound to a device)

> what is your opinion on DMA related stuff? 

Not having DMA support would be a regression. Please keep the DAC + DMA
part as is. I can help you will all the DMA related testing...

Regards
Vignesh

> also using macronix(QSPI-NOR)
> flash/Micron(QSPI-NAND).
> ---
> With Regards
> Vadivel
>>> Ramuthevar Vadivel Murugan (2):
>>>    dt-bindings: spi: Add support for cadence-qspi IP Intel LGM SoC
>>>    spi: cadence-qspi: Add QSPI support for Intel LGM SoC
>>>
>>>   .../devicetree/bindings/spi/cadence,qspi-nand.yaml |  84 +++
>>>   drivers/spi/Kconfig    |   9 +
>>>   drivers/spi/Makefile   |   1 +
>>>   drivers/spi/spi-cadence-qspi-apb.c | 644
>>> +
>>>   drivers/spi/spi-cadence-qspi-apb.h | 174 ++
>>>   drivers/spi/spi-cadence-qspi.c | 461
>>> +++
>>>   drivers/spi/spi-cadence-qspi.h |  73 +++
>>>   7 files changed, 1446 insertions(+)
>>>   create mode 100644
>>> Documentation/devicetree/bindings/spi/cadence,qspi-nand.yaml
>>>   create mode 100644 drivers/spi/spi-cadence-qspi-apb.c
>>>   create mode 100644 drivers/spi/spi-cadence-qspi-apb.h
>>>   create mode 100644 drivers/spi/spi-cadence-qspi.c
>>>   create mode 100644 drivers/spi/spi-cadence-qspi.h
>>>

-- 
Regards
Vignesh


Re: [PATCH v3 3/3] clk: qcom: Add Global Clock controller (GCC) driver for SC7180

2019-10-09 Thread Stephen Boyd
Quoting Taniya Das (2019-10-09 02:19:39)
> Hi Stephen,
> 
> On 10/5/2019 4:50 AM, Stephen Boyd wrote:
> > Quoting Taniya Das (2019-10-04 10:39:31)
> >>
> >> Could you please confirm if you are referring to update the below?
> > 
> > I wasn't suggesting that explicitly but sure. Something like this would
> > be necessary to make clk_get() pass back a NULL pointer to the caller.
> > Does everything keep working with this change?
> > 
> 
> Even if I pass back NULL, I don't see it working. Please suggest how to 
> take it forward.
> 

Why doesn't it work?



Re: [PATCH] net: stmmac: Remove break after a return

2019-10-09 Thread Jakub Kicinski
On Wed,  9 Oct 2019 22:29:00 +0800, Tiezhu Yang wrote:
> Since break is not useful after a return, remove it.
> 
> Fixes: 3b57de958e2a ("net: stmmac: Support devicetree configs for mcast and 
> ucast filter entries")
> Signed-off-by: Tiezhu Yang 

Applied, thanks


Re: [PATCH] rcu: avoid data-race in rcu_gp_fqs_check_wake()

2019-10-09 Thread Eric Dumazet
On Wed, Oct 9, 2019 at 8:18 PM Paul E. McKenney  wrote:

> Again, good catch, applied for review and testing, thank you!
>
> I added another READ_ONCE() to dump_blkd_tasks(), which is not exercised
> unless you get an RCU CPU stall warning or some such.  The updated patch
> is below, please let me know if I messed anything up.
>
> Thanx, Paul

This looks good to me, thanks Paul.


Re: [PATCH] net/ethernet: xgmac don't set .driver twice

2019-10-09 Thread Jakub Kicinski
On Wed,  9 Oct 2019 14:26:27 +0100, Ben Dooks wrote:
> Cleanup the .driver setup to just do it once, to avoid
> the following sparse warning:
> 
> drivers/net/ethernet/calxeda/xgmac.c:1914:10: warning: Initializer entry 
> defined twice
> drivers/net/ethernet/calxeda/xgmac.c:1920:10:   also defined here
> 
> Signed-off-by: Ben Dooks 

Applied, thanks


[PATCH] sock_get_timeout: drop unnecessary return variable

2019-10-09 Thread Vito Caputo
Remove pointless use of size return variable by directly returning
sizes.

Signed-off-by: Vito Caputo 
---
 net/core/sock.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index fac2b4d80de5..e01ff0d3be95 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -333,7 +333,6 @@ EXPORT_SYMBOL(__sk_backlog_rcv);
 static int sock_get_timeout(long timeo, void *optval, bool old_timeval)
 {
struct __kernel_sock_timeval tv;
-   int size;
 
if (timeo == MAX_SCHEDULE_TIMEOUT) {
tv.tv_sec = 0;
@@ -354,13 +353,11 @@ static int sock_get_timeout(long timeo, void *optval, 
bool old_timeval)
old_tv.tv_sec = tv.tv_sec;
old_tv.tv_usec = tv.tv_usec;
*(struct __kernel_old_timeval *)optval = old_tv;
-   size = sizeof(old_tv);
-   } else {
-   *(struct __kernel_sock_timeval *)optval = tv;
-   size = sizeof(tv);
+   return sizeof(old_tv);
}
 
-   return size;
+   *(struct __kernel_sock_timeval *)optval = tv;
+   return sizeof(tv);
 }
 
 static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, 
bool old_timeval)
-- 
2.11.0



Re: [PATCH v2 0/2] Avoid regmap debugfs collisions in qcom llcc driver

2019-10-09 Thread Bjorn Andersson
On Wed 09 Oct 10:59 PDT 2019, Evan Green wrote:

> On Wed, Oct 9, 2019 at 10:46 AM Bjorn Andersson
>  wrote:
> >
> > On Wed 09 Oct 09:01 PDT 2019, Evan Green wrote:
> >
> > > On Tue, Oct 8, 2019 at 6:58 PM Stephen Boyd  wrote:
> > > >
> > > > Quoting Bjorn Andersson (2019-10-08 16:55:04)
> > > > > On Tue 08 Oct 16:45 PDT 2019, Stephen Boyd wrote:
> > > > > > @@ drivers/soc/qcom/llcc-slice.c
> > > > > >
> > > > > >   static struct llcc_drv_data *drv_data = (void *) 
> > > > > > -EPROBE_DEFER;
> > > > > >
> > > > > > --static const struct regmap_config llcc_regmap_config = {
> > > > > > +-static struct regmap_config llcc_regmap_config = {
> > > > > >  -.reg_bits = 32,
> > > > > >  -.reg_stride = 4,
> > > > > >  -.val_bits = 32,
> > > > > > @@ drivers/soc/qcom/llcc-slice.c: static struct regmap 
> > > > > > *qcom_llcc_init_mmio(struct
> > > > > >   {
> > > > > >   struct resource *res;
> > > > > >   void __iomem *base;
> > > > > > -+static struct regmap_config llcc_regmap_config = {
> > > > > > ++struct regmap_config llcc_regmap_config = {
> > > > >
> > > > > Now that this isn't static I like the end result better. Not sure 
> > > > > about
> > > > > the need for splitting it in two patches, but if Evan is happy I'll 
> > > > > take
> > > > > it.
> > > > >
> > > >
> > > > Well I split it into bug fix and micro-optimization so backport choices
> > > > can be made. But yeah, I hope Evan is happy enough to provide a
> > > > reviewed-by tag!
> > >
> > > It's definitely better without the static local since it no longer has
> > > the cognitive trap, but I still don't really get why we're messing
> > > with the global v. local aspect of it. We're now inconsistent with
> > > every other caller of this function, and for what exactly? We've
> > > traded some data space for a call to memset() and some instructions. I
> > > would have thought anecdotally that memory was the cheaper thing (ie
> > > cpu speeds stopped increasing awhile ago, but memory is still getting
> > > cheaper).
> > >
> >
> > The reason for making the structure local is because it's being modified
> > per instance, meaning it would still work as long as
> > qcom_llcc_init_mmio() is never called concurrently for two llcc
> > instances. But the correctness outweighs the performance degradation of
> > setting it up on the stack in my view.
> >
> 
> I hadn't considered the concurrency aspect of the change, since I had
> anchored myself on the static local. I'm convinced. Might be worth
> mentioning that in the commit message.
> 
> For the series:
> Reviewed-by: Evan Green 

Thank you, patches applied.

Regards,
Bjorn


Re: [PATCH -next] userfaultfd: remove set but not used variable 'h'

2019-10-09 Thread Wei Yang
On Wed, Oct 09, 2019 at 08:42:46PM -0700, Mike Kravetz wrote:
>On 10/9/19 8:30 PM, Wei Yang wrote:
>> On Wed, Oct 09, 2019 at 07:25:18PM -0700, Mike Kravetz wrote:
>>> On 10/9/19 6:23 PM, Wei Yang wrote:
 On Wed, Oct 09, 2019 at 05:45:57PM -0700, Mike Kravetz wrote:
> On 10/9/19 5:27 AM, YueHaibing wrote:
>> Fixes gcc '-Wunused-but-set-variable' warning:
>>
>> mm/userfaultfd.c: In function '__mcopy_atomic_hugetlb':
>> mm/userfaultfd.c:217:17: warning:
>>  variable 'h' set but not used [-Wunused-but-set-variable]
>>
>> It is not used since commit 78911d0e18ac ("userfaultfd: use vma_pagesize
>> for all huge page size calculation")
>>
>
> Thanks!  That should have been removed with the recent cleanups.
>
>> Signed-off-by: YueHaibing 
>
> Reviewed-by: Mike Kravetz 

 If I am correct, this is removed in a recent patch.
>>>
>>> I'm having a hard time figuring out what is actually in the latest mmotm
>>> tree.  Andrew added a build fixup patch ab169389eb5 in linux-next which
>>> adds the reference to h.  Is there a patch after that to remove the 
>>> reference?
>>>
>> 
>> I checked linux-next tree, this commit removes the reference.
>> 
>> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=add4eaeef3766b7491d70d473c48c0b6d6ca5cb7
>> 
>
>Yes, but unless I am mistaken this adds it back,
>
>https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=ab169389eb5ff9da7113a21737574edc6d22c072
>

Oops, we may leave this to Andrew.

>-- 
>Mike Kravetz

-- 
Wei Yang
Help you, Help me


[PATCH] af_unix: __unix_find_socket_byname() cleanup

2019-10-09 Thread Vito Caputo
Remove pointless return variable dance.

Appears vestigial from when the function did locking as seen in
unix_find_socket_byinode(), but locking is handled in
unix_find_socket_byname() for __unix_find_socket_byname().

Signed-off-by: Vito Caputo 
---
 net/unix/af_unix.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 67e87db5877f..c853ad0875f4 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -284,11 +284,9 @@ static struct sock *__unix_find_socket_byname(struct net 
*net,
 
if (u->addr->len == len &&
!memcmp(u->addr->name, sunname, len))
-   goto found;
+   return s;
}
-   s = NULL;
-found:
-   return s;
+   return NULL;
 }
 
 static inline struct sock *unix_find_socket_byname(struct net *net,
-- 
2.11.0



Re: [PATCH -next] userfaultfd: remove set but not used variable 'h'

2019-10-09 Thread Mike Kravetz
On 10/9/19 8:30 PM, Wei Yang wrote:
> On Wed, Oct 09, 2019 at 07:25:18PM -0700, Mike Kravetz wrote:
>> On 10/9/19 6:23 PM, Wei Yang wrote:
>>> On Wed, Oct 09, 2019 at 05:45:57PM -0700, Mike Kravetz wrote:
 On 10/9/19 5:27 AM, YueHaibing wrote:
> Fixes gcc '-Wunused-but-set-variable' warning:
>
> mm/userfaultfd.c: In function '__mcopy_atomic_hugetlb':
> mm/userfaultfd.c:217:17: warning:
>  variable 'h' set but not used [-Wunused-but-set-variable]
>
> It is not used since commit 78911d0e18ac ("userfaultfd: use vma_pagesize
> for all huge page size calculation")
>

 Thanks!  That should have been removed with the recent cleanups.

> Signed-off-by: YueHaibing 

 Reviewed-by: Mike Kravetz 
>>>
>>> If I am correct, this is removed in a recent patch.
>>
>> I'm having a hard time figuring out what is actually in the latest mmotm
>> tree.  Andrew added a build fixup patch ab169389eb5 in linux-next which
>> adds the reference to h.  Is there a patch after that to remove the 
>> reference?
>>
> 
> I checked linux-next tree, this commit removes the reference.
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=add4eaeef3766b7491d70d473c48c0b6d6ca5cb7
> 

Yes, but unless I am mistaken this adds it back,

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=ab169389eb5ff9da7113a21737574edc6d22c072

-- 
Mike Kravetz


[PATCH 4/4] staging: rtl8723bs: Remove unnecessary blank lines

2019-10-09 Thread Wambui Karuga
Remove multiple blank lines in
drivers/staging/rtl8723bs/core/rtw_mlme.c.
Issues reported by checkpatch.pl as:
CHECK: Please don't use multiple blank lines

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 47 ---
 1 file changed, 47 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 17da4170e861..02bc60d8478f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -208,7 +208,6 @@ void _rtw_free_network(struct   mlme_priv *pmlmepriv, 
struct wlan_network *pnetwor
 
pmlmepriv->num_of_scanned--;
 
-
/* DBG_871X("_rtw_free_network:SSID =%s\n", 
pnetwork->network.Ssid.Ssid); */
 
spin_unlock_bh(&free_queue->lock);
@@ -300,12 +299,8 @@ void rtw_free_network_queue(struct adapter *padapter, u8 
isfreeall)
spin_unlock_bh(&scanned_queue->lock);
 }
 
-
-
-
 sint rtw_if_up(struct adapter *padapter)
 {
-
sint res;
 
if (padapter->bDriverStopped || padapter->bSurpriseRemoved ||
@@ -317,7 +312,6 @@ sint rtw_if_up(struct adapter *padapter)
return res;
 }
 
-
 void rtw_generate_random_ibss(u8 *pibss)
 {
unsigned long curtime = jiffies;
@@ -335,7 +329,6 @@ u8 *rtw_get_capability_from_ie(u8 *ie)
return ie + 8 + 2;
 }
 
-
 u16 rtw_get_capability(struct wlan_bssid_ex *bss)
 {
__le16  val;
@@ -423,7 +416,6 @@ int is_same_network(struct wlan_bssid_ex *src, struct 
wlan_bssid_ex *dst, u8 fea
memcpy((u8 *)&tmps, rtw_get_capability_from_ie(src->IEs), 2);
memcpy((u8 *)&tmpd, rtw_get_capability_from_ie(dst->IEs), 2);
 
-
s_cap = le16_to_cpu(tmps);
d_cap = le16_to_cpu(tmpd);
 
@@ -465,7 +457,6 @@ struct  wlan_network
*rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
 {
struct list_head*plist, *phead;
 
-
struct  wlan_network*pwlan = NULL;
struct  wlan_network*oldest = NULL;
 
@@ -577,12 +568,8 @@ static void update_current_network(struct adapter 
*adapter, struct wlan_bssid_ex
}
 }
 
-
 /*
-
 Caller must hold pmlmepriv->lock first.
-
-
 */
 void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex 
*target)
 {
@@ -623,7 +610,6 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
 
}
 
-
/* If we didn't find a match, then get a new network slot to initialize
 * with this beacon's information */
/* if (phead == plist) { */
@@ -759,7 +745,6 @@ int rtw_is_desired_network(struct adapter *adapter, struct 
wlan_network *pnetwor
}
}
 
-
if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 
0)) {
DBG_871X("desired_encmode: %d, privacy: %d\n", desired_encmode, 
privacy);
bselected = false;
@@ -770,7 +755,6 @@ int rtw_is_desired_network(struct adapter *adapter, struct 
wlan_network *pnetwor
bselected = false;
}
 
-
return bselected;
 }
 
@@ -780,7 +764,6 @@ void rtw_atimdone_event_callback(struct adapter 
*adapter, u8 *pbuf)
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive 
atimdone_event\n"));
 }
 
-
 void rtw_survey_event_callback(struct adapter  *adapter, u8 *pbuf)
 {
u32 len;
@@ -797,7 +780,6 @@ void rtw_survey_event_callback(struct adapter   
*adapter, u8 *pbuf)
return;
}
 
-
spin_lock_bh(&pmlmepriv->lock);
 
/*  update IBSS_network 's timestamp */
@@ -830,8 +812,6 @@ void rtw_survey_event_callback(struct adapter   
*adapter, u8 *pbuf)
spin_unlock_bh(&pmlmepriv->lock);
 }
 
-
-
 void rtw_surveydone_event_callback(struct adapter  *adapter, u8 *pbuf)
 {
u8 timer_cancelled = false;
@@ -862,7 +842,6 @@ void rtw_surveydone_event_callback(struct adapter   
*adapter, u8 *pbuf)
if (timer_cancelled)
_cancel_timer(&pmlmepriv->scan_to_timer, &timer_cancelled);
 
-
spin_lock_bh(&pmlmepriv->lock);
 
rtw_set_signal_stat_timer(&adapter->recvpriv);
@@ -1002,7 +981,6 @@ static void find_network(struct adapter *adapter)
else
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, 
("rtw_free_assoc_resources : pwlan == NULL\n\n"));
 
-
if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) &&
(adapter->stapriv.asoc_sta_count == 1))
rtw_free_network_nolock(adapter, pwlan);
@@ -1181,7 +1159,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
psta->wireless_mode = pmlmeext->cur_wireless_mode;
psta->raid = networktype_to_raid_ex(padapter, psta);
 
-
/* sta mode */
rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true);
 
@@ -1213,7 +1190,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
  

[PATCH 2/4] staging: rtl8723bs: Remove unnecessary braces for single statements

2019-10-09 Thread Wambui Karuga
Clean up multiple unnecessary braces around single statement blocks in
drivers/staging/rtl8723bs/core/rtw_mlme.c
Issues reported by checkpatch.pl as:
WARNING: braces {} are not necessary for single statement blocks or
WARNING: braces {} are not necessary for any arm of this statement

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 37 ---
 1 file changed, 12 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 7f27287223e8..b15b761782b8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -112,9 +112,8 @@ void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
 {
if (pmlmepriv) {
rtw_free_mlme_priv_ie_data(pmlmepriv);
-   if (pmlmepriv->free_bss_buf) {
+   if (pmlmepriv->free_bss_buf)
vfree(pmlmepriv->free_bss_buf);
-   }
}
 }
 
@@ -753,11 +752,10 @@ int rtw_is_desired_network(struct adapter *adapter, 
struct wlan_network *pnetwor
 
if (psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPA2PSK) {
p = rtw_get_ie(pnetwork->network.IEs + 
_BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, (pnetwork->network.IELength - 
_BEACON_IE_OFFSET_));
-   if (p && ie_len > 0) {
+   if (p && ie_len > 0)
bselected = true;
-   } else {
+   else
bselected = false;
-   }
}
}
 
@@ -822,9 +820,8 @@ void rtw_survey_event_callback(struct adapter   
*adapter, u8 *pbuf)
 
/*  lock pmlmepriv->lock when you accessing network_q */
if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) {
-   if (pnetwork->Ssid.Ssid[0] == 0) {
+   if (pnetwork->Ssid.Ssid[0] == 0)
pnetwork->Ssid.SsidLength = 0;
-   }
rtw_add_network(adapter, pnetwork);
}
 
@@ -893,9 +890,8 @@ void rtw_surveydone_event_callback(struct adapter   
*adapter, u8 *pbuf)
 
pmlmepriv->fw_state = 
WIFI_ADHOC_MASTER_STATE;
 
-   if (rtw_createbss_cmd(adapter) != 
_SUCCESS) {
-   RT_TRACE(_module_rtl871x_mlme_c_, 
_drv_err_, ("Error =>rtw_createbss_cmd status FAIL\n"));
-   }
+   if (rtw_createbss_cmd(adapter) != 
_SUCCESS)
+   
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error =>rtw_createbss_cmd status 
FAIL\n"));
 
pmlmepriv->to_join = false;
}
@@ -1166,9 +1162,8 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 
psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress);
-   if (!psta) {
+   if (!psta)
psta = rtw_alloc_stainfo(pstapriv, 
pnetwork->network.MacAddress);
-   }
 
if (psta) { /* update ptarget_sta */
 
@@ -1347,11 +1342,10 @@ void rtw_joinbss_event_prehandle(struct adapter 
*adapter, u8 *pbuf)
rtw_get_encrypt_decrypt_from_registrypriv(adapter);
 
 
-   if (pmlmepriv->assoc_ssid.SsidLength == 0) {
+   if (pmlmepriv->assoc_ssid.SsidLength == 0)
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@   joinbss 
event call back  for Any SSid\n"));
-   } else {
+   else
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@   
rtw_joinbss_event_callback for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid));
-   }
 
the_same_macaddr = !memcmp(pnetwork->network.MacAddress, 
cur_network->network.MacAddress, ETH_ALEN);
 
@@ -1723,13 +1717,8 @@ void rtw_stadel_event_callback(struct adapter *adapter, 
u8 *pbuf)
_clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE);
}
 
-   if (rtw_createbss_cmd(adapter) != _SUCCESS) {
-
+   if (rtw_createbss_cmd(adapter) != _SUCCESS)
RT_TRACE(_module_rtl871x_ioctl_set_c_, 
_drv_err_, ("***Error =>stadel_event_callback: rtw_createbss_cmd status 
FAIL***\n "));
-
-   }
-
-
}
 
}
@@ -1902,9 +1891,8 @@ void rtw_dynamic_check_timer_handler(struct adapter 
*adapter)
}
 
} else {
-   if (is_primary_adapter(adapter)) {
+   if (is_primary_adapter(adapter))
rtw_dynamic_chk_wk_cmd(adapter);
-   }
}
 
/* auto site survey */
@@ -2988,9 +2976,8 @@ void rtw_append_exented_cap(struct adapter *padapter, u8 
*out_i

[PATCH 3/4] staging: rtl8723bs: Remove comparisons to booleans in conditionals.

2019-10-09 Thread Wambui Karuga
Remove comparisons to true and false in multiple if statements in
drivers/staging/rtl8723bs/core/rtw_mlme.c
Issues reported by checkpatch.pl as:
CHECK: Using comparison to false is error prone
CHECK: Using comparison to true is error prone

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 29 +++
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index b15b761782b8..17da4170e861 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -187,7 +187,7 @@ void _rtw_free_network(struct   mlme_priv *pmlmepriv, 
struct wlan_network *pnetwor
if (!pnetwork)
return;
 
-   if (pnetwork->fixed == true)
+   if (pnetwork->fixed)
return;
 
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) ||
@@ -222,7 +222,7 @@ void _rtw_free_network_nolock(structmlme_priv 
*pmlmepriv, struct wlan_network *
if (!pnetwork)
return;
 
-   if (pnetwork->fixed == true)
+   if (pnetwork->fixed)
return;
 
/* spin_lock_irqsave(&free_queue->lock, irqL); */
@@ -480,7 +480,7 @@ struct  wlan_network
*rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
 
pwlan = LIST_CONTAINOR(plist, struct wlan_network, list);
 
-   if (pwlan->fixed != true) {
+   if (!pwlan->fixed) {
if (oldest == NULL || time_after(oldest->last_scanned, 
pwlan->last_scanned))
oldest = pwlan;
}
@@ -867,7 +867,7 @@ void rtw_surveydone_event_callback(struct adapter   
*adapter, u8 *pbuf)
 
rtw_set_signal_stat_timer(&adapter->recvpriv);
 
-   if (pmlmepriv->to_join == true) {
+   if (pmlmepriv->to_join) {
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
if (check_fwstate(pmlmepriv, _FW_LINKED) == false) {
set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
@@ -1368,7 +1368,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, 
u8 *pbuf)
if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) {
/* s1. find ptarget_wlan */
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-   if (the_same_macaddr == true) {
+   if (the_same_macaddr) {
ptarget_wlan = 
rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
} else {
pcur_wlan = 
rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress);
@@ -1843,7 +1843,7 @@ static void rtw_auto_scan_handler(struct adapter 
*padapter)
goto exit;
}
 
-   if (pmlmepriv->LinkDetectInfo.bBusyTraffic == true) {
+   if (pmlmepriv->LinkDetectInfo.bBusyTraffic) {
DBG_871X(FUNC_ADPT_FMT" exit BusyTraffic\n", 
FUNC_ADPT_ARG(padapter));
goto exit;
}
@@ -1863,20 +1863,20 @@ void rtw_dynamic_check_timer_handler(struct adapter 
*adapter)
if (!adapter)
return;
 
-   if (adapter->hw_init_completed == false)
+   if (!adapter->hw_init_completed)
return;
 
-   if ((adapter->bDriverStopped == true) || (adapter->bSurpriseRemoved == 
true))
+   if (adapter->bDriverStopped || adapter->bSurpriseRemoved)
return;
 
-   if (adapter->net_closed == true)
+   if (adapter->net_closed)
return;
 
if (is_primary_adapter(adapter))
DBG_871X("IsBtDisabled =%d, IsBtControlLps =%d\n", 
hal_btcoex_IsBtDisabled(adapter), hal_btcoex_IsBtControlLps(adapter));
 
-   if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode == true)
-   && (hal_btcoex_IsBtControlLps(adapter) == false)
+   if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode)
+   && !(hal_btcoex_IsBtControlLps(adapter))
) {
u8 bEnterPS;
 
@@ -2047,7 +2047,7 @@ static int rtw_check_join_candidate(struct mlme_priv *mlme
 
 
/* check bssid, if needed */
-   if (mlme->assoc_by_bssid == true) {
+   if (mlme->assoc_by_bssid) {
if (memcmp(competitor->network.MacAddress, mlme->assoc_bssid, 
ETH_ALEN))
goto exit;
}
@@ -2805,7 +2805,6 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, 
uint ie_len, u8 channe
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
u8 cbw40_enable = 0;
 
-
if (!phtpriv->ht_option)
return;
 
@@ -2815,7 +2814,7 @@ void rtw_update_ht_cap(

[PATCH 0/4] Fix style and formatting issues in rtw_mlme.c

2019-10-09 Thread Wambui Karuga
This patchest addresses multiple style and formatting issues in the
file drivers/staging/rtl8723bs/core/rtw_mlme.c.
These issues are all reported by checkpatch.pl

Wambui Karuga (4):
  staging: rtl8723bs: Remove comparisons to NULL in conditionals
  staging: rtl8723bs: Remove unnecessary braces for single statements
  staging: rtl8723bs: Remove comparisons to booleans in conditionals.
  staging: rtl8723bs: Remove unnecessary blank lines

 drivers/staging/rtl8723bs/core/rtw_mlme.c | 157 +++---
 1 file changed, 48 insertions(+), 109 deletions(-)

-- 
2.23.0



[PATCH 1/4] staging: rtl8723bs: Remove comparisons to NULL in conditionals

2019-10-09 Thread Wambui Karuga
Remove most comparisons to NULL in conditionals in
drivers/staging/rtl8723bs/core/rtw_mlme.c
Issues reported by checkpatch.pl as:
CHECK: Comparison to NULL could be written

Signed-off-by: Wambui Karuga 
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 46 +++
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 0ac7712223af..7f27287223e8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -40,7 +40,7 @@ int   rtw_init_mlme_priv(struct adapter *padapter)
 
pbuf = vzalloc(array_size(MAX_BSS_CNT, sizeof(struct wlan_network)));
 
-   if (pbuf == NULL) {
+   if (!pbuf) {
res = _FAIL;
goto exit;
}
@@ -185,7 +185,7 @@ void _rtw_free_network(struct   mlme_priv *pmlmepriv, 
struct wlan_network *pnetwor
 /* _irqL irqL; */
struct __queue *free_queue = &(pmlmepriv->free_bss_pool);
 
-   if (pnetwork == NULL)
+   if (!pnetwork)
return;
 
if (pnetwork->fixed == true)
@@ -220,7 +220,7 @@ void _rtw_free_network_nolock(structmlme_priv 
*pmlmepriv, struct wlan_network *
 
struct __queue *free_queue = &(pmlmepriv->free_bss_pool);
 
-   if (pnetwork == NULL)
+   if (!pnetwork)
return;
 
if (pnetwork->fixed == true)
@@ -633,7 +633,7 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
/* If there are no more slots, expire the oldest */
/* list_del_init(&oldest->list); */
pnetwork = oldest;
-   if (pnetwork == NULL) {
+   if (!pnetwork) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, 
("\n\n\nsomething wrong here\n\n\n"));
goto exit;
}
@@ -654,7 +654,7 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
 
pnetwork = rtw_alloc_network(pmlmepriv); /*  will 
update scan_time */
 
-   if (pnetwork == NULL) {
+   if (!pnetwork) {
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, 
("\n\n\nsomething wrong here\n\n\n"));
goto exit;
}
@@ -738,7 +738,7 @@ int rtw_is_desired_network(struct adapter *adapter, struct 
wlan_network *pnetwor
privacy = pnetwork->network.Privacy;
 
if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) {
-   if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, 
pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen) != NULL)
+   if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, 
pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen))
return true;
else
return false;
@@ -1166,7 +1166,7 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct 
adapter *padapter, str
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 
psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress);
-   if (psta == NULL) {
+   if (!psta) {
psta = rtw_alloc_stainfo(pstapriv, 
pnetwork->network.MacAddress);
}
 
@@ -1413,7 +1413,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, 
u8 *pbuf)
/* s3. find ptarget_sta & update ptarget_sta after 
update cur_network only for station mode */
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == 
true) {
ptarget_sta = 
rtw_joinbss_update_stainfo(adapter, pnetwork);
-   if (ptarget_sta == NULL) {
+   if (!ptarget_sta) {
RT_TRACE(_module_rtl871x_mlme_c_, 
_drv_err_, ("Can't update stainfo when joinbss_event callback\n"));

spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
goto ignore_joinbss_callback;
@@ -1503,7 +1503,7 @@ void rtw_sta_media_status_rpt(struct adapter *adapter, 
struct sta_info *psta, u3
 {
u16 media_status_rpt;
 
-   if (psta == NULL)
+   if (!psta)
return;
 
media_status_rpt = (u16)((psta->mac_id<<8)|mstatus); /*   
MACID|OPMODE:1 connect */
@@ -1561,7 +1561,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, 
u8 *pbuf)
 
/* for AD-HOC mode */
psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr);
-   if (psta != NULL) {
+   if (psta) {
/* the sta have been in sta_info_queue => do nothing */
 
RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: 
rtw_stassoc_event_callback: sta has been in sta_ha

Re: [PATCH] scsi: fix kconfig dependency warning related to 53C700_LE_ON_BE

2019-10-09 Thread Martin K. Petersen


Thomas,

> Add the missing depends SCSI_SNI_53C710 to 53C700_LE_ON_BE to fix it.

Applied to 5.4/scsi-fixes, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: sni_53c710 fix compilation error

2019-10-09 Thread Martin K. Petersen


Thomas,

> Drop out memory dev_printk() with wring device pointer argument.

Applied to 5.4/scsi-fixes, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 1/3] dt-bindings: power: add Amlogic secure power domains bindings

2019-10-09 Thread Jianxin Pan
Hi Rob,

Thanks for your review.

I'm sorry to reply so late, for I've been on vacation in the last week.

On 2019/10/2 6:09, Rob Herring wrote:
> On Thu, Sep 19, 2019 at 08:11:02AM -0400, Jianxin Pan wrote:
>> Add the bindings for the Amlogic Secure power domains, controlling the
>> secure power domains.
>>
>> The bindings targets the Amlogic A1 and C1 compatible SoCs, in which the
>> power domain registers are in secure world.
>>
>> Signed-off-by: Jianxin Pan 
>> Signed-off-by: Zhiqiang Liang 
>> ---
>>  .../bindings/power/amlogic,meson-sec-pwrc.yaml | 32 
>> ++
>>  include/dt-bindings/power/meson-a1-power.h | 32 
>> ++
>>  2 files changed, 64 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/power/amlogic,meson-sec-pwrc.yaml
>>  create mode 100644 include/dt-bindings/power/meson-a1-power.h
>>
>> diff --git 
>> a/Documentation/devicetree/bindings/power/amlogic,meson-sec-pwrc.yaml 
>> b/Documentation/devicetree/bindings/power/amlogic,meson-sec-pwrc.yaml
>> new file mode 100644
>> index ..327e0d9
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/power/amlogic,meson-sec-pwrc.yaml
>> @@ -0,0 +1,32 @@
>> +# SPDX-License-Identifier: (GPL-2.0+ OR MIT)
>> +# Copyright (c) 2019 Amlogic, Inc
>> +# Author: Jianxin Pan 
>> +%YAML 1.2
>> +---
>> +$id: "http://devicetree.org/schemas/power/amlogic,meson-sec-pwrc.yaml#";
>> +$schema: "http://devicetree.org/meta-schemas/core.yaml#";
>> +
>> +title: Amlogic Meson Secure Power Domains
>> +
>> +maintainers:
>> +  - Jianxin Pan 
>> +
>> +description: |+
>> +  A1/C1 series The Secure Power Domains node should be the child of a syscon
>> +  node with the required property.
> 
> 'a syscon node' is not specific enough. It must be a specific node.
> 
I will fix this.
In A1/C1, power control is in secure domain, and syscon parent is not needed.
>> +
>> +properties:
>> +  compatible:
>> +enum:
>> +  - amlogic,meson-a1-pwrc
>> +
>> +required:
>> +  - compatible
>> +
>> +examples:
>> +  - |
>> +pwrc: power-controller {
>> +  compatible = "amlogic,meson-a1-pwrc";
> 
> But why do you need this node? It has no resources.
> 
> #power-domain-cells needed?
I will add #power-domain-cells and secure-monitor here.
Thank you for the review.
> 
>> +};
>> +
>> +
>> diff --git a/include/dt-bindings/power/meson-a1-power.h 
>> b/include/dt-bindings/power/meson-a1-power.h
>> new file mode 100644
>> index ..6cf50bf
>> --- /dev/null
>> +++ b/include/dt-bindings/power/meson-a1-power.h
>> @@ -0,0 +1,32 @@
>> +/* SPDX-License-Identifier: (GPL-2.0+ or MIT) */
>> +/*
>> + * Copyright (c) 2019 Amlogic, Inc.
>> + * Author: Jianxin Pan 
>> + */
>> +
>> +#ifndef _DT_BINDINGS_MESON_A1_POWER_H
>> +#define _DT_BINDINGS_MESON_A1_POWER_H
>> +
>> +#define PWRC_DSPA_ID8
>> +#define PWRC_DSPB_ID9
>> +#define PWRC_UART_ID10
>> +#define PWRC_DMC_ID 11
>> +#define PWRC_I2C_ID 12
>> +#define PWRC_PSRAM_ID   13
>> +#define PWRC_ACODEC_ID  14
>> +#define PWRC_AUDIO_ID   15
>> +#define PWRC_OTP_ID 16
>> +#define PWRC_DMA_ID 17
>> +#define PWRC_SD_EMMC_ID 18
>> +#define PWRC_RAMA_ID19
>> +#define PWRC_RAMB_ID20
>> +#define PWRC_IR_ID  21
>> +#define PWRC_SPICC_ID   22
>> +#define PWRC_SPIFC_ID   23
>> +#define PWRC_USB_ID 24
>> +#define PWRC_NIC_ID 25
>> +#define PWRC_PDMIN_ID   26
>> +#define PWRC_RSA_ID 27
>> +#define PWRC_MAX_ID 28
>> +
>> +#endif
>> -- 
>> 2.7.4
>>
> 
> .
> 



Re: [PATCH -next] userfaultfd: remove set but not used variable 'h'

2019-10-09 Thread Wei Yang
On Wed, Oct 09, 2019 at 07:25:18PM -0700, Mike Kravetz wrote:
>On 10/9/19 6:23 PM, Wei Yang wrote:
>> On Wed, Oct 09, 2019 at 05:45:57PM -0700, Mike Kravetz wrote:
>>> On 10/9/19 5:27 AM, YueHaibing wrote:
 Fixes gcc '-Wunused-but-set-variable' warning:

 mm/userfaultfd.c: In function '__mcopy_atomic_hugetlb':
 mm/userfaultfd.c:217:17: warning:
  variable 'h' set but not used [-Wunused-but-set-variable]

 It is not used since commit 78911d0e18ac ("userfaultfd: use vma_pagesize
 for all huge page size calculation")

>>>
>>> Thanks!  That should have been removed with the recent cleanups.
>>>
 Signed-off-by: YueHaibing 
>>>
>>> Reviewed-by: Mike Kravetz 
>> 
>> If I am correct, this is removed in a recent patch.
>
>I'm having a hard time figuring out what is actually in the latest mmotm
>tree.  Andrew added a build fixup patch ab169389eb5 in linux-next which
>adds the reference to h.  Is there a patch after that to remove the reference?
>

I checked linux-next tree, this commit removes the reference.

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=add4eaeef3766b7491d70d473c48c0b6d6ca5cb7

>-- 
>Mike Kravetz

-- 
Wei Yang
Help you, Help me


Re: [PATCH v2] HID: core: check whether usage page item is after usage id item

2019-10-09 Thread Candle Sun
On Thu, Oct 10, 2019 at 2:00 AM Jiri Kosina  wrote:
>
> On Wed, 9 Oct 2019, Nicolas Saenz Julienne wrote:
>
> > > diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> > > index 3eaee2c..3394222 100644
> > > --- a/drivers/hid/hid-core.c
> > > +++ b/drivers/hid/hid-core.c
> > > @@ -35,6 +35,8 @@
> > >
> > >  #include "hid-ids.h"
> > >
> > > +#define GET_COMPLETE_USAGE(page, id) (((page) << 16) + ((id) & 0x))
> >
> > Not sure I like the macro. I'd rather have the explicit code. That said, 
> > lets
> > see what Benjamin has to say.
>
> Not sure about Benjamin :) but I personally would ask for putting it
> somewhere into hid.h as static inline.
>
> And even if it's for some reason insisted on this staying macro, please at
> least put it as close to the place(s) it's being used as possible, in
> order to maintain some code sanity.
>
> Thanks,
>
> --
> Jiri Kosina
> SUSE Labs
>

Thanks Nicolas and Jiri,
If macro is not good, I will change it to static function. But the
funciton is only used in hid-core.c,
maybe placing it into hid.h is not good?

Regards,
Candle


Re: [PATCH] rcu: avoid data-race in rcu_gp_fqs_check_wake()

2019-10-09 Thread Paul E. McKenney
On Wed, Oct 09, 2019 at 02:21:54PM -0700, Eric Dumazet wrote:
> rcu_gp_fqs_check_wake() uses rcu_preempt_blocked_readers_cgp()
> to read ->gp_tasks while otehr cpus might write over this field.
> 
> We need READ_ONCE()/WRITE_ONCE() pairs to avoid compiler
> tricks and KCSAN splats like the following :
> 
> BUG: KCSAN: data-race in rcu_gp_fqs_check_wake / 
> rcu_preempt_deferred_qs_irqrestore
> 
> write to 0x85a7f190 of 8 bytes by task 7317 on cpu 0:
>  rcu_preempt_deferred_qs_irqrestore+0x43d/0x580 kernel/rcu/tree_plugin.h:507
>  rcu_read_unlock_special+0xec/0x370 kernel/rcu/tree_plugin.h:659
>  __rcu_read_unlock+0xcf/0xe0 kernel/rcu/tree_plugin.h:394
>  rcu_read_unlock include/linux/rcupdate.h:645 [inline]
>  __ip_queue_xmit+0x3b0/0xa40 net/ipv4/ip_output.c:533
>  ip_queue_xmit+0x45/0x60 include/net/ip.h:236
>  __tcp_transmit_skb+0xdeb/0x1cd0 net/ipv4/tcp_output.c:1158
>  __tcp_send_ack+0x246/0x300 net/ipv4/tcp_output.c:3685
>  tcp_send_ack+0x34/0x40 net/ipv4/tcp_output.c:3691
>  tcp_cleanup_rbuf+0x130/0x360 net/ipv4/tcp.c:1575
>  tcp_recvmsg+0x633/0x1a30 net/ipv4/tcp.c:2179
>  inet_recvmsg+0xbb/0x250 net/ipv4/af_inet.c:838
>  sock_recvmsg_nosec net/socket.c:871 [inline]
>  sock_recvmsg net/socket.c:889 [inline]
>  sock_recvmsg+0x92/0xb0 net/socket.c:885
>  sock_read_iter+0x15f/0x1e0 net/socket.c:967
>  call_read_iter include/linux/fs.h:1864 [inline]
>  new_sync_read+0x389/0x4f0 fs/read_write.c:414
> 
> read to 0x85a7f190 of 8 bytes by task 10 on cpu 1:
>  rcu_gp_fqs_check_wake kernel/rcu/tree.c:1556 [inline]
>  rcu_gp_fqs_check_wake+0x93/0xd0 kernel/rcu/tree.c:1546
>  rcu_gp_fqs_loop+0x36c/0x580 kernel/rcu/tree.c:1611
>  rcu_gp_kthread+0x143/0x220 kernel/rcu/tree.c:1768
>  kthread+0x1d4/0x200 drivers/block/aoe/aoecmd.c:1253
>  ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352
> 
> Reported by Kernel Concurrency Sanitizer on:
> CPU: 1 PID: 10 Comm: rcu_preempt Not tainted 5.3.0+ #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS 
> Google 01/01/2011
> 
> Signed-off-by: Eric Dumazet 
> Cc: "Paul E. McKenney" 
> Reported-by: syzbot 

Again, good catch, applied for review and testing, thank you!

I added another READ_ONCE() to dump_blkd_tasks(), which is not exercised
unless you get an RCU CPU stall warning or some such.  The updated patch
is below, please let me know if I messed anything up.

Thanx, Paul



commit 53a6fffb998fd442e4049b145d8843fecc2bb396
Author: Eric Dumazet 
Date:   Wed Oct 9 14:21:54 2019 -0700

rcu: Avoid data-race in rcu_gp_fqs_check_wake()

The rcu_gp_fqs_check_wake() function uses rcu_preempt_blocked_readers_cgp()
to read ->gp_tasks while other cpus might overwrite this field.

We need READ_ONCE()/WRITE_ONCE() pairs to avoid compiler
tricks and KCSAN splats like the following :

BUG: KCSAN: data-race in rcu_gp_fqs_check_wake / 
rcu_preempt_deferred_qs_irqrestore

write to 0x85a7f190 of 8 bytes by task 7317 on cpu 0:
 rcu_preempt_deferred_qs_irqrestore+0x43d/0x580 kernel/rcu/tree_plugin.h:507
 rcu_read_unlock_special+0xec/0x370 kernel/rcu/tree_plugin.h:659
 __rcu_read_unlock+0xcf/0xe0 kernel/rcu/tree_plugin.h:394
 rcu_read_unlock include/linux/rcupdate.h:645 [inline]
 __ip_queue_xmit+0x3b0/0xa40 net/ipv4/ip_output.c:533
 ip_queue_xmit+0x45/0x60 include/net/ip.h:236
 __tcp_transmit_skb+0xdeb/0x1cd0 net/ipv4/tcp_output.c:1158
 __tcp_send_ack+0x246/0x300 net/ipv4/tcp_output.c:3685
 tcp_send_ack+0x34/0x40 net/ipv4/tcp_output.c:3691
 tcp_cleanup_rbuf+0x130/0x360 net/ipv4/tcp.c:1575
 tcp_recvmsg+0x633/0x1a30 net/ipv4/tcp.c:2179
 inet_recvmsg+0xbb/0x250 net/ipv4/af_inet.c:838
 sock_recvmsg_nosec net/socket.c:871 [inline]
 sock_recvmsg net/socket.c:889 [inline]
 sock_recvmsg+0x92/0xb0 net/socket.c:885
 sock_read_iter+0x15f/0x1e0 net/socket.c:967
 call_read_iter include/linux/fs.h:1864 [inline]
 new_sync_read+0x389/0x4f0 fs/read_write.c:414

read to 0x85a7f190 of 8 bytes by task 10 on cpu 1:
 rcu_gp_fqs_check_wake kernel/rcu/tree.c:1556 [inline]
 rcu_gp_fqs_check_wake+0x93/0xd0 kernel/rcu/tree.c:1546
 rcu_gp_fqs_loop+0x36c/0x580 kernel/rcu/tree.c:1611
 rcu_gp_kthread+0x143/0x220 kernel/rcu/tree.c:1768
 kthread+0x1d4/0x200 drivers/block/aoe/aoecmd.c:1253
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 10 Comm: rcu_preempt Not tainted 5.3.0+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS 
Google 01/01/2011

Signed-off-by: Eric Dumazet 
Reported-by: syzbot 
[ paulmck:  Added another READ_ONCE() for RCU CPU stall warnings. ]
Signed-off-by: Paul E. McKenney 

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index d43f4e0..56a

Re: "reuse mergeable anon_vma as parent when fork" causes a crash on s390

2019-10-09 Thread Wei Yang
On Thu, Oct 10, 2019 at 10:36:01AM +0800, Wei Yang wrote:
>Hi, Qian, Shakeel
>
>Thanks for testing.
>
>Sounds I missed some case to handle. anon_vma_clone() now would be called in
>vma_adjust, which is a different case when it is introduced.
>

Well, I have to correct my statement. The reason is we may did something more
in anon_vma_clone().

Here is a quick fix, while I need to go through all the cases carefully.

diff --git a/mm/rmap.c b/mm/rmap.c
index 12f6c3d7fd9d..2844f442208d 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -271,7 +271,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct 
vm_area_struct *src)
 * 1. Parent has vm_prev, which implies we have vm_prev.
 * 2. Parent and its vm_prev have the same anon_vma.
 */
-   if (pprev && pprev->anon_vma == src->anon_vma)
+   if (!dst->anon_vma && pprev && pprev->anon_vma == src->anon_vma)
dst->anon_vma = prev->anon_vma;
 
list_for_each_entry_reverse(pavc, &src->anon_vma_chain, same_vma) {

>BTW, do you have the specific test case? So that I could verify my change. The
>kernel build test doesn't trigger this.
>
>Thanks a lot :-)
>
>On Wed, Oct 09, 2019 at 03:21:11PM -0700, Shakeel Butt wrote:
>-- 
>Wei Yang
>Help you, Help me

-- 
Wei Yang
Help you, Help me


[PATCH] KPC2000: kpc2000_spi.c: Fix style issues (Unecessary parenthesis)

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

Signed-off-by: Chandra Annamaneni 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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



[PATCH] KPC2000: kpc2000_spi.c: Fix style issues (misaligned brace)

2019-10-09 Thread Chandra Annamaneni
Resolved: ERROR: else should follow close brace '}'

Signed-off-by: Chandra Annamaneni 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

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



[PATCH] KPC2000: kpc2000_spi.c: Fix style issues (alignment)

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

Signed-off-by: Chandra Annamaneni 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

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



[PATCH] KPC2000: kpc2000_spi.c: Fix style issues (line length)

2019-10-09 Thread Chandra Annamaneni
Resoved: "WARNING: line over 80 characters" from checkpatch.pl

Signed-off-by: Chandra Annamaneni 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index 3be33c4..ef78b6d 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -30,19 +30,19 @@
 #include "kpc.h"
 
 static struct mtd_partition p2kr0_spi0_parts[] = {
-   { .name = "SLOT_0", .size = 7798784,.offset = 0,
},
-   { .name = "SLOT_1", .size = 7798784,.offset = 
MTDPART_OFS_NXTBLK},
-   { .name = "SLOT_2", .size = 7798784,.offset = 
MTDPART_OFS_NXTBLK},
-   { .name = "SLOT_3", .size = 7798784,.offset = 
MTDPART_OFS_NXTBLK},
-   { .name = "CS0_EXTRA",  .size = MTDPART_SIZ_FULL,   .offset = 
MTDPART_OFS_NXTBLK},
+   { .name = "SLOT_0",  .size = 7798784,  .offset = 0,},
+   { .name = "SLOT_1",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
+   { .name = "SLOT_2",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
+   { .name = "SLOT_3",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
+   { .name = "CS0_EXTRA", .size = MTDPART_SIZ_FULL, .offset = 
MTDPART_OFS_NXTBLK},
 };
 
 static struct mtd_partition p2kr0_spi1_parts[] = {
-   { .name = "SLOT_4", .size = 7798784,.offset = 0,
},
-   { .name = "SLOT_5", .size = 7798784,.offset = 
MTDPART_OFS_NXTBLK},
-   { .name = "SLOT_6", .size = 7798784,.offset = 
MTDPART_OFS_NXTBLK},
-   { .name = "SLOT_7", .size = 7798784,.offset = 
MTDPART_OFS_NXTBLK},
-   { .name = "CS1_EXTRA",  .size = MTDPART_SIZ_FULL,   .offset = 
MTDPART_OFS_NXTBLK},
+   { .name = "SLOT_4",  .size = 7798784,  .offset = 0,},
+   { .name = "SLOT_5",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
+   { .name = "SLOT_6",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
+   { .name = "SLOT_7",  .size = 7798784,  .offset = MTDPART_OFS_NXTBLK},
+   { .name = "CS1_EXTRA",  .size = MTDPART_SIZ_FULL, .offset = 
MTDPART_OFS_NXTBLK},
 };
 
 static struct flash_platform_data p2kr0_spi0_pdata = {
-- 
2.7.4



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

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

Signed-off-by: Chandra Annamaneni 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 1 +
 1 file changed, 1 insertion(+)

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



Re: [PATCH] rcu: Fix data-race due to atomic_t copy-by-value

2019-10-09 Thread Paul E. McKenney
On Wed, Oct 09, 2019 at 05:57:43PM +0200, Marco Elver wrote:
> This fixes a data-race where `atomic_t dynticks` is copied by value. The
> copy is performed non-atomically, resulting in a data-race if `dynticks`
> is updated concurrently.
> 
> This data-race was found with KCSAN:
> ==
> BUG: KCSAN: data-race in dyntick_save_progress_counter / rcu_irq_enter
> 
> write to 0x989dbdbe98e0 of 4 bytes by task 10 on cpu 3:
>  atomic_add_return include/asm-generic/atomic-instrumented.h:78 [inline]
>  rcu_dynticks_snap kernel/rcu/tree.c:310 [inline]
>  dyntick_save_progress_counter+0x43/0x1b0 kernel/rcu/tree.c:984
>  force_qs_rnp+0x183/0x200 kernel/rcu/tree.c:2286
>  rcu_gp_fqs kernel/rcu/tree.c:1601 [inline]
>  rcu_gp_fqs_loop+0x71/0x880 kernel/rcu/tree.c:1653
>  rcu_gp_kthread+0x22c/0x3b0 kernel/rcu/tree.c:1799
>  kthread+0x1b5/0x200 kernel/kthread.c:255
>  
> 
> read to 0x989dbdbe98e0 of 4 bytes by task 154 on cpu 7:
>  rcu_nmi_enter_common kernel/rcu/tree.c:828 [inline]
>  rcu_irq_enter+0xda/0x240 kernel/rcu/tree.c:870
>  irq_enter+0x5/0x50 kernel/softirq.c:347
>  
> 
> Reported by Kernel Concurrency Sanitizer on:
> CPU: 7 PID: 154 Comm: kworker/7:1H Not tainted 5.3.0+ #5
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 
> 04/01/2014
> Workqueue: kblockd blk_mq_run_work_fn
> ==
> 
> Signed-off-by: Marco Elver 

Good catch, queued for review and testing.

Thanx, Paul

> Cc: Paul E. McKenney 
> Cc: Josh Triplett 
> Cc: Steven Rostedt 
> Cc: Mathieu Desnoyers 
> Cc: Lai Jiangshan 
> Cc: Joel Fernandes 
> Cc: Ingo Molnar 
> Cc: Dmitry Vyukov 
> Cc: r...@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  include/trace/events/rcu.h |  4 ++--
>  kernel/rcu/tree.c  | 11 ++-
>  2 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h
> index 694bd040cf51..fdd31c5fd126 100644
> --- a/include/trace/events/rcu.h
> +++ b/include/trace/events/rcu.h
> @@ -442,7 +442,7 @@ TRACE_EVENT_RCU(rcu_fqs,
>   */
>  TRACE_EVENT_RCU(rcu_dyntick,
>  
> - TP_PROTO(const char *polarity, long oldnesting, long newnesting, 
> atomic_t dynticks),
> + TP_PROTO(const char *polarity, long oldnesting, long newnesting, int 
> dynticks),
>  
>   TP_ARGS(polarity, oldnesting, newnesting, dynticks),
>  
> @@ -457,7 +457,7 @@ TRACE_EVENT_RCU(rcu_dyntick,
>   __entry->polarity = polarity;
>   __entry->oldnesting = oldnesting;
>   __entry->newnesting = newnesting;
> - __entry->dynticks = atomic_read(&dynticks);
> + __entry->dynticks = dynticks;
>   ),
>  
>   TP_printk("%s %lx %lx %#3x", __entry->polarity,
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index 81105141b6a8..62e59596a30a 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -576,7 +576,7 @@ static void rcu_eqs_enter(bool user)
>   }
>  
>   lockdep_assert_irqs_disabled();
> - trace_rcu_dyntick(TPS("Start"), rdp->dynticks_nesting, 0, 
> rdp->dynticks);
> + trace_rcu_dyntick(TPS("Start"), rdp->dynticks_nesting, 0, 
> atomic_read(&rdp->dynticks));
>   WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !user && 
> !is_idle_task(current));
>   rdp = this_cpu_ptr(&rcu_data);
>   do_nocb_deferred_wakeup(rdp);
> @@ -649,14 +649,15 @@ static __always_inline void rcu_nmi_exit_common(bool 
> irq)
>* leave it in non-RCU-idle state.
>*/
>   if (rdp->dynticks_nmi_nesting != 1) {
> - trace_rcu_dyntick(TPS("--="), rdp->dynticks_nmi_nesting, 
> rdp->dynticks_nmi_nesting - 2, rdp->dynticks);
> + trace_rcu_dyntick(TPS("--="), rdp->dynticks_nmi_nesting, 
> rdp->dynticks_nmi_nesting - 2,
> +   atomic_read(&rdp->dynticks));
>   WRITE_ONCE(rdp->dynticks_nmi_nesting, /* No store tearing. */
>  rdp->dynticks_nmi_nesting - 2);
>   return;
>   }
>  
>   /* This NMI interrupted an RCU-idle CPU, restore RCU-idleness. */
> - trace_rcu_dyntick(TPS("Startirq"), rdp->dynticks_nmi_nesting, 0, 
> rdp->dynticks);
> + trace_rcu_dyntick(TPS("Startirq"), rdp->dynticks_nmi_nesting, 0, 
> atomic_read(&rdp->dynticks));
>   WRITE_ONCE(rdp->dynticks_nmi_nesting, 0); /* Avoid store tearing. */
>  
>   if (irq)
> @@ -743,7 +744,7 @@ static void rcu_eqs_exit(bool user)
>   rcu_dynticks_task_exit();
>   rcu_dynticks_eqs_exit();
>   rcu_cleanup_after_idle();
> - trace_rcu_dyntick(TPS("End"), rdp->dynticks_nesting, 1, rdp->dynticks);
> + trace_rcu_dyntick(TPS("End"), rdp->dynticks_nesting, 1, 
> atomic_read(&rdp->dynticks));
>   WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !user && 
> !is_idle_task(current));
>   WRITE_ONCE(rdp->dynticks_nesting, 1

Re: [PATCH v2] HID: core: check whether usage page item is after usage id item

2019-10-09 Thread Candle Sun
On Thu, Oct 10, 2019 at 1:01 AM Nicolas Saenz Julienne
 wrote:
>
> On Wed, 2019-10-09 at 20:53 +0800, Candle Sun wrote:
> > From: Candle Sun 
> >
> > Upstream commit 58e75155009c ("HID: core: move Usage Page concatenation
> > to Main item") adds support for Usage Page item after Usage ID items
> > (such as keyboards manufactured by Primax).
> >
> > Usage Page concatenation in Main item works well for following report
> > descriptor patterns:
> >
> > USAGE_PAGE (Keyboard)   05 07
> > USAGE_MINIMUM (Keyboard LeftControl)19 E0
> > USAGE_MAXIMUM (Keyboard Right GUI)  29 E7
> > LOGICAL_MINIMUM (0) 15 00
> > LOGICAL_MAXIMUM (1) 25 01
> > REPORT_SIZE (1) 75 01
> > REPORT_COUNT (8)95 08
> > INPUT (Data,Var,Abs)81 02
> >
> > -
> >
> > USAGE_MINIMUM (Keyboard LeftControl)19 E0
> > USAGE_MAXIMUM (Keyboard Right GUI)  29 E7
> > LOGICAL_MINIMUM (0) 15 00
> > LOGICAL_MAXIMUM (1) 25 01
> > REPORT_SIZE (1) 75 01
> > REPORT_COUNT (8)95 08
> > USAGE_PAGE (Keyboard)   05 07
> > INPUT (Data,Var,Abs)81 02
> >
> > But it makes the parser act wrong for the following report
> > descriptor pattern(such as some Gamepads):
> >
> > USAGE_PAGE (Button) 05 09
> > USAGE (Button 1)09 01
> > USAGE (Button 2)09 02
> > USAGE (Button 4)09 04
> > USAGE (Button 5)09 05
> > USAGE (Button 7)09 07
> > USAGE (Button 8)09 08
> > USAGE (Button 14)   09 0E
> > USAGE (Button 15)   09 0F
> > USAGE (Button 13)   09 0D
> > USAGE_PAGE (Consumer Devices)   05 0C
> > USAGE (Back)0a 24 02
> > USAGE (HomePage)0a 23 02
> > LOGICAL_MINIMUM (0) 15 00
> > LOGICAL_MAXIMUM (1) 25 01
> > REPORT_SIZE (1) 75 01
> > REPORT_COUNT (11)   95 0B
> > INPUT (Data,Var,Abs)81 02
> >
> > With Usage Page concatenation in Main item, parser recognizes all the
> > 11 Usages as consumer keys, it is not the HID device's real intention.
> >
> > This patch adds usage_page_last to flag whether Usage Page is after
> > Usage ID items. usage_page_last is false default, it is set as true
> > once Usage Page item is encountered and is reverted by next Usage ID
> > item.
> >
> > Usage Page concatenation on the currently defined Usage Page will do
> > firstly in Local parsing when Usage ID items encountered.
> >
> > When Main item is parsing, concatenation will do again with last
> > defined Usage Page if usage_page_last flag is true.
>
> Functionally I think this is the right approach. Sadly I don't have access to
> any  Primax device anymore so I can't test it. But I suggest you update
> hid-tools' parser and add a new unit test to verify we aren't missing 
> anything.
>
> You can base your code on this:
>
> https://gitlab.freedesktop.org/libevdev/hid-tools/merge_requests/37/commits
>

Thanks Nicolas. I will check and try to do it.

Candle

> > Signed-off-by: Candle Sun 
> > Signed-off-by: Nianfu Bai 
> > ---
> > Changes in v2:
> > - Update patch title
> > - Add GET_COMPLETE_USAGE macro
> > - Change the logic of checking whether to concatenate usage page again
> >   in main parsing
> > ---
> >  drivers/hid/hid-core.c | 31 +--
> >  include/linux/hid.h|  1 +
> >  2 files changed, 26 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> > index 3eaee2c..3394222 100644
> > --- a/drivers/hid/hid-core.c
> > +++ b/drivers/hid/hid-core.c
> > @@ -35,6 +35,8 @@
> >
> >  #include "hid-ids.h"
> >
> > +#define GET_COMPLETE_USAGE(page, id) (((page) << 16) + ((id) & 0x))
>
> Not sure I like the macro. I'd rather have the explicit code. That said, lets
> see what Benjamin has to say.
>
> > +
> >  /*
> >   * Version Information
> >   */
> > @@ -221,7 +223,15 @@ static int hid_add_usage(struct hid_parser *parser,
> > unsigned usage, u8 size)
> >   hid_err(parser->device, "usage index exceeded\n");
> >   return -1;
> >   }
> > - parser->local.usage[parser->local.usage_index] = usage;
> > +
> > + if (size <= 2) {
> > + parser->local.usage_page_last = false;
> > + parser->local.usage[parser->local.usage_index] =
> > + GET_COMPLETE_USAGE(parser->global.usage_page, usage);
> > + } else {
> > + parser->local.usage[parser->local.usage_index] = usage;
> > +

[PATCH v3 2/2] mfd: intel-lpss: use devm_ioremap_uc for MMIO

2019-10-09 Thread Tuowen Zhao
Some BIOS erroneously specifies write-combining BAR for intel-lpss-pci
in MTRR. This will cause the system to hang during boot. If possible,
this bug could be corrected with a firmware update.

This patch use devm_ioremap_uc to overwrite/ignore the MTRR settings
by forcing the use of strongly uncachable pages for intel-lpss.

The BIOS bug is present on Dell XPS 13 7390 2-in-1:

[0.001734]   5 base 40 mask 60 write-combining

40-7f : PCI Bus :00
  40-400fff : :00:02.0 (i915)
  401000-401fff : :00:15.0 (intel-lpss-pci)

Link: https://bugzilla.kernel.org/show_bug.cgi?id=203485
Tested-by: AceLan Kao 
Signed-off-by: Tuowen Zhao 
Acked-by: Mika Westerberg 
Acked-by: Andy Shevchenko 
---
 drivers/mfd/intel-lpss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c
index bfe4ff337581..b0f0781a6b9c 100644
--- a/drivers/mfd/intel-lpss.c
+++ b/drivers/mfd/intel-lpss.c
@@ -384,7 +384,7 @@ int intel_lpss_probe(struct device *dev,
if (!lpss)
return -ENOMEM;
 
-   lpss->priv = devm_ioremap(dev, info->mem->start + LPSS_PRIV_OFFSET,
+   lpss->priv = devm_ioremap_uc(dev, info->mem->start + LPSS_PRIV_OFFSET,
  LPSS_PRIV_SIZE);
if (!lpss->priv)
return -ENOMEM;
-- 
2.23.0



[PATCH v3 1/2] lib: devres: add a helper function for ioremap_uc

2019-10-09 Thread Tuowen Zhao
Implement a resource managed strongly uncachable ioremap function.

Tested-by: AceLan Kao 
Signed-off-by: Tuowen Zhao 
Acked-by: Mika Westerberg 
Acked-by: Andy Shevchenko 
---
Changes from previous version:

  * Split the patch in 2
  * Use GPL export for devm_ioremap_uc
  * Add entry to devres doc

 .../driver-api/driver-model/devres.rst|  1 +
 include/linux/io.h|  2 ++
 lib/devres.c  | 19 +++
 3 files changed, 22 insertions(+)

diff --git a/Documentation/driver-api/driver-model/devres.rst 
b/Documentation/driver-api/driver-model/devres.rst
index a100bef54952..92628fdc2f11 100644
--- a/Documentation/driver-api/driver-model/devres.rst
+++ b/Documentation/driver-api/driver-model/devres.rst
@@ -314,6 +314,7 @@ IOMAP
   devm_ioport_unmap()
   devm_ioremap()
   devm_ioremap_nocache()
+  devm_ioremap_uc()
   devm_ioremap_wc()
   devm_ioremap_resource() : checks resource, requests memory region, ioremaps
   devm_iounmap()
diff --git a/include/linux/io.h b/include/linux/io.h
index accac822336a..a59834bc0a11 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -64,6 +64,8 @@ static inline void devm_ioport_unmap(struct device *dev, void 
__iomem *addr)
 
 void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
   resource_size_t size);
+void __iomem *devm_ioremap_uc(struct device *dev, resource_size_t offset,
+  resource_size_t size);
 void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
   resource_size_t size);
 void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
diff --git a/lib/devres.c b/lib/devres.c
index 6a0e9bd6524a..17624d35e82d 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -9,6 +9,7 @@
 enum devm_ioremap_type {
DEVM_IOREMAP = 0,
DEVM_IOREMAP_NC,
+   DEVM_IOREMAP_UC,
DEVM_IOREMAP_WC,
 };
 
@@ -39,6 +40,9 @@ static void __iomem *__devm_ioremap(struct device *dev, 
resource_size_t offset,
case DEVM_IOREMAP_NC:
addr = ioremap_nocache(offset, size);
break;
+   case DEVM_IOREMAP_UC:
+   addr = ioremap_uc(offset, size);
+   break;
case DEVM_IOREMAP_WC:
addr = ioremap_wc(offset, size);
break;
@@ -68,6 +72,21 @@ void __iomem *devm_ioremap(struct device *dev, 
resource_size_t offset,
 }
 EXPORT_SYMBOL(devm_ioremap);
 
+/**
+ * devm_ioremap_uc - Managed ioremap_uc()
+ * @dev: Generic device to remap IO address for
+ * @offset: Resource address to map
+ * @size: Size of map
+ *
+ * Managed ioremap_uc().  Map is automatically unmapped on driver detach.
+ */
+void __iomem *devm_ioremap_uc(struct device *dev, resource_size_t offset,
+ resource_size_t size)
+{
+   return __devm_ioremap(dev, offset, size, DEVM_IOREMAP_UC);
+}
+EXPORT_SYMBOL_GPL(devm_ioremap_uc);
+
 /**
  * devm_ioremap_nocache - Managed ioremap_nocache()
  * @dev: Generic device to remap IO address for
-- 
2.23.0



[git pull] a couple of mount fixes

2019-10-09 Thread Al Viro
A couple of regressions from work.mount series.

The following changes since commit a3bc18a48e2e678efe62f1f9989902f9cd19e0ff:

  jffs2: Fix mounting under new mount API (2019-09-26 10:26:55 -0400)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git work.mount3

for you to fetch changes up to 6fcf0c72e4b9360768cf5ef543c4f14c34800ee8:

  vfs: add missing blkdev_put() in get_tree_bdev() (2019-10-09 22:53:57 -0400)


Al Viro (1):
  shmem: fix LSM options parsing

Ian Kent (1):
  vfs: add missing blkdev_put() in get_tree_bdev()

 fs/super.c | 5 -
 mm/shmem.c | 6 ++
 2 files changed, 10 insertions(+), 1 deletion(-)


[PATCH] kvm/x86 : Replace BUG_ON(1) with BUG()

2019-10-09 Thread richard.p...@oppo.com
Signed-off-by: Peng Hao 
---
 arch/x86/kvm/vmx/nested.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index e76eb4f..d0e6c40 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -4945,8 +4945,7 @@ static int handle_invept(struct kvm_vcpu *vcpu)
 */
    break;
    default:
-   BUG_ON(1);
-   break;
+   BUG();
    }
 
    return nested_vmx_succeed(vcpu);
-- 
2.7.4

Re: [PATCH] devfreq: exynos-bus: workaround dev_pm_opp_set_rate() errors on Exynos5422/5800 SoCs

2019-10-09 Thread Chanwoo Choi
On 2019년 10월 08일 22:49, k.koniec...@partner.samsung.com wrote:
> Commit 4294a779bd8d ("PM / devfreq: exynos-bus: Convert to use
> dev_pm_opp_set_rate()") introduced errors:
> exynos-bus: new bus device registered: soc:bus_wcore ( 84000 KHz ~ 40 KHz)
> exynos-bus: new bus device registered: soc:bus_noc ( 67000 KHz ~ 10 KHz)
> exynos-bus: new bus device registered: soc:bus_fsys_apb (10 KHz ~ 20 
> KHz)
> ...
> exynos-bus soc:bus_wcore: dev_pm_opp_set_rate: failed to find current OPP for 
> freq 53200 (-34)
> exynos-bus soc:bus_noc: dev_pm_opp_set_rate: failed to find current OPP for 
> freq 11100 (-34)
> exynos-bus soc:bus_fsys_apb: dev_pm_opp_set_rate: failed to find current OPP 
> for freq 22200 (-34)
> 
> They are caused by incorrect PLL assigned to clock source, which results
> in clock rate outside of OPP range. Add workaround for this in
> exynos_bus_parse_of() by adjusting clock rate to those present in OPP.

If the clock caused this issue, you can set the initial clock on DeviceTree
with assigned-clock-* properties. Because the probe time of clock driver
is early than the any device drivers.

It is not proper to fix the clock issue on other device driver.
I think you can fix it by using the supported clock properties.


> 
> Fixes: 4294a779bd8d ("PM / devfreq: exynos-bus: Convert to use 
> dev_pm_opp_set_rate()")
> Reported-by: Krzysztof Kozlowski 
> Signed-off-by: Kamil Konieczny 
> ---
>  drivers/devfreq/exynos-bus.c | 14 +++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
> index c832673273a2..37bd34d5625b 100644
> --- a/drivers/devfreq/exynos-bus.c
> +++ b/drivers/devfreq/exynos-bus.c
> @@ -243,7 +243,7 @@ static int exynos_bus_parse_of(struct device_node *np,
>  {
>   struct device *dev = bus->dev;
>   struct dev_pm_opp *opp;
> - unsigned long rate;
> + unsigned long rate, opp_rate;
>   int ret;
>  
>   /* Get the clock to provide each bus with source clock */
> @@ -267,13 +267,21 @@ static int exynos_bus_parse_of(struct device_node *np,
>   }
>  
>   rate = clk_get_rate(bus->clk);
> -
> - opp = devfreq_recommended_opp(dev, &rate, 0);
> + opp_rate = rate;
> + opp = devfreq_recommended_opp(dev, &opp_rate, 0);
>   if (IS_ERR(opp)) {
>   dev_err(dev, "failed to find dev_pm_opp\n");
>   ret = PTR_ERR(opp);
>   goto err_opp;
>   }
> + /*
> +  * FIXME: U-boot leaves clock source at incorrect PLL, this results
> +  * in clock rate outside defined OPP rate. Work around this bug by
> +  * setting clock rate to recommended one.
> +  */
> + if (rate > opp_rate)
> + clk_set_rate(bus->clk, opp_rate);
> +
>   bus->curr_freq = dev_pm_opp_get_freq(opp);
>   dev_pm_opp_put(opp);
>  
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics


Re: [PATCH RFC] perf_event: Add support for LSM and SELinux checks

2019-10-09 Thread James Morris
On Wed, 9 Oct 2019, Casey Schaufler wrote:

> On 10/9/2019 3:14 PM, James Morris wrote:
> > On Wed, 9 Oct 2019, Casey Schaufler wrote:
> >
> >> Please consider making the perf_alloc security blob maintained
> >> by the infrastructure rather than the individual modules. This
> >> will save it having to be changed later.
> > Is anyone planning on using this with full stacking?
> >
> > If not, we don't need the extra code & complexity. Stacking should only 
> > cover what's concretely required by in-tree users.
> 
> I don't believe it's any simpler for SELinux to do the allocation
> than for the infrastructure to do it. I don't see anyone's head
> exploding over the existing infrastructure allocation of blobs.
> We're likely to want it at some point, so why not avoid the hassle
> and delay by doing it the "new" way up front?

Because it is not necessary.

-- 
James Morris




Re: [RESEND,PATCH] net: stmmac: dwmac-mediatek: fix wrong delay value issue when resume back

2019-10-09 Thread Jakub Kicinski
On Wed, 9 Oct 2019 15:33:48 +0800, Biao Huang wrote:
> mac_delay value will be divided by 550/170 in mt2712_delay_ps2stage(),
> which is invoked at the beginning of mt2712_set_delay(), and the value
> should be restored at the end of mt2712_set_delay().
> Or, mac_delay will be divided again when invoking mt2712_set_delay()
> when resume back.
> So, add mt2712_delay_stage2ps() to mt2712_set_delay() to recovery the
> original mac_delay value.
> 
> Signed-off-by: Biao Huang 

Applied, thanks.


[PATCH v7] gpio/mpc8xxx: change irq handler from chained to normal

2019-10-09 Thread Hui Song
From: Song Hui 

More than one gpio controllers can share one interrupt, change the
driver to request shared irq.

While this will work, it will mess up userspace accounting of the number
of interrupts per second in tools such as vmstat.  The reason is that
for every GPIO interrupt, /proc/interrupts records the count against GIC
interrupt 68 or 69, as well as the GPIO itself.  So, for every GPIO
interrupt, the total number of interrupts that the system has seen
increments by two.

Signed-off-by: Laurentiu Tudor 
Signed-off-by: Alex Marginean 
Signed-off-by: Song Hui 
---
Changes in v7:
- make unsigned int convert to unsigned long.
Changes in v6:
- change request_irq to devm_request_irq and add commit message.
Changes in v5:
- add traverse every bit function.
Changes in v4:
- convert 'pr_err' to 'dev_err'.
Changes in v3:
- update the patch description.
Changes in v2:
- delete the compatible of ls1088a.
 drivers/gpio/gpio-mpc8xxx.c | 29 +++--
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index 16a47de..5a0f030 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define MPC8XXX_GPIO_PINS  32
 
@@ -127,20 +128,20 @@ static int mpc8xxx_gpio_to_irq(struct gpio_chip *gc, 
unsigned offset)
return -ENXIO;
 }
 
-static void mpc8xxx_gpio_irq_cascade(struct irq_desc *desc)
+static irqreturn_t mpc8xxx_gpio_irq_cascade(int irq, void *data)
 {
-   struct mpc8xxx_gpio_chip *mpc8xxx_gc = irq_desc_get_handler_data(desc);
-   struct irq_chip *chip = irq_desc_get_chip(desc);
+   struct mpc8xxx_gpio_chip *mpc8xxx_gc = data;
struct gpio_chip *gc = &mpc8xxx_gc->gc;
-   unsigned int mask;
+   unsigned long mask;
+   int i;
 
mask = gc->read_reg(mpc8xxx_gc->regs + GPIO_IER)
& gc->read_reg(mpc8xxx_gc->regs + GPIO_IMR);
-   if (mask)
+   for_each_set_bit(i, &mask, 32)
generic_handle_irq(irq_linear_revmap(mpc8xxx_gc->irq,
-32 - ffs(mask)));
-   if (chip->irq_eoi)
-   chip->irq_eoi(&desc->irq_data);
+31 - i));
+
+   return IRQ_HANDLED;
 }
 
 static void mpc8xxx_irq_unmask(struct irq_data *d)
@@ -409,8 +410,16 @@ static int mpc8xxx_probe(struct platform_device *pdev)
if (devtype->gpio_dir_in_init)
devtype->gpio_dir_in_init(gc);
 
-   irq_set_chained_handler_and_data(mpc8xxx_gc->irqn,
-mpc8xxx_gpio_irq_cascade, mpc8xxx_gc);
+   ret = devm_request_irq(&pdev->dev, mpc8xxx_gc->irqn,
+  mpc8xxx_gpio_irq_cascade,
+  IRQF_NO_THREAD | IRQF_SHARED, "gpio-cascade",
+  mpc8xxx_gc);
+   if (ret) {
+   dev_err(&pdev->dev, "%s: failed to devm_request_irq(%d), ret = 
%d\n",
+   np->full_name, mpc8xxx_gc->irqn, ret);
+   goto err;
+   }
+
return 0;
 err:
iounmap(mpc8xxx_gc->regs);
-- 
2.9.5



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

2019-10-09 Thread Steven Rostedt
On Tue, 8 Oct 2019 10:43:35 -0400
Steven Rostedt  wrote:


> BTW, I'd really like to take this patch series through my tree. That
> way I can really hammer it, as well as I have code that will be built
> on top of it.

I did a bit of hammering and found two bugs. One I sent a patch to fix
(adding a module when tracing is enabled), but the other bug I
triggered, I'm too tired to debug right now. But figured I'd mention it
anyway.

If you add on the kernel command line:

 ftrace=function ftrace_filter=schedule

You will get this (note, I had KASAN enabled, so it showed more info):



[1.274356] ftrace: allocating 34274 entries in 134 pages
[1.320059] Starting tracer 'function'
[1.323724] 
==
[1.330798] BUG: KASAN: null-ptr-deref in __get_locked_pte+0x21/0x210
[1.337186] Read of size 8 at addr 0050 by task swapper/0
[1.343579]
[1.345049] CPU: 0 PID: 0 Comm: swapper Not tainted 5.4.0-rc2-test+ #50
[1.351613] Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS 
K01 v03.03 07/14/2016
[1.360510] Call Trace:
[1.362932]  dump_stack+0x7c/0xc0
[1.366213]  ? __get_locked_pte+0x21/0x210
[1.370272]  ? __get_locked_pte+0x21/0x210
[1.374331]  __kasan_report.cold.10+0x5/0x3e
[1.378566]  ? __get_locked_pte+0x21/0x210
[1.382625]  kasan_report+0xe/0x20
[1.385993]  __get_locked_pte+0x21/0x210
[1.389880]  ? 0xa05c
[1.393162]  __text_poke+0x1ca/0x5b0
[1.396705]  ? optimize_nops.isra.8+0xd0/0xd0
[1.401023]  ? insn_get_length+0x4f/0x70
[1.404910]  ? text_poke_loc_init+0x186/0x220
[1.409229]  ? text_poke_kgdb+0x10/0x10
[1.413031]  ? 0xa000
[1.416312]  text_poke_bp_batch+0xb4/0x1e0
[1.420372]  ? __text_poke+0x5b0/0x5b0
[1.424088]  ? do_raw_spin_lock+0x113/0x1d0
[1.428233]  ? 0xa05c
[1.431515]  ? 0xa000
[1.434797]  text_poke_bp+0x7a/0xa0
[1.438253]  ? text_poke_queue+0xb0/0xb0
[1.442139]  ? 0xa000
[1.445421]  ? 0xa05c
[1.448706]  ? find_vmap_area+0x56/0x80
[1.452505]  arch_ftrace_update_trampoline+0x114/0x380
[1.457603]  ? ftrace_caller+0x4e/0x4e
[1.461316]  ? 0xa091
[1.464599]  ? arch_ftrace_update_code+0x10/0x10
[1.469179]  ? mutex_lock+0x86/0xd0
[1.472634]  ? __mutex_lock_slowpath+0x10/0x10
[1.477039]  ? mutex_unlock+0x1d/0x40
[1.480668]  ? arch_jump_label_transform_queue+0x7a/0x90
[1.485937]  ? __jump_label_update+0x91/0x140
[1.490256]  ? mutex_unlock+0x1d/0x40
[1.493885]  ? tracing_start_sched_switch.cold.0+0x60/0x60
[1.499327]  __register_ftrace_function+0xaf/0xf0
[1.503991]  ftrace_startup+0x24/0x130
[1.507706]  register_ftrace_function+0x2d/0x80
[1.512198]  function_trace_init+0xc1/0x100
[1.516346]  tracing_set_tracer+0x1fb/0x3c0
[1.520492]  ? free_snapshot+0x50/0x50
[1.524205]  ? __kasan_kmalloc.constprop.6+0xc1/0xd0
[1.529131]  ? __list_add_valid+0x29/0xa0
[1.533106]  register_tracer+0x235/0x26c
[1.536993]  early_trace_init+0x29b/0x3a0
[1.540967]  start_kernel+0x2a3/0x5f7
[1.544595]  ? mem_encrypt_init+0x6/0x6
[1.548396]  ? load_ucode_intel_bsp+0x5e/0xa3
[1.552715]  ? init_intel_microcode+0xc3/0xc3
[1.557036]  ? load_ucode_bsp+0xcc/0x154
[1.560923]  secondary_startup_64+0xa4/0xb0
[1.565070] 
==


-- Steve


Re: [PATCH tip/core/rcu 4/9] drivers/scsi: Replace rcu_swap_protected() with rcu_replace()

2019-10-09 Thread Martin K. Petersen


Paul,

> I do not intend to actually remove rcu_swap_protected() until 5.6 for
> exactly this sort of thing.  My plan is to take another pass through
> the tree after 5.5 comes out, and these will be caught at that time.
>
> Does that work for you?

Yep, that's great. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


[PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write

2019-10-09 Thread Steven Rostedt
From: Steven Rostedt (VMware) 

In the process of using text_poke_bp() for ftrace on x86, when
performing the following action:

 # rmmod snd_hda_codec_hdmi
 # echo function > /sys/kernel/tracing/current_tracer
 # modprobe snd_hda_codec_hdmi

It triggered this:

 BUG: unable to handle page fault for address: a03d
 #PF: supervisor write access in kernel mode
 #PF: error_code(0x0003) - permissions violation
 PGD 2a12067 P4D 2a12067 PUD 2a13063 PMD c42bc067 PTE c58a0061
 Oops: 0003 [#1] PREEMPT SMP KASAN PTI
 CPU: 1 PID: 1182 Comm: modprobe Not tainted 5.4.0-rc2-test+ #50
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 
07/14/2016
 RIP: 0010:memcpy_erms+0x6/0x10
 Code: 90 90 90 90 eb 1e 0f 1f 00 48 89 f8 48 89 d1 48 c1 e9 03 83 e2 07 f3 48 
a5 89 d1 f3 a4 c3 66 0f 1f 44 00 00 48 89 f8 48 89 d1  a4 c3 0f 1f 80 00 00 
00 00 48 89 f8 48 83 fa 20 72 7e 40 38 fe
 RSP: 0018:8880a10479e0 EFLAGS: 00010246
 RAX: a03d RBX: a03d RCX: 0005
 RDX: 0005 RSI: 8363e160 RDI: a03d
 RBP: 88807e9ec000 R08: fbfff407a001 R09: fbfff407a001
 R10: fbfff407a000 R11: a03d0004 R12: 8221f160
 R13: a03d R14: 88807e9ec000 R15: a0481640
 FS:  7eff92e28280() GS:8880d484() knlGS:
 CS:  0010 DS:  ES:  CR0: 80050033
 CR2: a03d CR3: a1048001 CR4: 001606e0
 Call Trace:
  ftrace_make_call+0x76/0x90
  ftrace_module_enable+0x493/0x4f0
  load_module+0x3a31/0x3e10
  ? ring_buffer_read+0x70/0x70
  ? module_frob_arch_sections+0x20/0x20
  ? rb_commit+0xee/0x600
  ? tracing_generic_entry_update+0xe1/0xf0
  ? ring_buffer_unlock_commit+0xfb/0x220
  ? 0xa061
  ? __do_sys_finit_module+0x11a/0x1b0
  __do_sys_finit_module+0x11a/0x1b0
  ? __ia32_sys_init_module+0x40/0x40
  ? ring_buffer_unlock_commit+0xfb/0x220
  ? function_trace_call+0x179/0x260
  ? __do_sys_finit_module+0x1b0/0x1b0
  ? __do_sys_finit_module+0x1b0/0x1b0
  ? do_syscall_64+0x58/0x1a0
  do_syscall_64+0x68/0x1a0
  entry_SYSCALL_64_after_hwframe+0x49/0xbe
 RIP: 0033:0x7eff92f42efd

The reason is that ftrace_module_enable() is called after the module
has set its text to read-only. There's subtle reasons that this needs
to be called afterward, and we need to continue to do so.

Instead of going back to the original way of changing all modules to
read-write to update functions for a module being loaded, add two new
module helpers set_module_text_rw() and set_module_text_ro() that takes
a module as a parameter and only modifies the text for that one module.
Then move the logic for this from the architecture code in ftrace, to
the generic code, and have ftrace on module load do the modification.
It only affects the module being loaded.

Link: http://lkml.kernel.org/r/20191007081716.0761623...@infradead.org

Signed-off-by: Steven Rostedt (VMware) 
---
diff --git a/include/linux/module.h b/include/linux/module.h
index 6d20895e7739..143c902bcbcf 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -846,11 +846,15 @@ extern int module_sysfs_initialized;
 #define __MODULE_STRING(x) __stringify(x)
 
 #ifdef CONFIG_STRICT_MODULE_RWX
+extern void set_module_text_rw(const struct module *mod);
+extern void set_module_text_ro(const struct module *mod);
 extern void set_all_modules_text_rw(void);
 extern void set_all_modules_text_ro(void);
 extern void module_enable_ro(const struct module *mod, bool after_init);
 extern void module_disable_ro(const struct module *mod);
 #else
+static inline void set_module_text_rw(const struct module *mod) { }
+static inline void set_module_text_ro(const struct module *mod) { }
 static inline void set_all_modules_text_rw(void) { }
 static inline void set_all_modules_text_ro(void) { }
 static inline void module_enable_ro(const struct module *mod, bool after_init) 
{ }
diff --git a/kernel/module.c b/kernel/module.c
index ff2d7359a418..8f3a18d3ac75 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2029,6 +2029,37 @@ static void module_enable_nx(const struct module *mod)
frob_writable_data(&mod->init_layout, set_memory_nx);
 }
 
+void set_module_text_rw(const struct module *mod)
+{
+   if (!rodata_enabled)
+   return;
+
+   mutex_lock(&module_mutex);
+   if (mod->state == MODULE_STATE_UNFORMED)
+   goto out;
+
+   frob_text(&mod->core_layout, set_memory_rw);
+   frob_text(&mod->init_layout, set_memory_rw);
+out:
+   mutex_unlock(&module_mutex);
+}
+
+void set_module_text_ro(const struct module *mod)
+{
+   if (!rodata_enabled)
+   return;
+
+   mutex_lock(&module_mutex);
+   if (mod->state == MODULE_STATE_UNFORMED ||
+   mod->state == MODULE_STATE_GOING)
+   goto out;
+
+   frob_text(&mod->core_layout, set_memory_ro);
+   frob_text(&mod->init_layout, set_memory_ro);
+out:
+   mutex_unlock(&module_mutex

Re: "reuse mergeable anon_vma as parent when fork" causes a crash on s390

2019-10-09 Thread Wei Yang
Hi, Qian, Shakeel

Thanks for testing.

Sounds I missed some case to handle. anon_vma_clone() now would be called in
vma_adjust, which is a different case when it is introduced.

BTW, do you have the specific test case? So that I could verify my change. The
kernel build test doesn't trigger this.

Thanks a lot :-)

On Wed, Oct 09, 2019 at 03:21:11PM -0700, Shakeel Butt wrote:
>On Wed, Oct 9, 2019 at 2:30 PM Qian Cai  wrote:
>>
>> The linux-next commit "mm/rmap.c: reuse mergeable anon_vma as parent when 
>> fork"
>> [1] causes a crash on s390 while compiling some C code. Reverted it fixes the
>> issue.
>>
>> [1] 
>> https://lore.kernel.org/lkml/20191004160632.30251-1-richardw.y...@linux.intel.com/
>>
>> 00: [  330.681233] vma 49a08008 start 03ff8ee7f000 end 
>> 03ff8eee4
>> 00: 000
>> 00: [  330.681233] next 4f272008 prev 65c84230 mm 
>> 37d1c1
>> 00: 00
>> 00: [  330.681233] prot 711 anon_vma 1f4e4a80 vm_ops 
>> 00: [  330.681233] pgoff 3ff8ee7f file  private_data 
>> 000
>> 00: 0
>> 00: [  330.681233] flags: 
>> 0x8100073(read|write|mayread|maywrite|mayexec|account|
>> 00: softdirty)
>> 00: [  330.681344] [ cut here ]
>> 00: [  330.681357] kernel BUG at include/linux/rmap.h:159!
>> 00: [  330.681442] illegal operation: 0001 ilc:1 [#1] SMP DEBUG_PAGEALLOC
>> 00: [  330.681460] Modules linked in: ip_tables x_tables xfs dasd_fba_mod 
>> dasd_e
>> 00: ckd_mod dm_mirror dm_region_hash dm_log dm_mod
>> 00: [  330.681502] CPU: 0 PID: 7651 Comm: cc1 Not tainted 
>> 5.4.0-rc2-next-2019100
>> 00: 9+ #4
>> 00: [  330.681516] Hardware name: IBM 2964 N96 400 (z/VM 6.4.0)
>> 00: [  330.681530] Krnl PSW : 0704c0018000 531d9cac 
>> (__vma_adjust+0x
>> 00: cf4/0xf30)
>> 00: [  330.681561]R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:0 
>> PM:0
>> 00:  RI:0 EA:3
>> 00: [  330.681579] Krnl GPRS: 0001 0300 
>> 0146
>> 00:  6cc03da4
>> 00: [  330.681595]0300 5304378c 
>> 513de008
>> 00:  
>> 00: [  330.681611]49a08008 49a08080 
>> 
>> 00:  5a178438
>> 00: [  330.681627]53bae3b0 37d1c100 
>> 531d9ca8
>> 00:  235ef880
>> 01: HCPGSP2629I The virtual machine is placed in CP mode due to a SIGP stop 
>> from
>>  CPU 01.
>> 01: HCPGSP2629I The virtual machine is placed in CP mode due to a SIGP stop 
>> from
>>  CPU 00.
>> 00: [  330.681668] Krnl Code: 531d9c9c: fae0b9040028ap  
>> 2308
>> 00: (15,%r11),40(1,%r0)
>> 00: [  330.681668]531d9ca2: c0e5145fbrasl   
>> %r14
>> 00: ,531bc560
>> 00: [  330.681668]   #531d9ca8: a7f40001brc 
>> 15,5
>> 00: 31d9caa
>> 00: [  330.681668]   >531d9cac: c020005f1a5alarl
>> %r2,
>> 00: 53dbd160
>> 00: [  330.681668]531d9cb2: c0e50015ec2bbrasl   
>> %r14
>> 00: ,53497508
>> 00: [  330.681668]531d9cb8: e320f0d80004lg  
>> %r2,
>> 00: 216(%r15)
>> 00: [  330.681668]531d9cbe: c0e500040de1brasl   
>> %r14
>> 00: ,5325b880
>> 00: [  330.681668]531d9cc4: 4120d038la  
>> %r2,
>> 00: 56(%r13)
>> 00: [  330.682579] Call Trace:
>> 00: [  330.682665] ([<531d9ca8>] __vma_adjust+0xcf0/0xf30)
>> 00: [  330.682684]  [<531da4f0>] vma_merge+0x608/0x6b8
>> 00: [  330.682699]  [<531de3b8>] mmap_region+0x1e0/0x9b0
>> 00: [  330.682713]  [<531defec>] do_mmap+0x464/0x650
>> 00: [  330.682730]  [<531930ba>] vm_mmap_pgoff+0x132/0x1c0
>> 00: [  330.682745]  [<531da7b4>] ksys_mmap_pgoff+0xd4/0x458
>> 00: [  330.682761]  [<531dac54>] __s390x_sys_old_mmap+0xdc/0x108
>> 00: [  330.682779]  [<537dcdd0>] system_call+0xd8/0x2b4
>> 00: [  330.682791] INFO: lockdep is turned off.
>> 00: [  330.682801] Last Breaking-Event-Address:
>> 00: [  330.682815]  [<531d9ca8>] __vma_adjust+0xcf0/0xf30
>> 00: [  330.682833] Kernel panic - not syncing: Fatal exception: panic_on_oops
>
>Our internal syzbot instance also hit this bug and bisected to the same patch.
>
>Report:
>
>[   74.249839][ T8601] vma 88808c0f7eb0 start 2000 end
>2100
>[   74.249839][ T8601] next 888095f5e568 prev 888091279318 mm
>8880894555c0
>[   74.249839][ T8601] prot 25 anon_vma 88809a9c4b40 vm_ops 
>
>[   74.249839][ T8601] pgoff 2 file  private_data
>
>[   74.249839][ T8601] flags:
>0x8100077(read|write|exec|mayread|maywrite|mayexec|account|softdirty)
>[   74.289454][ T8601] [ cut here ]
>[   74.294941][ T8601] kernel BUG at include/linux/rmap.h:159!
>[   74.301474][ T8601] invalid opcode:  [#1] PREEMPT SMP KASAN
>[   74

Re: [PATCH] scsi: ch: add include guard to chio.h

2019-10-09 Thread Martin K. Petersen


Masahiro,

>> Fine with me. Is it going through your tree or should I pick it up?
>
> Could you please apply it to your tree?

Applied to 5.5/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] qla2xxx: fix a potential NULL pointer dereference

2019-10-09 Thread Martin K. Petersen


Allen,

> alloc_workqueue is not checked for errors and as a result,
> a potential NULL dereference could occur.

Applied to 5.4/scsi-fixes, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v17 01/14] bitops: Introduce the for_each_set_clump8 macro

2019-10-09 Thread Masahiro Yamada
On Thu, Oct 10, 2019 at 3:54 AM Geert Uytterhoeven  wrote:
>
> Hi Andy,
>
> On Wed, Oct 9, 2019 at 7:09 PM Andy Shevchenko
>  wrote:
> > On Thu, Oct 10, 2019 at 01:28:08AM +0900, Masahiro Yamada wrote:
> > > On Thu, Oct 10, 2019 at 12:27 AM William Breathitt Gray
> > >  wrote:
> > > >
> > > > This macro iterates for each 8-bit group of bits (clump) with set bits,
> > > > within a bitmap memory region. For each iteration, "start" is set to the
> > > > bit offset of the found clump, while the respective clump value is
> > > > stored to the location pointed by "clump". Additionally, the
> > > > bitmap_get_value8 and bitmap_set_value8 functions are introduced to
> > > > respectively get and set an 8-bit value in a bitmap memory region.
> >
> > > Why is the return type "unsigned long" where you know
> > > it return the 8-bit value ?
> >
> > Because bitmap API operates on unsigned long type. This is not only
> > consistency, but for sake of flexibility in case we would like to introduce
> > more calls like clump16 or so.
>
> TBH, that doesn't convince me: those functions explicitly take/return an
> 8-bit value, and have "8" in their name.  The 8-bit value is never
> really related to, retrieved from, or stored in a full "unsigned long"
> element of a bitmap, only to/from/in a part (byte) of it.
>
> Following your rationale, all of iowrite{8,16,32,64}*() should take an
> "unsigned long" value, too.
>

+1

Using u8/u16/u32/u64 looks more consistent with other bitmap helpers.

void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, unsigned
int nbits);
void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits);
static inline void bitmap_from_u64(unsigned long *dst, u64 mask);



If you want to see more examples from other parts,


int of_property_read_u8(const struct device_node *np,
const char *propname,
u8 *out_value)


int of_property_read_u16(const struct device_node *np,
 const char *propname,
 u16 *out_value)


-- 
Best Regards
Masahiro Yamada


Re: [PATCH -next] userfaultfd: remove set but not used variable 'h'

2019-10-09 Thread Mike Kravetz
On 10/9/19 6:23 PM, Wei Yang wrote:
> On Wed, Oct 09, 2019 at 05:45:57PM -0700, Mike Kravetz wrote:
>> On 10/9/19 5:27 AM, YueHaibing wrote:
>>> Fixes gcc '-Wunused-but-set-variable' warning:
>>>
>>> mm/userfaultfd.c: In function '__mcopy_atomic_hugetlb':
>>> mm/userfaultfd.c:217:17: warning:
>>>  variable 'h' set but not used [-Wunused-but-set-variable]
>>>
>>> It is not used since commit 78911d0e18ac ("userfaultfd: use vma_pagesize
>>> for all huge page size calculation")
>>>
>>
>> Thanks!  That should have been removed with the recent cleanups.
>>
>>> Signed-off-by: YueHaibing 
>>
>> Reviewed-by: Mike Kravetz 
> 
> If I am correct, this is removed in a recent patch.

I'm having a hard time figuring out what is actually in the latest mmotm
tree.  Andrew added a build fixup patch ab169389eb5 in linux-next which
adds the reference to h.  Is there a patch after that to remove the reference?

-- 
Mike Kravetz


Re: [Patch v4 2/2] linux/bits.h: Add compile time sanity check of GENMASK inputs

2019-10-09 Thread Masahiro Yamada
On Thu, Oct 10, 2019 at 6:45 AM Rikard Falkeborn
 wrote:
>
> GENMASK() and GENMASK_ULL() are supposed to be called with the high bit
> as the first argument and the low bit as the second argument. Mixing
> them will return a mask with zero bits set.
>
> Recent commits show getting this wrong is not uncommon, see e.g.
> commit aa4c0c9091b0 ("net: stmmac: Fix misuses of GENMASK macro") and
> commit 9bdd7bb3a844 ("clocksource/drivers/npcm: Fix misuse of GENMASK
> macro").
>
> To prevent such mistakes from appearing again, add compile time sanity
> checking to the arguments of GENMASK() and GENMASK_ULL(). If both
> arguments are known at compile time, and the low bit is higher than the
> high bit, break the build to detect the mistake immediately.
>
> Since GENMASK() is used in declarations, BUILD_BUG_ON_ZERO() must be
> used instead of BUILD_BUG_ON().
>
> __builtin_constant_p does not evaluate is argument, it only checks if it
> is a constant or not at compile time, and __builtin_choose_expr does not
> evaluate the expression that is not chosen. Therefore, GENMASK(x++, 0)
> does only evaluate x++ once.
>
> Commit 95b980d62d52 ("linux/bits.h: make BIT(), GENMASK(), and friends
> available in assembly") made the macros in linux/bits.h available in
> assembly. Since BUILD_BUG_OR_ZERO() is not asm compatible, disable the
> checks if the file is included in an asm file.
>
> Due to bugs in GCC versions before 4.9 [0], disable the check if
> building with a too old GCC compiler.
>
> [0]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
>
> Signed-off-by: Rikard Falkeborn 

Reviewed-by: Masahiro Yamada 



> ---
> Geert, can you check if this works better? I do not have gcc 4.6-4.8
> readily installed.
>
> Kees, Masahiro, since I changed this patch, I didn't include your
> reviewed-by tags.
>
> Changes in v4:
>   - Disable the argument check for GCC < 4.9 due to a compiler bug.
> Changes in v3:
>   - Changed back to shorter macro argument names
>   - Remove casts and use 0 instead of UL(0) in GENMASK_INPUT_CHECK(),
> since all results in GENMASK_INPUT_CHECK() are now ints. Update
> commit message to reflect that.
>
> Changes in v2:
>   - Add comment about why inputs are not checked when used in asm file
>   - Use UL(0) instead of 0
>   - Extract mask creation in a separate macro to improve readability
>   - Use high and low instead of h and l (part of this was extracted to a
> separate patch)
>   - Updated commit message
>
> Joe Perches sent a series to fix the existing misuses of GENMASK().
> Those patches have been merged into Linus tree except two places where
> the GENMASK misuse is in unused macros, which will not fail to build.
> There was also a patch by Nathan Chancellor that have now been merged.
>
>  include/linux/bits.h | 22 --
>  1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/bits.h b/include/linux/bits.h
> index 669d69441a62..f108302a3121 100644
> --- a/include/linux/bits.h
> +++ b/include/linux/bits.h
> @@ -18,12 +18,30 @@
>   * position @h. For example
>   * GENMASK_ULL(39, 21) gives us the 64bit vector 0x00e0.
>   */
> -#define GENMASK(h, l) \
> +#if !defined(__ASSEMBLY__) && \
> +   (!defined(CONFIG_CC_IS_GCC) || CONFIG_GCC_VERSION >= 49000)
> +#include 
> +#define GENMASK_INPUT_CHECK(h, l) \
> +   (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
> +   __builtin_constant_p((l) > (h)), (l) > (h), 0)))
> +#else
> +/*
> + * BUILD_BUG_ON_ZERO is not available in h files included from asm files,
> + * disable the input check if that is the case.
> + */
> +#define GENMASK_INPUT_CHECK(h, l) 0
> +#endif
> +
> +#define __GENMASK(h, l) \
> (((~UL(0)) - (UL(1) << (l)) + 1) & \
>  (~UL(0) >> (BITS_PER_LONG - 1 - (h
> +#define GENMASK(h, l) \
> +   (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
>
> -#define GENMASK_ULL(h, l) \
> +#define __GENMASK_ULL(h, l) \
> (((~ULL(0)) - (ULL(1) << (l)) + 1) & \
>  (~ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h
> +#define GENMASK_ULL(h, l) \
> +   (GENMASK_INPUT_CHECK(h, l) + __GENMASK_ULL(h, l))
>
>  #endif /* __LINUX_BITS_H */
> --
> 2.23.0
>


-- 
Best Regards
Masahiro Yamada


Re: [PATCH net-next] act_mirred: Fix mirred_init_module error handling

2019-10-09 Thread Jakub Kicinski
On Wed, 9 Oct 2019 11:10:52 +0800, YueHaibing wrote:
> If tcf_register_action failed, mirred_device_notifier
> should be unregistered.
> 
> Fixes: 3b87956ea645 ("net sched: fix race in mirred device removal")
> Signed-off-by: YueHaibing 

Why does the subject say net-next, looks like the bug was introduced
all the way back in 2.6.36. For fixes for code which is already in
Linus'es main tree the subject should say [PATCH net]. Those are on the
fast path to the -rc releases and stable.

Applied to net, and queued for stable, please let me know if I
misunderstood the intention here.


  1   2   3   4   5   6   7   8   9   10   >