[PATCH] ethernet: (niu) fix missing checks of niu_pci_eeprom_read

2018-12-24 Thread Kangjie Lu
niu_pci_eeprom_read() may fail, so we should check its return value
before using the read data.

Signed-off-by: Kangjie Lu 
---
 drivers/net/ethernet/sun/niu.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index 9319d84bf49f..d84501441edd 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -8100,6 +8100,8 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 
start, u32 end)
start += 3;
 
prop_len = niu_pci_eeprom_read(np, start + 4);
+   if (prop_len < 0)
+   return prop_len;
err = niu_pci_vpd_get_propname(np, start + 5, namebuf, 64);
if (err < 0)
return err;
@@ -8144,8 +8146,12 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 
start, u32 end)
netif_printk(np, probe, KERN_DEBUG, np->dev,
 "VPD_SCAN: Reading in property [%s] 
len[%d]\n",
 namebuf, prop_len);
-   for (i = 0; i < prop_len; i++)
-   *prop_buf++ = niu_pci_eeprom_read(np, off + i);
+   for (i = 0; i < prop_len; i++) {
+   err = niu_pci_eeprom_read(np, off + i);
+   if (err >= 0)
+   *prop_buf = err;
+   ++prop_buf;
+   }
}
 
start += len;
-- 
2.17.2 (Apple Git-113)



Re: [PATCH RESEND v8 2/2] mtd: rawnand: meson: add support for Amlogic NAND flash controller

2018-12-24 Thread Liang Yang

Hi Martin,
On 2018/12/23 1:07, Martin Blumenstingl wrote:

Hi Jianxin, Hi Liang,

On Fri, Dec 21, 2018 at 12:45 PM Jianxin Pan  wrote:


From: Liang Yang 

Add initial support for the Amlogic NAND flash controller which found
in the Meson-GXBB/GXL/AXG SoCs.

Signed-off-by: Liang Yang 
Signed-off-by: Yixun Lan 
Signed-off-by: Jianxin Pan 
---
  drivers/mtd/nand/raw/Kconfig  |   10 +
  drivers/mtd/nand/raw/Makefile |1 +
  drivers/mtd/nand/raw/meson_nand.c | 1468 +
  3 files changed, 1479 insertions(+)
  create mode 100644 drivers/mtd/nand/raw/meson_nand.c

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 1a55d3e..d05ff20 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -541,4 +541,14 @@ config MTD_NAND_TEGRA
   is supported. Extra OOB bytes when using HW ECC are currently
   not supported.

+config MTD_NAND_MESON
+   tristate "Support for NAND controller on Amlogic's Meson SoCs"
+   depends on ARCH_MESON || COMPILE_TEST
+   depends on COMMON_CLK_AMLOGIC
+   select COMMON_CLK_REGMAP_MESON

I believe that "depends on COMMON_CLK_AMLOGIC" and "select
COMMON_CLK_REGMAP_MESON" are not necessary:
the driver should build fine without them because it's only
interfacing with the common clock framework.
the common clock framework is enabled by ARCH_MESON and for the
COMPILE_TEST case the common clock framework provides stub
implementations inside the headers.


+   select MFD_SYSCON
+   help
+ Enables support for NAND controller on Amlogic's Meson SoCs.
+ This controller is found on Meson GXBB, GXL, AXG SoCs.

you are explicitly mentioning GXBB here but you don't add a "GXBB" compatible.
I suggest to shorten this sentence ("This controller is found on Meson
SoCs.") because this driver can also support the 32-bit
Meson8/Meson8b/Meson8m2 SoCs with minor adjustments.

we only have tested on Meson GXL and AXG platform, but it should support 
GXBB and Meson8/Meson8b/Meson8m2 and the differences between these 
controllers are only the base address of register and some SD_EMMC_CLOCK 
control bits.


i think "This controller is found on Meson SoCs." is ok.


Regards
Martin

.



Re: [PATCH v14 2/5] x86/boot: Introduce efi_get_rsdp_addr() to find RSDP from EFI table

2018-12-24 Thread Chao Fan
On Mon, Dec 17, 2018 at 06:36:05PM +0100, Ingo Molnar wrote:
>
>* Ingo Molnar  wrote:
>
>> > +  if (!(efi_guidcmp(guid, ACPI_TABLE_GUID)))
>> > +  rsdp_addr = (acpi_physical_address)table;
>> > +  else if (!(efi_guidcmp(guid, ACPI_20_TABLE_GUID)))
>> > +  return (acpi_physical_address)table;
>> 
>> 'return' is not a function.
>

Hi Ingo,

I will remove the typecast in next version.
But when doing more tests, I found a special condition.

>Disregard this - I got confused by the type cast.
>
>The type cast is ugly nevertheless. 'table' is an 'unsigned long'.
>
>So 'acpi_physical_address' is basically an u64/u32, depending on 
>ACPI_MACHINE_WIDTH, right?
>
>Since this is x86, can ACPI_MACHINE_WIDTH ever get out of sync with the 
>native 'unsigned long' size?

Not always.
Here is define of acpi_physical_address:

#if ACPI_MACHINE_WIDTH == 64
typedef u64 acpi_physical_address;
#elif ACPI_MACHINE_WIDTH == 32
#ifdef ACPI_32BIT_PHYSICAL_ADDRESS
typedef u32 acpi_physical_address;
#else   /* ACPI_32BIT_PHYSICAL_ADDRESS */

/*
 * It is reported that, after some calculations, the physical addresses
can
 * wrap over the 32-bit boundary on 32-bit PAE environment.
 * https://bugzilla.kernel.org/show_bug.cgi?id=87971
 */
typedef u64 acpi_physical_address;
#endif

That means in 32-bit with PAE, acpi_physical_address is u64.
I set up a debian9-32bit with PAE in QEMU and found size of
acpi_physical_address is 8. So they are not always sync.
Of course, that doesn't influence the conclusion, since return table directly
can always work. It will return u32 to u32, u64 to u64, or u32 to u64.
So the typecast about acpi_physical_address can be removed.

Thanks,
Chao Fan

>
>If not then why not make the return type 'unsigned long', instead of 
>'acpi_physical_address' that you have to wade through a couple of headers 
>to figure out its true size. Does that cause complications elsewhere?
>
>I.e. the excessive type casts are ugly and make the code somewhat 
>fragile.
>
>Thanks,
>
>   Ingo
>
>




[PATCH] ethernet: (80003es2lan) fix missing checks for return value of reg write

2018-12-24 Thread Kangjie Lu
e1000_write_kmrn_reg_80003es2lan() may fail. The fix checks its return
value and returns with its error code if it fails.

Signed-off-by: Kangjie Lu 
---
 drivers/net/ethernet/intel/e1000e/80003es2lan.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c 
b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
index 257bd59bc9c6..7e2d4b9839bb 100644
--- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c
+++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
@@ -699,8 +699,11 @@ static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
if (ret_val)
return ret_val;
kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
-   e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
-kum_reg_data);
+   ret_val =
+   e1000_write_kmrn_reg_80003es2lan(hw,
+   E1000_KMRNCTRLSTA_INBAND_PARAM, kum_reg_data);
+   if (ret_val)
+   return ret_val;
 
ret_val = e1000e_get_auto_rd_done(hw);
if (ret_val)
@@ -757,8 +760,11 @@ static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
_reg_data);
kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
-   e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
-kum_reg_data);
+   ret_val =
+   e1000_write_kmrn_reg_80003es2lan(hw,
+   E1000_KMRNCTRLSTA_INBAND_PARAM, kum_reg_data);
+   if (ret_val)
+   return ret_val;
 
/* Set the transmit descriptor write-back policy */
reg_data = er32(TXDCTL(0));
-- 
2.17.2 (Apple Git-113)



Re: [PATCH] bpf: fix missing checks of the return value of check_reg_arg

2018-12-24 Thread Alexei Starovoitov
On Tue, Dec 25, 2018 at 01:17:10AM -0600, Kangjie Lu wrote:
> check_reg_arg() may fail. This fix inserts checks for its return value.
> If check_reg_arg() fails, issues an error message.
> 
> Signed-off-by: Kangjie Lu 
> ---
>  kernel/bpf/verifier.c | 15 ---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 51ba84d4d34a..fde91a5c0b5a 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -2619,7 +2619,10 @@ static int check_func_call(struct bpf_verifier_env 
> *env, struct bpf_insn *insn,
>   /* after the call registers r0 - r5 were scratched */
>   for (i = 0; i < CALLER_SAVED_REGS; i++) {
>   mark_reg_not_init(env, caller->regs, caller_saved[i]);
> - check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
> + err = check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
> + if (err)
> + verbose(env,
> + "check_reg_arg() fails in setting 
> caller saved regs\n");

Such patch was already posted.
These calls cannot fail.
I prefer to leave them as-is.



[PATCH] bpf: fix missing checks of the return value of check_reg_arg

2018-12-24 Thread Kangjie Lu
check_reg_arg() may fail. This fix inserts checks for its return value.
If check_reg_arg() fails, issues an error message.

Signed-off-by: Kangjie Lu 
---
 kernel/bpf/verifier.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 51ba84d4d34a..fde91a5c0b5a 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -2619,7 +2619,10 @@ static int check_func_call(struct bpf_verifier_env *env, 
struct bpf_insn *insn,
/* after the call registers r0 - r5 were scratched */
for (i = 0; i < CALLER_SAVED_REGS; i++) {
mark_reg_not_init(env, caller->regs, caller_saved[i]);
-   check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
+   err = check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
+   if (err)
+   verbose(env,
+   "check_reg_arg() fails in setting 
caller saved regs\n");
}
 
/* only increment it after check_reg_arg() finished */
@@ -2842,7 +2845,10 @@ static int check_helper_call(struct bpf_verifier_env 
*env, int func_id, int insn
/* reset caller saved regs */
for (i = 0; i < CALLER_SAVED_REGS; i++) {
mark_reg_not_init(env, regs, caller_saved[i]);
-   check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
+   err = check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
+   if (err)
+   verbose(env,
+   "check_reg_arg() fails in resetting caller 
saved regs\n");
}
 
/* update return register (already marked as written above) */
@@ -4435,7 +4441,10 @@ static int check_ld_abs(struct bpf_verifier_env *env, 
struct bpf_insn *insn)
/* reset caller saved regs to unreadable */
for (i = 0; i < CALLER_SAVED_REGS; i++) {
mark_reg_not_init(env, regs, caller_saved[i]);
-   check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
+   err = check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
+   if (err)
+   verbose(env,
+   "check_reg_arg() fails in resetting caller 
saved regs to unreadable\n");
}
 
/* mark destination R0 register as readable, since it contains
-- 
2.17.2 (Apple Git-113)



Re: [PATCH v7 1/2] dmaengine: 8250_mtk_dma: add MediaTek uart DMA support

2018-12-24 Thread Nicolas Boichat
Not a full review, a few comments below.

Thanks,

On Tue, Dec 25, 2018 at 9:27 AM Long Cheng  wrote:
>
> In DMA engine framework, add 8250 uart dma to support MediaTek uart.
> If MediaTek uart enabled(SERIAL_8250_MT6577), and want to improve
> the performance, can enable the function.
>
> Signed-off-by: Long Cheng 
> ---
>  drivers/dma/mediatek/8250_mtk_dma.c |  694 
> +++
>  drivers/dma/mediatek/Kconfig|   11 +
>  drivers/dma/mediatek/Makefile   |1 +
>  3 files changed, 706 insertions(+)
>  create mode 100644 drivers/dma/mediatek/8250_mtk_dma.c
>
> diff --git a/drivers/dma/mediatek/8250_mtk_dma.c 
> b/drivers/dma/mediatek/8250_mtk_dma.c
> new file mode 100644
> index 000..c4090f2
> --- /dev/null
> +++ b/drivers/dma/mediatek/8250_mtk_dma.c
> @@ -0,0 +1,694 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * MediaTek 8250 DMA driver.
> + *
> + * Copyright (c) 2018 MediaTek Inc.
> + * Author: Long Cheng 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

Alphabetical order.

> +
> +#include "../virt-dma.h"
> +
> +#define MTK_UART_APDMA_CHANNELS(CONFIG_SERIAL_8250_NR_UARTS 
> * 2)
> +
> +#define VFF_EN_B   BIT(0)
> +#define VFF_STOP_B BIT(0)
> +#define VFF_FLUSH_BBIT(0)
> +#define VFF_4G_SUPPORT_B   BIT(0)
> +#define VFF_RX_INT_EN0_B   BIT(0)  /*rx valid size >=  vff thre*/
> +#define VFF_RX_INT_EN1_B   BIT(1)
> +#define VFF_TX_INT_EN_BBIT(0)  /*tx left size >= vff thre*/
> +#define VFF_WARM_RST_B BIT(0)
> +#define VFF_RX_INT_FLAG_CLR_B  (BIT(0) | BIT(1))
> +#define VFF_TX_INT_FLAG_CLR_B  0
> +#define VFF_STOP_CLR_B 0
> +#define VFF_FLUSH_CLR_B0
> +#define VFF_INT_EN_CLR_B   0
> +#define VFF_4G_SUPPORT_CLR_B   0
> +
> +/* interrupt trigger level for tx */
> +#define VFF_TX_THRE(n) ((n) * 7 / 8)
> +/* interrupt trigger level for rx */
> +#define VFF_RX_THRE(n) ((n) * 3 / 4)
> +
> +#define MTK_UART_APDMA_RING_SIZE   0xU
> +/* invert this bit when wrap ring head again*/
> +#define MTK_UART_APDMA_RING_WRAP   0x1U
> +
> +#define VFF_INT_FLAG   0x00
> +#define VFF_INT_EN 0x04
> +#define VFF_EN 0x08
> +#define VFF_RST0x0c
> +#define VFF_STOP   0x10
> +#define VFF_FLUSH  0x14
> +#define VFF_ADDR   0x1c
> +#define VFF_LEN0x24
> +#define VFF_THRE   0x28
> +#define VFF_WPT0x2c
> +#define VFF_RPT0x30
> +/*TX: the buffer size HW can read. RX: the buffer size SW can read.*/
> +#define VFF_VALID_SIZE 0x3c
> +/*TX: the buffer size SW can write. RX: the buffer size HW can write.*/
> +#define VFF_LEFT_SIZE  0x40
> +#define VFF_DEBUG_STATUS   0x50
> +#define VFF_4G_SUPPORT 0x54
> +
> +struct mtk_uart_apdmadev {
> +   struct dma_device ddev;
> +   struct clk *clk;
> +   bool support_33bits;
> +   unsigned int dma_irq[MTK_UART_APDMA_CHANNELS];
> +};
> +
> +struct mtk_uart_apdma_desc {
> +   struct virt_dma_desc vd;
> +
> +   unsigned int avail_len;
> +};
> +
> +struct mtk_chan {
> +   struct virt_dma_chan vc;
> +   struct dma_slave_config cfg;
> +   void __iomem *base;
> +   struct mtk_uart_apdma_desc *desc;
> +
> +   bool requested;
> +
> +   unsigned int rx_status;
> +};
> +
> +static inline struct mtk_uart_apdmadev *
> +to_mtk_uart_apdma_dev(struct dma_device *d)
> +{
> +   return container_of(d, struct mtk_uart_apdmadev, ddev);
> +}
> +
> +static inline struct mtk_chan *to_mtk_uart_apdma_chan(struct dma_chan *c)
> +{
> +   return container_of(c, struct mtk_chan, vc.chan);
> +}
> +
> +static inline struct mtk_uart_apdma_desc *to_mtk_uart_apdma_desc
> +   (struct dma_async_tx_descriptor *t)
> +{
> +   return container_of(t, struct mtk_uart_apdma_desc, vd.tx);
> +}
> +
> +static void mtk_uart_apdma_chan_write(struct mtk_chan *c,
> +  unsigned int reg, unsigned int val)
> +{
> +   writel(val, c->base + reg);
> +}
> +
> +static unsigned int
> +mtk_uart_apdma_chan_read(struct mtk_chan *c, unsigned int reg)
> +{
> +   return readl(c->base + reg);
> +}
> +
> +static void mtk_uart_apdma_desc_free(struct virt_dma_desc *vd)
> +{
> +   struct dma_chan *chan = vd->tx.chan;
> +   struct mtk_chan *c = to_mtk_uart_apdma_chan(chan);
> +
> +   kfree(c->desc);
> +   c->desc = NULL;

Why? I'm afraid this may mask double-free.

> +}
> +
> +static void mtk_uart_apdma_start_tx(struct mtk_chan *c)
> +{
> +   unsigned int txcount = c->desc->avail_len;

Variable name is confusing... I'd rather have a boolean `transmitted`
(or something), set to 0 here, and set to 

[PATCH] edac: unregister the mci device before free the mci memory

2018-12-24 Thread Liwei Song
this patch can fix the following kmemleak:

unreferenced object 0x881022b60ee0 (size 32):
  comm "udevd", pid 262, jiffies 4294709066 (age 1410.265s)
  hex dump (first 32 bytes):
00 7c e8 18 10 88 ff ff 00 74 e8 18 10 88 ff ff .|...t..
00 70 e8 18 10 88 ff ff 00 00 00 00 00 00 00 00 .p..
  backtrace:
[] kmemleak_alloc+0x26/0x50
[] __kmalloc+0x154/0x2f0
[] edac_mc_alloc+0x278/0x6d0
[] 0xa0106f9d
[] local_pci_probe+0x3e/0x70
[] pci_device_probe+0x121/0x130
[] driver_probe_device+0x105/0x260
[] __driver_attach+0x93/0xa0
[] bus_for_each_dev+0x63/0xa0
[] driver_attach+0x1e/0x20
[] bus_add_driver+0x1f0/0x290
[] driver_register+0x64/0xf0
[] __pci_register_driver+0x4c/0x50
[] 0xa010d050
[] do_one_initcall+0x102/0x160
[] load_module+0x1a65/0x2230

The kmemleak happened when run "rmmod sb_edac.ko".
In edac_mc_free, only after mci device is ungistered, it will do the mci
free task, or it will do the mci unregister action, adjust the sequence
of the free task to ungister the device first and then free the mci
struct, then all memory allocated(Include dimms, csrows, channels)by
edac_mc_alloc() will got freed by edac_mc_free();

Because all allocated memory was freed by edac_mc_free() and the release
hook in edac_mc_sysfs.c can not release all allocated memory of EDAC MC,
so remove the free fragment from it to aviod duplicated memory free.

Signed-off-by: Liwei Song 
---
 drivers/edac/edac_mc.c   |  7 ---
 drivers/edac/edac_mc_sysfs.c | 12 
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 7d3edd713932..12d9dc9cf85e 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -506,6 +506,10 @@ void edac_mc_free(struct mem_ctl_info *mci)
 {
edac_dbg(1, "\n");
 
+   /* the mci instance is freed here, when the sysfs object is dropped */
+   if (device_is_registered(>dev))
+   edac_unregister_sysfs(mci);
+
/* If we're not yet registered with sysfs free only what was allocated
 * in edac_mc_alloc().
 */
@@ -513,9 +517,6 @@ void edac_mc_free(struct mem_ctl_info *mci)
_edac_mc_free(mci);
return;
}
-
-   /* the mci instance is freed here, when the sysfs object is dropped */
-   edac_unregister_sysfs(mci);
 }
 EXPORT_SYMBOL_GPL(edac_mc_free);
 
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 20374b8248f0..20211b4ee2f1 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -276,10 +276,6 @@ static const struct attribute_group *csrow_attr_groups[] = 
{
 
 static void csrow_attr_release(struct device *dev)
 {
-   struct csrow_info *csrow = container_of(dev, struct csrow_info, dev);
-
-   edac_dbg(1, "Releasing csrow device %s\n", dev_name(dev));
-   kfree(csrow);
 }
 
 static const struct device_type csrow_attr_type = {
@@ -616,10 +612,6 @@ static const struct attribute_group *dimm_attr_groups[] = {
 
 static void dimm_attr_release(struct device *dev)
 {
-   struct dimm_info *dimm = container_of(dev, struct dimm_info, dev);
-
-   edac_dbg(1, "Releasing dimm device %s\n", dev_name(dev));
-   kfree(dimm);
 }
 
 static const struct device_type dimm_attr_type = {
@@ -892,10 +884,6 @@ static const struct attribute_group *mci_attr_groups[] = {
 
 static void mci_attr_release(struct device *dev)
 {
-   struct mem_ctl_info *mci = container_of(dev, struct mem_ctl_info, dev);
-
-   edac_dbg(1, "Releasing csrow device %s\n", dev_name(dev));
-   kfree(mci);
 }
 
 static const struct device_type mci_attr_type = {
-- 
2.7.4



Re: [PATCH v2] signal: add procfd_signal() syscall

2018-12-24 Thread Lai Jiangshan
On Tue, Dec 25, 2018 at 1:32 PM Lai Jiangshan
 wrote:
>
> Is it possible to avoid adding any syscall?
>
> Since holding /proc/pid/reg_file can also hold the pid.
> With this guarantee, /proc/pid/uuid (universally unique identifier ) can be
> introduced to identify tasks, the kernel generates
> a uuid for every task when created.
>
> save_pid_uuid_pair_for_later_kill(int pid) {
>   /* save via /proc/$pid/uuid */
>   /* don't need to keep any fd after save */
> }
>
> safe_kill(pid, uuid, sig) {
> fd = open(/proc/$pid/uuid); /* also hold the pid until close() if
> open() successes */
> if (open successes and read uuid from fd and if it equals to uuid)
> kill(pid, sig)
> close(fd)
> }
>
> All things needed to be done is to implement /proc/pid/uuid. And if pid can't
> be recycled within 1 ticket, or the user can ensure it. The user can use
> starttime(in /proc/pid/stat) instead.
>
> save_pid_starttime_pair_for_later_kill(int pid) {
>   /* save via /proc/$pid/stat */
>   /* don't need to keep any fd after save or keep it for 1 ticket at most */
> }
>
> safe_kill(pid, starttime, sig) {
> fd = open(/proc/$pid/stat); /* also hold the pid until close() if
> open() successes */
> if (open successes and read starttime from fd and if it equals to 
> starttime)
> kill(pid, sig)
> close(fd)
> }
>
> In this case, zero LOC is added in the kernel. All of it depends on
> the guarantee that holding /proc/pid/reg_file also holds the pid,
> one of which I haven't checked carefully either.
>

Oh, Sorry, I was wrong, the pid isn't reserved even when
the fd is kept in the user space. And I'm sorry that I had
replied to an "old" email thread.


[PATCH] usb: gspca: add a missed return-value check for do_command

2018-12-24 Thread Kangjie Lu
do_command() may fail. The fix adds the missed return value of
do_command(). If it fails, returns its error code.

Signed-off-by: Kangjie Lu 
---
 drivers/media/usb/gspca/cpia1.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/gspca/cpia1.c b/drivers/media/usb/gspca/cpia1.c
index 2b09af8865f4..23fbda56fc91 100644
--- a/drivers/media/usb/gspca/cpia1.c
+++ b/drivers/media/usb/gspca/cpia1.c
@@ -547,10 +547,14 @@ static int do_command(struct gspca_dev *gspca_dev, u16 
command,
}
if (sd->params.qx3.button) {
/* button pressed - unlock the latch */
-   do_command(gspca_dev, CPIA_COMMAND_WriteMCPort,
+   ret = do_command(gspca_dev, CPIA_COMMAND_WriteMCPort,
   3, 0xdf, 0xdf, 0);
-   do_command(gspca_dev, CPIA_COMMAND_WriteMCPort,
+   if (ret)
+   return ret;
+   ret = do_command(gspca_dev, CPIA_COMMAND_WriteMCPort,
   3, 0xff, 0xff, 0);
+   if (ret)
+   return ret;
}
 
/* test whether microscope is cradled */
-- 
2.17.2 (Apple Git-113)



[PATCH] backlight: (adp8870) fix a missing check for adp8870_write

2018-12-24 Thread Kangjie Lu
adp8870_write() may fail. This fix checks if adp8870_write fails, and if
so, returns its error code.

Signed-off-by: Kangjie Lu 
---
 drivers/video/backlight/adp8870_bl.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/video/backlight/adp8870_bl.c 
b/drivers/video/backlight/adp8870_bl.c
index 8d50e0299578..79901fb4fcd1 100644
--- a/drivers/video/backlight/adp8870_bl.c
+++ b/drivers/video/backlight/adp8870_bl.c
@@ -811,9 +811,14 @@ static ssize_t adp8870_bl_ambient_light_zone_store(struct 
device *dev,
if (!ret) {
reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT);
reg_val |= (val - 1) << CFGR_BLV_SHIFT;
-   adp8870_write(data->client, ADP8870_CFGR, reg_val);
-   }
-   mutex_unlock(>lock);
+   ret = adp8870_write(data->client,
+   ADP8870_CFGR, reg_val);
+   if (ret) {
+   mutex_unlock(>lock);
+   return ret;
+   }
+   }   else
+   mutex_unlock(>lock);
}
 
return count;
-- 
2.17.2 (Apple Git-113)



Re: [PATCH v2] signal: add procfd_signal() syscall

2018-12-24 Thread Lai Jiangshan
Is it possible to avoid adding any syscall?

Since holding /proc/pid/reg_file can also hold the pid.
With this guarantee, /proc/pid/uuid (universally unique identifier ) can be
introduced to identify tasks, the kernel generates
a uuid for every task when created.

save_pid_uuid_pair_for_later_kill(int pid) {
  /* save via /proc/$pid/uuid */
  /* don't need to keep any fd after save */
}

safe_kill(pid, uuid, sig) {
fd = open(/proc/$pid/uuid); /* also hold the pid until close() if
open() successes */
if (open successes and read uuid from fd and if it equals to uuid)
kill(pid, sig)
close(fd)
}

All things needed to be done is to implement /proc/pid/uuid. And if pid can't
be recycled within 1 ticket, or the user can ensure it. The user can use
starttime(in /proc/pid/stat) instead.

save_pid_starttime_pair_for_later_kill(int pid) {
  /* save via /proc/$pid/stat */
  /* don't need to keep any fd after save or keep it for 1 ticket at most */
}

safe_kill(pid, starttime, sig) {
fd = open(/proc/$pid/stat); /* also hold the pid until close() if
open() successes */
if (open successes and read starttime from fd and if it equals to starttime)
kill(pid, sig)
close(fd)
}

In this case, zero LOC is added in the kernel. All of it depends on
the guarantee that holding /proc/pid/reg_file also holds the pid,
one of which I haven't checked carefully either.

On Fri, Dec 7, 2018 at 3:05 AM Christian Brauner  wrote:
>
> On December 7, 2018 7:56:44 AM GMT+13:00, Florian Weimer  
> wrote:
> >* Andy Lutomirski:
> >
> >>> I suppose that's fine.  Or alternatively, when thread group support
> >is
> >>> added, introduce a flag that applications have to use to enable it,
> >so
> >>> that they can probe for support by checking support for the flag.
> >>>
> >>> I wouldn't be opposed to a new system call like this either:
> >>>
> >>>  int procfd_open (pid_t thread_group, pid_t thread_id, unsigned
> >flags);
> >>>
> >>> But I think this is frowned upon on the kernel side.
> >>
> >> I have no problem with it, except that I think it shouldn’t return an
> >> fd that can be used for proc filesystem access.
> >
> >Oh no, my intention was that it would just be used with  *_send_signal
> >and related functions.
>
> Let's postpone that discussion a little.
> I think we don't need a syscall to base this off of pids.
> As I said I rather send my revived version of CLONE_NEWFD that would serve 
> the same task.
> The same way we could also just add a new open() flag that blocks fs access 
> completely.
> I just pitched that idea to Serge a few days back: O_NOCHDIR or similar.
> That could even be part of Aleksa's path resolution patchset.
>
> >
> >Thanks,
> >Florian
>


[PATCH v2] gpu: anx7808: fix a missing check in anx78xx_poweron

2018-12-24 Thread Kangjie Lu
Both anx78xx_set_bits() and anx78xx_clear_bits() in the poweron process
may fail. The fix inserts checks for their return values.

Signed-off-by: Kangjie Lu 
---
 drivers/gpu/drm/bridge/analogix-anx78xx.c | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix-anx78xx.c 
b/drivers/gpu/drm/bridge/analogix-anx78xx.c
index f8433c93f463..3b0fe2b188db 100644
--- a/drivers/gpu/drm/bridge/analogix-anx78xx.c
+++ b/drivers/gpu/drm/bridge/analogix-anx78xx.c
@@ -638,10 +638,22 @@ static void anx78xx_poweron(struct anx78xx *anx78xx)
gpiod_set_value_cansleep(pdata->gpiod_reset, 0);
 
/* Power on registers module */
-   anx78xx_set_bits(anx78xx->map[I2C_IDX_TX_P2], SP_POWERDOWN_CTRL_REG,
-SP_HDCP_PD | SP_AUDIO_PD | SP_VIDEO_PD | SP_LINK_PD);
-   anx78xx_clear_bits(anx78xx->map[I2C_IDX_TX_P2], SP_POWERDOWN_CTRL_REG,
-  SP_REGISTER_PD | SP_TOTAL_PD);
+   err = anx78xx_set_bits(anx78xx->map[I2C_IDX_TX_P2],
+   SP_POWERDOWN_CTRL_REG,
+   SP_HDCP_PD | SP_AUDIO_PD | SP_VIDEO_PD | SP_LINK_PD);
+   if (err) {
+   DRM_ERROR("Failed to set register bits: %d\n",
+   err);
+   return;
+   }
+   err = anx78xx_clear_bits(anx78xx->map[I2C_IDX_TX_P2],
+   SP_POWERDOWN_CTRL_REG,
+   SP_REGISTER_PD | SP_TOTAL_PD);
+   if (err) {
+   DRM_ERROR("Failed to clear register bits: %d\n",
+   err);
+   return;
+   }
 
anx78xx->powered = true;
 }
-- 
2.17.2 (Apple Git-113)



[PATCH v2] gpu: anx7808: fix a missing check in anx78xx_poweron

2018-12-24 Thread Kangjie Lu
Both anx78xx_set_bits() and anx78xx_clear_bits() in the poweron process
may fail. The fix inserts checks for their return values.

Signed-off-by: Kangjie Lu 
---
 drivers/gpu/drm/bridge/analogix-anx78xx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/bridge/analogix-anx78xx.c 
b/drivers/gpu/drm/bridge/analogix-anx78xx.c
index 3b0fe2b188db..4f35aced65a0 100644
--- a/drivers/gpu/drm/bridge/analogix-anx78xx.c
+++ b/drivers/gpu/drm/bridge/analogix-anx78xx.c
@@ -646,6 +646,7 @@ static void anx78xx_poweron(struct anx78xx *anx78xx)
err);
return;
}
+
err = anx78xx_clear_bits(anx78xx->map[I2C_IDX_TX_P2],
SP_POWERDOWN_CTRL_REG,
SP_REGISTER_PD | SP_TOTAL_PD);
-- 
2.17.2 (Apple Git-113)



[PATCH] ASoC: rockchip: fix platform_no_drv_owner.cocci warnings

2018-12-24 Thread kbuild test robot
From: kbuild test robot 

sound/soc/codecs/rk3328_codec.c:508:6-11: No need to set .owner here. The core 
will do it.

 Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Fixes: dc1b33660692 ("ASoC: rockchip: support ACODEC for rk3328")
CC: Katsuhiro Suzuki 
Signed-off-by: kbuild test robot 
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 
master
head:   6a1d293238c1774cef23c25b5188b0c134c29a34
commit: dc1b33660692441867a8ec5be147915dfa3bc8cb [11432/12209] ASoC: rockchip: 
support ACODEC for rk3328

 rk3328_codec.c |1 -
 1 file changed, 1 deletion(-)

--- a/sound/soc/codecs/rk3328_codec.c
+++ b/sound/soc/codecs/rk3328_codec.c
@@ -505,7 +505,6 @@ MODULE_DEVICE_TABLE(of, rk3328_codec_of_
 static struct platform_driver rk3328_codec_driver = {
.driver = {
   .name = "rk3328-codec",
-  .owner = THIS_MODULE,
   .of_match_table = of_match_ptr(rk3328_codec_of_match),
},
.probe = rk3328_platform_probe,


[PATCH v2] touchscreen: elants: fix a missing check of return values

2018-12-24 Thread Kangjie Lu
elants_i2c_send() may fail, let's check its return values. The fix does
the check and reports an error message upon the failure.

Signed-off-by: Kangjie Lu 
---
 drivers/input/touchscreen/elants_i2c.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/elants_i2c.c 
b/drivers/input/touchscreen/elants_i2c.c
index f2cb23121833..8ccba4ccee37 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -245,8 +245,22 @@ static int elants_i2c_calibrate(struct elants_data *ts)
ts->state = ELAN_WAIT_RECALIBRATION;
reinit_completion(>cmd_done);
 
-   elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
-   elants_i2c_send(client, rek, sizeof(rek));
+   error = elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
+   if (error) {
+   dev_err(>dev,
+   "error in sending the w_flashkey command for 
calibration: %d\n",
+   error);
+   enable_irq(client->irq);
+   return error;
+   }
+  error = elants_i2c_send(client, rek, sizeof(rek));
+   if (error) {
+   dev_err(>dev,
+   "error in sending the rek command for 
calibration: %d\n",
+   error);
+   enable_irq(client->irq);
+   return error;
+   }
 
enable_irq(client->irq);
 
-- 
2.17.2 (Apple Git-113)



[PATCH] kvm/arm : remove unnecessary local variable

2018-12-24 Thread Peng Hao
Remove unnecessary local variable in vgic_set_common_attr

Signed-off-by: Peng Hao 
---
 virt/kvm/arm/vgic/vgic-kvm-device.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/virt/kvm/arm/vgic/vgic-kvm-device.c 
b/virt/kvm/arm/vgic/vgic-kvm-device.c
index 114dce9..53e5df7 100644
--- a/virt/kvm/arm/vgic/vgic-kvm-device.c
+++ b/virt/kvm/arm/vgic/vgic-kvm-device.c
@@ -163,7 +163,7 @@ int kvm_vgic_addr(struct kvm *kvm, unsigned long type, u64 
*addr, bool write)
 static int vgic_set_common_attr(struct kvm_device *dev,
struct kvm_device_attr *attr)
 {
-   int r;
+   int r = 0;
 
switch (attr->group) {
case KVM_DEV_ARM_VGIC_GRP_ADDR: {
@@ -180,7 +180,6 @@ static int vgic_set_common_attr(struct kvm_device *dev,
case KVM_DEV_ARM_VGIC_GRP_NR_IRQS: {
u32 __user *uaddr = (u32 __user *)(long)attr->addr;
u32 val;
-   int ret = 0;
 
if (get_user(val, uaddr))
return -EFAULT;
@@ -199,14 +198,14 @@ static int vgic_set_common_attr(struct kvm_device *dev,
mutex_lock(>kvm->lock);
 
if (vgic_ready(dev->kvm) || dev->kvm->arch.vgic.nr_spis)
-   ret = -EBUSY;
+   r = -EBUSY;
else
dev->kvm->arch.vgic.nr_spis =
val - VGIC_NR_PRIVATE_IRQS;
 
mutex_unlock(>kvm->lock);
 
-   return ret;
+   return r;
}
case KVM_DEV_ARM_VGIC_GRP_CTRL: {
switch (attr->attr) {
-- 
1.8.3.1



[PATCH v3] pinctrl:mediatek:add EINT support to virtual GPIOs

2018-12-24 Thread chuanjia.liu
From: Chuanjia Liu 

Virtual gpio only used inside SOC and not being exported to outside SOC.
Some modules use virtual gpio as eint and doesn't nedd SMT.
So this patch add EINT support to virtual GPIOs.

Signed-off-by: Chuanjia Liu 
---
change note:
v3 : 1. modify subject and description
  2. modify comments
---
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 4a9e0d4c2bbc..a0db145f798d 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -290,7 +290,15 @@ static int mtk_xt_set_gpio_as_eint(void *data, unsigned 
long eint_n)
return err;
 
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SMT, MTK_ENABLE);
-   if (err)
+   /*
+*SMT is supposed to be supported by every real GPIO and doesn't
+*support virtual GPIOs, so the extra condition err != -ENOTSUPP
+*is just for adding EINT support to these virtual GPIOs. It should
+*add an extra flag in the pin descriptor when more pins with
+*distinctive characteristic come out.
+*/
+
+   if (err && err != -ENOTSUPP)
return err;
 
return 0;
-- 
2.19.1



Re: [PATCH] infiniband/qedr: Potential null ptr dereference of qp

2018-12-24 Thread Leon Romanovsky
On Mon, Dec 24, 2018 at 12:24:45PM -0600, Aditya Pakki wrote:
> idr_find() may fail and return a NULL pointer. The fix checks the
> return value of the function and returns an error in case of NULL.
>
> Signed-off-by: Aditya Pakki 
> ---
>  drivers/infiniband/hw/qedr/qedr_iw_cm.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/infiniband/hw/qedr/qedr_iw_cm.c 
> b/drivers/infiniband/hw/qedr/qedr_iw_cm.c
> index 505fa3648762..93b16237b767 100644
> --- a/drivers/infiniband/hw/qedr/qedr_iw_cm.c
> +++ b/drivers/infiniband/hw/qedr/qedr_iw_cm.c
> @@ -492,6 +492,8 @@ int qedr_iw_connect(struct iw_cm_id *cm_id, struct 
> iw_cm_conn_param *conn_param)
>   int i;
>
>   qp = idr_find(>qpidr.idr, conn_param->qpn);
> + if (unlikely(!qp))
> + return -EINVAL;

As was already pointed, qedr is racy in their accesses to idr_find() and
NULL pointer is less worry about their IDR code.

>
>   laddr = (struct sockaddr_in *)_id->m_local_addr;
>   raddr = (struct sockaddr_in *)_id->m_remote_addr;
> --
> 2.17.1
>


signature.asc
Description: PGP signature


Re: [PATCH 17/18] drm/mediatek: add ovl0/ovl0_2l usecase

2018-12-24 Thread Nicolas Boichat
On Mon, Dec 24, 2018 at 6:52 PM Yongqiang Niu
 wrote:
>
> This patch add ovl0/ovl0_2l usecase
>
> Signed-off-by: Yongqiang Niu 
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 38 
> ++---
>  1 file changed, 35 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
> b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index a5af4be..25cf063 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -283,6 +283,15 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc 
> *mtk_crtc)
>
> for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
> struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[i];
> +   enum mtk_ddp_comp_id prev = DDP_COMPONENT_ID_MAX;
> +
> +   if (i > 0) {
> +   struct mtk_ddp_comp *comp_prev;
> +
> +   comp_prev = mtk_crtc->ddp_comp[i - 1];
> +   prev = comp_prev->id;

Just

if (i > 0)
  prev = mtk_crtc->ddp_comp[i - 1]->id;
else
  prev = DDP_COMPONENT_ID_MAX;

> +   }
> +   mtk_ddp_comp_connect(comp, prev);
>
> mtk_ddp_comp_config(comp, width, height, vrefresh, bpc);
> mtk_ddp_comp_start(comp);
> @@ -292,10 +301,19 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc 
> *mtk_crtc)
> for (i = 0; i < mtk_crtc->layer_nr; i++) {
> struct drm_plane *plane = _crtc->planes[i];
> struct mtk_plane_state *plane_state;
> +   struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0];
> +   unsigned int comp_layer_nr = mtk_ddp_comp_layer_nr(comp);
> +   unsigned int local_layer = 0;

No need to init to 0.

>
> plane_state = to_mtk_plane_state(plane->state);
> -   mtk_ddp_comp_layer_config(mtk_crtc->ddp_comp[0], i,
> - plane_state);
> +
> +   if (i >= comp_layer_nr) {
> +   comp = mtk_crtc->ddp_comp[1];
> +   local_layer = i - comp_layer_nr;
> +   } else {
> +   local_layer = i;
> +   }
> +   mtk_ddp_comp_layer_config(comp, local_layer, plane_state);
> }
>
> return 0;
> @@ -340,6 +358,8 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc)
> struct mtk_crtc_state *state = 
> to_mtk_crtc_state(mtk_crtc->base.state);
> struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0];
> unsigned int i;
> +   unsigned int comp_layer_nr = mtk_ddp_comp_layer_nr(comp);
> +   unsigned int local_layer = 0;

ditto, don't init to 0.

>
> /*
>  * TODO: instead of updating the registers here, we should prepare
> @@ -362,7 +382,15 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc)
> plane_state = to_mtk_plane_state(plane->state);
>
> if (plane_state->pending.config) {
> -   mtk_ddp_comp_layer_config(comp, i, 
> plane_state);
> +   if (i >= comp_layer_nr) {
> +   comp = mtk_crtc->ddp_comp[1];
> +   local_layer = i - comp_layer_nr;
> +   } else {
> +   local_layer = i;
> +   }
> +
> +   mtk_ddp_comp_layer_config(comp, local_layer,
> + plane_state);
> plane_state->pending.config = false;
> }
> }
> @@ -604,6 +632,10 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
> }
>
> mtk_crtc->layer_nr = mtk_ddp_comp_layer_nr(mtk_crtc->ddp_comp[0]);
> +   if (mtk_crtc->ddp_comp_nr > 1 &&
> +   mtk_ddp_comp_get_type(mtk_crtc->ddp_comp[1]->id) == MTK_DISP_OVL)
> +   mtk_crtc->layer_nr +=
> +   mtk_ddp_comp_layer_nr(mtk_crtc->ddp_comp[1]);
> mtk_crtc->planes = devm_kcalloc(dev, mtk_crtc->layer_nr,
> sizeof(struct drm_plane),
> GFP_KERNEL);
> --
> 1.8.1.1.dirty
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 16/18] drm/mediatek: add function mtk_ddp_comp_get_type

2018-12-24 Thread Nicolas Boichat
On Mon, Dec 24, 2018 at 6:53 PM Yongqiang Niu
 wrote:
>
> This patch add function mtk_ddp_comp_get_type
>
> Signed-off-by: Yongqiang Niu 
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 10 ++
>  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h |  1 +
>  2 files changed, 11 insertions(+)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c 
> b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> index 1c0f9cc..71b565c 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> @@ -350,6 +350,16 @@ int mtk_ddp_comp_get_id(struct device_node *node,
> return -EINVAL;
>  }
>
> +enum mtk_ddp_comp_type mtk_ddp_comp_get_type(enum mtk_ddp_comp_id comp_id)
> +{
> +   enum mtk_ddp_comp_type comp_type = MTK_DDP_COMP_TYPE_MAX;
> +
> +   if (comp_id < DDP_COMPONENT_ID_MAX)
> +   comp_type = mtk_ddp_matches[comp_id].type;

return mtk_ddp_matches[comp_id].type

> +
> +   return comp_type;

return MTK_DDP_COMP_TYPE_MAX

> +}
> +
>  int mtk_ddp_comp_init(struct device *dev, struct device_node *node,
>   struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id,
>   const struct mtk_ddp_comp_funcs *funcs)
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h 
> b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
> index b908172..599e293 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
> @@ -198,5 +198,6 @@ void mtk_ddp_write_mask(unsigned int value,
> struct mtk_ddp_comp *comp,
> unsigned int offset,
> unsigned int mask);
> +enum mtk_ddp_comp_type mtk_ddp_comp_get_type(enum mtk_ddp_comp_id comp_id);
>
>  #endif /* MTK_DRM_DDP_COMP_H */
> --
> 1.8.1.1.dirty
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 10/18] drm/mediatek: add gmc_bits for ovl private data

2018-12-24 Thread Nicolas Boichat
On Mon, Dec 24, 2018 at 6:53 PM Yongqiang Niu
 wrote:
>
> This patch add gmc_bits for ovl private data
>
> Signed-off-by: Yongqiang Niu 
> ---
>  drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 23 +--
>  1 file changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c 
> b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> index 28d1911..afb313c 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> @@ -39,7 +39,9 @@
>  #define DISP_REG_OVL_ADDR_MT8173   0x0f40
>  #define DISP_REG_OVL_ADDR(ovl, n)  ((ovl)->data->addr + 0x20 * 
> (n))
>
> -#defineOVL_RDMA_MEM_GMC0x40402020
> +#define GMC_THRESHOLD_BITS 16
> +#define GMC_THRESHOLD_HIGH ((1 << GMC_THRESHOLD_BITS) / 4)
> +#define GMC_THRESHOLD_LOW  ((1 << GMC_THRESHOLD_BITS) / 8)
>
>  #define OVL_CON_BYTE_SWAP  BIT(24)
>  #define OVL_CON_MTX_YUV_TO_RGB (6 << 16)
> @@ -57,6 +59,7 @@
>
>  struct mtk_disp_ovl_data {
> unsigned int addr;
> +   unsigned int gmc_bits;
> bool fmt_rgb565_is_0;
>  };
>
> @@ -140,9 +143,23 @@ static unsigned int mtk_ovl_layer_nr(struct mtk_ddp_comp 
> *comp)
>  static void mtk_ovl_layer_on(struct mtk_ddp_comp *comp, unsigned int idx)
>  {
> unsigned int reg;
> +   unsigned int gmc_thrshd_l;
> +   unsigned int gmc_thrshd_h;
> +   unsigned int gmc_value;
> +   struct mtk_disp_ovl *ovl = comp_to_ovl(comp);
>
> writel(0x1, comp->regs + DISP_REG_OVL_RDMA_CTRL(idx));
> -   writel(OVL_RDMA_MEM_GMC, comp->regs + DISP_REG_OVL_RDMA_GMC(idx));
> +
> +   gmc_thrshd_l = GMC_THRESHOLD_LOW >>
> + (GMC_THRESHOLD_BITS - ovl->data->gmc_bits);
> +   gmc_thrshd_h = GMC_THRESHOLD_HIGH >>
> + (GMC_THRESHOLD_BITS - ovl->data->gmc_bits);
> +   if (ovl->data->gmc_bits == 10)
> +   gmc_value = gmc_thrshd_h | gmc_thrshd_h << 16;

I don't really get what this does, but is it intentional that you
don't use gmc_thrshd_l here?

Also, if you only ever use 8 or 10 bits gmc, maybe it's easier to
hard-code the 2 values?
if (ovl->data->gmc_bits == 10)
  gmc_value = OVL_RDMA_MEM_GMC_10BIT;
else
  gmc_value = OVL_RDMA_MEM_GMC_8BIT; //0x40402020

> +   else
> +   gmc_value = gmc_thrshd_l | gmc_thrshd_l << 8 |
> +   gmc_thrshd_h << 16 | gmc_thrshd_h << 24;
> +   writel(gmc_value, comp->regs + DISP_REG_OVL_RDMA_GMC(idx));
>
> reg = readl(comp->regs + DISP_REG_OVL_SRC_CON);
> reg = reg | BIT(idx);
> @@ -324,11 +341,13 @@ static int mtk_disp_ovl_remove(struct platform_device 
> *pdev)
>
>  static const struct mtk_disp_ovl_data mt2701_ovl_driver_data = {
> .addr = DISP_REG_OVL_ADDR_MT2701,
> +   .gmc_bits = 8,
> .fmt_rgb565_is_0 = false,
>  };
>
>  static const struct mtk_disp_ovl_data mt8173_ovl_driver_data = {
> .addr = DISP_REG_OVL_ADDR_MT8173,
> +   .gmc_bits = 8,
> .fmt_rgb565_is_0 = true,
>  };
>
> --
> 1.8.1.1.dirty
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 03/18] drm/mediatek: redefine mtk_ddp_sout_sel

2018-12-24 Thread Nicolas Boichat
On Mon, Dec 24, 2018 at 6:52 PM Yongqiang Niu
 wrote:
>
> This patch redefine mtk_ddp_sout_sel

Can you describe a bit more why you are making this change?

> Signed-off-by: Yongqiang Niu 
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 32 
>  1 file changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c 
> b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> index adb37e4..592f852 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> @@ -405,21 +405,27 @@ static unsigned int mtk_ddp_sel_in(enum mtk_ddp_comp_id 
> cur,
> return value;
>  }
>
> -static void mtk_ddp_sout_sel(void __iomem *config_regs,
> -enum mtk_ddp_comp_id cur,
> -enum mtk_ddp_comp_id next)
> +static unsigned int mtk_ddp_sout_sel(void __iomem *config_regs,

You don't use config_regs anymore, drop it.

> +enum mtk_ddp_comp_id cur,
> +enum mtk_ddp_comp_id next,
> +unsigned int *addr)
>  {
> +   unsigned int value;
> +
> if (cur == DDP_COMPONENT_BLS && next == DDP_COMPONENT_DSI0) {
> -   writel_relaxed(BLS_TO_DSI_RDMA1_TO_DPI1,
> -  config_regs + DISP_REG_CONFIG_OUT_SEL);
> +   *addr = DISP_REG_CONFIG_OUT_SEL;
> +   value = BLS_TO_DSI_RDMA1_TO_DPI1;

You can directly return BLS_TO_DSI_RDMA1_TO_DPI1.

> } else if (cur == DDP_COMPONENT_BLS && next == DDP_COMPONENT_DPI0) {
> -   writel_relaxed(BLS_TO_DPI_RDMA1_TO_DSI,
> -  config_regs + DISP_REG_CONFIG_OUT_SEL);
> -   writel_relaxed(DSI_SEL_IN_RDMA,
> -  config_regs + DISP_REG_CONFIG_DSI_SEL);
> -   writel_relaxed(DPI_SEL_IN_BLS,
> -  config_regs + DISP_REG_CONFIG_DPI_SEL);
> +   *addr = DISP_REG_CONFIG_OUT_SEL;
> +   value = BLS_TO_DPI_RDMA1_TO_DSI;

I (kind of) understand the change above, as you still end up writing
BLS_TO_DSI_RDMA1_TO_DPI1 in DISP_REG_CONFIG_OUT_SEL.

This changes the behaviour, as now you only write
BLS_TO_DPI_RDMA1_TO_DSI to DISP_REG_CONFIG_OUT_SEL, but the previous
revision of the code would also write to DISP_REG_CONFIG_DSI_SEL and
DISP_REG_CONFIG_DPI_SEL. Why?

> +   } else if (cur == DDP_COMPONENT_RDMA1 && next == DDP_COMPONENT_DSI0) {
> +   *addr = DISP_REG_CONFIG_DSI_SEL;
> +   value = DSI_SEL_IN_RDMA;
> +   } else {
> +   value = 0;
> }
> +
> +   return value;
>  }
>
>  void mtk_ddp_add_comp_to_path(void __iomem *config_regs,
> @@ -434,7 +440,9 @@ void mtk_ddp_add_comp_to_path(void __iomem *config_regs,
> writel_relaxed(reg, config_regs + addr);
> }
>
> -   mtk_ddp_sout_sel(config_regs, cur, next);
> +   value = mtk_ddp_sout_sel(cur, next, );
> +   if (value)
> +   writel_relaxed(value, config_regs + addr);

Why this change? I don't see mtk_ddp_sout_sel being used later in the
series, so I'm not sure why we don't directly write the value into the
register.



> value = mtk_ddp_sel_in(cur, next, );
> if (value) {
> --
> 1.8.1.1.dirty
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2] pinctrl:mediatek:add judgment conditions

2018-12-24 Thread Chuanjia Liu
On Sun, 2018-12-23 at 02:50 +0800, Sean Wang wrote:
> On Mon, Dec 17, 2018 at 6:32 PM  wrote:
> >
> 
> I thought the subject still is much general, it should be further
> improved with something like "add EINT support to virtual GPIOs" and
> should say more about what virtual GPIOs means by MTKers in the patch
> description because "virtual" is a usual term used throughout the
> kernel and that would easily cause others to fail to interpret
> correctly.
> 
Thank you for your advice,I will modify subject and description.
> > From: Chuanjia Liu 
> >
> > This patch avoid return err when virtual gpio set SMT.
> >
> > Signed-off-by: Chuanjia Liu 
> > ---
> > change note:
> > v2 : 1. delete virtual gpio number
> >  2. add judgment conditions
> > ---
> >  drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 6 +-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
> > b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
> > index 4a9e0d4c2bbc..a576e417744a 100644
> > --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
> > +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
> > @@ -290,7 +290,11 @@ static int mtk_xt_set_gpio_as_eint(void *data, 
> > unsigned long eint_n)
> > return err;
> >
> > err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SMT, MTK_ENABLE);
> > -   if (err)
> > +
> > +   /* SMT doesn't support virtual GPIO, add err != -ENOTSUPP is used 
> > for
> > +* avoid return err when virtual gpio set SMT.
> > +*/
> 
> I'd prefer to the comments as the below
> 
> /*
> SMT is supposed to be supported by every real GPIO and doesn't support
> virtual GPIOs, so the extra condition err != -ENOTSUPP is just for
> adding EINT support to these virtual GPIOs. It should add an extra
> flag in the pin descriptor when more pins with distinctive
> characteristic come out.
> */
> 
Thank you for your advice,I will modify comments.
> > +   if (err && err != -ENOTSUPP)
> > return err;
> >
> > return 0;
> > --
> > 2.19.1
> >




Re: [PATCH] f2fs: fix use-after-free issue with sbi->stat_info

2018-12-24 Thread Chao Yu
On 2018/12/24 21:06, Sahitya Tummala wrote:
> iput() on sbi->node_inode can update sbi->stat_info
> in the below context, if the f2fs_write_checkpoint()
> has failed with error.
> 
> f2fs_balance_fs_bg+0x1ac/0x1ec
> f2fs_write_node_pages+0x4c/0x260
> do_writepages+0x80/0xbc
> __writeback_single_inode+0xdc/0x4ac
> writeback_single_inode+0x9c/0x144
> write_inode_now+0xc4/0xec
> iput+0x194/0x22c
> f2fs_put_super+0x11c/0x1e8
> generic_shutdown_super+0x70/0xf4
> kill_block_super+0x2c/0x5c
> kill_f2fs_super+0x44/0x50
> deactivate_locked_super+0x60/0x8c
> deactivate_super+0x68/0x74
> cleanup_mnt+0x40/0x78
> 
> Fix this by moving f2fs_destroy_stats() further below iput().
> 
> Signed-off-by: Sahitya Tummala 
> ---
>  fs/f2fs/super.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index e184ad4e..df41a3a 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -1058,9 +1058,6 @@ static void f2fs_put_super(struct super_block *sb)
>   f2fs_write_checkpoint(sbi, );
>   }
>  
> - /* f2fs_write_checkpoint can update stat informaion */
> - f2fs_destroy_stats(sbi);

The code order in error path of fill_super is almost the same as the one of
put_super, could you please check that as well?

Thanks,

> -
>   /*
>* normally superblock is clean, so we need to release this.
>* In addition, EIO will skip do checkpoint, we need this as well.
> @@ -1080,6 +1077,12 @@ static void f2fs_put_super(struct super_block *sb)
>   iput(sbi->node_inode);
>   iput(sbi->meta_inode);
>  
> + /*
> +  * iput() can update stat information, if f2fs_write_checkpoint()
> +  * above failed with error.
> +  */
> + f2fs_destroy_stats(sbi);
> +
>   /* destroy f2fs internal modules */
>   f2fs_destroy_node_manager(sbi);
>   f2fs_destroy_segment_manager(sbi);
> 



[PATCH] perfmon: use ARRAY_SIZE() macro

2018-12-24 Thread Gustavo A. R. Silva
Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element
or, as in this particular case, sizeof the structure name.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva 
---
 arch/ia64/kernel/perfmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 46bff1661836..b39df5078e19 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -4644,7 +4644,7 @@ static pfm_cmd_desc_t pfm_cmd_tab[]={
 /* 32 */PFM_CMD(pfm_write_ibrs, PFM_CMD_PCLRWS, PFM_CMD_ARG_MANY, 
pfarg_dbreg_t, NULL),
 /* 33 */PFM_CMD(pfm_write_dbrs, PFM_CMD_PCLRWS, PFM_CMD_ARG_MANY, 
pfarg_dbreg_t, NULL)
 };
-#define PFM_CMD_COUNT  (sizeof(pfm_cmd_tab)/sizeof(pfm_cmd_desc_t))
+#define PFM_CMD_COUNT  ARRAY_SIZE(pfm_cmd_tab)
 
 static int
 pfm_check_task_state(pfm_context_t *ctx, int cmd, unsigned long flags)
-- 
2.20.1



Re: [PATCH -next] ACPI/IORT: fix build when CONFIG_IOMMU_API=n

2018-12-24 Thread Hanjun Guo
Hi Qian,

Good catch, minor comments below.

On 2018/12/25 1:20, Qian Cai wrote:
> rivers/acpi/arm64/iort.c:880:1: error: expected identifier or '(' before '{' 
> token
  ^^
  drivers

>  { return NULL; }
>  ^
> drivers/acpi/arm64/iort.c:879:39: warning: 'iort_fwspec_iommu_ops' used but 
> never defined
>  static inline const struct iommu_ops *iort_fwspec_iommu_ops(struct device 
> *dev);
>^
> Signed-off-by: Qian Cai 
> ---
>  drivers/acpi/arm64/iort.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
> index fdd90ffceb85..5d29783ee5bd 100644
> --- a/drivers/acpi/arm64/iort.c
> +++ b/drivers/acpi/arm64/iort.c
> @@ -876,7 +876,7 @@ int iort_iommu_msi_get_resv_regions(struct device *dev, 
> struct list_head *head)
>   return (resv == its->its_count) ? resv : -ENODEV;
>  }
>  #else
> -static inline const struct iommu_ops *iort_fwspec_iommu_ops(struct device 
> *dev);
> +static inline const struct iommu_ops *iort_fwspec_iommu_ops(struct device 
> *dev)
>  { return NULL; }
>  static inline int iort_add_device_replay(const struct iommu_ops *ops,
>struct device *dev)

Acked-by: Hanjun Guo 

Lorenzo, I think this is 4.21-rc1 material if it's OK for you.

Thanks
Hanjun



Re: [PATCH] ubifs: Get/put page when changing PG_private

2018-12-24 Thread zhangjun

On 2018/12/21 下午4:56, Richard Weinberger wrote:

Am Samstag, 15. Dezember 2018, 16:01:30 CET schrieb Richard Weinberger:

The page migration code assumes that a page with PG_private
set has its page count elevated by 1.
UBIFS never did this and therefore the migration code was unable
to migrate some pages owned by UBIFS.
The lead to situations where the CMA memory allocator failed to
allocate memory.

Fix this by using get/put_page when changing PG_private.

Cc: 
Cc: zhangjun 
Fixes: 4ac1c17b2044 ("UBIFS: Implement ->migratepage()")
Reported-by: zhangjun 
Signed-off-by: Richard Weinberger 

FYI, on the XFS side a similar change caused a regression.
https://marc.info/?l=linux-fsdevel=154530861202448=2

Until this regression is not fully understood, including the implications
for UBIFS, I'll not merge this patch.

Thanks,
//richard



Hello,richard


Before fully understanding this regression, in order to fix the bug of 
cma_alloc(),

submit a conservative patch that modifies count in iomap_migrate_page().
Can you consider merging first?

https://marc.info/?l=linux-kernel=154473132332661=2


Thanks
//zhangjun



[PATCH -next] powerpc/powernv/npu: Fix debugfs_simple_attr.cocci warnings

2018-12-24 Thread YueHaibing
Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
for debugfs files.

Semantic patch information:
Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
imposes some significant overhead as compared to
DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().

Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci

Signed-off-by: YueHaibing 
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c 
b/arch/powerpc/platforms/powernv/pci-ioda.c
index 1d6406a..c4cf230 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -3147,8 +3147,8 @@ static int pnv_pci_diag_data_set(void *data, u64 val)
return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(pnv_pci_diag_data_fops, NULL,
-   pnv_pci_diag_data_set, "%llu\n");
+DEFINE_DEBUGFS_ATTRIBUTE(pnv_pci_diag_data_fops, NULL, pnv_pci_diag_data_set,
+"%llu\n");
 
 #endif /* CONFIG_DEBUG_FS */
 
@@ -3173,8 +3173,8 @@ static void pnv_pci_ioda_create_dbgfs(void)
continue;
}
 
-   debugfs_create_file("dump_diag_regs", 0200, phb->dbgfs, hose,
-   _pci_diag_data_fops);
+   debugfs_create_file_unsafe("dump_diag_regs", 0200, phb->dbgfs,
+  hose, _pci_diag_data_fops);
}
 #endif /* CONFIG_DEBUG_FS */
 }







Re: [PATCH] arm64: kaslr: Reserve size of ARM64_MEMSTART_ALIGN in linear region

2018-12-24 Thread Yueyi Li
Hi Ard,


On 2018/12/24 17:45, Ard Biesheuvel wrote:
> Does the following change fix your issue as well?
>
> index 9b432d9fcada..9dcf0ff75a11 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -447,7 +447,7 @@ void __init arm64_memblock_init(void)
>   * memory spans, randomize the linear region as well.
>   */
>  if (memstart_offset_seed > 0 && range >= 
> ARM64_MEMSTART_ALIGN) {
> -   range = range / ARM64_MEMSTART_ALIGN + 1;
> +   range /= ARM64_MEMSTART_ALIGN;
>  memstart_addr -= ARM64_MEMSTART_ALIGN *
>   ((range * memstart_offset_seed) >> 
> 16);
>  }

Yes, it can fix this also. I just think modify the first *range* 
calculation would be easier to
  grasp, what do you think?



Thanks,
Yueyi


[PATCH -next] mailbox: hi6220: fix platform_no_drv_owner.cocci warnings

2018-12-24 Thread YueHaibing
Remove .owner field if calls are used which set it automatically
Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Signed-off-by: YueHaibing 
---
 drivers/mailbox/hi6220-mailbox.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/mailbox/hi6220-mailbox.c b/drivers/mailbox/hi6220-mailbox.c
index c32cbfa..735ff94 100644
--- a/drivers/mailbox/hi6220-mailbox.c
+++ b/drivers/mailbox/hi6220-mailbox.c
@@ -363,7 +363,6 @@ static int hi6220_mbox_probe(struct platform_device *pdev)
 static struct platform_driver hi6220_mbox_driver = {
.driver = {
.name = "hi6220-mbox",
-   .owner = THIS_MODULE,
.of_match_table = hi6220_mbox_of_match,
},
.probe  = hi6220_mbox_probe,







[PATCH -next] ASoC: rockchip: fix platform_no_drv_owner.cocci warnings

2018-12-24 Thread YueHaibing
Remove .owner field if calls are used which set it automatically
Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Signed-off-by: YueHaibing 
---
 sound/soc/codecs/rk3328_codec.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/soc/codecs/rk3328_codec.c b/sound/soc/codecs/rk3328_codec.c
index f3442a2..24f8f86 100644
--- a/sound/soc/codecs/rk3328_codec.c
+++ b/sound/soc/codecs/rk3328_codec.c
@@ -508,7 +508,6 @@ static int rk3328_platform_probe(struct platform_device 
*pdev)
 static struct platform_driver rk3328_codec_driver = {
.driver = {
   .name = "rk3328-codec",
-  .owner = THIS_MODULE,
   .of_match_table = of_match_ptr(rk3328_codec_of_match),
},
.probe = rk3328_platform_probe,







RE: [PATCH] soc/fsl/qe: fix err handling of ucc_of_parse_tdm

2018-12-24 Thread Qiang Zhao
Hi Wen,

Will you send another version to resolve the issue described in the comments?

BR
Qiang

> -Original Message-
> From: Li Yang 
> Sent: 2018年12月6日 4:10
> To: wang.y...@zte.com.cn
> Cc: Qiang Zhao ; zhong.weid...@zte.com.cn; lkml
> ; julia.law...@lip6.fr; linuxppc-dev
> ; wen.yan...@zte.com.cn; moderated
> list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
> 
> Subject: Re: [PATCH] soc/fsl/qe: fix err handling of ucc_of_parse_tdm
> 
> On Thu, Nov 22, 2018 at 2:42 PM Yi Wang  wrote:
> >
> > From: Wen Yang 
> >
> > Currently there are 2 problems with the ucc_of_parse_tdm function:
> > 1,a possible null pointer dereference in ucc_of_parse_tdm, detected by
> > the semantic patch deref_null.cocci, with the following warning:
> > drivers/soc/fsl/qe/qe_tdm.c:177:21-24: ERROR: pdev is NULL but
> dereferenced.
> > 2,dev gets modified, so in any case that devm_iounmap() will fail even
> > when the new pdev is valid, because the iomap was done with a different
> pdev.
> > This patch fixes them.
> 
> While we are at this, I think this logic need more serious fixing.  I see 
> there is
> no driver bind with the "fsl,t1040-qe-si" or "fsl,t1040-qe-siram" device.  So
> allocating resources using devm_*() with these devices won't provide a
> cleanup path for these resources when the caller fails.  I think we should
> probably allocate resource under device of caller (e.g. ucc-hdlc), so that 
> when
> caller probe fails or is removed it will trigger the cleanup.
> 
> >
> > Suggested-by: Christophe LEROY 
> > Signed-off-by: Wen Yang 
> > CC: Julia Lawall 
> > CC: Zhao Qiang 
> > ---
> >  drivers/soc/fsl/qe/qe_tdm.c | 20 ++--
> >  1 file changed, 10 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/soc/fsl/qe/qe_tdm.c b/drivers/soc/fsl/qe/qe_tdm.c
> > index f78c346..9a29f0b 100644
> > --- a/drivers/soc/fsl/qe/qe_tdm.c
> > +++ b/drivers/soc/fsl/qe/qe_tdm.c
> > @@ -47,7 +47,7 @@ int ucc_of_parse_tdm(struct device_node *np, struct
> ucc_tdm *utdm,
> > struct resource *res;
> > struct device_node *np2;
> > static int siram_init_flag;
> > -   struct platform_device *pdev;
> > +   struct platform_device *pdev_si, *pdev_siram;
> >
> > sprop = of_get_property(np, "fsl,rx-sync-clock", NULL);
> > if (sprop) {
> > @@ -129,16 +129,16 @@ int ucc_of_parse_tdm(struct device_node *np,
> struct ucc_tdm *utdm,
> > if (!np2)
> > return -EINVAL;
> >
> > -   pdev = of_find_device_by_node(np2);
> > -   if (!pdev) {
> > +   pdev_si = of_find_device_by_node(np2);
> > +   if (!pdev_si) {
> > pr_err("%pOFn: failed to lookup pdev\n", np2);
> > of_node_put(np2);
> > return -EINVAL;
> > }
> >
> > of_node_put(np2);
> > -   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > -   utdm->si_regs = devm_ioremap_resource(>dev, res);
> > +   res = platform_get_resource(pdev_si, IORESOURCE_MEM, 0);
> > +   utdm->si_regs = devm_ioremap_resource(_si->dev, res);
> > if (IS_ERR(utdm->si_regs)) {
> > ret = PTR_ERR(utdm->si_regs);
> > goto err_miss_siram_property; @@ -150,8 +150,8 @@
> int
> > ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm,
> > goto err_miss_siram_property;
> > }
> >
> > -   pdev = of_find_device_by_node(np2);
> > -   if (!pdev) {
> > +   pdev_siram = of_find_device_by_node(np2);
> > +   if (!pdev_siram) {
> > ret = -EINVAL;
> > pr_err("%pOFn: failed to lookup pdev\n", np2);
> > of_node_put(np2);
> > @@ -159,8 +159,8 @@ int ucc_of_parse_tdm(struct device_node *np, struct
> ucc_tdm *utdm,
> > }
> >
> > of_node_put(np2);
> > -   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > -   utdm->siram = devm_ioremap_resource(>dev, res);
> > +   res = platform_get_resource(pdev_siram, IORESOURCE_MEM, 0);
> > +   utdm->siram = devm_ioremap_resource(_siram->dev, res);
> > if (IS_ERR(utdm->siram)) {
> > ret = PTR_ERR(utdm->siram);
> > goto err_miss_siram_property; @@ -174,7 +174,7 @@
> int
> > ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm,
> > return ret;
> >
> >  err_miss_siram_property:
> > -   devm_iounmap(>dev, utdm->si_regs);
> > +   devm_iounmap(_si->dev, utdm->si_regs);
> > return ret;
> >  }
> >  EXPORT_SYMBOL(ucc_of_parse_tdm);
> > --
> > 2.9.5
> >


[PATCH 1/2 fix] lib/genalloc.c: Use the vzalloc_node to allocate the bitmap.

2018-12-24 Thread Huang Shijie
Some devices may have big memory on chip, such as over 1G.
In some cases, the nbytes maybe bigger then 4M which is the bounday of
the memory buddy system (4K default).

So use vzalloc_node() to allocate the bitmap.
Also use vfree to free the it.

Signed-off-by: Huang Shijie 
---
The v1 did not free the memory with vfree.
This patch fixes it.

---
 lib/genalloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/genalloc.c b/lib/genalloc.c
index 5deb25c40a5a..f365d71cdc77 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -187,7 +187,7 @@ int gen_pool_add_virt(struct gen_pool *pool, unsigned long 
virt, phys_addr_t phy
int nbytes = sizeof(struct gen_pool_chunk) +
BITS_TO_LONGS(nbits) * sizeof(long);
 
-   chunk = kzalloc_node(nbytes, GFP_KERNEL, nid);
+   chunk = vzalloc_node(nbytes, nid);
if (unlikely(chunk == NULL))
return -ENOMEM;
 
@@ -251,7 +251,7 @@ void gen_pool_destroy(struct gen_pool *pool)
bit = find_next_bit(chunk->bits, end_bit, 0);
BUG_ON(bit < end_bit);
 
-   kfree(chunk);
+   vfree(chunk);
}
kfree_const(pool->name);
kfree(pool);
-- 
2.17.1



[PATCH v7 2/2] arm: dts: mt2712: add uart APDMA to device tree

2018-12-24 Thread Long Cheng
1. add uart APDMA controller device node
2. add uart 0/1/2/3/4/5 DMA function

Signed-off-by: Long Cheng 
---
 arch/arm64/boot/dts/mediatek/mt2712e.dtsi |   50 +
 1 file changed, 50 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi 
b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
index 976d92a..be1a22a 100644
--- a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
@@ -300,6 +300,9 @@
interrupts = ;
clocks = <_clk>, <_clk>;
clock-names = "baud", "bus";
+   dmas = < 10
+11>;
+   dma-names = "tx", "rx";
status = "disabled";
};
 
@@ -369,6 +372,38 @@
 (GIC_CPU_MASK_RAW(0x13) | IRQ_TYPE_LEVEL_HIGH)>;
};
 
+   apdma: dma-controller@11000400 {
+   compatible = "mediatek,mt2712-uart-dma",
+"mediatek,mt6577-uart-dma";
+   reg = <0 0x11000400 0 0x80>,
+ <0 0x11000480 0 0x80>,
+ <0 0x11000500 0 0x80>,
+ <0 0x11000580 0 0x80>,
+ <0 0x11000600 0 0x80>,
+ <0 0x11000680 0 0x80>,
+ <0 0x11000700 0 0x80>,
+ <0 0x11000780 0 0x80>,
+ <0 0x11000800 0 0x80>,
+ <0 0x11000880 0 0x80>,
+ <0 0x11000900 0 0x80>,
+ <0 0x11000980 0 0x80>;
+   interrupts = ,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+;
+   clocks = < CLK_PERI_AP_DMA>;
+   clock-names = "apdma";
+   #dma-cells = <1>;
+   };
+
auxadc: adc@11001000 {
compatible = "mediatek,mt2712-auxadc";
reg = <0 0x11001000 0 0x1000>;
@@ -385,6 +420,9 @@
interrupts = ;
clocks = <_clk>, <_clk>;
clock-names = "baud", "bus";
+   dmas = < 0
+1>;
+   dma-names = "tx", "rx";
status = "disabled";
};
 
@@ -395,6 +433,9 @@
interrupts = ;
clocks = <_clk>, <_clk>;
clock-names = "baud", "bus";
+   dmas = < 2
+3>;
+   dma-names = "tx", "rx";
status = "disabled";
};
 
@@ -405,6 +446,9 @@
interrupts = ;
clocks = <_clk>, <_clk>;
clock-names = "baud", "bus";
+   dmas = < 4
+5>;
+   dma-names = "tx", "rx";
status = "disabled";
};
 
@@ -415,6 +459,9 @@
interrupts = ;
clocks = <_clk>, <_clk>;
clock-names = "baud", "bus";
+   dmas = < 6
+7>;
+   dma-names = "tx", "rx";
status = "disabled";
};
 
@@ -629,6 +676,9 @@
interrupts = ;
clocks = <_clk>, <_clk>;
clock-names = "baud", "bus";
+   dmas = < 8
+9>;
+   dma-names = "tx", "rx";
status = "disabled";
};
 
-- 
1.7.9.5



[PATCH v7 1/2] dmaengine: 8250_mtk_dma: add MediaTek uart DMA support

2018-12-24 Thread Long Cheng
In DMA engine framework, add 8250 uart dma to support MediaTek uart.
If MediaTek uart enabled(SERIAL_8250_MT6577), and want to improve
the performance, can enable the function.

Signed-off-by: Long Cheng 
---
 drivers/dma/mediatek/8250_mtk_dma.c |  694 +++
 drivers/dma/mediatek/Kconfig|   11 +
 drivers/dma/mediatek/Makefile   |1 +
 3 files changed, 706 insertions(+)
 create mode 100644 drivers/dma/mediatek/8250_mtk_dma.c

diff --git a/drivers/dma/mediatek/8250_mtk_dma.c 
b/drivers/dma/mediatek/8250_mtk_dma.c
new file mode 100644
index 000..c4090f2
--- /dev/null
+++ b/drivers/dma/mediatek/8250_mtk_dma.c
@@ -0,0 +1,694 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * MediaTek 8250 DMA driver.
+ *
+ * Copyright (c) 2018 MediaTek Inc.
+ * Author: Long Cheng 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../virt-dma.h"
+
+#define MTK_UART_APDMA_CHANNELS(CONFIG_SERIAL_8250_NR_UARTS * 
2)
+
+#define VFF_EN_B   BIT(0)
+#define VFF_STOP_B BIT(0)
+#define VFF_FLUSH_BBIT(0)
+#define VFF_4G_SUPPORT_B   BIT(0)
+#define VFF_RX_INT_EN0_B   BIT(0)  /*rx valid size >=  vff thre*/
+#define VFF_RX_INT_EN1_B   BIT(1)
+#define VFF_TX_INT_EN_BBIT(0)  /*tx left size >= vff thre*/
+#define VFF_WARM_RST_B BIT(0)
+#define VFF_RX_INT_FLAG_CLR_B  (BIT(0) | BIT(1))
+#define VFF_TX_INT_FLAG_CLR_B  0
+#define VFF_STOP_CLR_B 0
+#define VFF_FLUSH_CLR_B0
+#define VFF_INT_EN_CLR_B   0
+#define VFF_4G_SUPPORT_CLR_B   0
+
+/* interrupt trigger level for tx */
+#define VFF_TX_THRE(n) ((n) * 7 / 8)
+/* interrupt trigger level for rx */
+#define VFF_RX_THRE(n) ((n) * 3 / 4)
+
+#define MTK_UART_APDMA_RING_SIZE   0xU
+/* invert this bit when wrap ring head again*/
+#define MTK_UART_APDMA_RING_WRAP   0x1U
+
+#define VFF_INT_FLAG   0x00
+#define VFF_INT_EN 0x04
+#define VFF_EN 0x08
+#define VFF_RST0x0c
+#define VFF_STOP   0x10
+#define VFF_FLUSH  0x14
+#define VFF_ADDR   0x1c
+#define VFF_LEN0x24
+#define VFF_THRE   0x28
+#define VFF_WPT0x2c
+#define VFF_RPT0x30
+/*TX: the buffer size HW can read. RX: the buffer size SW can read.*/
+#define VFF_VALID_SIZE 0x3c
+/*TX: the buffer size SW can write. RX: the buffer size HW can write.*/
+#define VFF_LEFT_SIZE  0x40
+#define VFF_DEBUG_STATUS   0x50
+#define VFF_4G_SUPPORT 0x54
+
+struct mtk_uart_apdmadev {
+   struct dma_device ddev;
+   struct clk *clk;
+   bool support_33bits;
+   unsigned int dma_irq[MTK_UART_APDMA_CHANNELS];
+};
+
+struct mtk_uart_apdma_desc {
+   struct virt_dma_desc vd;
+
+   unsigned int avail_len;
+};
+
+struct mtk_chan {
+   struct virt_dma_chan vc;
+   struct dma_slave_config cfg;
+   void __iomem *base;
+   struct mtk_uart_apdma_desc *desc;
+
+   bool requested;
+
+   unsigned int rx_status;
+};
+
+static inline struct mtk_uart_apdmadev *
+to_mtk_uart_apdma_dev(struct dma_device *d)
+{
+   return container_of(d, struct mtk_uart_apdmadev, ddev);
+}
+
+static inline struct mtk_chan *to_mtk_uart_apdma_chan(struct dma_chan *c)
+{
+   return container_of(c, struct mtk_chan, vc.chan);
+}
+
+static inline struct mtk_uart_apdma_desc *to_mtk_uart_apdma_desc
+   (struct dma_async_tx_descriptor *t)
+{
+   return container_of(t, struct mtk_uart_apdma_desc, vd.tx);
+}
+
+static void mtk_uart_apdma_chan_write(struct mtk_chan *c,
+  unsigned int reg, unsigned int val)
+{
+   writel(val, c->base + reg);
+}
+
+static unsigned int
+mtk_uart_apdma_chan_read(struct mtk_chan *c, unsigned int reg)
+{
+   return readl(c->base + reg);
+}
+
+static void mtk_uart_apdma_desc_free(struct virt_dma_desc *vd)
+{
+   struct dma_chan *chan = vd->tx.chan;
+   struct mtk_chan *c = to_mtk_uart_apdma_chan(chan);
+
+   kfree(c->desc);
+   c->desc = NULL;
+}
+
+static void mtk_uart_apdma_start_tx(struct mtk_chan *c)
+{
+   unsigned int txcount = c->desc->avail_len;
+   unsigned int len, send, left, wpt, wrap;
+
+   if (mtk_uart_apdma_chan_read(c, VFF_LEFT_SIZE) == 0U) {
+   mtk_uart_apdma_chan_write(c, VFF_INT_EN, VFF_TX_INT_EN_B);
+   } else {
+   len = mtk_uart_apdma_chan_read(c, VFF_LEN);
+
+   while (((left = mtk_uart_apdma_chan_read(c,
+   VFF_LEFT_SIZE)) > 0U)
+   && (c->desc->avail_len != 0U)) {
+   send = min_t(unsigned int, left, c->desc->avail_len);
+   wpt = mtk_uart_apdma_chan_read(c, 

[PATCH v7 0/2] add uart DMA function

2018-12-24 Thread Long Cheng
In Mediatek SOCs, the uart can support DMA function.
Base on DMA engine formwork, we add the DMA code to support uart. And put the 
code under drivers/dma.

This series contains document bindings, Kconfig to control the function enable 
or not,
device tree including interrupt and dma device node, the code of UART DMA

Changes compared to v6:
-Correct spelling
Changes compared to v5:
-move 'requst irqs' to alloc channel
-remove tasklet.
Changes compared to v4:
-modify Kconfig depends on.
Changes compared to v3:
-fix CONFIG_PM, will cause build fail
Changes compared to v2:
-remove unimportant parameters
-instead of cookie, use APIs of virtual channel.
-use of_dma_xlate_by_chan_id.
Changes compared to v1:
-mian revised file, 8250_mtk_dma.c
--parameters renamed for standard
--remove atomic operation


Long Cheng (2):
  dmaengine: 8250_mtk_dma: add MediaTek uart DMA support
  arm: dts: mt2712: add uart APDMA to device tree

 arch/arm64/boot/dts/mediatek/mt2712e.dtsi |   50 +++
 drivers/dma/mediatek/8250_mtk_dma.c   |  694 +
 drivers/dma/mediatek/Kconfig  |   11 +
 drivers/dma/mediatek/Makefile |1 +
 4 files changed, 756 insertions(+)
 create mode 100644 drivers/dma/mediatek/8250_mtk_dma.c

-- 
1.7.9.5



[GIT PULL] x86/platform change for v4.21

2018-12-24 Thread Ingo Molnar
Linus,

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

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

   # HEAD: c04e55388a4f2184e37827a1d2e733cded52d653 x86/platform/olpc: Do not 
call of_platform_bus_probe()

An OLPC platform support simplification patch.

 Thanks,

Ingo

-->
Rob Herring (1):
  x86/platform/olpc: Do not call of_platform_bus_probe()


 arch/x86/platform/olpc/olpc_dt.c | 18 --
 1 file changed, 18 deletions(-)


Re: rfc: bool structure members (was Re: [PATCH V3] net/mlx4: Get rid of page operation after dma_alloc_coherent)

2018-12-24 Thread Jason Gunthorpe
On Sun, Dec 23, 2018 at 06:42:20PM +0200, Gal Pressman wrote:
> On 22-Dec-18 01:52, Jason Gunthorpe wrote:
> > On Thu, Dec 20, 2018 at 09:12:43PM -0800, Joe Perches wrote:
> >> Care to submit a coding_style.rst patch or
> >> improve the one below this?
> > 
> > I took yours and revised it a little bit. I spent some time looking at
> > assembly and decided to drop the performance note, the number of cases
> > that run into overhead seems pretty small and probably already
> > requires !! to be correct. There is also an equally unlikely gain, ie
> > 'if (a & b)' optimizes a tiny bit better for bool types.
> > 
> > I also added a small intro on bool, as I know some people are
> > unfamiliar with C11 _Bool and might think bool is just '#define bool
> > u8'
> > 
> > (for those added to the cc) I'm looking at cases, like the patch that
> > spawned this, where the struct has a single bool and no performance
> > considerations. As CH said, seeing that get converted to int due to
> > checkpatch is worse than having used bool. Using u8 won't make this
> > struct smaller or faster.
> > 
> 
> Since a "Using bool" section is added, perhaps it's worth documenting the bool
> usage as a function parameter [1]?
> 
> [1] https://www.spinics.net/lists/linux-rdma/msg72336.html

I'm not really sure how to express that as something concrete.. That
specific case clearly called out for a flags as it was a widely used
API - maybe less spread out cases like static functions or something
are OK??

Jason


Build regressions/improvements in v4.20

2018-12-24 Thread Geert Uytterhoeven
Below is the list of build error/warning regressions/improvements in
v4.20[1] compared to v4.19[2].

Summarized:
  - build errors: +3/-0
  - build warnings: +489/-453

JFYI, when comparing v4.20[1] to v4.20-rc7[3], the summaries are:
  - build errors: +0/-0
  - build warnings: +120/-144

Happy fixing! ;-)

Thanks to the linux-next team for providing the build service.

[1] 
http://kisskb.ellerman.id.au/kisskb/branch/linus/head/8fe28cb58bcb235034b64cbbb7550a8a43fd88be/
 (all 240 configs)
[2] 
http://kisskb.ellerman.id.au/kisskb/branch/linus/head/84df9525b0c27f3ebc2ebb1864fa62a97fdedb7d/
 (all 240 configs)
[3] 
http://kisskb.ellerman.id.au/kisskb/branch/linus/head/7566ec393f4161572ba6f11ad5171fd5d59b0fbd/
 (all 240 configs)


*** ERRORS ***

3 error regressions:
  + /kisskb/src/arch/s390/kernel/nospec-branch.c: error: macro "memcpy" passed 
6 arguments, but takes just 3:  => 130:61
  + /kisskb/src/sound/pci/hda/patch_ca0132.c: error: implicit declaration of 
function 'pci_iomap' [-Werror=implicit-function-declaration]:  => 8800:3
  + /kisskb/src/sound/pci/hda/patch_ca0132.c: error: implicit declaration of 
function 'pci_iounmap' [-Werror=implicit-function-declaration]:  => 8417:3


*** WARNINGS ***

[Deleted 632 lines about "warning: -ffunction-sections disabled; it makes 
profiling impossible [enabled by default]" on powerpc-all{mod,yes}config*]

489 warning regressions:
  + /kisskb/src/arch/arc/mm/tlb.c: warning: ISO C90 forbids variable length 
array 'pd0' [-Wvla]:  => 914:2
  + /kisskb/src/arch/arc/mm/tlb.c: warning: variable length array 'pd0' is used 
[-Wvla]:  => 914:2
  + /kisskb/src/arch/m68k/atari/config.c: warning: variable length array 
'switches' is used [-Wvla]:  => 151:2
  + /kisskb/src/arch/m68k/kernel/signal.c: warning: variable length array 'buf' 
is used [-Wvla]:  => 654:3
  + /kisskb/src/arch/s390/kernel/machine_kexec.c: warning: 'do_start_kdump' 
defined but not used [-Wunused-function]:  => 145:22
  + /kisskb/src/arch/s390/kernel/nospec-branch.c: warning: statement with no 
effect [-Wunused-value]:  => 130:3
  + /kisskb/src/arch/um/os-Linux/umid.c: warning: ISO C90 forbids variable 
length array 'dir' [-Wvla]:  => 388:2
  + /kisskb/src/arch/um/os-Linux/umid.c: warning: ISO C90 forbids variable 
length array 'file' [-Wvla]:  => 213:2, 138:2
  + /kisskb/src/drivers/gpu/drm/drm_atomic_uapi.c: warning: format '%zu' 
expects argument of type 'size_t', but argument 5 has type 'unsigned int' 
[-Wformat=]:  => 131:21
  + /kisskb/src/drivers/lightnvm/core.c: warning: 'ret' may be used 
uninitialized in this function [-Wuninitialized]:  => 977:6
  + /kisskb/src/drivers/mtd/nand/raw/mpc5121_nfc.c: warning: unused variable 
'mtd' [-Wunused-variable]:  => 306:19
  + /kisskb/src/drivers/net/ethernet/broadcom/bnxt/bnxt.h: warning: "writeq" 
redefined [enabled by default]:  => 1631:0
  + /kisskb/src/drivers/net/ethernet/broadcom/bnxt/bnxt.h: warning: "writeq" 
redefined:  => 1631:0, 1631
  + /kisskb/src/drivers/net/ethernet/broadcom/bnxt/bnxt.h: warning: 
"writeq_relaxed" redefined [enabled by default]:  => 1639:0
  + /kisskb/src/drivers/net/ethernet/broadcom/bnxt/bnxt.h: warning: 
"writeq_relaxed" redefined:  => 1639:0, 1639
  + /kisskb/src/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c: warning: 
the frame size of 1200 bytes is larger than 1024 bytes [-Wframe-larger-than=]:  
=> 216:1
  + /kisskb/src/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c: warning: 
the frame size of 1232 bytes is larger than 1024 bytes [-Wframe-larger-than=]:  
=> 216:1
  + /kisskb/src/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c: warning: 
the frame size of 1248 bytes is larger than 1024 bytes [-Wframe-larger-than=]:  
=> 216:1
  + /kisskb/src/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c: warning: 
the frame size of 1528 bytes is larger than 1024 bytes [-Wframe-larger-than=]:  
=> 216:1
  + /kisskb/src/drivers/net/wireless/quantenna/qtnfmac/commands.c: warning: 
'resp' may be used uninitialized in this function [-Wmaybe-uninitialized]:  => 
133:54
  + /kisskb/src/drivers/net/wireless/quantenna/qtnfmac/commands.c: warning: 
'resp' may be used uninitialized in this function [-Wuninitialized]:  => 133:38
  + /kisskb/src/drivers/scsi/myrs.c: warning: 'sshdr.sense_key' may be used 
uninitialized in this function [-Wmaybe-uninitialized]:  => 821:24
  + /kisskb/src/kernel/rcu/srcutree.c: warning: 'levelspread[]' may be 
used uninitialized in this function [-Wuninitialized]:  => 152:32
  + /kisskb/src/kernel/rcu/srcutree.c: warning: 'levelspread[]' may be 
used uninitialized in this function [-Wuninitialized]:  => 152:32
  + /kisskb/src/kernel/rcu/srcutree.c: warning: 'levelspread[]' may be 
used uninitialized in this function [-Wuninitialized]:  => 133:33
  + /kisskb/src/kernel/rcu/srcutree.c: warning: 'levelspread[]' may be 
used uninitialized in this function [-Wuninitialized]:  => 133:33
  + /kisskb/src/kernel/rcu/srcutree.c: warning: 'levelspread[]' may be 
used uninitialized in this function 

[GIT PULL] x86/mm changes for v4.21

2018-12-24 Thread Ingo Molnar
Linus,

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

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

   # HEAD: 6848ac7ca39a226ede5df7af0efcc4ef0611e99c x86/mm/dump_pagetables: Use 
DEFINE_SHOW_ATTRIBUTE()

The main changes in this cycle were:

 - Update and clean up x86 fault handling, by Andy Lutomirski.

 - Drop usage of __flush_tlb_all() in kernel_physical_mapping_init() and 
   related fallout, by Dan Williams.

 - CPA cleanups and reorganization by Peter Zijlstra: simplify the flow 
   and remove a few warts.

 - Other misc cleanups.

  out-of-topic modifications in x86-mm-for-linus:
  -
  include/asm-generic/5level-fixup.h # 0a9fe8ca844d: x86/mm: Validate 
kernel_phys
  include/asm-generic/pgtable-nop4d-hack.h# 0a9fe8ca844d: x86/mm: Validate 
kernel_phys
  include/asm-generic/pgtable-nop4d.h# 0a9fe8ca844d: x86/mm: Validate 
kernel_phys
  include/asm-generic/pgtable-nopud.h# 0a9fe8ca844d: x86/mm: Validate 
kernel_phys
  include/asm-generic/pgtable.h  # 4369deaa2f02: generic/pgtable: Introduce 
s
   # 0cebbb60f759: generic/pgtable: Introduce {
   # c683c37cd132: generic/pgtable: Make {pmd, 

 Thanks,

Ingo

-->
Andy Lutomirski (12):
  x86/fault: Check user_mode(regs) when avoiding an mmap_sem deadlock
  x86/cpufeatures, x86/fault: Mark SMAP as disabled when configured out
  x86/fault: Fold smap_violation() into do_user_addr_fault()
  x86/fault: Fix SMAP #PF handling buglet for implicit supervisor accesses
  x86/fault: Improve the condition for signalling vs OOPSing
  x86/fault: Make error_code sanitization more robust
  x86/fault: Don't set thread.cr2, etc before OOPSing
  x86/fault: Remove sw_error_code
  x86/fault: Don't try to recover from an implicit supervisor access
  x86/oops: Show the correct CS value in show_regs()
  x86/vsyscall/64: Use X86_PF constants in the simulated #PF error code
  x86/fault: Decode page fault OOPSes better

Dan Williams (5):
  generic/pgtable: Make {pmd, pud}_same() unconditionally available
  generic/pgtable: Introduce {p4d,pgd}_same()
  generic/pgtable: Introduce set_pte_safe()
  x86/mm: Validate kernel_physical_mapping_init() PTE population
  x86/mm: Drop usage of __flush_tlb_all() in kernel_physical_mapping_init()

Ingo Molnar (1):
  x86/fault: Clean up the page fault oops decoder a bit

Peter Zijlstra (9):
  x86/mm/cpa: Add ARRAY and PAGES_ARRAY selftests
  x86/mm/cpa: Add __cpa_addr() helper
  x86/mm/cpa: Make cpa_data::vaddr invariant
  x86/mm/cpa: Simplify the code after making cpa->vaddr invariant
  x86/mm/cpa: Optimize cpa_flush_array() TLB invalidation
  x86/mm/cpa: Make cpa_data::numpages invariant
  x86/mm/cpa: Fold cpa_flush_range() and cpa_flush_array() into a single 
cpa_flush() function
  x86/mm/cpa: Better use CLFLUSHOPT
  x86/mm/cpa: Rename @addrinarray to @numpages

Waiman Long (1):
  x86/mm/fault: Allow stack access below %rsp

Yangtao Li (1):
  x86/mm/dump_pagetables: Use DEFINE_SHOW_ATTRIBUTE()


 arch/x86/entry/vsyscall/vsyscall_64.c|   2 +-
 arch/x86/include/asm/disabled-features.h |   8 +-
 arch/x86/include/asm/pgalloc.h   |  27 +++
 arch/x86/kernel/process_64.c |   5 +-
 arch/x86/mm/debug_pagetables.c   |  58 +--
 arch/x86/mm/fault.c  | 244 +---
 arch/x86/mm/init_64.c|  30 ++--
 arch/x86/mm/mm_internal.h|   2 +
 arch/x86/mm/pageattr-test.c  |  31 +++-
 arch/x86/mm/pageattr.c   | 271 +--
 arch/x86/mm/tlb.c|   4 +-
 include/asm-generic/5level-fixup.h   |   1 +
 include/asm-generic/pgtable-nop4d-hack.h |   1 +
 include/asm-generic/pgtable-nop4d.h  |   1 +
 include/asm-generic/pgtable-nopud.h  |   1 +
 include/asm-generic/pgtable.h|  56 ++-
 16 files changed, 396 insertions(+), 346 deletions(-)



[GIT PULL] x86/fpu changes for v4.21

2018-12-24 Thread Ingo Molnar
Linus,

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

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

   # HEAD: 12209993e98c5fa1855c467f22a24e3d5b8be205 x86/fpu: Don't export 
__kernel_fpu_{begin,end}()

Misc preparatory changes for an upcoming FPU optimization that will delay 
the loading of FPU registers to return-to-userspace.

 Thanks,

Ingo

-->
Sebastian Andrzej Siewior (7):
  x86/fpu: Use unsigned long long shift in xfeature_uncompacted_offset()
  x86/process/32: Remove asm/math_emu.h include
  x86/thread_info: Remove _TIF_ALLWORK_MASK
  x86/pkeys: Make init_pkru_value static
  x86/fpu: Add might_fault() to user_insn()
  x86/fpu: Update comment for __raw_xsave_addr()
  x86/fpu: Don't export __kernel_fpu_{begin,end}()


 arch/x86/include/asm/efi.h  |  6 ++
 arch/x86/include/asm/fpu/api.h  | 15 +--
 arch/x86/include/asm/fpu/internal.h |  3 +++
 arch/x86/include/asm/thread_info.h  |  8 
 arch/x86/kernel/fpu/core.c  |  6 ++
 arch/x86/kernel/fpu/xstate.c|  4 +---
 arch/x86/kernel/process_32.c|  3 ---
 arch/x86/mm/pkeys.c |  1 +
 8 files changed, 14 insertions(+), 32 deletions(-)


[GIT PULL] x86/cpu changes for v4.21

2018-12-24 Thread Ingo Molnar
Linus,

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

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

   # HEAD: aa02ef099cff042c2a9109782ec2bf1bffc955d4 x86/topology: Use 
total_cpus for max logical packages calculation

Misc changes:

 - Fix nr_cpus= boot option interaction bug with logical package 
   management

 - Clean up UMIP detection messages

 - Add WBNOINVD instruction detection

 - Remove the unused get_scattered_cpuid_leaf() function.

 Thanks,

Ingo

-->
Borislav Petkov (1):
  x86/umip: Print UMIP line only once

Hui Wang (1):
  x86/topology: Use total_cpus for max logical packages calculation

Janakarajan Natarajan (1):
  x86/cpufeatures: Add WBNOINVD feature definition

Lendacky, Thomas (1):
  x86/umip: Make the UMIP activated message generic

Sean Christopherson (1):
  x86/cpufeatures: Remove get_scattered_cpuid_leaf()


 arch/x86/include/asm/cpufeatures.h |  1 +
 arch/x86/kernel/cpu/common.c   |  2 +-
 arch/x86/kernel/cpu/cpu.h  |  3 ---
 arch/x86/kernel/cpu/scattered.c| 24 
 arch/x86/kernel/smpboot.c  |  2 +-
 5 files changed, 3 insertions(+), 29 deletions(-)



Re: [GIT PULL] x86/amd-nb changes for v4.21

2018-12-24 Thread Guenter Roeck

On 12/24/18 2:50 PM, Ingo Molnar wrote:

Linus,

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

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

# HEAD: 210ba1201ff950b3d05bfd8fa5d47540cea393c0 hwmon/k10temp: Add support 
for AMD family 17h, model 30h CPUs

Update DF/SMN access and k10temp for AMD F17h M30h, by Brian Woods:

   "Updates the data fabric/system management network code needed to get
k10temp working for M30h.  Since there are now processors which have
multiple roots per DF/SMN interface, there needs to some logic which
skips N-1 root complexes per DF/SMN interface.  This is because the root
complexes per interface are redundant (as far as DF/SMN goes).  These
changes shouldn't effect past processors and, for F17h M0Xh, the
mappings stay the same."

The hwmon changes were seen and acked by hwmon maintainer Guenter Roeck.

   out-of-topic modifications in x86-amd-nb-for-linus:
   -
   drivers/hwmon/k10temp.c# 210ba1201ff9: hwmon/k10temp: Add 
support f
# dedf7dce4cec: hwmon/k10temp, x86/amd_nb: C


This will likely result in a minor conflict against the changes coming in
from the hwmon tree (overlapping PCI IDs). Resolution is to accept both changes.

Guenter


   include/linux/pci_ids.h# be3518a16ef2: x86/amd_nb: Add PCI 
device I
# dedf7dce4cec: hwmon/k10temp, x86/amd_nb: C

  Thanks,

Ingo

-->
Woods, Brian (4):
   hwmon/k10temp, x86/amd_nb: Consolidate shared device IDs
   x86/amd_nb: Add support for newer PCI topologies
   x86/amd_nb: Add PCI device IDs for family 17h, model 30h
   hwmon/k10temp: Add support for AMD family 17h, model 30h CPUs


  arch/x86/kernel/amd_nb.c | 53 
  drivers/hwmon/k10temp.c  | 10 ++---
  include/linux/pci_ids.h  |  3 +++
  3 files changed, 50 insertions(+), 16 deletions(-)





[GIT PULL] x86/cleanups for v4.21

2018-12-24 Thread Ingo Molnar
Linus,

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

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

   # HEAD: 4b1bacab61aa252d15dde99cd0440a965bd863e5 x86/kprobes: Remove 
trampoline_handler() prototype

Misc cleanups.

  out-of-topic modifications in x86-cleanups-for-linus:
  ---
  include/acpi/cppc_acpi.h   # ad3bc25a3207: x86/kernel: Fix more 
-Wmissi
  include/linux/ftrace.h # 89f579ce99f7: x86/headers: Fix 
-Wmissing-p
  include/linux/kexec.h  # 89f579ce99f7: x86/headers: Fix 
-Wmissing-p
  include/linux/kprobes.h# ad3bc25a3207: x86/kernel: Fix more 
-Wmissi
  include/linux/of_fdt.h # 89f579ce99f7: x86/headers: Fix 
-Wmissing-p
  include/linux/ptrace.h # 89f579ce99f7: x86/headers: Fix 
-Wmissing-p

 Thanks,

Ingo

-->
Borislav Petkov (5):
  x86/gart: Rewrite early_gart_iommu_check() comment
  x86/mce: Fix -Wmissing-prototypes warnings
  x86/traps: Complete prototype declarations
  x86/kernel: Fix more -Wmissing-prototypes warnings
  x86/kprobes: Remove trampoline_handler() prototype

Ingo Molnar (1):
  x86: Fix various typos in comments

Yafang Shao (1):
  x86/process: Avoid unnecessary NULL check in get_wchan()

Yi Wang (1):
  x86/headers: Fix -Wmissing-prototypes warning


 arch/x86/crypto/cast5_avx_glue.c   |  2 +-
 arch/x86/crypto/cast6_avx_glue.c   |  2 +-
 arch/x86/entry/common.c|  2 +-
 arch/x86/entry/vdso/vma.c  |  2 +-
 arch/x86/events/intel/bts.c|  2 +-
 arch/x86/events/intel/core.c   |  2 +-
 arch/x86/events/intel/ds.c |  2 +-
 arch/x86/events/intel/p4.c |  2 +-
 arch/x86/include/asm/alternative.h |  2 +-
 arch/x86/include/asm/cmpxchg.h |  2 +-
 arch/x86/include/asm/crash.h   |  1 +
 arch/x86/include/asm/efi.h |  2 +-
 arch/x86/include/asm/irq.h |  7 +++
 arch/x86/include/asm/irq_work.h|  1 +
 arch/x86/include/asm/kvm_para.h|  1 +
 arch/x86/include/asm/paravirt.h|  5 ++
 arch/x86/include/asm/reboot.h  |  1 +
 arch/x86/include/asm/setup.h   |  3 ++
 arch/x86/include/asm/sighandling.h |  5 ++
 arch/x86/include/asm/smp.h |  6 +++
 arch/x86/include/asm/trace/exceptions.h|  1 +
 arch/x86/include/asm/trace/irq_vectors.h   |  1 +
 arch/x86/include/asm/traps.h   | 59 +-
 arch/x86/include/asm/tsc.h |  1 +
 arch/x86/kernel/acpi/boot.c|  2 +-
 arch/x86/kernel/aperture_64.c  | 25 +
 arch/x86/kernel/apic/apic.c|  1 +
 arch/x86/kernel/apic/apic_flat_64.c|  7 +--
 arch/x86/kernel/apic/vector.c  |  1 +
 arch/x86/kernel/apic/x2apic_uv_x.c |  4 +-
 arch/x86/kernel/asm-offsets.c  |  3 +-
 arch/x86/kernel/check.c|  3 +-
 arch/x86/kernel/cpu/amd.c  |  1 +
 arch/x86/kernel/cpu/aperfmperf.c   |  1 +
 arch/x86/kernel/cpu/bugs.c |  2 +
 arch/x86/kernel/cpu/cacheinfo.c|  1 +
 arch/x86/kernel/cpu/mcheck/mce.c   |  2 +-
 arch/x86/kernel/cpu/mcheck/mce_amd.c   |  5 +-
 arch/x86/kernel/cpu/mcheck/therm_throt.c   |  3 +-
 arch/x86/kernel/cpu/mcheck/threshold.c |  3 +-
 arch/x86/kernel/cpu/scattered.c|  3 +-
 arch/x86/kernel/cpu/topology.c |  2 +
 arch/x86/kernel/crash.c|  1 +
 arch/x86/kernel/crash_dump_64.c|  2 +-
 arch/x86/kernel/devicetree.c   |  1 +
 arch/x86/kernel/fpu/xstate.c   |  2 +-
 arch/x86/kernel/jailhouse.c|  1 +
 arch/x86/kernel/kprobes/core.c |  2 +-
 arch/x86/kernel/process.c  |  5 +-
 arch/x86/kernel/process_64.c   |  2 +-
 arch/x86/kernel/quirks.c   |  1 +
 arch/x86/kernel/sysfb_efi.c|  3 ++
 arch/x86/kernel/tracepoint.c   |  2 +
 arch/x86/kvm/vmx.c |  4 +-
 arch/x86/kvm/x86.c |  2 +-
 arch/x86/mm/pageattr.c |  2 +-
 arch/x86/platform/ce4100/ce4100.c  |  4 +-
 .../intel-mid/device_libs/platform_bcm43xx.c   |  2 +-
 .../intel-mid/device_libs/platform_mrfld_spidev.c  |  2 +-
 

[GIT PULL] x86/amd-nb changes for v4.21

2018-12-24 Thread Ingo Molnar
Linus,

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

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

   # HEAD: 210ba1201ff950b3d05bfd8fa5d47540cea393c0 hwmon/k10temp: Add support 
for AMD family 17h, model 30h CPUs

Update DF/SMN access and k10temp for AMD F17h M30h, by Brian Woods:

  "Updates the data fabric/system management network code needed to get
   k10temp working for M30h.  Since there are now processors which have
   multiple roots per DF/SMN interface, there needs to some logic which
   skips N-1 root complexes per DF/SMN interface.  This is because the root
   complexes per interface are redundant (as far as DF/SMN goes).  These
   changes shouldn't effect past processors and, for F17h M0Xh, the
   mappings stay the same."

The hwmon changes were seen and acked by hwmon maintainer Guenter Roeck.

  out-of-topic modifications in x86-amd-nb-for-linus:
  -
  drivers/hwmon/k10temp.c# 210ba1201ff9: hwmon/k10temp: Add support 
f
   # dedf7dce4cec: hwmon/k10temp, x86/amd_nb: C
  include/linux/pci_ids.h# be3518a16ef2: x86/amd_nb: Add PCI device 
I
   # dedf7dce4cec: hwmon/k10temp, x86/amd_nb: C

 Thanks,

Ingo

-->
Woods, Brian (4):
  hwmon/k10temp, x86/amd_nb: Consolidate shared device IDs
  x86/amd_nb: Add support for newer PCI topologies
  x86/amd_nb: Add PCI device IDs for family 17h, model 30h
  hwmon/k10temp: Add support for AMD family 17h, model 30h CPUs


 arch/x86/kernel/amd_nb.c | 53 
 drivers/hwmon/k10temp.c  | 10 ++---
 include/linux/pci_ids.h  |  3 +++
 3 files changed, 50 insertions(+), 16 deletions(-)


[GIT PULL] x86/build changes for v4.21

2018-12-24 Thread Ingo Molnar
Linus,

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

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

   # HEAD: e4f752dda0de351efd198f438b68e743029da68a x86/um/vdso: Drop implicit 
common-page-size linker flag

 - resolve LLVM build bug by removing redundant GNU specific flag

 - remove obsolete -funit-at-a-time and -fno-unit-at-a-time use from x86 
   PowerPC and UM.

The UML change was seen and acked by UML maintainer Richard Weinberger.

  out-of-topic modifications in x86-build-for-linus:
  
  arch/powerpc/Makefile  # 63fea0af43af: x86, powerpc: Remove 
-funit-

 Thanks,

Ingo

-->
Masahiro Yamada (2):
  x86/um: Remove -fno-unit-at-a-time workaround for pre-4.0 GCC
  x86, powerpc: Remove -funit-at-a-time compiler option entirely

Nick Desaulniers (1):
  x86/um/vdso: Drop implicit common-page-size linker flag


 arch/powerpc/Makefile | 4 
 arch/x86/Makefile | 4 
 arch/x86/Makefile.um  | 9 -
 arch/x86/um/vdso/Makefile | 2 +-
 4 files changed, 1 insertion(+), 18 deletions(-)


[GIT PULL] x86/boot changes for v4.21

2018-12-24 Thread Ingo Molnar
Linus,

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

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

   # HEAD: 69be4efeb959147ff86f22e35aea9526f9b86715 x86/boot: Add missing 
va_end() to die()

Two cleanups.

 Thanks,

Ingo

-->
Jordan Borgner (1):
  x86/boot: Simplify the detect_memory*() control flow

Mattias Jacobsson (1):
  x86/boot: Add missing va_end() to die()


 arch/x86/boot/boot.h|  2 +-
 arch/x86/boot/memory.c  | 31 ++-
 arch/x86/boot/tools/build.c |  1 +
 3 files changed, 12 insertions(+), 22 deletions(-)



[GIT PULL] x86/asm changes for v4.21

2018-12-24 Thread Ingo Molnar
Linus,

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

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

   # HEAD: 29434801e7e9c6d05fbea4533b3c0bd6be612f62 x86/vdso: Remove a 
stale/misleading comment from the linker script

Two changes:

 - Remove (some) remnants of the vDSO's fake section table mechanism that
   were left behind when the vDSO build process reverted to using
   "objdump -S" to strip the userspace image.

 - Remove hardcoded POPCNT mnemonics now that the minimum binutils 
   version supports the symbolic form.

 Thanks,

Ingo

-->
Sean Christopherson (2):
  x86/vdso: Remove obsolete "fake section table" reservation
  x86/vdso: Remove a stale/misleading comment from the linker script

Uros Bizjak (1):
  x86: Use POPCNT mnemonics in arch_hweight.h


 arch/x86/entry/vdso/vdso-layout.lds.S | 27 ---
 arch/x86/entry/vdso/vdso2c.c  |  8 
 arch/x86/include/asm/arch_hweight.h   | 10 ++
 3 files changed, 2 insertions(+), 43 deletions(-)


Re: [PATCH][V2] drivers/net: appletalk/cops: remove redundant if statement and mask

2018-12-24 Thread David Miller
From: Colin King 
Date: Mon, 24 Dec 2018 19:41:46 +

> From: Colin Ian King 
> 
> The two different assignments for pkt_len are actually the same and
> so the if statement is redundant and can be removed.  Masking a u8
> return value from inb() with 0xFF is also redundant and can also be
> emoved.
> 
> Similarly, the two different outb calls are identical as the mask
> of 0xff on the second outb is redundant since a u8 is being written,
> so the if statement is also redundant and can be also removed.
> 
> Detected by CoverityScan, CID#1475639 ("Identical code for different
> branches")
> 
> ---
> 
> V2: Remove the if statement for the outb calls, thanks to David
> Miller for spotting this.
> 
> Signed-off-by: Colin Ian King 

Colin, I almost didn't notice how the "---" there is in the wrong spot
and therefore was cutting out your changelog and signoff.

I fixed it up, but please be more careful in the future.

Thanks.


Re: [PATCH v2] bnx2x: Fix NULL pointer dereference in bnx2x_del_all_vlans() on some hw

2018-12-24 Thread David Miller
From: Ivan Mironov 
Date: Mon, 24 Dec 2018 20:13:05 +0500

> This happened when I tried to boot normal Fedora 29 system with latest
> available kernel (from fedora rawhide, plus some unrelated custom
> patches):
 ...
> After some investigation I figured out that recently added cleanup code
> tries to call VLAN filtering de-initialization function which exist only
> for newer hardware. Corresponding function pointer is not
> set (== 0) for older hardware, namely these chips:
> 
>   #define CHIP_NUM_57710  0x164e
>   #define CHIP_NUM_57711  0x164f
>   #define CHIP_NUM_57711E 0x1650
> 
> And I have one of those in my test system:
> 
>   Broadcom Inc. and subsidiaries NetXtreme II BCM57711E 10-Gigabit PCIe 
> [14e4:1650]
> 
> Function bnx2x_init_vlan_mac_fp_objs() from
> drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h decides whether to
> initialize relevant pointers in bnx2x_sp_objs.vlan_obj or not.
> 
> This regression was introduced after v4.20-rc7, and still exists in v4.20
> release.
> 
> Fixes: 04f05230c5c13 ("bnx2x: Remove configured vlans as part of unload 
> sequence.")
> Signed-off-by: Ivan Mironov 

Applied, thanks.


Re: [PATCH] net/net_namespace: Check the return value of register_pernet_subsys()

2018-12-24 Thread David Miller
From: Aditya Pakki 
Date: Sun, 23 Dec 2018 19:42:38 -0600

> In net_ns_init(), register_pernet_subsys() could fail while registering
> network namespace subsystems. The fix checks the return value and
> sends a panic() on failure.
> 
> Signed-off-by: Aditya Pakki 

Applied.


[GIT PULL] scheduler changes for v4.21

2018-12-24 Thread Ingo Molnar
Linus,

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

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

   # HEAD: 732cd75b8c920d3727e69957b14faa7c2d7c3b75 sched/fair: Select an 
energy-efficient CPU on task wake-up

The main changes in this cycle were:

 - Introduce "Energy Aware Scheduling" - by Quentin Perret. This is a 
   coherent topology description of CPUs in cooperation with the PM 
   subsystem, with the goal to schedule more energy-efficiently on 
   assymetric SMP platform - such as waking up tasks to the more 
   energy-efficient CPUs first, as long as the system isn't 
   oversubscribed.

   For details of the design, see:

  https://marc.info/?l=linux-kernel=153243513908731=2

 - Misc cleanups and smaller enhancements.

 Thanks,

Ingo

-->
Ingo Molnar (1):
  sched: Fix various typos in comments

Morten Rasmussen (1):
  sched/fair: Add over-utilization/tipping point indicator

Muchun Song (2):
  sched/core: Introduce set_next_task() helper for better code readability
  sched/fair: Make some variables static

Patrick Bellasi (2):
  sched/fair: Mask UTIL_AVG_UNCHANGED usages
  sched/fair: Add lsub_positive() and use it consistently

Quentin Perret (11):
  sched/topology: Relocate arch_scale_cpu_capacity() to the internal header
  sched/cpufreq: Prepare schedutil for Energy Aware Scheduling
  PM: Introduce an Energy Model management framework
  sched/topology: Reference the Energy Model of CPUs when available
  sched/topology: Add lowest CPU asymmetry sched_domain level pointer
  sched/topology: Disable EAS on inappropriate platforms
  sched/topology: Make Energy Aware Scheduling depend on schedutil
  sched/toplogy: Introduce the 'sched_energy_present' static key
  sched/fair: Clean-up update_sg_lb_stats parameters
  sched/fair: Introduce an energy estimation helper function
  sched/fair: Select an energy-efficient CPU on task wake-up

Valentin Schneider (2):
  sched/fair: Clean up load_balance() condition
  sched/fair: Don't increase sd->balance_interval on newidle balance

Vincent Guittot (1):
  sched/topology: Remove the ::smt_gain field from 'struct sched_domain'

Viresh Kumar (2):
  sched/core: Create task_has_idle_policy() helper
  sched/core: Clean up the #ifdef block in add_nr_running()

Yangtao Li (1):
  sched/core: Remove unnecessary unlikely() in push_*_task()


 drivers/cpufreq/cpufreq.c|   1 +
 include/linux/cpufreq.h  |   8 +
 include/linux/energy_model.h | 187 +++
 include/linux/sched.h|   4 +-
 include/linux/sched/cpufreq.h|   6 +
 include/linux/sched/isolation.h  |   4 +-
 include/linux/sched/mm.h |   2 +-
 include/linux/sched/stat.h   |   2 +-
 include/linux/sched/topology.h   |  17 +-
 kernel/power/Kconfig |  15 ++
 kernel/power/Makefile|   2 +
 kernel/power/energy_model.c  | 201 
 kernel/sched/core.c  |   6 +-
 kernel/sched/cpufreq_schedutil.c |  90 +++--
 kernel/sched/cputime.c   |   2 +-
 kernel/sched/deadline.c  |  25 ++-
 kernel/sched/debug.c |   2 +-
 kernel/sched/fair.c  | 385 +--
 kernel/sched/isolation.c |  14 +-
 kernel/sched/rt.c|  28 ++-
 kernel/sched/sched.h |  97 +++---
 kernel/sched/topology.c  | 231 ++-
 22 files changed, 1179 insertions(+), 150 deletions(-)
 create mode 100644 include/linux/energy_model.h
 create mode 100644 kernel/power/energy_model.c


Re: [PATCH] net/netlink_compat: Fix a missing check of nla_parse_nested

2018-12-24 Thread David Miller
From: Aditya Pakki 
Date: Sun, 23 Dec 2018 18:54:53 -0600

> In tipc_nl_compat_sk_dump(), if nla_parse_nested() fails, it could return
> an error. To be consistent with other invocations of the function call,
> on error, the fix passes the return value upstream.
> 
> Signed-off-by: Aditya Pakki 

Applied, thanks.


Re: [BUG] net: sungem: device driver frees DMA memory with wrong function

2018-12-24 Thread David Miller
From: Corentin Labbe 
Date: Sun, 23 Dec 2018 20:38:21 +0100

> During a boot on a qemu machine, I hit the following problem:
 ...
> After some pr_info, I found that the function triggering this is the 
> pci_unmap_page() in gem_tx().
> So clearly this WARNING() is strange since it says "unmapped as single".

I also went through the code paths and this makes no sense to me either.


[GIT PULL] perf updates for v4.21

2018-12-24 Thread Ingo Molnar
Linus,

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

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

   # HEAD: 883f4def8b77e6870ce42be279564cca0256c611 Merge tag 
'perf-core-for-mingo-4.21-20181218' of 
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

The main changes in this cycle on the kernel side:

 - rework kprobes blacklist handling (Masami Hiramatsu)
 - misc cleanups

on the tooling side these areas were the main focus:

 - 'perf trace' enhancements (Arnaldo Carvalho de Melo)
 - 'perf bench' enhancements (Davidlohr Bueso)
 - 'perf record'enhancements (Alexey Budankov)
 - 'perf annotate'  enhancements (Jin Yao)
 - 'perf top'   enhancements (Jiri Olsa)
 - Intel hw tracing enhancements (Adrian Hunter)
 - ARM hw tracing   enhancements (Leo Yan, Mathieu Poirier)

 - ... plus lots of other enhancements, cleanups and fixes.

(See the Git log for more details.)

 Thanks,

Ingo

-->
Adrian Hunter (10):
  perf machine: Record if a arch has a single user/kernel address space
  perf thread: Add fallback functions for cases where cpumode is 
insufficient
  perf tools: Use fallback for sample_addr_correlates_sym() cases
  perf script: Use fallbacks for branch stacks
  tools lib traceevent: Fix compile warnings in 
tools/lib/traceevent/event-parse.c
  perf tests record: Allow for 'sleep' being 'coreutils'
  perf test: Fix perf_event_attr test failure
  perf intel-pt: Fix error with config term "pt=0"
  perf dso: Export data_file_size() method there are no symbols
  perf auxtrace: Alter addr_filter__entire_dso() to work if there are no 
symbols

Alexey Budankov (5):
  tools build feature: Check if libaio is available
  perf mmap: Map data buffer for preserving collected data
  perf record: Enable asynchronous trace writing
  perf record: Extend trace writing to multi AIO
  perf record: Fix memory leak on AIO objects deallocation

Andi Kleen (2):
  perf tools: Support 'srccode' output
  perf vendor events intel: Fix Load_Miss_Real_Latency on SKL/SKX

Arnaldo Carvalho de Melo (77):
  perf bpf: Add unistd.h to the headers accessible to bpf proggies
  perf augmented_syscalls: Filter on a hard coded pid
  perf augmented_syscalls: Remove needless linux/socket.h include
  perf bpf: Add defines for map insertion/lookup
  perf bpf: Add simple pid_filter class accessible to BPF proggies
  perf augmented_syscalls: Drop 'write', 'poll' for testing without self 
pid filter
  perf augmented_syscalls: Use pid_filter
  perf evlist: Rename perf_evlist__set_filter* to 
perf_evlist__set_tp_filter*
  perf trace: Add "_from_option" suffix to trace__set_filter()
  perf trace: See if there is a map named "filtered_pids"
  perf trace: Fill in BPF "filtered_pids" map when present
  perf augmented_syscalls: Remove example hardcoded set of filtered pids
  Revert "perf augmented_syscalls: Drop 'write', 'poll' for testing without 
self pid filter"
  perf bpf: Reduce the hardcoded .max_entries for pid_maps
  tools build feature: Check if eventfd() is available
  perf build: Give better hint about devel package for libssl
  perf env: Also consider env->arch == NULL as local operation
  tools include: Adopt ERR_CAST() from the kernel err.h header
  perf top: Allow passing a kallsyms file
  perf beauty mmap_flags: Check if the arch has a mmap.h file
  perf trace: We need to consider "nr" if "__syscall_nr" is not there
  perf dso: Fix unchecked usage of strncpy()
  perf header: Fix unchecked usage of strncpy()
  perf header: Fix unchecked usage of strncpy()
  perf help: Remove needless use of strncpy()
  perf svghelper: Fix unchecked usage of strncpy()
  perf ui helpline: Use strlcpy() as a shorter form of strncpy() + explicit 
set nul
  perf probe: Fix unchecked usage of strncpy()
  perf parse-events: Fix unchecked usage of strncpy()
  perf trace: Rename delivery functions to ease making ordered_events 
selectable
  perf trace: Allow selecting use the use of the ordered_events code
  perf trace beauty: Beautify renameat2's fd arg wrt AT_FDCWD
  perf beauty: Add a string table generator for renameat2's flags constants
  perf beauty: Wire up the renameat flags table generator to the Makefile
  perf trace: Beautify renameat2's flags argument
  perf trace beauty: renameat's newdirfd may also be AT_FDCWD
  tools lib subcmd: Don't add the kernel sources to the include path
  perf tools: Add missing sigqueue() prototype for systems lacking it
  perf header: Fix up argument to ctime()
  perf tools: Add missing open_memstream() prototype for systems lacking it
  perf tools: Cast off_t to s64 to avoid warning on bionic libc
  perf trace: Rename set_ev_qualifier_filter to clarify its a tracepoint 
filter
  perf 

[GIT PULL] locking changes for v4.21

2018-12-24 Thread Ingo Molnar
Linus,

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

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

   # HEAD: 80eb865768703c0f85a0603762742ae1dedf21f0 sched/fair: Clean up 
comment in nohz_idle_balance()

The main change in this cycle are initial preparatory bits of dynamic 
lockdep keys support from Bart Van Assche. There's also misc changes, a 
comment cleanup and a data structure cleanup.

 Thanks,

Ingo

-->
Andrea Parri (1):
  sched/fair: Clean up comment in nohz_idle_balance()

Bart Van Assche (13):
  tools/lib/lockdep/tests: Display compiler warning and error messages
  tools/lib/lockdep/tests: Fix shellcheck warnings
  tools/lib/lockdep/tests: Improve testing accuracy
  tools/lib/lockdep/tests: Run lockdep tests a second time under Valgrind
  tools/lib/lockdep: Rename "trywlock" into "trywrlock"
  tools/lib/lockdep: Add dummy print_irqtrace_events() implementation
  tools/lib/lockdep/tests: Test the lockdep_reset_lock() implementation
  locking/lockdep: Declare local symbols static
  locking/lockdep: Inline __lockdep_init_map()
  locking/lockdep: Introduce lock_class_cache_is_registered()
  locking/lockdep: Remove a superfluous INIT_LIST_HEAD() statement
  locking/lockdep: Make concurrent lockdep_reset_lock() calls safe
  locking/lockdep: Stop using RCU primitives to access 'all_lock_classes'

Waiman Long (1):
  locking/lockdep: Remove ::version from lock_class structure


 include/linux/lockdep.h   |  2 -
 kernel/locking/lockdep.c  | 76 +++
 kernel/sched/fair.c   |  4 +-
 tools/lib/lockdep/include/liblockdep/common.h |  1 +
 tools/lib/lockdep/include/liblockdep/mutex.h  |  1 +
 tools/lib/lockdep/include/liblockdep/rwlock.h |  6 +--
 tools/lib/lockdep/lockdep.c   |  5 ++
 tools/lib/lockdep/run_tests.sh| 39 +-
 tools/lib/lockdep/tests/AA.sh |  2 +
 tools/lib/lockdep/tests/ABA.sh|  2 +
 tools/lib/lockdep/tests/ABBA.c|  3 ++
 tools/lib/lockdep/tests/ABBA.sh   |  2 +
 tools/lib/lockdep/tests/ABBA_2threads.sh  |  2 +
 tools/lib/lockdep/tests/ABBCCA.c  |  4 ++
 tools/lib/lockdep/tests/ABBCCA.sh |  2 +
 tools/lib/lockdep/tests/ABBCCDDA.c|  5 ++
 tools/lib/lockdep/tests/ABBCCDDA.sh   |  2 +
 tools/lib/lockdep/tests/ABCABC.c  |  4 ++
 tools/lib/lockdep/tests/ABCABC.sh |  2 +
 tools/lib/lockdep/tests/ABCDBCDA.c|  5 ++
 tools/lib/lockdep/tests/ABCDBCDA.sh   |  2 +
 tools/lib/lockdep/tests/ABCDBDDA.c|  5 ++
 tools/lib/lockdep/tests/ABCDBDDA.sh   |  2 +
 tools/lib/lockdep/tests/WW.sh |  2 +
 tools/lib/lockdep/tests/unlock_balance.c  |  2 +
 tools/lib/lockdep/tests/unlock_balance.sh |  2 +
 26 files changed, 131 insertions(+), 53 deletions(-)
 create mode 100644 tools/lib/lockdep/tests/AA.sh
 create mode 100644 tools/lib/lockdep/tests/ABA.sh
 create mode 100644 tools/lib/lockdep/tests/ABBA.sh
 create mode 100644 tools/lib/lockdep/tests/ABBA_2threads.sh
 create mode 100644 tools/lib/lockdep/tests/ABBCCA.sh
 create mode 100644 tools/lib/lockdep/tests/ABBCCDDA.sh
 create mode 100644 tools/lib/lockdep/tests/ABCABC.sh
 create mode 100644 tools/lib/lockdep/tests/ABCDBCDA.sh
 create mode 100644 tools/lib/lockdep/tests/ABCDBDDA.sh
 create mode 100644 tools/lib/lockdep/tests/WW.sh
 create mode 100644 tools/lib/lockdep/tests/unlock_balance.sh



[GIT PULL] EFI changes for v4.21

2018-12-24 Thread Ingo Molnar
Linus,

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

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

   # HEAD: 1debf0958fa27b7c469dbf22754929ec59a7c0e7 x86/efi: Don't unmap EFI 
boot services code/data regions for EFI_OLD_MEMMAP and EFI_MIXED_MODE

The main changes in this cycle were:

  - Allocate the E820 buffer before doing the GetMemoryMap/ExitBootServices
dance so we don't run out of space

  - Clear EFI boot services mappings when freeing the memory

  - Harden efivars against callers that invoke it on non-EFI boots 

  - Reduce the number of memblock reservations resulting from extensive
use of the new efi_mem_reserve_persistent() API

  - Other assorted fixes and cleanups.

 Thanks,

Ingo

-->
Ard Biesheuvel (2):
  efi: Permit multiple entries in persistent memreserve data structure
  efi: Reduce the amount of memblock reservations for persistent allocations

Arend van Spriel (1):
  firmware/efi: Add NULL pointer checks in efivars API functions

Julien Thierry (2):
  efi/fdt: Indentation fix
  efi/fdt: Simplify the get_fdt() flow

Nathan Chancellor (1):
  efi/libstub: Disable some warnings for x86{,_64}

Sai Praneeth Prakhya (4):
  x86/mm/pageattr: Introduce helper function to unmap EFI boot services
  x86/efi: Unmap EFI boot services code/data regions from efi_pgd
  x86/efi: Move efi__boot_services() to arch/x86
  x86/efi: Don't unmap EFI boot services code/data regions for 
EFI_OLD_MEMMAP and EFI_MIXED_MODE


 arch/x86/include/asm/efi.h  |  2 +
 arch/x86/include/asm/pgtable_types.h|  8 ++-
 arch/x86/mm/pageattr.c  | 40 -
 arch/x86/platform/efi/efi.c |  2 +
 arch/x86/platform/efi/quirks.c  | 41 ++
 drivers/firmware/efi/efi.c  | 54 +-
 drivers/firmware/efi/libstub/Makefile   |  5 +-
 drivers/firmware/efi/libstub/arm-stub.c |  2 +-
 drivers/firmware/efi/libstub/fdt.c  | 30 +-
 drivers/firmware/efi/vars.c | 99 ++---
 include/linux/efi.h | 19 +--
 init/main.c |  4 --
 12 files changed, 242 insertions(+), 64 deletions(-)



Re: [PATCH] net/mlx5e: fix semicolon.cocci warnings

2018-12-24 Thread David Miller
From: kbuild test robot 
Date: Sat, 22 Dec 2018 20:02:16 +0800

> From: kbuild test robot 
> 
> drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:1339:57-58: Unneeded 
> semicolon
> 
> 
>  Remove unneeded semicolon.
> 
> Generated by: scripts/coccinelle/misc/semicolon.cocci
> 
> Fixes: 4c8fb2986d44 ("net/mlx5e: Increase VF representors' SQ size to 128")
> CC: Gavi Teitz 
> Signed-off-by: kbuild test robot 

Applied.


[GIT PULL] RCU updates for v4.21

2018-12-24 Thread Ingo Molnar
Linus,

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

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

   # HEAD: 4bbfd7467cfc7d42e18d3008fa6a28ffd56e901a Merge branch 'for-mingo' of 
git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu into core/rcu

The biggest RCU changes in this cycle were:

- Convert RCU's BUG_ON() and similar calls to WARN_ON() and similar.

- Replace calls of RCU-bh and RCU-sched update-side functions
  to their vanilla RCU counterparts.  This series is a step
  towards complete removal of the RCU-bh and RCU-sched update-side
  functions.

  ( Note that some of these conversions are going upstream via their
respective maintainers. )

- Documentation updates, including a number of flavor-consolidation
  updates from Joel Fernandes.

- Miscellaneous fixes.

- Automate generation of the initrd filesystem used for
  rcutorture testing.

- Convert spin_is_locked() assertions to instead use lockdep.

  ( Note that some of these conversions are going upstream via their
respective maintainers. )

- SRCU updates, especially including a fix from Dennis Krein
  for a bag-on-head-class bug.

- RCU torture-test updates.

 Thanks,

Ingo

-->
Connor Shu (1):
  rcutorture: Automatically create initrd directory

Dennis Krein (1):
  srcu: Lock srcu_data structure in srcu_gp_start()

Joe Perches (1):
  checkpatch: Create table of obsolete APIs and apply to RCU

Joel Fernandes (Google) (19):
  rcu: Remove unused rcu_state externs
  rcu: Fix rcu_{node,data} comments about gp_seq_needed
  doc: Clarify RCU data-structure comment about rcu_tree fanout
  doc: Remove rcu_preempt_state reference in stallwarn
  doc: Update information about resched_cpu
  doc: Remove rcu_dynticks from Data-Structures
  doc: rcu: Update Data-Structures for RCU flavor consolidation
  doc: rcu: Better clarify the rcu_segcblist ->len field
  doc: rcu: Update description of gp_seq fields in rcu_data
  doc: rcu: Update core and full API in whatisRCU
  doc: rcu: Add more rationale for using rcu_read_lock_sched in checklist
  doc: rcu: Remove obsolete suggestion from checklist
  doc: rcu: Remove obsolete checklist item about synchronize_rcu usage
  doc: rcu: Encourage use of rcu_barrier in checklist
  doc: Make reader aware of rcu_dereference_protected
  doc: Remove obsolete (non-)requirement about disabling preemption
  doc: Make listing in RCU perf/scale requirements use rcu_assign_pointer()
  doc: Correct parameter in stallwarn
  doc: Fix "struction" typo in RCU memory-ordering documentation

Lance Roy (7):
  x86/PCI: Replace spin_is_locked() with lockdep
  sfc: Replace spin_is_locked() with lockdep
  smsc: Replace spin_is_locked() with lockdep
  userfaultfd: Replace spin_is_locked() with lockdep
  locking/mutex: Replace spin_is_locked() with lockdep
  mm: Replace spin_is_locked() with lockdep
  KVM: arm/arm64: vgic: Replace spin_is_locked() with lockdep

Paul E. McKenney (76):
  rcu: Eliminate BUG_ON() for sync.c
  rcu: Eliminate BUG_ON() for kernel/rcu/tree.c
  rcu: Eliminate synchronize_rcu_mult()
  rcu: Consolidate the RCU update functions invoked by sync.c
  sched/membarrier: Replace synchronize_sched() with synchronize_rcu()
  sparc/oprofile: Convert timer_stop() to use synchronize_rcu()
  s390/mm: Convert tlb_table_flush() to use call_rcu()
  powerpc: Convert hugepd_free() to use call_rcu()
  doc: Set down forward-progress requirements
  rcutorture: Add initrd support for systems lacking dracut
  rcutorture: Make initrd/init execute in userspace
  rcutorture: Add cross-compile capability to initrd.sh
  srcu: Prevent __call_srcu() counter wrap with read-side critical section
  rcu: Stop expedited grace periods from relying on stop-machine
  rcu: Eliminate BUG_ON() for kernel/rcu/tree_plugin.h
  rcu: Eliminate BUG_ON() for kernel/rcu/update.c
  doc: Document rcutorture forward-progress test kernel parameters
  doc: RCU scheduler spinlock rcu_read_unlock() restriction remains
  MAINTAINERS: Update from @linux.vnet.ibm.com to @linux.ibm.com
  rcu: Avoid double multiply by HZ
  rcu: Parameterize rcu_check_gp_start_stall()
  rcu: Add state name to show_rcu_gp_kthreads() output
  rcu: Add jiffies-since-GP-activity to show_rcu_gp_kthreads()
  rcu: Trace end of grace period before end of grace period
  rcu: Speed up expedited GPs when interrupting RCU reader
  rcu: Replace this_cpu_ptr() with __this_cpu_read()
  rcu: Avoid signed integer overflow in rcu_preempt_deferred_qs()
  MAINTAINERS:  Add Joel Fernandes as RCU reviewer
  checkpatch.pl: Suggest lockdep instead of asserting !spin_is_locked()
  

[GIT PULL] Please pull RDMA subsystem changes

2018-12-24 Thread Jason Gunthorpe
Hi Linus,

These are the proposed RDMA patches for 4.21.

There is a conflict with the net tree merged in 4.20 and the Mellanox shared
tree. DaveM has a resolution for this in his net-next tree already, but if you
merge RDMA first, here is the resolution:

  struct mlx5_ifc_flow_table_eswitch_cap_bits {
-   u8  reserved_at_0[0x1c];
-   u8  fdb_multi_path_to_table[0x1];
-   u8  reserved_at_1d[0x1];
+   u8  reserved_at_0[0x1a];
u8  multi_fdb_encap[0x1];
-   u8  reserved_at_1f[0x1e1];
+   u8  reserved_at_1b[0x1];
+   u8  fdb_multi_path_to_table[0x1];
+   u8  reserved_at_1d[0x3];
+
+   u8  reserved_at_20[0x1e0];

There is also a conflict in -next with the NFS tree, in this case the correct
resolution is to continue to delete net/sunrpc/xprtrdma/fmr_ops.c

Things got a bit busy in a rush up to the US holiday season, so we may see a
busier early -rc cycle, I've seen a few thing that suggest there are some new
bugs now. The major changes to the uapi will hopefully encourage all the
driver maintainer do to early testing.

This PR is generated off v4.20, typically we've waited until net-next is
merged. For this reason you will see below a large number of patches that
duplicate ones in net-next from the Mellanox shared branch.

The tag for-linus-merged with my merge resolution to your tree is also
available to pull.

The following changes since commit 40e020c129cfc991e8ab4736d2665351ffd1468d:

  Linux 4.20-rc6 (2018-12-09 15:31:00 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git tags/for-linus

for you to fetch changes up to f617e5ffe04fd46010b618c9eeadaa04588704c9:

  RDMA/srpt: Use kmem_cache_free() instead of kfree() (2018-12-22 16:07:47 
-0700)


4.21 merge window pull request

This has been a fairly typical cycle, with the usual sorts of driver
updates. Several series continue to come through which improve and
modernize various parts of the core code, and we finally are starting to
get the uAPI command interface cleaned up.

- Various driver fixes for bnxt_re, cxgb3/4, hfi1, hns, i40iw, mlx4, mlx5,
  qib, rxe, usnic

- Rework the entire syscall flow for uverbs to be able to run over
  ioctl(). Finally getting past the historic bad choice to use write()
  for command execution

- More functional coverage with the mlx5 'devx' user API

- Start of the HFI1 series for 'TID RDMA'

- SRQ support in the hns driver

- Support for new IBTA defined 2x lane widths

- A big series to consolidate all the driver function pointers into
  a big struct and have drivers provide a 'static const' version of the
  struct instead of open coding initialization

- New 'advise_mr' uAPI to control device caching/loading of page tables

- Support for inline data in SRPT

- Modernize how umad uses the driver core and creates cdev's and sysfs
  files

- First steps toward removing 'uobject' from the view of the drivers


Alex Vesker (1):
  IB/mlx5: Enable TX on a DEVX flow table

Allen Pais (1):
  RDMA/hns: prefer dma_zalloc_coherent to dma_alloc_coherent/memse

Andrew Boyer (2):
  RDMA/rxe: Distinguish between down links and disabled links
  RDMA/rxe: Add link_down, rdma_sends, rdma_recvs stats counters

Artemy Kovalyov (1):
  IB/mlx5: Allow modify AV in DCI QP to RTR

Ashutosh Dixit (1):
  IB/hfi1: Consider LMC in 16B/bypass ingress packet check

Bart Van Assche (15):
  include/scsi/srp.h: Move response flag definitions into this file
  include/scsi/srp.h: Add support for immediate data
  RDMA/srp: Document srp_parse_in() arguments
  RDMA/srp: Handle large SCSI CDBs correctly
  RDMA/srp: Propagate ib_post_send() failures to the SCSI mid-layer
  RDMA/srp: Move srp_rdma_ch.max_ti_iu_len declaration
  RDMA/srp: Rework handling of the maximum information unit length
  RDMA/srp: Add support for immediate data
  RDMA/srpt: Fix a use-after-free in the channel release code
  RDMA/srpt: Improve coding style conformance
  RDMA/srpt: Join split strings
  RDMA/srpt: Make kernel-doc headers complete
  RDMA/srpt: Remove driver version and release date
  RDMA/srpt: Rework the srpt_alloc_srq() error path
  RDMA/srpt: Add support for immediate data

Chuck Lever (1):
  rxe: IB_WR_REG_MR does not capture MR's iova field

Colin Ian King (3):
  IB/qib: fix spelling mistake "colescing" -> "coalescing"
  RDMA/drivers: Fix spelling mistake "initalize" -> "initialize"
  IB/usnic: fix spelling mistake "miniumum" -> "minimum"

Dan Carpenter (4):
  IB/qib: Fix an error code in qib_sdma_verbs_send()
  RDMA/hns: Fix an error code in hns_roce_create_srq()
  IB/uverbs: Signedness bug in UVERBS_HANDLER()
  RDMA/mlx5: Signedness bug in UVERBS_HANDLER()

Daniel Jurgens (1):
  

Re: rfc: bool structure members (was Re: [PATCH V3] net/mlx4: Get rid of page operation after dma_alloc_coherent)

2018-12-24 Thread Jason Gunthorpe
On Sun, Dec 23, 2018 at 04:53:12PM +, Al Viro wrote:
> On Sun, Dec 23, 2018 at 06:42:20PM +0200, Gal Pressman wrote:
> > > -17) Don't re-invent the kernel macros
> > > +17) Using bool
> > > +--
> > > +
> > > +The Linux kernel uses the C11 standard for the bool type. bool values 
> > > can only
> 
> C99, surely?

Oops, yes, that is right

Jason


[PATCH] platform: x86: Add check for led_classdev_register

2018-12-24 Thread Aditya Pakki
In function alienware_zone_init, the function led_classdev_register
can return an error on failure. The fix checks the error and frees
the allocated resources.

Signed-off-by: Aditya Pakki 
---
 drivers/platform/x86/alienware-wmi.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/alienware-wmi.c 
b/drivers/platform/x86/alienware-wmi.c
index f10af5c383c5..63ab6a2eb613 100644
--- a/drivers/platform/x86/alienware-wmi.c
+++ b/drivers/platform/x86/alienware-wmi.c
@@ -441,6 +441,7 @@ static int alienware_zone_init(struct platform_device *dev)
u8 zone;
char buffer[10];
char *name;
+   int ret;
 
if (interface == WMAX) {
lighting_control_state = WMAX_RUNNING;
@@ -492,7 +493,17 @@ static int alienware_zone_init(struct platform_device *dev)
zone_attrs[quirks->num_zones] = _attr_lighting_control_state.attr;
zone_attribute_group.attrs = zone_attrs;
 
-   led_classdev_register(>dev, _led);
+   ret = led_classdev_register(>dev, _led);
+   if (ret < 0) {
+   if (zone_dev_attrs) {
+   for (zone = 0; zone < quirks->num_zones; zone++)
+   kfree(zone_dev_attrs[zone].attr.name);
+   }
+   kfree(zone_dev_attrs);
+   kfree(zone_data);
+   kfree(zone_attrs);
+   return ret;
+   }
 
return sysfs_create_group(>dev.kobj, _attribute_group);
 }
-- 
2.17.1



[PATCH v2 01/14] spi: stm32: switch to SPDX identifier

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

Adopt the SPDX license identifier headers to ease license compliance
management.

Signed-off-by: Cezary Gapinski 
---
 drivers/spi/spi-stm32.c | 27 +++
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index ad1e55d..5f30578 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -1,23 +1,10 @@
-/*
- * STMicroelectronics STM32 SPI Controller driver (master mode only)
- *
- * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
- * Author(s): Amelie Delaunay  for STMicroelectronics.
- *
- * License terms: GPL V2.0.
- *
- * spi_stm32 driver is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * spi_stm32 driver is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 
more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * spi_stm32 driver. If not, see .
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// STMicroelectronics STM32 SPI Controller driver (master mode only)
+//
+// Copyright (C) 2017, STMicroelectronics - All Rights Reserved
+// Author(s): Amelie Delaunay  for STMicroelectronics.
+
 #include 
 #include 
 #include 
-- 
2.7.4



[PATCH v2 08/14] spi: stm32: rename interrupt function

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

Interrupt function is used as a thread so rename it to express
meaning directly by more clear function name.

Signed-off-by: Cezary Gapinski 
---
 drivers/spi/spi-stm32.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 2ece69a..9cb7d33 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -466,11 +466,11 @@ static bool stm32_spi_can_dma(struct spi_master *master,
 }
 
 /**
- * stm32_spi_irq - Interrupt handler for SPI controller events
+ * stm32_spi_irq_thread - Thread of interrupt handler for SPI controller
  * @irq: interrupt line
  * @dev_id: SPI controller master interface
  */
-static irqreturn_t stm32_spi_irq(int irq, void *dev_id)
+static irqreturn_t stm32_spi_irq_thread(int irq, void *dev_id)
 {
struct spi_master *master = dev_id;
struct stm32_spi *spi = spi_master_get_devdata(master);
@@ -1113,7 +1113,7 @@ static int stm32_spi_probe(struct platform_device *pdev)
goto err_master_put;
}
ret = devm_request_threaded_irq(>dev, spi->irq, NULL,
-   stm32_spi_irq, IRQF_ONESHOT,
+   stm32_spi_irq_thread, IRQF_ONESHOT,
pdev->name, master);
if (ret) {
dev_err(>dev, "irq%d request failed: %d\n", spi->irq,
-- 
2.7.4



[PATCH v2 11/14] spi: stm32: introduce compatible data cfg

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

Prepare support for STM32F4 spi variant by introducing compatible
configuration data.
Move STM32H7 specific stuff to compatible data structure:
 - registers & bit fields
 - routines to control driver
 - baud rate divisor definitions
 - fifo availability
 - split IRQ functions to parts to be called when the IRQ occurs
   and for threaded interrupt what helps to provide less discontinuous
   mode for drivers without FIFO.

Signed-off-by: Cezary Gapinski 
---
 drivers/spi/spi-stm32.c | 337 +---
 1 file changed, 236 insertions(+), 101 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index b19d02b..8b10074 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -117,9 +117,95 @@
 #define SPI_1HZ_NS 10
 
 /**
+ * stm32_spi_reg - stm32 SPI register & bitfield desc
+ * @reg:   register offset
+ * @mask:  bitfield mask
+ * @shift: left shift
+ */
+struct stm32_spi_reg {
+   int reg;
+   int mask;
+   int shift;
+};
+
+/**
+ * stm32_spi_regspec - stm32 registers definition, compatible dependent data
+ * en: enable register and SPI enable bit
+ * dma_rx_en: SPI DMA RX enable register end SPI DMA RX enable bit
+ * dma_tx_en: SPI DMA TX enable register end SPI DMA TX enable bit
+ * cpol: clock polarity register and polarity bit
+ * cpha: clock phase register and phase bit
+ * lsb_first: LSB transmitted first register and bit
+ * br: baud rate register and bitfields
+ * rx: SPI RX data register
+ * tx: SPI TX data register
+ */
+struct stm32_spi_regspec {
+   const struct stm32_spi_reg en;
+   const struct stm32_spi_reg dma_rx_en;
+   const struct stm32_spi_reg dma_tx_en;
+   const struct stm32_spi_reg cpol;
+   const struct stm32_spi_reg cpha;
+   const struct stm32_spi_reg lsb_first;
+   const struct stm32_spi_reg br;
+   const struct stm32_spi_reg rx;
+   const struct stm32_spi_reg tx;
+};
+
+struct stm32_spi;
+
+/**
+ * stm32_spi_cfg - stm32 compatible configuration data
+ * @regs: registers descriptions
+ * @get_fifo_size: routine to get fifo size
+ * @get_bpw_mask: routine to get bits per word mask
+ * @disable: routine to disable controller
+ * @config: routine to configure controller as SPI Master
+ * @set_bpw: routine to configure registers to for bits per word
+ * @set_mode: routine to configure registers to desired mode
+ * @set_data_idleness: optional routine to configure registers to desired idle
+ * time between frames (if driver has this functionality)
+ * set_number_of_data: optional routine to configure registers to desired
+ * number of data (if driver has this functionality)
+ * @can_dma: routine to determine if the transfer is eligible for DMA use
+ * @transfer_one_dma_start: routine to start transfer a single spi_transfer
+ * using DMA
+ * @dma_rx cb: routine to call after DMA RX channel operation is complete
+ * @dma_tx cb: routine to call after DMA TX channel operation is complete
+ * @transfer_one_irq: routine to configure interrupts for driver
+ * @irq_handler_event: Interrupt handler for SPI controller events
+ * @irq_handler_thread: thread of interrupt handler for SPI controller
+ * @baud_rate_div_min: minimum baud rate divisor
+ * @baud_rate_div_max: maximum baud rate divisor
+ * @has_fifo: boolean to know if fifo is used for driver
+ * @has_startbit: boolean to know if start bit is used to start transfer
+ */
+struct stm32_spi_cfg {
+   const struct stm32_spi_regspec *regs;
+   int (*get_fifo_size)(struct stm32_spi *spi);
+   int (*get_bpw_mask)(struct stm32_spi *spi);
+   void (*disable)(struct stm32_spi *spi);
+   int (*config)(struct stm32_spi *spi);
+   void (*set_bpw)(struct stm32_spi *spi);
+   int (*set_mode)(struct stm32_spi *spi, unsigned int comm_type);
+   void (*set_data_idleness)(struct stm32_spi *spi, u32 length);
+   int (*set_number_of_data)(struct stm32_spi *spi, u32 length);
+   void (*transfer_one_dma_start)(struct stm32_spi *spi);
+   void (*dma_rx_cb)(void *data);
+   void (*dma_tx_cb)(void *data);
+   int (*transfer_one_irq)(struct stm32_spi *spi);
+   irqreturn_t (*irq_handler_event)(int irq, void *dev_id);
+   irqreturn_t (*irq_handler_thread)(int irq, void *dev_id);
+   unsigned int baud_rate_div_min;
+   unsigned int baud_rate_div_max;
+   bool has_fifo;
+};
+
+/**
  * struct stm32_spi - private data of the SPI controller
  * @dev: driver model representation of the controller
  * @master: controller master interface
+ * @cfg: compatible configuration data
  * @base: virtual memory area
  * @clk: hw kernel clock feeding the SPI clock generator
  * @clk_rate: rate of the hw kernel clock feeding the SPI clock generator
@@ -145,6 +231,7 @@
 struct stm32_spi {
struct device *dev;
struct spi_master *master;
+   const struct stm32_spi_cfg *cfg;
void __iomem 

[PATCH v2 14/14] spi: stm32: add description about STM32F4 bindings

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

Add description that STM32F4 can be used in compatible property.
Master Inter-Data Idleness optional property cannot be used in STM32F4.

Signed-off-by: Cezary Gapinski 
---
 Documentation/devicetree/bindings/spi/spi-stm32.txt | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/spi-stm32.txt 
b/Documentation/devicetree/bindings/spi/spi-stm32.txt
index 1b3fa2c1..d82755c 100644
--- a/Documentation/devicetree/bindings/spi/spi-stm32.txt
+++ b/Documentation/devicetree/bindings/spi/spi-stm32.txt
@@ -7,7 +7,9 @@ from 4 to 32-bit data size. Although it can be configured as 
master or slave,
 only master is supported by the driver.
 
 Required properties:
-- compatible: Must be "st,stm32h7-spi".
+- compatible: Should be one of:
+  "st,stm32h7-spi"
+  "st,stm32f4-spi"
 - reg: Offset and length of the device's register set.
 - interrupts: Must contain the interrupt id.
 - clocks: Must contain an entry for spiclk (which feeds the internal clock
@@ -30,8 +32,9 @@ Child nodes represent devices on the SPI bus
   See ../spi/spi-bus.txt
 
 Optional properties:
-- st,spi-midi-ns: (Master Inter-Data Idleness) minimum time delay in
- nanoseconds inserted between two consecutive data frames.
+- st,spi-midi-ns: Only for STM32H7, (Master Inter-Data Idleness) minimum time
+ delay in nanoseconds inserted between two consecutive data
+ frames.
 
 
 Example:
-- 
2.7.4



[PATCH v2 07/14] spi: stm32: rename STM32 SPI registers to STM32H7

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

Rename STM32 SPI registers to be related to STM32H7 SPI driver
and not STM32 generally.

Signed-off-by: Cezary Gapinski 
---
 drivers/spi/spi-stm32.c | 381 +---
 1 file changed, 199 insertions(+), 182 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index b639be7..2ece69a 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -20,86 +20,86 @@
 
 #define DRIVER_NAME "spi_stm32"
 
-/* STM32 SPI registers */
-#define STM32_SPI_CR1  0x00
-#define STM32_SPI_CR2  0x04
-#define STM32_SPI_CFG1 0x08
-#define STM32_SPI_CFG2 0x0C
-#define STM32_SPI_IER  0x10
-#define STM32_SPI_SR   0x14
-#define STM32_SPI_IFCR 0x18
-#define STM32_SPI_TXDR 0x20
-#define STM32_SPI_RXDR 0x30
-#define STM32_SPI_I2SCFGR  0x50
-
-/* STM32_SPI_CR1 bit fields */
-#define SPI_CR1_SPEBIT(0)
-#define SPI_CR1_MASRX  BIT(8)
-#define SPI_CR1_CSTART BIT(9)
-#define SPI_CR1_CSUSP  BIT(10)
-#define SPI_CR1_HDDIR  BIT(11)
-#define SPI_CR1_SSIBIT(12)
-
-/* STM32_SPI_CR2 bit fields */
-#define SPI_CR2_TSIZE_SHIFT0
-#define SPI_CR2_TSIZE  GENMASK(15, 0)
-
-/* STM32_SPI_CFG1 bit fields */
-#define SPI_CFG1_DSIZE_SHIFT   0
-#define SPI_CFG1_DSIZE GENMASK(4, 0)
-#define SPI_CFG1_FTHLV_SHIFT   5
-#define SPI_CFG1_FTHLV GENMASK(8, 5)
-#define SPI_CFG1_RXDMAEN   BIT(14)
-#define SPI_CFG1_TXDMAEN   BIT(15)
-#define SPI_CFG1_MBR_SHIFT 28
-#define SPI_CFG1_MBR   GENMASK(30, 28)
-#define SPI_CFG1_MBR_MIN   0
-#define SPI_CFG1_MBR_MAX   (GENMASK(30, 28) >> 28)
-
-/* STM32_SPI_CFG2 bit fields */
-#define SPI_CFG2_MIDI_SHIFT4
-#define SPI_CFG2_MIDI  GENMASK(7, 4)
-#define SPI_CFG2_COMM_SHIFT17
-#define SPI_CFG2_COMM  GENMASK(18, 17)
-#define SPI_CFG2_SP_SHIFT  19
-#define SPI_CFG2_SPGENMASK(21, 19)
-#define SPI_CFG2_MASTERBIT(22)
-#define SPI_CFG2_LSBFRST   BIT(23)
-#define SPI_CFG2_CPHA  BIT(24)
-#define SPI_CFG2_CPOL  BIT(25)
-#define SPI_CFG2_SSM   BIT(26)
-#define SPI_CFG2_AFCNTRBIT(31)
-
-/* STM32_SPI_IER bit fields */
-#define SPI_IER_RXPIE  BIT(0)
-#define SPI_IER_TXPIE  BIT(1)
-#define SPI_IER_DXPIE  BIT(2)
-#define SPI_IER_EOTIE  BIT(3)
-#define SPI_IER_TXTFIE BIT(4)
-#define SPI_IER_OVRIE  BIT(6)
-#define SPI_IER_MODFIE BIT(9)
-#define SPI_IER_ALLGENMASK(10, 0)
-
-/* STM32_SPI_SR bit fields */
-#define SPI_SR_RXP BIT(0)
-#define SPI_SR_TXP BIT(1)
-#define SPI_SR_EOT BIT(3)
-#define SPI_SR_OVR BIT(6)
-#define SPI_SR_MODFBIT(9)
-#define SPI_SR_SUSPBIT(11)
-#define SPI_SR_RXPLVL_SHIFT13
-#define SPI_SR_RXPLVL  GENMASK(14, 13)
-#define SPI_SR_RXWNE   BIT(15)
-
-/* STM32_SPI_IFCR bit fields */
-#define SPI_IFCR_ALL   GENMASK(11, 3)
-
-/* STM32_SPI_I2SCFGR bit fields */
-#define SPI_I2SCFGR_I2SMOD BIT(0)
-
-/* SPI Master Baud Rate min/max divisor */
-#define SPI_MBR_DIV_MIN(2 << SPI_CFG1_MBR_MIN)
-#define SPI_MBR_DIV_MAX(2 << SPI_CFG1_MBR_MAX)
+/* STM32H7 SPI registers */
+#define STM32H7_SPI_CR10x00
+#define STM32H7_SPI_CR20x04
+#define STM32H7_SPI_CFG1   0x08
+#define STM32H7_SPI_CFG2   0x0C
+#define STM32H7_SPI_IER0x10
+#define STM32H7_SPI_SR 0x14
+#define STM32H7_SPI_IFCR   0x18
+#define STM32H7_SPI_TXDR   0x20
+#define STM32H7_SPI_RXDR   0x30
+#define STM32H7_SPI_I2SCFGR0x50
+
+/* STM32H7_SPI_CR1 bit fields */
+#define STM32H7_SPI_CR1_SPEBIT(0)
+#define STM32H7_SPI_CR1_MASRX  BIT(8)
+#define STM32H7_SPI_CR1_CSTART BIT(9)
+#define STM32H7_SPI_CR1_CSUSP  BIT(10)
+#define STM32H7_SPI_CR1_HDDIR  BIT(11)
+#define STM32H7_SPI_CR1_SSIBIT(12)
+
+/* STM32H7_SPI_CR2 bit fields */
+#define STM32H7_SPI_CR2_TSIZE_SHIFT0
+#define STM32H7_SPI_CR2_TSIZE  GENMASK(15, 0)
+
+/* STM32H7_SPI_CFG1 bit fields */
+#define STM32H7_SPI_CFG1_DSIZE_SHIFT   0
+#define STM32H7_SPI_CFG1_DSIZE GENMASK(4, 0)
+#define STM32H7_SPI_CFG1_FTHLV_SHIFT   5
+#define STM32H7_SPI_CFG1_FTHLV GENMASK(8, 5)
+#define STM32H7_SPI_CFG1_RXDMAEN   BIT(14)
+#define STM32H7_SPI_CFG1_TXDMAEN   BIT(15)
+#define STM32H7_SPI_CFG1_MBR_SHIFT 28
+#define STM32H7_SPI_CFG1_MBR   GENMASK(30, 28)
+#define STM32H7_SPI_CFG1_MBR_MIN   0
+#define STM32H7_SPI_CFG1_MBR_MAX   (GENMASK(30, 28) >> 28)
+
+/* STM32H7_SPI_CFG2 bit fields */
+#define STM32H7_SPI_CFG2_MIDI_SHIFT4
+#define STM32H7_SPI_CFG2_MIDI  GENMASK(7, 4)
+#define STM32H7_SPI_CFG2_COMM_SHIFT

[PATCH v2 13/14] ARM: dts: stm32: add SPI support on STM32F429 SoC

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

This patch adds all SPI instances of the STM32F429 SoC.

Signed-off-by: Cezary Gapinski 
---
 arch/arm/boot/dts/stm32f429.dtsi | 60 
 1 file changed, 60 insertions(+)

diff --git a/arch/arm/boot/dts/stm32f429.dtsi b/arch/arm/boot/dts/stm32f429.dtsi
index 8d6f028..8dbec00 100644
--- a/arch/arm/boot/dts/stm32f429.dtsi
+++ b/arch/arm/boot/dts/stm32f429.dtsi
@@ -314,6 +314,26 @@
status = "disabled";
};
 
+   spi2: spi@40003800 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "st,stm32f4-spi";
+   reg = <0x40003800 0x400>;
+   interrupts = <36>;
+   clocks = < 0 STM32F4_APB1_CLOCK(SPI2)>;
+   status = "disabled";
+   };
+
+   spi3: spi@40003C00 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "st,stm32f4-spi";
+   reg = <0x40003C00 0x400>;
+   interrupts = <51>;
+   clocks = < 0 STM32F4_APB1_CLOCK(SPI3)>;
+   status = "disabled";
+   };
+
usart2: serial@40004400 {
compatible = "st,stm32-uart";
reg = <0x40004400 0x400>;
@@ -523,6 +543,26 @@
status = "disabled";
};
 
+   spi1: spi@40013000 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "st,stm32f4-spi";
+   reg = <0x40013000 0x400>;
+   interrupts = <35>;
+   clocks = < 0 STM32F4_APB2_CLOCK(SPI1)>;
+   status = "disabled";
+   };
+
+   spi4: spi@40013400 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "st,stm32f4-spi";
+   reg = <0x40013400 0x400>;
+   interrupts = <84>;
+   clocks = < 0 STM32F4_APB2_CLOCK(SPI4)>;
+   status = "disabled";
+   };
+
syscfg: system-config@40013800 {
compatible = "syscon";
reg = <0x40013800 0x400>;
@@ -587,6 +627,26 @@
};
};
 
+   spi5: spi@40015000 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "st,stm32f4-spi";
+   reg = <0x40015000 0x400>;
+   interrupts = <85>;
+   clocks = < 0 STM32F4_APB2_CLOCK(SPI5)>;
+   status = "disabled";
+   };
+
+   spi6: spi@40015400 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "st,stm32f4-spi";
+   reg = <0x40015400 0x400>;
+   interrupts = <86>;
+   clocks = < 0 STM32F4_APB2_CLOCK(SPI6)>;
+   status = "disabled";
+   };
+
pwrcfg: power-config@40007000 {
compatible = "syscon";
reg = <0x40007000 0x400>;
-- 
2.7.4



[PATCH v2 09/14] spi: stm32: split transfer one setup function

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

Split stm32_spi_transfer_one_setup function into smaller chunks
to be more generic for other stm32 SPI family drivers.

Signed-off-by: Cezary Gapinski 
---
 drivers/spi/spi-stm32.c | 270 ++--
 1 file changed, 192 insertions(+), 78 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 9cb7d33..bc8513f 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -101,11 +101,18 @@
 #define STM32H7_SPI_MBR_DIV_MIN(2 << STM32H7_SPI_CFG1_MBR_MIN)
 #define STM32H7_SPI_MBR_DIV_MAX(2 << STM32H7_SPI_CFG1_MBR_MAX)
 
-/* SPI Communication mode */
+/* STM32H7 SPI Communication mode */
+#define STM32H7_SPI_FULL_DUPLEX0
+#define STM32H7_SPI_SIMPLEX_TX 1
+#define STM32H7_SPI_SIMPLEX_RX 2
+#define STM32H7_SPI_HALF_DUPLEX3
+
+/* SPI Communication type */
 #define SPI_FULL_DUPLEX0
 #define SPI_SIMPLEX_TX 1
 #define SPI_SIMPLEX_RX 2
-#define SPI_HALF_DUPLEX3
+#define SPI_3WIRE_TX   3
+#define SPI_3WIRE_RX   4
 
 #define SPI_1HZ_NS 10
 
@@ -232,13 +239,16 @@ static int stm32_spi_get_bpw_mask(struct stm32_spi *spi)
 }
 
 /**
- * stm32_spi_prepare_mbr - Determine SPI_CFG1.MBR value
+ * stm32_spi_prepare_mbr - Determine baud rate divisor value
  * @spi: pointer to the spi controller data structure
  * @speed_hz: requested speed
+ * @min_div: minimum baud rate divisor
+ * @max_div: maximum baud rate divisor
  *
- * Return SPI_CFG1.MBR value in case of success or -EINVAL
+ * Return baud rate divisor value in case of success or -EINVAL
  */
-static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz)
+static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz,
+u32 min_div, u32 max_div)
 {
u32 div, mbrdiv;
 
@@ -251,8 +261,7 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 
speed_hz)
 * no need to check it there.
 * However, we need to ensure the following calculations.
 */
-   if (div < STM32H7_SPI_MBR_DIV_MIN ||
-   div > STM32H7_SPI_MBR_DIV_MAX)
+   if ((div < min_div) || (div > max_div))
return -EINVAL;
 
/* Determine the first power of 2 greater than or equal to div */
@@ -802,7 +811,8 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
}
 
if (tx_dma_desc) {
-   if (spi->cur_comm == SPI_SIMPLEX_TX) {
+   if (spi->cur_comm == SPI_SIMPLEX_TX ||
+   spi->cur_comm == SPI_3WIRE_TX) {
tx_dma_desc->callback = stm32_spi_dma_cb;
tx_dma_desc->callback_param = spi;
}
@@ -848,92 +858,130 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi 
*spi,
 }
 
 /**
- * stm32_spi_transfer_one_setup - common setup to transfer a single
- *   spi_transfer either using DMA or
- *   interrupts.
+ * stm32_spi_set_bpw - configure bits per word
+ * @spi: pointer to the spi controller data structure
  */
-static int stm32_spi_transfer_one_setup(struct stm32_spi *spi,
-   struct spi_device *spi_dev,
-   struct spi_transfer *transfer)
+static void stm32_spi_set_bpw(struct stm32_spi *spi)
 {
-   unsigned long flags;
-   u32 cfg1_clrb = 0, cfg1_setb = 0, cfg2_clrb = 0, cfg2_setb = 0;
-   u32 mode, nb_words;
-   int ret = 0;
+   u32 bpw, fthlv;
+   u32 cfg1_clrb = 0, cfg1_setb = 0;
 
-   spin_lock_irqsave(>lock, flags);
+   bpw = spi->cur_bpw - 1;
 
-   if (spi->cur_bpw != transfer->bits_per_word) {
-   u32 bpw, fthlv;
-
-   spi->cur_bpw = transfer->bits_per_word;
-   bpw = spi->cur_bpw - 1;
+   cfg1_clrb |= STM32H7_SPI_CFG1_DSIZE;
+   cfg1_setb |= (bpw << STM32H7_SPI_CFG1_DSIZE_SHIFT) &
+STM32H7_SPI_CFG1_DSIZE;
 
-   cfg1_clrb |= STM32H7_SPI_CFG1_DSIZE;
-   cfg1_setb |= (bpw << STM32H7_SPI_CFG1_DSIZE_SHIFT) &
-STM32H7_SPI_CFG1_DSIZE;
+   spi->cur_fthlv = stm32_spi_prepare_fthlv(spi);
+   fthlv = spi->cur_fthlv - 1;
 
-   spi->cur_fthlv = stm32_spi_prepare_fthlv(spi);
-   fthlv = spi->cur_fthlv - 1;
+   cfg1_clrb |= STM32H7_SPI_CFG1_FTHLV;
+   cfg1_setb |= (fthlv << STM32H7_SPI_CFG1_FTHLV_SHIFT) &
+STM32H7_SPI_CFG1_FTHLV;
 
-   cfg1_clrb |= STM32H7_SPI_CFG1_FTHLV;
-   cfg1_setb |= (fthlv << STM32H7_SPI_CFG1_FTHLV_SHIFT) &
-STM32H7_SPI_CFG1_FTHLV;
-   }
-
-   if (spi->cur_speed != transfer->speed_hz) {
-   int mbr;
+   writel_relaxed(
+   (readl_relaxed(spi->base + STM32H7_SPI_CFG1) &
+

[PATCH v2 05/14] spi: stm32: use explicit CPOL and CPHA mode bits

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

Driver supports SPI mode 0 to 3 not only the mode 3.
Use SPI_CPOL and SPI_CPHA indicates that these bits
can be changed to obtain modes 0 - 3.

Signed-off-by: Cezary Gapinski 
---
 drivers/spi/spi-stm32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 8310f14..f7056b7 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -1142,7 +1142,7 @@ static int stm32_spi_probe(struct platform_device *pdev)
master->dev.of_node = pdev->dev.of_node;
master->auto_runtime_pm = true;
master->bus_num = pdev->id;
-   master->mode_bits = SPI_MODE_3 | SPI_CS_HIGH | SPI_LSB_FIRST |
+   master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_CS_HIGH | SPI_LSB_FIRST |
SPI_3WIRE | SPI_LOOP;
master->bits_per_word_mask = stm32_spi_get_bpw_mask(spi);
master->max_speed_hz = spi->clk_rate / SPI_MBR_DIV_MIN;
-- 
2.7.4



[PATCH v2 12/14] spi: stm32: add support for STM32F4

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

Add routines, registers & bitfield definition. Also baud rate divisor
definitions for STM32F4 SPI. This version supports full-duplex,
simplex TX and half-duplex TX communication with 8 or 16-bit per word.
DMA capability is optionally supported for transfer longer than 16 bytes.
For transfer less than 16 bytes frames can be send in discontinuous mode.

Signed-off-by: Cezary Gapinski 
---
 drivers/spi/spi-stm32.c | 489 +++-
 1 file changed, 482 insertions(+), 7 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 8b10074..4186ed2 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -20,6 +20,59 @@
 
 #define DRIVER_NAME "spi_stm32"
 
+/* STM32F4 SPI registers */
+#define STM32F4_SPI_CR10x00
+#define STM32F4_SPI_CR20x04
+#define STM32F4_SPI_SR 0x08
+#define STM32F4_SPI_DR 0x0C
+#define STM32F4_SPI_I2SCFGR0x1C
+
+/* STM32F4_SPI_CR1 bit fields */
+#define STM32F4_SPI_CR1_CPHA   BIT(0)
+#define STM32F4_SPI_CR1_CPOL   BIT(1)
+#define STM32F4_SPI_CR1_MSTR   BIT(2)
+#define STM32F4_SPI_CR1_BR_SHIFT   3
+#define STM32F4_SPI_CR1_BR GENMASK(5, 3)
+#define STM32F4_SPI_CR1_SPEBIT(6)
+#define STM32F4_SPI_CR1_LSBFRSTBIT(7)
+#define STM32F4_SPI_CR1_SSIBIT(8)
+#define STM32F4_SPI_CR1_SSMBIT(9)
+#define STM32F4_SPI_CR1_RXONLY BIT(10)
+#define STM32F4_SPI_CR1_DFFBIT(11)
+#define STM32F4_SPI_CR1_CRCNEXTBIT(12)
+#define STM32F4_SPI_CR1_CRCEN  BIT(13)
+#define STM32F4_SPI_CR1_BIDIOE BIT(14)
+#define STM32F4_SPI_CR1_BIDIMODE   BIT(15)
+#define STM32F4_SPI_CR1_BR_MIN 0
+#define STM32F4_SPI_CR1_BR_MAX (GENMASK(5, 3) >> 3)
+
+/* STM32F4_SPI_CR2 bit fields */
+#define STM32F4_SPI_CR2_RXDMAENBIT(0)
+#define STM32F4_SPI_CR2_TXDMAENBIT(1)
+#define STM32F4_SPI_CR2_SSOE   BIT(2)
+#define STM32F4_SPI_CR2_FRFBIT(4)
+#define STM32F4_SPI_CR2_ERRIE  BIT(5)
+#define STM32F4_SPI_CR2_RXNEIE BIT(6)
+#define STM32F4_SPI_CR2_TXEIE  BIT(7)
+
+/* STM32F4_SPI_SR bit fields */
+#define STM32F4_SPI_SR_RXNEBIT(0)
+#define STM32F4_SPI_SR_TXE BIT(1)
+#define STM32F4_SPI_SR_CHSIDE  BIT(2)
+#define STM32F4_SPI_SR_UDR BIT(3)
+#define STM32F4_SPI_SR_CRCERR  BIT(4)
+#define STM32F4_SPI_SR_MODFBIT(5)
+#define STM32F4_SPI_SR_OVR BIT(6)
+#define STM32F4_SPI_SR_BSY BIT(7)
+#define STM32F4_SPI_SR_FRE BIT(8)
+
+/* STM32F4_SPI_I2SCFGR bit fields */
+#define STM32F4_SPI_I2SCFGR_I2SMOD BIT(11)
+
+/* STM32F4 SPI Baud Rate min/max divisor */
+#define STM32F4_SPI_BR_DIV_MIN (2 << STM32F4_SPI_CR1_BR_MIN)
+#define STM32F4_SPI_BR_DIV_MAX (2 << STM32F4_SPI_CR1_BR_MAX)
+
 /* STM32H7 SPI registers */
 #define STM32H7_SPI_CR10x00
 #define STM32H7_SPI_CR20x04
@@ -116,6 +169,12 @@
 
 #define SPI_1HZ_NS 10
 
+/*
+ * use PIO for small transfers, avoiding DMA setup/teardown overhead for 
drivers
+ * without fifo buffers.
+ */
+#define SPI_DMA_MIN_BYTES  16
+
 /**
  * stm32_spi_reg - stm32 SPI register & bitfield desc
  * @reg:   register offset
@@ -257,6 +316,21 @@ struct stm32_spi {
dma_addr_t phys_addr;
 };
 
+static const struct stm32_spi_regspec stm32f4_spi_regspec = {
+   .en = { STM32F4_SPI_CR1, STM32F4_SPI_CR1_SPE },
+
+   .dma_rx_en = { STM32F4_SPI_CR2, STM32F4_SPI_CR2_RXDMAEN },
+   .dma_tx_en = { STM32F4_SPI_CR2, STM32F4_SPI_CR2_TXDMAEN },
+
+   .cpol = { STM32F4_SPI_CR1, STM32F4_SPI_CR1_CPOL },
+   .cpha = { STM32F4_SPI_CR1, STM32F4_SPI_CR1_CPHA },
+   .lsb_first = { STM32F4_SPI_CR1, STM32F4_SPI_CR1_LSBFRST },
+   .br = { STM32F4_SPI_CR1, STM32F4_SPI_CR1_BR, STM32F4_SPI_CR1_BR_SHIFT },
+
+   .rx = { STM32F4_SPI_DR },
+   .tx = { STM32F4_SPI_DR },
+};
+
 static const struct stm32_spi_regspec stm32h7_spi_regspec = {
/* SPI data transfer is enabled but spi_ker_ck is idle.
 * CFG1 and CFG2 registers are write protected when SPE is enabled.
@@ -316,6 +390,16 @@ static int stm32h7_spi_get_fifo_size(struct stm32_spi *spi)
 }
 
 /**
+ * stm32f4_spi_get_bpw_mask - Return bits per word mask
+ * @spi: pointer to the spi controller data structure
+ */
+static int stm32f4_spi_get_bpw_mask(struct stm32_spi *spi)
+{
+   dev_dbg(spi->dev, "8-bit or 16-bit data frame supported\n");
+   return SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
+}
+
+/**
  * stm32h7_spi_get_bpw_mask - Return bits per word mask
  * @spi: pointer to the spi controller data structure
  */
@@ -409,6 +493,35 @@ static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi)
 }
 
 /**
+ * stm32f4_spi_write_tx - Write bytes to 

[PATCH v2 10/14] spi: stm32: add start dma transfer function

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

Add transfer_one_dma_start function to be more generic for other
stm32 SPI family drivers.

Signed-off-by: Cezary Gapinski 
---
 drivers/spi/spi-stm32.c | 27 ++-
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index bc8513f..b19d02b 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -748,6 +748,23 @@ static int stm32_spi_transfer_one_irq(struct stm32_spi 
*spi)
 }
 
 /**
+ * stm32_spi_transfer_one_dma_start - Set SPI driver registers to start 
transfer
+ *   using DMA
+ */
+static void stm32_spi_transfer_one_dma_start(struct stm32_spi *spi)
+{
+   /* Enable the interrupts relative to the end of transfer */
+   stm32_spi_set_bits(spi, STM32H7_SPI_IER, STM32H7_SPI_IER_EOTIE |
+STM32H7_SPI_IER_TXTFIE |
+STM32H7_SPI_IER_OVRIE |
+STM32H7_SPI_IER_MODFIE);
+
+   stm32_spi_enable(spi);
+
+   stm32_spi_set_bits(spi, STM32H7_SPI_CR1, STM32H7_SPI_CR1_CSTART);
+}
+
+/**
  * stm32_spi_transfer_one_dma - transfer a single spi_transfer using DMA
  *
  * It must returns 0 if the transfer is finished or 1 if the transfer is still
@@ -759,7 +776,6 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
struct dma_slave_config tx_dma_conf, rx_dma_conf;
struct dma_async_tx_descriptor *tx_dma_desc, *rx_dma_desc;
unsigned long flags;
-   u32 ier = 0;
 
spin_lock_irqsave(>lock, flags);
 
@@ -829,14 +845,7 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi 
*spi,
   STM32H7_SPI_CFG1_TXDMAEN);
}
 
-   /* Enable the interrupts relative to the end of transfer */
-   ier |= STM32H7_SPI_IER_EOTIE | STM32H7_SPI_IER_TXTFIE |
-  STM32H7_SPI_IER_OVRIE | STM32H7_SPI_IER_MODFIE;
-   writel_relaxed(ier, spi->base + STM32H7_SPI_IER);
-
-   stm32_spi_enable(spi);
-
-   stm32_spi_set_bits(spi, STM32H7_SPI_CR1, STM32H7_SPI_CR1_CSTART);
+   stm32_spi_transfer_one_dma_start(spi);
 
spin_unlock_irqrestore(>lock, flags);
 
-- 
2.7.4



[PATCH v2 06/14] spi: stm32: remove SPI LOOP mode

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

This driver does not support SPI LOOP mode by configuration
in registers.

Signed-off-by: Cezary Gapinski 
---
 drivers/spi/spi-stm32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index f7056b7..b639be7 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -1143,7 +1143,7 @@ static int stm32_spi_probe(struct platform_device *pdev)
master->auto_runtime_pm = true;
master->bus_num = pdev->id;
master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_CS_HIGH | SPI_LSB_FIRST |
-   SPI_3WIRE | SPI_LOOP;
+   SPI_3WIRE;
master->bits_per_word_mask = stm32_spi_get_bpw_mask(spi);
master->max_speed_hz = spi->clk_rate / SPI_MBR_DIV_MIN;
master->min_speed_hz = spi->clk_rate / SPI_MBR_DIV_MAX;
-- 
2.7.4



[PATCH v2 04/14] spi: fix typo in SPI_STM32 help text

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

Fix typo from STMicroelectonics to STMicroelectronics.

Signed-off-by: Cezary Gapinski 
---
 drivers/spi/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 9f89cb1..ceb6b7e 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -665,7 +665,7 @@ config SPI_STM32
tristate "STMicroelectronics STM32 SPI controller"
depends on ARCH_STM32 || COMPILE_TEST
help
- SPI driver for STMicroelectonics STM32 SoCs.
+ SPI driver for STMicroelectronics STM32 SoCs.
 
  STM32 SPI controller supports DMA and PIO modes. When DMA
  is not available, the driver automatically falls back to
-- 
2.7.4



[PATCH v2 00/14] Add support for STM32F4 SPI

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

This series of patches adds support for first generation of SPI
interface for STM32F4 family.

This version of driver is mostly different to STM32H7 one. Based on
linux kernel I2C drivers for STM32 where drivers were splited into
STM32F4 and STM32F7 family the same approach seems to be sufficient for
SPI STM32 drivers. Therefore STM32H7 driver was moved to spi-stm32h7.c
file and register and functions were renamed to be more specific to
STM32H7.

For current version master mode with full-duplex and 8/16 bit data
frame format are supported. There is no TX and RX FIFOs like
in STM32H7. DMA capabilility is supported for messages longer than
arbitrary number of bytes (that is set already to 16 bytes) when TX
and RX channels are set at the same time.

v2:
Based on Amelie Delaunay recommendation only one common file
spi-stm32.c is used. Before adding support for STM32F4 driver, first six
patches adds some improvements to actual driver.
Next patches rearrange driver to be more useful for new STM32F4 SPI
and adding support for this family.
This version also supports simplex-tx and 3wire-tx modes.

Cezary Gapinski (14):
  spi: stm32: switch to SPDX identifier
  spi: stm32: use NULL pointer instead of plain integer
  spi: stm32: fix DMA configuration with only one channel
  spi: fix typo in SPI_STM32 help text
  spi: stm32: use explicit CPOL and CPHA mode bits
  spi: stm32: remove SPI LOOP mode
  spi: stm32: rename STM32 SPI registers to STM32H7
  spi: stm32: rename interrupt function
  spi: stm32: split transfer one setup function
  spi: stm32: add start dma transfer function
  spi: stm32: introduce compatible data cfg
  spi: stm32: add support for STM32F4
  ARM: dts: stm32: add SPI support on STM32F429 SoC
  spi: stm32: add description about STM32F4 bindings

 .../devicetree/bindings/spi/spi-stm32.txt  |9 +-
 arch/arm/boot/dts/stm32f429.dtsi   |   60 +
 drivers/spi/Kconfig|2 +-
 drivers/spi/spi-stm32.c| 1403 +++-
 4 files changed, 1139 insertions(+), 335 deletions(-)

-- 
2.7.4



[PATCH v2 03/14] spi: stm32: fix DMA configuration with only one channel

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

When SPI driver is configured to work only with TX or RX DMA channel
then dmaengine functions can dereferene NULL pointer.

Running full-duplex mode when when only RX or TX DMA channel is
available can cause overrun condition or incorrect writing to transmit
buffer so disable this types of DMA configuration and go back to
interrupt mode.

Signed-off-by: Cezary Gapinski 
---
 drivers/spi/spi-stm32.c | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 51d7f72..8310f14 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -427,9 +427,9 @@ static void stm32_spi_disable(struct stm32_spi *spi)
if (!spi->cur_usedma && spi->rx_buf && (spi->rx_len > 0))
stm32_spi_read_rxfifo(spi, true);
 
-   if (spi->cur_usedma && spi->tx_buf)
+   if (spi->cur_usedma && spi->dma_tx)
dmaengine_terminate_all(spi->dma_tx);
-   if (spi->cur_usedma && spi->rx_buf)
+   if (spi->cur_usedma && spi->dma_rx)
dmaengine_terminate_all(spi->dma_rx);
 
stm32_spi_clr_bits(spi, STM32_SPI_CR1, SPI_CR1_SPE);
@@ -750,7 +750,7 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
spin_lock_irqsave(>lock, flags);
 
rx_dma_desc = NULL;
-   if (spi->rx_buf) {
+   if (spi->rx_buf && spi->dma_rx) {
stm32_spi_dma_config(spi, _dma_conf, DMA_DEV_TO_MEM);
dmaengine_slave_config(spi->dma_rx, _dma_conf);
 
@@ -765,7 +765,7 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
}
 
tx_dma_desc = NULL;
-   if (spi->tx_buf) {
+   if (spi->tx_buf && spi->dma_tx) {
stm32_spi_dma_config(spi, _dma_conf, DMA_MEM_TO_DEV);
dmaengine_slave_config(spi->dma_tx, _dma_conf);
 
@@ -776,8 +776,11 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi 
*spi,
DMA_PREP_INTERRUPT);
}
 
-   if ((spi->tx_buf && !tx_dma_desc) ||
-   (spi->rx_buf && !rx_dma_desc))
+   if ((spi->tx_buf && spi->dma_tx && !tx_dma_desc) ||
+   (spi->rx_buf && spi->dma_rx && !rx_dma_desc))
+   goto dma_desc_error;
+
+   if (spi->cur_comm == SPI_FULL_DUPLEX && (!tx_dma_desc || !rx_dma_desc))
goto dma_desc_error;
 
if (rx_dma_desc) {
@@ -822,7 +825,7 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
return 1;
 
 dma_submit_error:
-   if (spi->rx_buf)
+   if (spi->dma_rx)
dmaengine_terminate_all(spi->dma_rx);
 
 dma_desc_error:
@@ -832,6 +835,7 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
 
dev_info(spi->dev, "DMA issue: fall back to irq transfer\n");
 
+   spi->cur_usedma = false;
return stm32_spi_transfer_one_irq(spi);
 }
 
@@ -984,7 +988,7 @@ static int stm32_spi_transfer_one(struct spi_master *master,
spi->rx_len = spi->rx_buf ? transfer->len : 0;
 
spi->cur_usedma = (master->can_dma &&
-  stm32_spi_can_dma(master, spi_dev, transfer));
+  master->can_dma(master, spi_dev, transfer));
 
ret = stm32_spi_transfer_one_setup(spi, spi_dev, transfer);
if (ret) {
-- 
2.7.4



[PATCH v2 02/14] spi: stm32: use NULL pointer instead of plain integer

2018-12-24 Thread cezary . gapinski
From: Cezary Gapinski 

Patch fixes sparse warning: Using plain integer as NULL pointer. Replaces
second argument of function devm_clk_get from 0 to NULL.

Signed-off-by: Cezary Gapinski 
---
 drivers/spi/spi-stm32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 5f30578..51d7f72 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -1100,7 +1100,7 @@ static int stm32_spi_probe(struct platform_device *pdev)
goto err_master_put;
}
 
-   spi->clk = devm_clk_get(>dev, 0);
+   spi->clk = devm_clk_get(>dev, NULL);
if (IS_ERR(spi->clk)) {
ret = PTR_ERR(spi->clk);
dev_err(>dev, "clk get failed: %d\n", ret);
-- 
2.7.4



I want to present you as a relation ( NEXT OF KIN )....I expect your reply.

2018-12-24 Thread JOHN OLEH
Good Day,

I work with Union Bank, I want to present you as a relation ( NEXT OF
KIN ) to a Late customer of our bank who happens to come from the same
country with you, Our Late customer has no wife or Children as such I
want to present you as a relation ( NEXT OF KIN ) so as to enable our
bank to transfer the sum of US$10,500,000.00 to you as a relation (
NEXT OF KIN ) to our Late customer.

Once the US$10,500,000.00 is transferred to you I want you to take 30%
for yourself and 70% will be mine which you are to assist me put into
investment there in your country on any business that is profit
oriented.

If you agree to receive the fund US$10,500,000.00 I advise you to
reply back to me so we can proceed.

Regards,

Mr.John Oleh.

Union Bank.


[PATCH] hid: Add checks to fix of_led_classdev_register

2018-12-24 Thread Aditya Pakki
In lenovo_probe_tpkbd(), the function of_led_classdev_register() could
return an error value that is unchecked. The fix adds these checks.

Signed-off-by: Aditya Pakki 
---
 drivers/hid/hid-lenovo.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index 643b6eb54442..eacc76d2ab96 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -743,7 +743,9 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
data_pointer->led_mute.brightness_get = lenovo_led_brightness_get_tpkbd;
data_pointer->led_mute.brightness_set = lenovo_led_brightness_set_tpkbd;
data_pointer->led_mute.dev = dev;
-   led_classdev_register(dev, _pointer->led_mute);
+   ret = led_classdev_register(dev, _pointer->led_mute);
+   if (ret < 0)
+   goto err;
 
data_pointer->led_micmute.name = name_micmute;
data_pointer->led_micmute.brightness_get =
@@ -751,7 +753,11 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
data_pointer->led_micmute.brightness_set =
lenovo_led_brightness_set_tpkbd;
data_pointer->led_micmute.dev = dev;
-   led_classdev_register(dev, _pointer->led_micmute);
+   ret = led_classdev_register(dev, _pointer->led_micmute);
+   if (ret < 0) {
+   led_classdev_unregister(_pointer->led_mute);
+   goto err;
+   }
 
lenovo_features_set_tpkbd(hdev);
 
-- 
2.17.1



Re: [PATCH v2 2/9] i2c: reject new transfers when adapters are suspended

2018-12-24 Thread Hans de Goede

Hi,

Thank you for this new version.

On 22-12-18 21:26, Wolfram Sang wrote:

Using the 'is_suspended' flag from the PM core, we now reject new
transfers if the parent of the adapter is already marked suspended.


I've been running some tests and I'm afraid that those have
exposed multiple issues:

1) It seems that adap->dev.parent can be NULL in some cases, specifically
this patch causes the i915 driver to crash during probe on an Apollo Lake
laptop with an eDP panel. I've attached a fixup patch which fixes this.

2) There are multiple suspend stages: prepare suspend, suspend_late,
suspend_no_irq and several devices which need access to i2c-transfers
suspend from the suspend_late or even the suspend_no_irq handler.

The way this works is that first all devices are moved to the prepared
state, then a second run is done moving all devices over to suspended,
then a third run moving all devices over to suspend_late, etc.

To make this work, e.g. the i2c-designware driver has a nop suspend
callback and does the actual suspend from its suspend_late or
suspend_no_irq callback. But the is_suspended flag we are testing for
now gets set during the suspend phase. So when we are then asked to
do an i2c-transfer during the suspend_late phase we get a false-positive
triggering of the:

if (WARN(device_is_suspended(adap->dev.parent),
 "Accessing already suspended I2C/SMBus adapter"))
return -ESHUTDOWN;

WARN and a return of -ESHUTDOWN, because the adapter is in the
suspended state, but it has not actually been suspended / moved
to the D3 low-power state as that happens later when we reach
e.g. the suspend_no_irq phase of the suspend.

This is not only a problem with the somewhat complex PMIC
situation on some Cherry Trail devices, but it also breaks the
i915 driver since as a PCI device the i915 device also only
really gets turned off from the suspend_no_irq phase of the suspend.

Sorry, this is something which I should have realized before, but
well I didn't.

TL;DR: really only the adapter driver knows when the device is
put in such a state that it can no longer do transfers, as it
actually turns of clks / moves it D3 / etc. Which may happen at
any of the 3 suspend phases so any "core" based solution is going
to get this wrong.

I share your desire to have the check for this shared in core code,
but I'm afraid that just is not going to work.

Regards,

Hans











Signed-off-by: Wolfram Sang 
---
  Documentation/i2c/fault-codes | 4 
  drivers/i2c/i2c-core-base.c   | 3 +++
  drivers/i2c/i2c-core-smbus.c  | 4 
  3 files changed, 11 insertions(+)

diff --git a/Documentation/i2c/fault-codes b/Documentation/i2c/fault-codes
index 47c25abb7d52..0cee0fc545b4 100644
--- a/Documentation/i2c/fault-codes
+++ b/Documentation/i2c/fault-codes
@@ -112,6 +112,10 @@ EPROTO
case is when the length of an SMBus block data response
(from the SMBus slave) is outside the range 1-32 bytes.
  
+ESHUTDOWN

+   Returned when a transfer was requested using an adapter
+   which is already suspended.
+
  ETIMEDOUT
This is returned by drivers when an operation took too much
time, and was aborted before it completed.
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 28460f6a60cc..3ce238b782f3 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1865,6 +1865,9 @@ int __i2c_transfer(struct i2c_adapter *adap, struct 
i2c_msg *msgs, int num)
  
  	if (WARN_ON(!msgs || num < 1))

return -EINVAL;
+   if (WARN(device_is_suspended(adap->dev.parent),
+"Accessing already suspended I2C/SMBus adapter"))
+   return -ESHUTDOWN;
  
  	if (adap->quirks && i2c_check_for_quirks(adap, msgs, num))

return -EOPNOTSUPP;
diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c
index 9cd66cabb84f..e0f7f22feabd 100644
--- a/drivers/i2c/i2c-core-smbus.c
+++ b/drivers/i2c/i2c-core-smbus.c
@@ -547,6 +547,10 @@ s32 __i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
int try;
s32 res;
  
+	if (WARN(device_is_suspended(adapter->dev.parent),

+"Accessing already suspended I2C/SMBus adapter"))
+   return -ESHUTDOWN;
+
/* If enabled, the following two tracepoints are conditional on
 * read_write and protocol.
 */

>From 0ff431b48f7f2d08bbf299265c67589a598ec5d4 Mon Sep 17 00:00:00 2001
From: Hans de Goede 
Date: Mon, 24 Dec 2018 22:00:31 +0100
Subject: [PATCH] FIXUP: i2c: reject new transfers when adapters are suspended

Signed-off-by: Hans de Goede 
---
 drivers/i2c/i2c-core-base.c  | 2 +-
 drivers/i2c/i2c-core-smbus.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 3ce238b782f3..e2fae7ec6c95 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1865,7 +1865,7 @@ int 

[PATCH] net: chelsio: Add a missing check on cudg_get_buffer

2018-12-24 Thread Aditya Pakki
cudbg_collect_hw_sched() could fail when the function cudg_get_buffer()
returns an error. The fix adds a check to the latter function returning
error on failure

Signed-off-by: Aditya Pakki 
---
 drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c 
b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
index 7c49681407ad..127b1f624413 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
@@ -1229,6 +1229,10 @@ int cudbg_collect_hw_sched(struct cudbg_init *pdbg_init,
 
rc = cudbg_get_buff(pdbg_init, dbg_buff, sizeof(struct cudbg_hw_sched),
_buff);
+
+   if (rc)
+   return rc;
+
hw_sched_buff = (struct cudbg_hw_sched *)temp_buff.data;
hw_sched_buff->map = t4_read_reg(padap, TP_TX_MOD_QUEUE_REQ_MAP_A);
hw_sched_buff->mode = TIMERMODE_G(t4_read_reg(padap, TP_MOD_CONFIG_A));
-- 
2.17.1



Re: Fix 80d20d35af1e ("nohz: Fix local_timer_softirq_pending()") may have revealed another problem

2018-12-24 Thread Heiner Kallweit
On 15.10.2018 22:58, Heiner Kallweit wrote:
> On 28.09.2018 15:18, Frederic Weisbecker wrote:
>> On Thu, Sep 27, 2018 at 06:05:46PM +0200, Thomas Gleixner wrote:
>>> On Tue, 28 Aug 2018, Frederic Weisbecker wrote:
 On Fri, Aug 24, 2018 at 07:06:32PM +0200, Heiner Kallweit wrote:
> I tested it and Frederic is right, it doesn't help. Can it be somehow 
> related to
> the cpu being brought down during suspend? Because I get the warning only 
> during
> suspend when the cpu is inactive already (but still online).

 It's hard to tell, I haven't been able to reproduce on suspend to disk/mem.

 Does this script eventually trigger it after some time?
>>>
>>> Any update to this?
>>
>> Heiner? Can you please test the script I sent to you?
>>
>> Thanks.
>>
> Sorry, took some time .. And yes, running your script triggers the message 
> too.
> 
> [   25.646015] x86: Booting SMP configuration:
> [   25.646044] smpboot: Booting Node 0 Processor 1 APIC 0x2
> [   25.664491] smpboot: CPU 1 is now offline
> [   25.679299] x86: Booting SMP configuration:
> [   25.679329] smpboot: Booting Node 0 Processor 1 APIC 0x2
> [   25.698449] smpboot: CPU 1 is now offline
> [   25.711698] x86: Booting SMP configuration:
> [   25.711727] smpboot: Booting Node 0 Processor 1 APIC 0x2
> [   25.729185] NOHZ: local_softirq_pending 202
> [   25.729229] NOHZ: local_softirq_pending 202
> [   25.730759] smpboot: CPU 1 is now offline
> [   25.744053] x86: Booting SMP configuration:
> [   25.744083] smpboot: Booting Node 0 Processor 1 APIC 0x2
> [   25.762520] smpboot: CPU 1 is now offline
> [   25.776834] x86: Booting SMP configuration:
> [   25.776863] smpboot: Booting Node 0 Processor 1 APIC 0x2
> [   25.794189] NOHZ: local_softirq_pending 202
> [   25.796672] smpboot: CPU 1 is now offline
> [   25.805970] x86: Booting SMP configuration:
> [   25.805999] smpboot: Booting Node 0 Processor 1 APIC 0x2
> [   25.827360] smpboot: CPU 1 is now offline
> [   25.839043] x86: Booting SMP configuration:
> [   25.839073] smpboot: Booting Node 0 Processor 1 APIC 0x2
> [   25.858184] NOHZ: local_softirq_pending 202
> [   25.862182] smpboot: CPU 1 is now offline
> [   25.873759] x86: Booting SMP configuration:
> [   25.873789] smpboot: Booting Node 0 Processor 1 APIC 0x2
> [   25.893385] smpboot: CPU 1 is now offline
> 
Almost forgot about his topic, but the warning is still there.
Has there been any progress in analysis?


Re: [net] eedbbb0d98: RIP:inet_hashinfo2_init

2018-12-24 Thread Peter Oskolkov
A fix sent to netdev: https://patchwork.ozlabs.org/patch/1018304/

On Mon, Dec 24, 2018 at 5:01 AM kernel test robot  wrote:
>
>
> FYI, we noticed the following commit (built with gcc-7):
>
> commit: eedbbb0d98b2a89250a8bb83d9c71b77881e5247 ("net: dccp: initialize 
> (addr,port) listening hashtable")
> https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git master
>
> in testcase: trinity
> with following parameters:
>
> runtime: 300s
>
> test-description: Trinity is a linux system call fuzz tester.
> test-url: http://codemonkey.org.uk/projects/trinity/
>
>
> on test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 2G
>
> caused below changes (please refer to attached dmesg/kmsg for entire 
> log/backtrace):
>
>
> +---+++
> |   | 6a95147c51 | 
> eedbbb0d98 |
> +---+++
> | boot_successes| 4  | 4  
> |
> | boot_failures | 1  | 6  
> |
> | BUG:unable_to_handle_kernel   | 1  | 6  
> |
> | Oops:#[##]| 1  | 6  
> |
> | RIP:inet_lhash2_lookup| 1  |
> |
> | Kernel_panic-not_syncing:Fatal_exception_in_interrupt | 1  |
> |
> | RIP:inet_hashinfo2_init   | 0  | 6  
> |
> | Kernel_panic-not_syncing:Fatal_exception  | 0  | 6  
> |
> +---+++
>
>
>
> [   11.577638] BUG: unable to handle kernel paging request at 82cea1d0
> [   11.579009] PGD 260e067 P4D 260e067 PUD 260f063 PMD 7ef32063 PTE 
> 800ffd315062
> [   11.580404] Oops: 0010 [#1] SMP PTI
> [   11.581114] CPU: 1 PID: 523 Comm: modprobe Not tainted 
> 4.20.0-rc6-01475-geedbbb0 #1
> [   11.582531] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
> 1.10.2-1 04/01/2014
> [   11.584073] RIP: 0010:inet_hashinfo2_init+0x0/0x64
> [   11.584971] Code: Bad RIP value.
> [   11.585649] RSP: 0018:c9997ca0 EFLAGS: 00010246
> [   11.586596] RAX: a01aa000 RBX:  RCX: 
> 0015
> [   11.587813] RDX: 0020 RSI: a01a32b1 RDI: 
> a01a9dc0
> [   11.589037] RBP: a01b12ed R08:  R09: 
> 0001
> [   11.590259] R10:  R11:  R12: 
> 8880632d6ce0
> [   11.591475] R13: 0001 R14: 88807ee8fc00 R15: 
> c9997e98
> [   11.592711] FS:  7f454c916700() GS:88807250() 
> knlGS:
> [   11.594189] CS:  0010 DS:  ES:  CR0: 80050033
> [   11.595215] CR2: 82cea1a6 CR3: 7978a000 CR4: 
> 000406e0
> [   11.596436] Call Trace:
> [   11.597014]  dccp_init+0x61/0x309 [dccp]
> [   11.597788]  ? trace_event_define_fields_dccp_probe+0x227/0x227 [dccp]
> [   11.598947]  do_one_initcall+0x46/0x1e4
> [   11.599700]  ? _cond_resched+0x19/0x30
> [   11.600430]  ? kmem_cache_alloc_trace+0x3e/0x1e0
> [   11.601299]  do_init_module+0x5b/0x200
> [   11.602068]  load_module+0x1836/0x1cd0
> [   11.602814]  ? ima_post_read_file+0xe2/0x120
> [   11.603630]  ? __do_sys_finit_module+0xe9/0x110
> [   11.604471]  __do_sys_finit_module+0xe9/0x110
> [   11.605301]  do_syscall_64+0x5b/0x180
> [   11.606037]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
> [   11.606968] RIP: 0033:0x7f454c441229
> [   11.607693] Code: 00 f3 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 
> f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 
> 01 f0 ff ff 73 01 c3 48 8b 0d 3f 4c 2b 00 f7 d8 64 89 01 48
> [   11.610809] RSP: 002b:7fff3363ec38 EFLAGS: 0246 ORIG_RAX: 
> 0139
> [   11.612204] RAX: ffda RBX: 559e818104c0 RCX: 
> 7f454c441229
> [   11.613426] RDX:  RSI: 559e81177638 RDI: 
> 
> [   11.614653] RBP: 559e81177638 R08:  R09: 
> 0001
> [   11.615865] R10:  R11: 0246 R12: 
> 
> [   11.617090] R13: 559e8180f500 R14: 0004 R15: 
> 
> [   11.618310] Modules linked in: dccp(+) sr_mod cdrom sg ata_generic 
> pata_acpi crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel 
> ppdev aesni_intel crypto_simd cryptd glue_helper snd_pcm snd_timer snd 
> soundcore pcspkr serio_raw ata_piix libata i2c_piix4 parport_pc parport 
> floppy ip_tables
> [   11.622675] CR2: 82cea1d0
> [   11.623348] ---[ end trace b5a7a7e0716fa2b3 ]---
>
>
> To reproduce:
>
> git clone https://github.com/intel/lkp-tests.git
> cd lkp-tests

[PATCH -mmotm] arm64: fix build for MAX_USER_VA_BITS

2018-12-24 Thread Qian Cai
Some code in 9b31cf493ff was lost during merging into the -mmotm tree
for some reasons,

In file included from ./arch/arm64/include/asm/processor.h:46,
 from ./include/linux/rcupdate.h:43,
 from ./include/linux/rculist.h:11,
 from ./include/linux/pid.h:5,
 from ./include/linux/sched.h:14,
 from arch/arm64/kernel/asm-offsets.c:22:
./arch/arm64/include/asm/pgtable-hwdef.h:83:30: error:
'MAX_USER_VA_BITS' undeclared here (not in a function); did you mean
'MAX_USER_PRIO'?
 #define PTRS_PER_PGD  (1 << (MAX_USER_VA_BITS - PGDIR_SHIFT))
  ^~~~
./arch/arm64/include/asm/pgtable.h:442:26: note: in expansion of macro
'PTRS_PER_PGD'
 extern pgd_t init_pg_dir[PTRS_PER_PGD];
  ^~~~

Signed-off-by: Qian Cai 
---
 arch/arm64/include/asm/memory.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 1df0bb19117f..e1ec947e7c0c 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -67,6 +67,12 @@
 #define KERNEL_START  _text
 #define KERNEL_END_end
 
+#ifdef CONFIG_ARM64_USER_VA_BITS_52
+#define MAX_USER_VA_BITS   52
+#else
+#define MAX_USER_VA_BITS   VA_BITS
+#endif
+
 /*
  * Generic and tag-based KASAN require 1/8th and 1/16th of the kernel virtual
  * address space for the shadow region respectively. They can bloat the stack
-- 
2.17.2 (Apple Git-113)



Re: linux-next: Tree for Dec 24 (pinctrl/mediatek/)

2018-12-24 Thread Randy Dunlap
On 12/24/18 3:16 AM, Stephen Rothwell wrote:
> Hi all,
> 
> Just one more :-)
> 
> News: there will be no linux-next release until Jan 2.  Have a good break.
> 
> Changes since 20181221:
> 

on i386 or x86_64:

Lots of build errors for drivers/pinctrl/mediatek/pinctrl-moore.c when
CONFIG_OF is not enabled (but COMPILE_TEST is).


first this:
WARNING: unmet direct dependencies detected for PINCTRL_MTK_MOORE
  Depends on [n]: PINCTRL [=y] && (ARCH_MEDIATEK || COMPILE_TEST [=y]) && OF 
[=n]
  Selected by [y]:
  - PINCTRL_MT7623 [=y] && PINCTRL [=y] && (ARCH_MEDIATEK || COMPILE_TEST [=y]) 
&& (MACH_MT7623 || COMPILE_TEST [=y])


and then:
../drivers/pinctrl/mediatek/pinctrl-moore.c:22:44: error: array type has 
incomplete element type
 static const struct pinconf_generic_params mtk_custom_bindings[] = {
^
../drivers/pinctrl/mediatek/pinctrl-moore.c: In function 'mtk_pinmux_set_mux':
../drivers/pinctrl/mediatek/pinctrl-moore.c:46:2: error: implicit declaration 
of function 'pinmux_generic_get_function' 
[-Werror=implicit-function-declaration]
  func = pinmux_generic_get_function(pctldev, selector);
  ^
../drivers/pinctrl/mediatek/pinctrl-moore.c:46:7: warning: assignment makes 
pointer from integer without a cast [enabled by default]
  func = pinmux_generic_get_function(pctldev, selector);
   ^
../drivers/pinctrl/mediatek/pinctrl-moore.c:50:2: error: implicit declaration 
of function 'pinctrl_generic_get_group' [-Werror=implicit-function-declaration]
  grp = pinctrl_generic_get_group(pctldev, group);
  ^
../drivers/pinctrl/mediatek/pinctrl-moore.c:50:6: warning: assignment makes 
pointer from integer without a cast [enabled by default]
  grp = pinctrl_generic_get_group(pctldev, group);
  ^
In file included from ../include/linux/printk.h:331:0,
 from ../include/linux/kernel.h:14,
 from ../include/linux/list.h:9,
 from ../include/linux/kobject.h:19,
 from ../include/linux/device.h:16,
 from ../include/linux/gpio/driver.h:5,
 from ../drivers/pinctrl/mediatek/pinctrl-moore.c:11:
../drivers/pinctrl/mediatek/pinctrl-moore.c:55:7: error: dereferencing pointer 
to incomplete type
   func->name, grp->name);
   ^
../include/linux/dynamic_debug.h:136:9: note: in definition of macro 
'dynamic_dev_dbg'
   ##__VA_ARGS__);  \
 ^
../drivers/pinctrl/mediatek/pinctrl-moore.c:54:2: note: in expansion of macro 
'dev_dbg'
  dev_dbg(pctldev->dev, "enable function %s group %s\n",
  ^
../drivers/pinctrl/mediatek/pinctrl-moore.c:55:18: error: dereferencing pointer 
to incomplete type
   func->name, grp->name);
  ^
../include/linux/dynamic_debug.h:136:9: note: in definition of macro 
'dynamic_dev_dbg'
   ##__VA_ARGS__);  \
 ^
../drivers/pinctrl/mediatek/pinctrl-moore.c:54:2: note: in expansion of macro 
'dev_dbg'
  dev_dbg(pctldev->dev, "enable function %s group %s\n",
  ^
../drivers/pinctrl/mediatek/pinctrl-moore.c:57:21: error: dereferencing pointer 
to incomplete type
  for (i = 0; i < grp->num_pins; i++) {
 ^
../drivers/pinctrl/mediatek/pinctrl-moore.c:59:23: error: dereferencing pointer 
to incomplete type
   int *pin_modes = grp->data;
   ^
../drivers/pinctrl/mediatek/pinctrl-moore.c:60:16: error: dereferencing pointer 
to incomplete type
   int pin = grp->pins[i];
^
../drivers/pinctrl/mediatek/pinctrl-moore.c: In function 
'mtk_pinconf_group_get':
../drivers/pinctrl/mediatek/pinctrl-moore.c:357:2: error: implicit declaration 
of function 'pinctrl_generic_get_group_pins' 
[-Werror=implicit-function-declaration]
  ret = pinctrl_generic_get_group_pins(pctldev, group, , );
  ^
../drivers/pinctrl/mediatek/pinctrl-moore.c: At top level:
../drivers/pinctrl/mediatek/pinctrl-moore.c:397:22: error: 
'pinctrl_generic_get_group_count' undeclared here (not in a function)
  .get_groups_count = pinctrl_generic_get_group_count,
  ^
../drivers/pinctrl/mediatek/pinctrl-moore.c:398:20: error: 
'pinctrl_generic_get_group_name' undeclared here (not in a function)
  .get_group_name = pinctrl_generic_get_group_name,
^
../drivers/pinctrl/mediatek/pinctrl-moore.c:399:20: error: 
'pinctrl_generic_get_group_pins' undeclared here (not in a function)
  .get_group_pins = pinctrl_generic_get_group_pins,
^
../drivers/pinctrl/mediatek/pinctrl-moore.c:400:20: error: 
'pinconf_generic_dt_node_to_map_all' undeclared here (not in a function)
  .dt_node_to_map = pinconf_generic_dt_node_to_map_all,
^
../drivers/pinctrl/mediatek/pinctrl-moore.c:401:17: error: 
'pinconf_generic_dt_free_map' undeclared here (not in a function)
  .dt_free_map = pinconf_generic_dt_free_map,
 ^
../drivers/pinctrl/mediatek/pinctrl-moore.c:405:25: error: 
'pinmux_generic_get_function_count' undeclared here (not in a function)
  .get_functions_count = 

[GIT PULL] security: general updates for v4.21

2018-12-24 Thread James Morris
Hi Linus,

Please pull these general updates for the security subsystem for v4.21.

The main changes here are Paul Gortmaker's removal of unneccesary module.h 
infrastructure.

The following changes since commit 7566ec393f4161572ba6f11ad5171fd5d59b0fbd:

  Linux 4.20-rc7 (2018-12-16 15:46:55 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git 
next-general

for you to fetch changes up to b49d564344f773d8afee982153c8493e5f2eaf38:

  security: integrity: partial revert of make ima_main explicitly non-modular 
(2018-12-20 09:59:12 -0800)


James Morris (2):
  Merge tag 'v4.20-rc2' into next-general
  Merge tag 'v4.20-rc7' into next-general

Paul Gortmaker (6):
  security: integrity: make ima_main explicitly non-modular
  keys: remove needless modular infrastructure from ecryptfs_format
  security: integrity: make evm_main explicitly non-modular
  security: audit and remove any unnecessary uses of module.h
  security: fs: make inode explicitly non-modular
  security: integrity: partial revert of make ima_main explicitly 
non-modular

Yangtao Li (1):
  tomoyo: fix small typo

 security/apparmor/apparmorfs.c   | 2 +-
 security/commoncap.c | 1 -
 security/inode.c | 6 ++
 security/integrity/evm/evm_crypto.c  | 2 +-
 security/integrity/evm/evm_main.c| 5 +
 security/integrity/evm/evm_posix_acl.c   | 1 -
 security/integrity/evm/evm_secfs.c   | 2 +-
 security/integrity/iint.c| 2 +-
 security/integrity/ima/ima_api.c | 1 -
 security/integrity/ima/ima_appraise.c| 2 +-
 security/integrity/ima/ima_fs.c  | 2 +-
 security/integrity/ima/ima_init.c| 2 +-
 security/integrity/ima/ima_main.c| 5 ++---
 security/integrity/ima/ima_policy.c  | 2 +-
 security/integrity/ima/ima_queue.c   | 1 -
 security/keys/encrypted-keys/ecryptfs_format.c   | 5 ++---
 security/keys/encrypted-keys/masterkey_trusted.c | 1 -
 security/keys/gc.c   | 1 -
 security/keys/key.c  | 2 +-
 security/keys/keyctl.c   | 1 -
 security/keys/keyring.c  | 2 +-
 security/keys/permission.c   | 2 +-
 security/keys/proc.c | 1 -
 security/keys/process_keys.c | 1 -
 security/keys/request_key.c  | 2 +-
 security/keys/request_key_auth.c | 1 -
 security/keys/user_defined.c | 2 +-
 security/security.c  | 2 +-
 security/tomoyo/util.c   | 2 +-
 29 files changed, 22 insertions(+), 39 deletions(-)


[PATCH][V2] drivers/net: appletalk/cops: remove redundant if statement and mask

2018-12-24 Thread Colin King
From: Colin Ian King 

The two different assignments for pkt_len are actually the same and
so the if statement is redundant and can be removed.  Masking a u8
return value from inb() with 0xFF is also redundant and can also be
emoved.

Similarly, the two different outb calls are identical as the mask
of 0xff on the second outb is redundant since a u8 is being written,
so the if statement is also redundant and can be also removed.

Detected by CoverityScan, CID#1475639 ("Identical code for different
branches")

---

V2: Remove the if statement for the outb calls, thanks to David
Miller for spotting this.

Signed-off-by: Colin Ian King 
---
 drivers/net/appletalk/cops.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index bb49f6e40a19..494663a18ce0 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -777,10 +777,7 @@ static void cops_rx(struct net_device *dev)
 }
 
 /* Get response length. */
-   if(lp->board==DAYNA)
-   pkt_len = inb(ioaddr) & 0xFF;
-   else
-   pkt_len = inb(ioaddr) & 0x00FF;
+   pkt_len = inb(ioaddr);
 pkt_len |= (inb(ioaddr) << 8);
 /* Input IO code. */
 rsp_type=inb(ioaddr);
@@ -892,10 +889,7 @@ static netdev_tx_t cops_send_packet(struct sk_buff *skb,
 
/* Output IO length. */
outb(skb->len, ioaddr);
-   if(lp->board == DAYNA)
-   outb(skb->len >> 8, ioaddr);
-   else
-   outb((skb->len >> 8)&0x0FF, ioaddr);
+   outb(skb->len >> 8, ioaddr);
 
/* Output IO code. */
outb(LAP_WRITE, ioaddr);
-- 
2.19.1



[PATCH v2] drivers: thermal: int340x_thermal: Fix sysfs race condition

2018-12-24 Thread Aaron Hill
Changes since V1:
* Use dev_info instead of printk
* Use dev_warn instead of BUG_ON

Previously, sysfs_create_group was called before all initialization had
fully run - specifically, before pci_set_drvdata was called. Since the
sysctl group is visible to userspace as soon as sysfs_create_group
returns, a small window of time existed during which a process could read
from an uninitialized/partially-initialized device.

This commit moves the creation of the sysctl group to after all
initialized is completed. This ensures that it's impossible for
userspace to read from a sysctl file before initialization has fully
completed.

To catch any future regressions, I've added a check to ensure
that proc_thermal_emum_mode is never PROC_THERMAL_NONE when a process
tries to read from a sysctl file. Previously, the aforementioned race
condition could result in the 'else' branch
running while PROC_THERMAL_NONE was set,
leading to a null pointer deference.

Signed-off-by: Aaron Hill 
---
 .../processor_thermal_device.c| 28 ++-
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/thermal/int340x_thermal/processor_thermal_device.c 
b/drivers/thermal/int340x_thermal/processor_thermal_device.c
index 284cf2c5a8fd..0a43dbf0131b 100644
--- a/drivers/thermal/int340x_thermal/processor_thermal_device.c
+++ b/drivers/thermal/int340x_thermal/processor_thermal_device.c
@@ -81,10 +81,15 @@ static ssize_t power_limit_##index##_##suffix##_show(struct 
device *dev, \
struct device_attribute *attr, \
char *buf) \
 { \
+   if (proc_thermal_emum_mode == PROC_THERMAL_NONE) { \
+   dev_warn(dev, "Attempted to get power limit before device was 
initialized!\n"); \
+   return 0; \
+   } \
+   \
struct pci_dev *pci_dev; \
struct platform_device *pdev; \
struct proc_thermal_device *proc_dev; \
-\
+   \
if (proc_thermal_emum_mode == PROC_THERMAL_PLATFORM_DEV) { \
pdev = to_platform_device(dev); \
proc_dev = platform_get_drvdata(pdev); \
@@ -298,11 +303,6 @@ static int proc_thermal_add(struct device *dev,
*priv = proc_priv;
 
ret = proc_thermal_read_ppcc(proc_priv);
-   if (!ret) {
-   ret = sysfs_create_group(>kobj,
-_limit_attribute_group);
-
-   }
if (ret)
return ret;
 
@@ -316,8 +316,7 @@ static int proc_thermal_add(struct device *dev,
 
proc_priv->int340x_zone = int340x_thermal_zone_add(adev, ops);
if (IS_ERR(proc_priv->int340x_zone)) {
-   ret = PTR_ERR(proc_priv->int340x_zone);
-   goto remove_group;
+   return PTR_ERR(proc_priv->int340x_zone);
} else
ret = 0;
 
@@ -331,9 +330,6 @@ static int proc_thermal_add(struct device *dev,
 
 remove_zone:
int340x_thermal_zone_remove(proc_priv->int340x_zone);
-remove_group:
-   sysfs_remove_group(_priv->dev->kobj,
-  _limit_attribute_group);
 
return ret;
 }
@@ -364,7 +360,10 @@ static int int3401_add(struct platform_device *pdev)
platform_set_drvdata(pdev, proc_priv);
proc_thermal_emum_mode = PROC_THERMAL_PLATFORM_DEV;
 
-   return 0;
+   dev_info(>dev, "Creating sysfs group for 
PROC_THERMAL_PLATFORM_DEV\n");
+
+   return sysfs_create_group(>dev.kobj,
+_limit_attribute_group);
 }
 
 static int int3401_remove(struct platform_device *pdev)
@@ -441,7 +440,10 @@ static int  proc_thermal_pci_probe(struct pci_dev *pdev,
dev_err(>dev, "No auxiliary DTSs enabled\n");
}
 
-   return 0;
+   dev_info(>dev, "Creating sysfs group for PROC_THERMAL_PCI\n");
+
+   return sysfs_create_group(>dev.kobj,
+_limit_attribute_group);
 }
 
 static void  proc_thermal_pci_remove(struct pci_dev *pdev)
-- 
2.20.1



[GIT PULL] regmap updates for v4.21

2018-12-24 Thread Mark Brown
The following changes since commit 7566ec393f4161572ba6f11ad5171fd5d59b0fbd:

  Linux 4.20-rc7 (2018-12-16 15:46:55 -0800)

are available in the Git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git 
tags/regmap-v4.21

for you to fetch changes up to 58331d618bd9ced88a21a9b68c7743b84c2f4803:

  Merge remote-tracking branch 'regmap/topic/irq' into regmap-next (2018-12-19 
18:38:33 +)


regmap: Updates for v4.21

This has been a busy release for the regmap-irq code, there's several
new features been added, including an API cleanup for how we specify
types that affected one existing driver (gpio-max77620):

 - Support for hardware that flags rising and falling edges on separate
   status bits from Bartosz Golaszewski.
 - Support for explicitly clearing interrupts before unmasking from
   Bartosz Golaszewski.
 - Support for level triggered IRQs from Matti Vaittinen.


Bartosz Golaszewski (2):
  regmap: irq: handle HW using separate rising/falling edge interrupts
  regmap: irq: add an option to clear status registers on unmask

Mark Brown (2):
  Merge branch 'regmap-4.21' into regmap-next
  Merge remote-tracking branch 'regmap/topic/irq' into regmap-next

Matti Vaittinen (2):
  regmap: regmap-irq: Remove default irq type setting from core
  regmap: regmap-irq/gpio-max77620: add level-irq support

Tony Xie (1):
  regmap: add a new macro:REGMAP_IRQ_REG_LINE(_id, _reg_bits)

Yangtao Li (2):
  regmap: rbtree: convert to DEFINE_SHOW_ATTRIBUTE
  regmap: debugfs: convert to DEFINE_SHOW_ATTRIBUTE

 drivers/base/regmap/regcache-rbtree.c |  12 +--
 drivers/base/regmap/regmap-debugfs.c  |  12 +--
 drivers/base/regmap/regmap-irq.c  | 142 --
 drivers/gpio/gpio-max77620.c  |  96 +++
 include/linux/regmap.h|  41 --
 5 files changed, 200 insertions(+), 103 deletions(-)


signature.asc
Description: PGP signature


[GIT PULL] SPI updates for v4.21

2018-12-24 Thread Mark Brown
The following changes since commit 7566ec393f4161572ba6f11ad5171fd5d59b0fbd:

  Linux 4.20-rc7 (2018-12-16 15:46:55 -0800)

are available in the Git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git tags/spi-v4.21

for you to fetch changes up to 74ff666bd7ba2da563f99f2a8af7bf9f20008bc9:

  Merge remote-tracking branches 'spi/topic/mem' and 'spi/topic/mtd' into 
spi-next (2018-12-20 16:01:30 +)


spi: Updates for v4.21

The main thing this release has been a lot of work on the integration
with SPI NOR flashes, there's been some specific support for a while for
controller features designed to make them perform better but it's not
worked out as well as hoped so the interface has been redesigned in a
way that will hopefully do better - it's already been adopted by a
number of additional controllers so things are looking good.  Otherwise
most of the work has been driver specific:

 - Support for better integration with NOR flashes from Boris Brezillon
   and Yogesh Narayan Gaur plus usage of it in several drivers.
 - A big cleanup of the Rockchip driver from Emil Renner Berthing.
 - Lots of performance improvements for bcm2835 from Lukas Wunner.
 - Slave mode support for pxa2xx from Lubomir Rintel.
 - Support for Macronix MXIC, Mediatek MT7629 and MT8183, NPCM PSPI,
   and Renesas r8a77470.


Alok Chauhan (2):
  spi: spi-geni-qcom: fix nitpicks
  spi: spi-geni-qcom: Simplify probe function

Arnd Bergmann (1):
  mtd: atmel-quadspi: disallow building on ebsa110

Boris Brezillon (4):
  spi: spi-mem: Add missing word in the SPI_MEM_DATA_OUT description
  spi: spi-mem: Add SPI_MEM_NO_DATA to the spi_mem_data_dir enum
  spi: spi-mem: Split spi_mem_exec_op() code
  spi: spi-mem: Add a new API to support direct mapping

Chuanhua Han (1):
  spi: spi-fsl-dspi: use IRQF_SHARED mode to request IRQ

Clark Wang (4):
  spi: lpspi: Replace all "master" with "controller"
  spi: lpspi: Add slave mode support
  spi: lpspi: Let watermark change with send data length
  doc: lpspi: Document DT bindings for LPSPI slave mode

Colin Ian King (1):
  spi: npcm: fix u32 csgpio being checked for less than zero

Dan Carpenter (1):
  spi: npcm: Fix an error code in the probe function

Emil Renner Berthing (14):
  spi: rockchip: make spi_enable_chip take bool
  spi: rockchip: use designated init for dma config
  spi: rockchip: always use SPI mode
  spi: rockchip: use atomic_t state
  spi: rockchip: disable spi on error
  spi: rockchip: read transfer info directly
  spi: rockchip: don't store dma channels twice
  spi: rockchip: remove master pointer from dev data
  spi: rockchip: simplify use_dma logic
  spi: rockchip: set min/max speed
  spi: rockchip: precompute rx sample delay
  spi: rockchip: use irq rather than polling
  spi: rockchip: support 4bit words
  spi: rockchip: support lsb-first mode

Fabrizio Castro (2):
  spi: rspi: Add r8a77470 to the compatible list
  spi: sh-msiof: Add r8a774c0 support

Fredrik Ternerot (1):
  spi: pl022: Handle cs_change for last transfer

Hoan Nguyen An (1):
  spi: sh-msiof: Reduce the number of times write to and perform the 
transmission from FIFO

Jarkko Nikula (1):
  spi: pxa2xx: Remove LPSS private register restoring during resume

Jay Fang (1):
  spi: dw-mmio: add ACPI support

Keiji Hayashibara (2):
  spi: uniphier: fix incorrect property items
  spi: uniphier: re-add addressing properties

Leilk Liu (4):
  spi: mediatek: Add bindings for mediatek MT8183 soc platform
  spi: mediatek: add spi support for mt8183 IC
  spi: mediatek: Add bindings for mediatek MT7629 soc platform
  spi: mediatek: add spi support for mt7629 IC

Linus Walleij (1):
  spi: gpio: Support 3WIRE high-impedance turn-around

Lubomir Rintel (7):
  spi: pxa2xx: dt-bindings: Add spi-slave property
  spi: Deal with slaves that return from transfer_one() unfinished
  spi: pxa2xx: Add slave mode support
  spi: pxa2xx: dt-bindings: Add ready GPIO signal
  spi: pxa2xx: Add ready signal
  spi: pxa2xx: Deal with the leftover garbage in TXFIFO
  spi: pxa2xx: Fix '"CONFIG_OF" is not defined' warning

Lukas Wunner (10):
  spi: bcm2835: Avoid finishing transfer prematurely in IRQ mode
  spi: bcm2835: Fix book-keeping of DMA termination
  spi: bcm2835: Fix race on DMA termination
  spi: bcm2835: Drop unused code for native Chip Select
  spi: bcm2835: Document struct bcm2835_spi
  spi: bcm2835: Overcome sglist entry length limitation
  spi: bcm2835: Unbreak the build of esoteric configs
  spi: bcm2835: Polish transfer of DMA prologue
  spi: bcm2835: Speed up FIFO access if fill level is known
  spi: bcm2835: Synchronize with callback on DMA termination


Re: [PATCH 2/2] ARC: show_regs: fix lockdep splat for good

2018-12-24 Thread Michal Hocko
On Fri 21-12-18 09:55:34, Vineet Gupta wrote:
> On 12/21/18 5:04 AM, Michal Hocko wrote:
[...]
> > Yes, the fix might be more involved but I would much rather prefer a
> > correct code which builds on solid assumptions.
> 
> Right so the first step is reverting the disabled semantics for ARC and do 
> some
> heavy testing to make sure any fallouts are addressed etc. And if that works, 
> then
> propagate this change to core itself. Low risk strategy IMO - agree ?

Yeah, I would simply remove the preempt_disable and see what falls out.
smp_processor_id could be converted to the raw version etc...
-- 
Michal Hocko
SUSE Labs


Re: [PATCH net-next 0/3] vhost: accelerate metadata access through vmap()

2018-12-24 Thread Michael S. Tsirkin
On Mon, Dec 24, 2018 at 04:44:14PM +0800, Jason Wang wrote:
> 
> On 2018/12/17 上午3:57, Michael S. Tsirkin wrote:
> > On Sat, Dec 15, 2018 at 11:43:08AM -0800, David Miller wrote:
> > > From: Jason Wang 
> > > Date: Fri, 14 Dec 2018 12:29:54 +0800
> > > 
> > > > On 2018/12/14 上午4:12, Michael S. Tsirkin wrote:
> > > > > On Thu, Dec 13, 2018 at 06:10:19PM +0800, Jason Wang wrote:
> > > > > > Hi:
> > > > > > 
> > > > > > This series tries to access virtqueue metadata through kernel 
> > > > > > virtual
> > > > > > address instead of copy_user() friends since they had too much
> > > > > > overheads like checks, spec barriers or even hardware feature
> > > > > > toggling.
> > > > > > 
> > > > > > Test shows about 24% improvement on TX PPS. It should benefit other
> > > > > > cases as well.
> > > > > > 
> > > > > > Please review
> > > > > I think the idea of speeding up userspace access is a good one.
> > > > > However I think that moving all checks to start is way too aggressive.
> > > > 
> > > > So did packet and AF_XDP. Anyway, sharing address space and access
> > > > them directly is the fastest way. Performance is the major
> > > > consideration for people to choose backend. Compare to userspace
> > > > implementation, vhost does not have security advantages at any
> > > > level. If vhost is still slow, people will start to develop backends
> > > > based on e.g AF_XDP.
> > > Exactly, this is precisely how this kind of problem should be solved.
> > > 
> > > Michael, I strongly support the approach Jason is taking here, and I
> > > would like to ask you to seriously reconsider your objections.
> > > 
> > > Thank you.
> > Okay. Won't be the first time I'm wrong.
> > 
> > Let's say we ignore security aspects, but we need to make sure the
> > following all keep working (broken with this revision):
> > - file backed memory (I didn't see where we mark memory dirty -
> >if we don't we get guest memory corruption on close, if we do
> >then host crash as https://lwn.net/Articles/774411/ seems to apply here?)
> 
> 
> We only pin metadata pages, so I don't think they can be used for DMA. So it
> was probably not an issue. The real issue is zerocopy codes, maybe it's time
> to disable it by default?
> 
> 
> > - THP
> 
> 
> We will miss 2 or 4 pages for THP, I wonder whether or not it's measurable.
> 
> 
> > - auto-NUMA
> 
> 
> I'm not sure auto-NUMA will help for the case of IPC. It can damage the
> performance in the worst case if vhost and userspace are running in two
> different nodes. Anyway I can measure.
> 
> 
> > 
> > Because vhost isn't like AF_XDP where you can just tell people "use
> > hugetlbfs" and "data is removed on close" - people are using it in lots
> > of configurations with guest memory shared between rings and unrelated
> > data.
> 
> 
> This series doesn't share data, only metadata is shared.

Let me clarify - I mean that metadata is in same huge page with
unrelated guest data. 

> 
> > 
> > Jason, thoughts on these?
> > 
> 
> Based on the above, I can measure the impact of THP to see how it impacts.
> 
> For unsafe variants, it can only work for when we can batch the access and
> it needs non trivial rework on the vhost codes with unexpected amount of
> work for archs other than x86. I'm not sure it's worth to try.
> 
> Thanks

Yes I think we need better APIs in vhost. Right now
we have an API to get and translate a single buffer.
We should have one that gets a batch of descriptors
and stores it, then one that translates this batch.

IMHO this will benefit everyone even if we do vmap due to
better code locality.

-- 
MST


[PATCH] clk: Fix a missing check on regmap_bulk_read

2018-12-24 Thread Aditya Pakki
Currently, vc5_pll_recalc_rate() may produce incorrect output when
regmap_bulk_read() fails. The fix checks the return value of the
latter function and returns 0 in case of failure.

Signed-off-by: Aditya Pakki 
---
 drivers/clk/clk-versaclock5.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
index decffb3826ec..cd76a893c594 100644
--- a/drivers/clk/clk-versaclock5.c
+++ b/drivers/clk/clk-versaclock5.c
@@ -413,7 +413,8 @@ static unsigned long vc5_pll_recalc_rate(struct clk_hw *hw,
u32 div_int, div_frc;
u8 fb[5];
 
-   regmap_bulk_read(vc5->regmap, VC5_FEEDBACK_INT_DIV, fb, 5);
+   if (regmap_bulk_read(vc5->regmap, VC5_FEEDBACK_INT_DIV, fb, 5))
+   return 0;
 
div_int = (fb[0] << 4) | (fb[1] >> 4);
div_frc = (fb[2] << 16) | (fb[3] << 8) | fb[4];
-- 
2.17.1



[GIT PULL] regulator updates for v4.21

2018-12-24 Thread Mark Brown
The following changes since commit 7566ec393f4161572ba6f11ad5171fd5d59b0fbd:

  Linux 4.20-rc7 (2018-12-16 15:46:55 -0800)

are available in the Git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 
tags/regulator-v4.21

for you to fetch changes up to c3b5725965228014215de553eed3492dbd80a4bd:

  Merge remote-tracking branch 'regulator/topic/coupled' into regulator-next 
(2018-12-21 13:43:35 +)


regulator: Updates for v4.20

This has been a very busy release for the core, some fixes, one large new
feature and a big bit of refactoring to update the GPIO API:

 - Support for coupled regulators from Dmitry Osipenko based on a prior
   attempt by Maciej Purski, allowing us to handle situations where the
   voltages on two regulators can't be too far apart from each other.
 - Conversion of the GPIO support in both drivers and the core to use
   GPIO descriptors rather than numbers, part of the overall project to
   remove GPIO numbers.
 - Support for standby mode suspend states from Andrei Stefanescu.
 - New drivers for Allwinner AXP209, Cirrus Logic Lochnagar and
   Microchip MPC16502.


Adam Ford (1):
  regulator: pfuze100-regulator: add coin support to PF0100

andrei.stefane...@microchip.com (7):
  regulator: dt-bindings: add regulator-state-standby bindings
  regulator: of: add support for parsing regulator-state-standby
  regulator: dt-bindings: add MCP16502 regulator bindings
  MAINTAINERS: add maintainer for MCP16502 PMIC driver
  regulator: mcp16502: add regulator driver for MCP16502
  regulator: mcp16502: add support for suspend
  regulator: mcp16502: code cleanup

Axel Lin (4):
  regulator: bd718x7: Use regulator_map_voltage_ascend for buck5 and buck7
  regulator: mcp16502: Use #ifdef CONFIG_PM_SLEEP around 
mcp16502_suspend/resume_noirq
  regulator: mcp16502: Fix missing n_voltages setting
  regulator: mcp16502: Select REGMAP_I2C to fix build error

Boris Brezillon (1):
  regulator: act8945a-regulator: Implement PM functionalities

Charles Keepax (6):
  regulator: lochnagar: Explicitly include register headers
  regulator: lochnagar: Move driver to binding from DT
  regulator: lochnagar: Add initial binding documentation
  regulator: wm8994: Don't use devres for enable GPIOs
  regulator: Factor out location of init data OF node
  regulator: Allow regulator nodes to contain their own init data

Claudiu Beznea (5):
  regulator: act8945a-regulator: unlock expert registers
  regulator: act8945a-regulator: fix line over 80 chars warning
  regulator: act8945a-regulator: add shutdown function
  regulator: add documentation for regulator modes and suspend states
  regulator: act8945a-regulator: fix 'defined but not used' compiler warning

Dmitry Osipenko (12):
  regulator: core: Mutually resolve regulators coupling
  regulator: core: Don't allow to get regulator until all couples resolved
  regulator: Change regulator-coupled-max-spread property
  regulator: core: Limit regulators coupling to a single couple
  regulator: Document new regulator-max-step-microvolt property
  regulator: core: Add new max_uV_step constraint
  regulator: core: Decouple regulators on regulator_unregister()
  regulator: core: Use ww_mutex for regulators locking
  regulator: core: Properly handle case where supply is the couple
  regulator: core: Keep regulators-list locked while traversing the list
  regulator: Change regulator-coupled-max-spread property
  regulator: core: Export regulator_lock and regulator_unlock

Douglas Anderson (6):
  regulator: core: Properly expose requested_microamps in sysfs
  regulator: core: Don't double-disable supplies in 
regulator_disable_deferred()
  regulator: core: Only count load for enabled consumers
  regulator: core: Avoid propagating to supplies when possible
  regulator: core: Apply system load even if no consumer loads
  regulator: core: Clean enabling always-on regulators + their supplies

Geert Uytterhoeven (1):
  regulator: bd718x7: Remove double indirection for 
bd718xx_pmic_inits.rdatas

Kangjie Lu (2):
  drivers/regulator: fix a missing check of return value
  regulator: tps65910: fix a missing check of return value

Kuninori Morimoto (2):
  regulator: bd9571mwv: convert to SPDX identifiers
  regulator: as3711: convert to SPDX identifiers

Linus Walleij (20):
  regulator: s2mps11: Pass descriptor instead of GPIO number
  regulator: wm8994: Pass descriptor instead of GPIO number
  regulator: max77686: Pass descriptor instead of GPIO number
  regulator: core: Track dangling GPIO descriptors
  regulator: fixed: Let core handle GPIO descriptor
  regulator: lm363x: Let core handle GPIO descriptor
  

Re: Bug with report THP eligibility for each vma

2018-12-24 Thread Michal Hocko
On Mon 24-12-18 14:12:51, Mike Rapoport wrote:
> On Mon, Dec 24, 2018 at 08:49:16AM +0100, Michal Hocko wrote:
> > [Cc-ing mailing list and people involved in the original patch]
> > 
> > On Fri 21-12-18 13:42:24, Paul Oppenheimer wrote:
> > > Hello! I've never reported a kernel bug before, and since its on the
> > > "next" tree I was told to email the author of the relevant commit.
> > > Please redirect me to the correct place if I've made a mistake.
> > > 
> > > When opening firefox or chrome, and using it for a good 7 seconds, it
> > > hangs in "uninterruptible sleep" and I recieve a "BUG" in dmesg. This
> > > doesn't occur when reverting this commit:
> > > https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=48cf516f8c.
> > > Ive attached the output of decode_stacktrace.sh and the relevant dmesg
> > > log to this email.
> > > 
> > > Thanks
> > 
> > > BUG: unable to handle kernel NULL pointer dereference at 00e8
> > 
> > Thanks for the bug report! This is offset 232 and that matches
> > file->f_mapping as per pahole
> > pahole -C file ./vmlinux | grep f_mapping
> > struct address_space * f_mapping;/*   232 8 */
> > 
> > I thought that each file really has to have a mapping. But the following
> > should heal the issue and add an extra care.
> > 
> > diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> > index f64733c23067..fc9d70a9fbd1 100644
> > --- a/mm/huge_memory.c
> > +++ b/mm/huge_memory.c
> > @@ -66,6 +66,8 @@ bool transparent_hugepage_enabled(struct vm_area_struct 
> > *vma)
> >  {
> > if (vma_is_anonymous(vma))
> > return __transparent_hugepage_enabled(vma);
> > +   if (!vma->vm_file || !vma->vm_file->f_mapping)
> > +   return false;
> > if (shmem_mapping(vma->vm_file->f_mapping) && shmem_huge_enabled(vma))
> > return __transparent_hugepage_enabled(vma);
> 
> We have vma_is_shmem(), it can be used to replace shmem_mapping() without
> adding the check for !vma->vm_file

Yes, this looks like a much better choice. Thanks! Andrew, could you
fold this in instead.

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index f64733c23067..e093cf5e4640 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -66,7 +66,7 @@ bool transparent_hugepage_enabled(struct vm_area_struct *vma)
 {
if (vma_is_anonymous(vma))
return __transparent_hugepage_enabled(vma);
-   if (shmem_mapping(vma->vm_file->f_mapping) && shmem_huge_enabled(vma))
+   if (vma_is_shmem(vma) && shmem_huge_enabled(vma))
return __transparent_hugepage_enabled(vma);
 
return false;
-- 
Michal Hocko
SUSE Labs


Re: [B.A.T.M.A.N.] [PATCH] batman-adv/main: Fix check on return value of rtnl_link_register

2018-12-24 Thread Sven Eckelmann
On Monday, 24 December 2018 18.49.26 CET Aditya Pakki wrote:
> rtnl_link_register() may fail and can impact registering the device.
> The fix checks the return value and pushes the error upstream.

Regarding the commit message - what is "batman-adv/main"? Shouldn't this be 
"batman-adv: "?

And the device can still be registered without batadv_link_ops - just not 
using rtnl.

Kind regards,
Sven


signature.asc
Description: This is a digitally signed message part.


Re: [B.A.T.M.A.N.] [PATCH] batman-adv/main: Fix check on return value of rtnl_link_register

2018-12-24 Thread Sven Eckelmann
On Monday, 24 December 2018 18.49.26 CET Aditya Pakki wrote:
[...]
> diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
> index 69c0d85bceb3..e0007f242823 100644
> --- a/net/batman-adv/main.c
> +++ b/net/batman-adv/main.c
> @@ -109,7 +109,10 @@ static int __init batadv_init(void)
>   batadv_debugfs_init();
>  
>   register_netdevice_notifier(_hard_if_notifier);
> - rtnl_link_register(_link_ops);
> + ret = rtnl_link_register(_link_ops);
> + if (ret < 0)
> + return ret;
> +
>   batadv_netlink_register();

Uhm, but shouldn't the already initialized parts be unregistered/uninitialized 
in this case?

Rejecting this patch because this could cause a new bug.

Also "Fixes: " line is missing

Kind regards,
Sven

signature.asc
Description: This is a digitally signed message part.


Re: FYI: Userland breakage caused by udev bind commit

2018-12-24 Thread Christian Brauner
On Mon, Dec 24, 2018 at 10:28:20AM -0800, Linus Torvalds wrote:
> On Mon, Dec 24, 2018 at 10:13 AM Christian Brauner  
> wrote:
> >
> > So one possibility is to add a socket option for lib/kobject_uevent.c
> > that can be set via setsockopt. We did something like this in netlink
> > for strict property and header checking without breaking backwards
> > compatibility.
> 
> I'd actually prefer for it to be some /sys interface or other. Maybe
> it could even be per-device or class, and you could do something like
> 
>echo "enable bind" > /sys/bus/serio/uevent
> 
> the uevent code already supports a per-node "filter" function, maybe
> that notion could be extended to also have a filter for uevent types.

Hm, then we maybe we should think about proper kernel-side uevent
filtering at some point (thinking out loud). But that's also a lot of
complexity and I'm not sure that udev users actually would want this.
Would be helpful if a current udev maintainer could comment on this (I
think recently Yu Watanabe stepped up to maintain systemd-udevd? But I
haven't got his mail address.)
But imho, if we can come up with something simple like a flag first as
opt-in we can still allow for more fine-grained filtering later...

Christian

> 
> But I'm just handwaving. Maybe it's better per uevent socket or something.
> 
>   Linus


[PATCH] input/touchscreen: Fix a missing check on regmap_bulk_read

2018-12-24 Thread Aditya Pakki
regmap_bulk_read() can return a non zero value on failure. The fix
checks if the function call succeeded before calling mod_timer.

Signed-off-by: Aditya Pakki 
---
 drivers/input/touchscreen/ad7879.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/ad7879.c 
b/drivers/input/touchscreen/ad7879.c
index 6bad23ee47a1..735cb4c0d913 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -247,11 +247,12 @@ static void ad7879_timer(struct timer_list *t)
 static irqreturn_t ad7879_irq(int irq, void *handle)
 {
struct ad7879 *ts = handle;
+   int ret;
 
-   regmap_bulk_read(ts->regmap, AD7879_REG_XPLUS,
-ts->conversion_data, AD7879_NR_SENSE);
+   ret = regmap_bulk_read(ts->regmap, AD7879_REG_XPLUS,
+   ts->conversion_data, AD7879_NR_SENSE);
 
-   if (!ad7879_report(ts))
+   if (!ret && !ad7879_report(ts))
mod_timer(>timer, jiffies + TS_PEN_UP_TIMEOUT);
 
return IRQ_HANDLED;
-- 
2.17.1



  1   2   3   4   >