[PATCH 3/3] staging: rtl8712: usb_halinit.c: Remove p from variable names

2019-06-06 Thread Nishka Dasgupta
Remove leading 'p' from the names of the following pointer variables:
- padapter
- precvbuf
- pintfhdl
- pregistrypriv
- precvpriv.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta 
---
 drivers/staging/rtl8712/usb_halinit.c | 288 +-
 1 file changed, 144 insertions(+), 144 deletions(-)

diff --git a/drivers/staging/rtl8712/usb_halinit.c 
b/drivers/staging/rtl8712/usb_halinit.c
index 02e73c2412d4..6cc4a704c3a0 100644
--- a/drivers/staging/rtl8712/usb_halinit.c
+++ b/drivers/staging/rtl8712/usb_halinit.c
@@ -21,258 +21,258 @@
 #include "usb_ops.h"
 #include "usb_osintf.h"
 
-u8 r8712_usb_hal_bus_init(struct _adapter *padapter)
+u8 r8712_usb_hal_bus_init(struct _adapter *adapter)
 {
u8 val8 = 0;
u8 ret = _SUCCESS;
int PollingCnt = 20;
-   struct registry_priv *pregistrypriv = >registrypriv;
+   struct registry_priv *registrypriv = >registrypriv;
 
-   if (pregistrypriv->chip_version == RTL8712_FPGA) {
+   if (registrypriv->chip_version == RTL8712_FPGA) {
val8 = 0x01;
/* switch to 80M clock */
-   r8712_write8(padapter, SYS_CLKR, val8);
-   val8 = r8712_read8(padapter, SPS1_CTRL);
+   r8712_write8(adapter, SYS_CLKR, val8);
+   val8 = r8712_read8(adapter, SPS1_CTRL);
val8 = val8 | 0x01;
/* enable VSPS12 LDO Macro block */
-   r8712_write8(padapter, SPS1_CTRL, val8);
-   val8 = r8712_read8(padapter, AFE_MISC);
+   r8712_write8(adapter, SPS1_CTRL, val8);
+   val8 = r8712_read8(adapter, AFE_MISC);
val8 = val8 | 0x01;
/* Enable AFE Macro Block's Bandgap */
-   r8712_write8(padapter, AFE_MISC, val8);
-   val8 = r8712_read8(padapter, LDOA15_CTRL);
+   r8712_write8(adapter, AFE_MISC, val8);
+   val8 = r8712_read8(adapter, LDOA15_CTRL);
val8 = val8 | 0x01;
/* enable LDOA15 block */
-   r8712_write8(padapter, LDOA15_CTRL, val8);
-   val8 = r8712_read8(padapter, SPS1_CTRL);
+   r8712_write8(adapter, LDOA15_CTRL, val8);
+   val8 = r8712_read8(adapter, SPS1_CTRL);
val8 = val8 | 0x02;
/* Enable VSPS12_SW Macro Block */
-   r8712_write8(padapter, SPS1_CTRL, val8);
-   val8 = r8712_read8(padapter, AFE_MISC);
+   r8712_write8(adapter, SPS1_CTRL, val8);
+   val8 = r8712_read8(adapter, AFE_MISC);
val8 = val8 | 0x02;
/* Enable AFE Macro Block's Mbias */
-   r8712_write8(padapter, AFE_MISC, val8);
-   val8 = r8712_read8(padapter, SYS_ISO_CTRL + 1);
+   r8712_write8(adapter, AFE_MISC, val8);
+   val8 = r8712_read8(adapter, SYS_ISO_CTRL + 1);
val8 = val8 | 0x08;
/* isolate PCIe Analog 1.2V to PCIe 3.3V and PCIE Digital */
-   r8712_write8(padapter, SYS_ISO_CTRL + 1, val8);
-   val8 = r8712_read8(padapter, SYS_ISO_CTRL + 1);
+   r8712_write8(adapter, SYS_ISO_CTRL + 1, val8);
+   val8 = r8712_read8(adapter, SYS_ISO_CTRL + 1);
val8 = val8 & 0xEF;
/* attatch AFE PLL to MACTOP/BB/PCIe Digital */
-   r8712_write8(padapter, SYS_ISO_CTRL + 1, val8);
-   val8 = r8712_read8(padapter, AFE_XTAL_CTRL + 1);
+   r8712_write8(adapter, SYS_ISO_CTRL + 1, val8);
+   val8 = r8712_read8(adapter, AFE_XTAL_CTRL + 1);
val8 = val8 & 0xFB;
/* enable AFE clock */
-   r8712_write8(padapter, AFE_XTAL_CTRL + 1, val8);
-   val8 = r8712_read8(padapter, AFE_PLL_CTRL);
+   r8712_write8(adapter, AFE_XTAL_CTRL + 1, val8);
+   val8 = r8712_read8(adapter, AFE_PLL_CTRL);
val8 = val8 | 0x01;
/* Enable AFE PLL Macro Block */
-   r8712_write8(padapter, AFE_PLL_CTRL, val8);
+   r8712_write8(adapter, AFE_PLL_CTRL, val8);
val8 = 0xEE;
/* release isolation AFE PLL & MD */
-   r8712_write8(padapter, SYS_ISO_CTRL, val8);
-   val8 = r8712_read8(padapter, SYS_CLKR + 1);
+   r8712_write8(adapter, SYS_ISO_CTRL, val8);
+   val8 = r8712_read8(adapter, SYS_CLKR + 1);
val8 = val8 | 0x08;
/* enable MAC clock */
-   r8712_write8(padapter, SYS_CLKR + 1, val8);
-   val8 = r8712_read8(padapter, SYS_FUNC_EN + 1);
+   r8712_write8(adapter, SYS_CLKR + 1, val8);
+   val8 = r8712_read8(adapter, SYS_FUNC_EN + 1);
val8 = val8 | 0x08;
/* enable Core digital and enable IOREG R/W */
-   r8712_write8(padapter, SYS_FUNC_EN + 1, val8);
+ 

[PATCH 1/3] staging: rtl8712: xmit_linux.c: Remove leading p from variable names

2019-06-06 Thread Nishka Dasgupta
Remove leading p from the names of the following pointer variables:
- padapter
- pxmitpriv
- pnetdev
- pxmitframe.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta 
---
 drivers/staging/rtl8712/xmit_linux.c | 50 ++--
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/rtl8712/xmit_linux.c 
b/drivers/staging/rtl8712/xmit_linux.c
index 8bcb0775411f..223a4eba4bf4 100644
--- a/drivers/staging/rtl8712/xmit_linux.c
+++ b/drivers/staging/rtl8712/xmit_linux.c
@@ -93,22 +93,22 @@ void r8712_set_qos(struct pkt_file *ppktfile, struct 
pkt_attrib *pattrib)
 
 void r8712_SetFilter(struct work_struct *work)
 {
-   struct _adapter *padapter = container_of(work, struct _adapter,
+   struct _adapter *adapter = container_of(work, struct _adapter,
wkFilterRxFF0);
u8  oldvalue = 0x00, newvalue = 0x00;
unsigned long irqL;
 
-   oldvalue = r8712_read8(padapter, 0x117);
+   oldvalue = r8712_read8(adapter, 0x117);
newvalue = oldvalue & 0xfe;
-   r8712_write8(padapter, 0x117, newvalue);
+   r8712_write8(adapter, 0x117, newvalue);
 
-   spin_lock_irqsave(>lockRxFF0Filter, irqL);
-   padapter->blnEnableRxFF0Filter = 1;
-   spin_unlock_irqrestore(>lockRxFF0Filter, irqL);
+   spin_lock_irqsave(>lockRxFF0Filter, irqL);
+   adapter->blnEnableRxFF0Filter = 1;
+   spin_unlock_irqrestore(>lockRxFF0Filter, irqL);
do {
msleep(100);
-   } while (padapter->blnEnableRxFF0Filter == 1);
-   r8712_write8(padapter, 0x117, oldvalue);
+   } while (adapter->blnEnableRxFF0Filter == 1);
+   r8712_write8(adapter, 0x117, oldvalue);
 }
 
 int r8712_xmit_resource_alloc(struct _adapter *padapter,
@@ -147,36 +147,36 @@ void r8712_xmit_complete(struct _adapter *padapter, 
struct xmit_frame *pxframe)
pxframe->pkt = NULL;
 }
 
-int r8712_xmit_entry(_pkt *pkt, struct  net_device *pnetdev)
+int r8712_xmit_entry(_pkt *pkt, struct  net_device *netdev)
 {
-   struct xmit_frame *pxmitframe = NULL;
-   struct _adapter *padapter = netdev_priv(pnetdev);
-   struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
+   struct xmit_frame *xmitframe = NULL;
+   struct _adapter *adapter = netdev_priv(netdev);
+   struct xmit_priv *xmitpriv = &(adapter->xmitpriv);
 
-   if (!r8712_if_up(padapter))
+   if (!r8712_if_up(adapter))
goto _xmit_entry_drop;
 
-   pxmitframe = r8712_alloc_xmitframe(pxmitpriv);
-   if (!pxmitframe)
+   xmitframe = r8712_alloc_xmitframe(xmitpriv);
+   if (!xmitframe)
goto _xmit_entry_drop;
 
-   if ((!r8712_update_attrib(padapter, pkt, >attrib)))
+   if ((!r8712_update_attrib(adapter, pkt, >attrib)))
goto _xmit_entry_drop;
 
-   padapter->ledpriv.LedControlHandler(padapter, LED_CTL_TX);
-   pxmitframe->pkt = pkt;
-   if (r8712_pre_xmit(padapter, pxmitframe)) {
+   adapter->ledpriv.LedControlHandler(adapter, LED_CTL_TX);
+   xmitframe->pkt = pkt;
+   if (r8712_pre_xmit(adapter, xmitframe)) {
/*dump xmitframe directly or drop xframe*/
dev_kfree_skb_any(pkt);
-   pxmitframe->pkt = NULL;
+   xmitframe->pkt = NULL;
}
-   pxmitpriv->tx_pkts++;
-   pxmitpriv->tx_bytes += pxmitframe->attrib.last_txcmdsz;
+   xmitpriv->tx_pkts++;
+   xmitpriv->tx_bytes += xmitframe->attrib.last_txcmdsz;
return 0;
 _xmit_entry_drop:
-   if (pxmitframe)
-   r8712_free_xmitframe(pxmitpriv, pxmitframe);
-   pxmitpriv->tx_drop++;
+   if (xmitframe)
+   r8712_free_xmitframe(xmitpriv, xmitframe);
+   xmitpriv->tx_drop++;
dev_kfree_skb_any(pkt);
return 0;
 }
-- 
2.19.1



Re: properly communicate queue limits to the DMA layer

2019-06-06 Thread Jens Axboe
On 6/5/19 1:24 PM, Christoph Hellwig wrote:
> On Wed, Jun 05, 2019 at 01:17:15PM -0600, Jens Axboe wrote:
>> Since I'm heading out shortly and since I think this should make
>> the next -rc, I'll tentatively queue this up.
> 
> The SCSI bits will need a bit more review, and possibly tweaking
> fo megaraid and mpt3sas.  But they are really independent of the
> other patches, so maybe skip them for now and leave them for Martin
> to deal with.

I dropped the SCSI bits.

-- 
Jens Axboe



[PATCH 2/3] staging: rtl8712: usb_ops.c: Remove leading p from variable names

2019-06-06 Thread Nishka Dasgupta
Remove leading 'p' from the names of the following pointer variables:
- pintfhdl
- pintf_hdl (renamed to intfhdl in keeping with the convention in other
functions)
- poption
- pops
- pintfpriv.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta 
---
 drivers/staging/rtl8712/usb_ops.c | 84 +++
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/rtl8712/usb_ops.c 
b/drivers/staging/rtl8712/usb_ops.c
index eef52d5c730a..e64845e6adf3 100644
--- a/drivers/staging/rtl8712/usb_ops.c
+++ b/drivers/staging/rtl8712/usb_ops.c
@@ -22,7 +22,7 @@
 #include "usb_ops.h"
 #include "recv_osdep.h"
 
-static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr)
+static u8 usb_read8(struct intf_hdl *intfhdl, u32 addr)
 {
u8 request;
u8 requesttype;
@@ -30,19 +30,19 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr)
u16 index;
u16 len;
__le32 data;
-   struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
+   struct intf_priv *intfpriv = intfhdl->pintfpriv;
 
request = 0x05;
requesttype = 0x01; /* read_in */
index = 0;
wvalue = (u16)(addr & 0x);
len = 1;
-   r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, , len,
- requesttype);
+   r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, , len,
+   requesttype);
return (u8)(le32_to_cpu(data) & 0x0ff);
 }
 
-static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr)
+static u16 usb_read16(struct intf_hdl *intfhdl, u32 addr)
 {
u8 request;
u8 requesttype;
@@ -50,19 +50,19 @@ static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr)
u16 index;
u16 len;
__le32 data;
-   struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
+   struct intf_priv *intfpriv = intfhdl->pintfpriv;
 
request = 0x05;
requesttype = 0x01; /* read_in */
index = 0;
wvalue = (u16)(addr & 0x);
len = 2;
-   r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, , len,
- requesttype);
+   r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, , len,
+   requesttype);
return (u16)(le32_to_cpu(data) & 0x);
 }
 
-static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr)
+static u32 usb_read32(struct intf_hdl *intfhdl, u32 addr)
 {
u8 request;
u8 requesttype;
@@ -70,19 +70,19 @@ static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr)
u16 index;
u16 len;
__le32 data;
-   struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
+   struct intf_priv *intfpriv = intfhdl->pintfpriv;
 
request = 0x05;
requesttype = 0x01; /* read_in */
index = 0;
wvalue = (u16)(addr & 0x);
len = 4;
-   r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, , len,
- requesttype);
+   r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, , len,
+   requesttype);
return le32_to_cpu(data);
 }
 
-static void usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val)
+static void usb_write8(struct intf_hdl *intfhdl, u32 addr, u8 val)
 {
u8 request;
u8 requesttype;
@@ -90,7 +90,7 @@ static void usb_write8(struct intf_hdl *pintfhdl, u32 addr, 
u8 val)
u16 index;
u16 len;
__le32 data;
-   struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
+   struct intf_priv *intfpriv = intfhdl->pintfpriv;
 
request = 0x05;
requesttype = 0x00; /* write_out */
@@ -98,11 +98,11 @@ static void usb_write8(struct intf_hdl *pintfhdl, u32 addr, 
u8 val)
wvalue = (u16)(addr & 0x);
len = 1;
data = cpu_to_le32((u32)val & 0x00ff);
-   r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, , len,
- requesttype);
+   r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, , len,
+   requesttype);
 }
 
-static void usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val)
+static void usb_write16(struct intf_hdl *intfhdl, u32 addr, u16 val)
 {
u8 request;
u8 requesttype;
@@ -110,7 +110,7 @@ static void usb_write16(struct intf_hdl *pintfhdl, u32 
addr, u16 val)
u16 index;
u16 len;
__le32 data;
-   struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
+   struct intf_priv *intfpriv = intfhdl->pintfpriv;
 
request = 0x05;
requesttype = 0x00; /* write_out */
@@ -118,11 +118,11 @@ static void usb_write16(struct intf_hdl *pintfhdl, u32 
addr, u16 val)
wvalue = (u16)(addr & 0x);
len = 2;
data = cpu_to_le32((u32)val & 0x);
-   r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, , len,
- requesttype);
+   

Re: [PATCH] Powerpc/Watchpoint: Restore nvgprs while returning from exception

2019-06-06 Thread Michael Ellerman
Ravi Bangoria  writes:

> Powerpc hw triggers watchpoint before executing the instruction.
> To make trigger-after-execute behavior, kernel emulates the
> instruction. If the instruction is 'load something into non-
> volatile register', exception handler should restore emulated
> register state while returning back, otherwise there will be
> register state corruption. Ex, Adding a watchpoint on a list
> can corrput the list:
>
>   # cat /proc/kallsyms | grep kthread_create_list
>   c121c8b8 d kthread_create_list
>
> Add watchpoint on kthread_create_list->next:
>
>   # perf record -e mem:0xc121c8c0
>
> Run some workload such that new kthread gets invoked. Ex, I
> just logged out from console:
>
>   list_add corruption. next->prev should be prev (c1214e00), \
>   but was c121c8b8. (next=c121c8b8).
>   WARNING: CPU: 59 PID: 309 at lib/list_debug.c:25 __list_add_valid+0xb4/0xc0
>   CPU: 59 PID: 309 Comm: kworker/59:0 Kdump: loaded Not tainted 5.1.0-rc7+ #69
>   ...
>   NIP __list_add_valid+0xb4/0xc0
>   LR __list_add_valid+0xb0/0xc0
>   Call Trace:
>   __list_add_valid+0xb0/0xc0 (unreliable)
>   __kthread_create_on_node+0xe0/0x260
>   kthread_create_on_node+0x34/0x50
>   create_worker+0xe8/0x260
>   worker_thread+0x444/0x560
>   kthread+0x160/0x1a0
>   ret_from_kernel_thread+0x5c/0x70

This all depends on what code the compiler generates for the list
access. Can you include a disassembly of the relevant code in your
kernel so we have an example of the bad case.

> diff --git a/arch/powerpc/kernel/exceptions-64s.S 
> b/arch/powerpc/kernel/exceptions-64s.S
> index 9481a11..96de0d1 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -1753,7 +1753,7 @@ handle_dabr_fault:
>   ld  r5,_DSISR(r1)
>   addir3,r1,STACK_FRAME_OVERHEAD
>   bl  do_break
> -12:  b   ret_from_except_lite
> +12:  b   ret_from_except

This probably warrants a comment explaining why we can't use the (badly
named) "lite" version.

cheers


Re: [PATCH 13/15] x86/static_call: Add inline static call implementation for x86-64

2019-06-06 Thread Nadav Amit
> On Jun 5, 2019, at 6:08 AM, Peter Zijlstra  wrote:
> 
> From: Josh Poimboeuf 
> 
> Add the inline static call implementation for x86-64.  For each key, a
> temporary trampoline is created, named __static_call_tramp_.  The
> trampoline has an indirect jump to the destination function.
> 
> Objtool uses the trampoline naming convention to detect all the call
> sites.  It then annotates those call sites in the .static_call_sites
> section.
> 
> During boot (and module init), the call sites are patched to call
> directly into the destination function.  The temporary trampoline is
> then no longer used.
> 
> Cc: x...@kernel.org
> Cc: Steven Rostedt 
> Cc: Julia Cartwright 
> Cc: Ingo Molnar 
> Cc: Ard Biesheuvel 
> Cc: Jason Baron 
> Cc: Linus Torvalds 
> Cc: Jiri Kosina 
> Cc: Thomas Gleixner 
> Cc: Masami Hiramatsu 
> Cc: Borislav Petkov 
> Cc: David Laight 
> Cc: Jessica Yu 
> Cc: Andy Lutomirski 
> Cc: "H. Peter Anvin" 
> Signed-off-by: Josh Poimboeuf 
> Signed-off-by: Peter Zijlstra (Intel) 
> Link: 
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkml.kernel.org%2Fr%2F62188c62f6dda49ca2e20629ee8e5a62a6c0b500.1543200841.git.jpoimboe%40redhat.comdata=02%7C01%7Cnamit%40vmware.com%7C3a349bb2a7e042ef9d9d08d6e9b8fc2d%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C636953378066316039sdata=J%2BsCYwRi8GpP5GrJaLo8nM5jN2KNZlfwq7RDuKok%2FmE%3Dreserved=0
> ---
> arch/x86/Kconfig|3 
> arch/x86/include/asm/static_call.h  |   28 -
> arch/x86/kernel/asm-offsets.c   |6 +
> arch/x86/kernel/static_call.c   |   12 +-
> include/linux/static_call.h |2 
> tools/objtool/Makefile  |3 
> tools/objtool/check.c   |  125 
> +++-
> tools/objtool/check.h   |2 
> tools/objtool/elf.h |1 
> tools/objtool/include/linux/static_call_types.h |   19 +++
> tools/objtool/sync-check.sh |1 
> 11 files changed, 193 insertions(+), 9 deletions(-)
> create mode 100644 tools/objtool/include/linux/static_call_types.h
> 
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -199,6 +199,7 @@ config X86
>   select HAVE_STACKPROTECTOR  if CC_HAS_SANE_STACKPROTECTOR
>   select HAVE_STACK_VALIDATIONif X86_64
>   select HAVE_STATIC_CALL
> + select HAVE_STATIC_CALL_INLINE  if HAVE_STACK_VALIDATION
>   select HAVE_RSEQ
>   select HAVE_SYSCALL_TRACEPOINTS
>   select HAVE_UNSTABLE_SCHED_CLOCK
> @@ -213,6 +214,7 @@ config X86
>   select RTC_MC146818_LIB
>   select SPARSE_IRQ
>   select SRCU
> + select STACK_VALIDATION if HAVE_STACK_VALIDATION && 
> (HAVE_STATIC_CALL_INLINE || RETPOLINE)
>   select SYSCTL_EXCEPTION_TRACE
>   select THREAD_INFO_IN_TASK
>   select USER_STACKTRACE_SUPPORT
> @@ -439,7 +441,6 @@ config GOLDFISH
> config RETPOLINE
>   bool "Avoid speculative indirect branches in kernel"
>   default y
> - select STACK_VALIDATION if HAVE_STACK_VALIDATION
>   help
> Compile kernel with the retpoline compiler options to guard against
> kernel-to-user data leaks by avoiding speculative indirect
> --- a/arch/x86/include/asm/static_call.h
> +++ b/arch/x86/include/asm/static_call.h
> @@ -2,6 +2,20 @@
> #ifndef _ASM_STATIC_CALL_H
> #define _ASM_STATIC_CALL_H
> 
> +#include 
> +
> +#ifdef CONFIG_HAVE_STATIC_CALL_INLINE
> +
> +/*
> + * This trampoline is only used during boot / module init, so it's safe to 
> use
> + * the indirect branch without a retpoline.
> + */
> +#define __ARCH_STATIC_CALL_TRAMP_JMP(key, func)  
> \
> + ANNOTATE_RETPOLINE_SAFE \
> + "jmpq *" __stringify(key) "+" __stringify(SC_KEY_func) "(%rip) \n"
> +
> +#else /* !CONFIG_HAVE_STATIC_CALL_INLINE */
> +
> /*
>  * Manually construct a 5-byte direct JMP to prevent the assembler from
>  * optimizing it into a 2-byte JMP.
> @@ -12,9 +26,19 @@
>   ".long " #func " - " __ARCH_STATIC_CALL_JMP_LABEL(key) "\n" \
>   __ARCH_STATIC_CALL_JMP_LABEL(key) ":"
> 
> +#endif /* !CONFIG_HAVE_STATIC_CALL_INLINE */
> +
> /*
> - * This is a permanent trampoline which does a direct jump to the function.
> - * The direct jump get patched by static_call_update().
> + * For CONFIG_HAVE_STATIC_CALL_INLINE, this is a temporary trampoline which
> + * uses the current value of the key->func pointer to do an indirect jump to
> + * the function.  This trampoline is only used during boot, before the call
> + * sites get patched by static_call_update().  The name of this trampoline 
> has
> + * a magical aspect: objtool uses it to find static call sites so it can 
> create
> + * the .static_call_sites section.
> + *
> + * For CONFIG_HAVE_STATIC_CALL, this is a permanent trampoline which
> + * does a direct jump to the 

[PATCH] staging: rtl8712: recv_linux.c: Remove leading p from variable names

2019-06-06 Thread Nishka Dasgupta
Remove leading p from the following pointer variable names:
- padapter
- pmlmepriv
- precv_frame
- precvpriv
- pfree_recv_queue
- pattrib.
Issue found with Coccinelle

Signed-off-by: Nishka Dasgupta 
---
 drivers/staging/rtl8712/recv_linux.c | 50 ++--
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/rtl8712/recv_linux.c 
b/drivers/staging/rtl8712/recv_linux.c
index 4e20cbafa9fb..84c4c8580f9a 100644
--- a/drivers/staging/rtl8712/recv_linux.c
+++ b/drivers/staging/rtl8712/recv_linux.c
@@ -72,11 +72,11 @@ int r8712_os_recvbuf_resource_free(struct _adapter 
*padapter,
return _SUCCESS;
 }
 
-void r8712_handle_tkip_mic_err(struct _adapter *padapter, u8 bgroup)
+void r8712_handle_tkip_mic_err(struct _adapter *adapter, u8 bgroup)
 {
union iwreq_data wrqu;
struct iw_michaelmicfailure ev;
-   struct mlme_priv *pmlmepriv  = >mlmepriv;
+   struct mlme_priv *mlmepriv  = >mlmepriv;
 
memset(, 0x00, sizeof(ev));
if (bgroup)
@@ -84,54 +84,54 @@ void r8712_handle_tkip_mic_err(struct _adapter *padapter, 
u8 bgroup)
else
ev.flags |= IW_MICFAILURE_PAIRWISE;
ev.src_addr.sa_family = ARPHRD_ETHER;
-   ether_addr_copy(ev.src_addr.sa_data, >assoc_bssid[0]);
+   ether_addr_copy(ev.src_addr.sa_data, >assoc_bssid[0]);
memset(, 0x00, sizeof(wrqu));
wrqu.data.length = sizeof(ev);
-   wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, ,
+   wireless_send_event(adapter->pnetdev, IWEVMICHAELMICFAILURE, ,
(char *));
 }
 
-void r8712_recv_indicatepkt(struct _adapter *padapter,
-   union recv_frame *precv_frame)
+void r8712_recv_indicatepkt(struct _adapter *adapter,
+   union recv_frame *recvframe)
 {
-   struct recv_priv *precvpriv;
-   struct  __queue *pfree_recv_queue;
+   struct recv_priv *recvpriv;
+   struct  __queue *free_recv_queue;
_pkt *skb;
-   struct rx_pkt_attrib *pattrib = _frame->u.hdr.attrib;
+   struct rx_pkt_attrib *attrib = >u.hdr.attrib;
 
-   precvpriv = >recvpriv;
-   pfree_recv_queue = >free_recv_queue;
-   skb = precv_frame->u.hdr.pkt;
+   recvpriv = >recvpriv;
+   free_recv_queue = >free_recv_queue;
+   skb = recvframe->u.hdr.pkt;
if (!skb)
goto _recv_indicatepkt_drop;
-   skb->data = precv_frame->u.hdr.rx_data;
-   skb->len = precv_frame->u.hdr.len;
+   skb->data = recvframe->u.hdr.rx_data;
+   skb->len = recvframe->u.hdr.len;
skb_set_tail_pointer(skb, skb->len);
-   if ((pattrib->tcpchk_valid == 1) && (pattrib->tcp_chkrpt == 1))
+   if ((attrib->tcpchk_valid == 1) && (attrib->tcp_chkrpt == 1))
skb->ip_summed = CHECKSUM_UNNECESSARY;
else
skb->ip_summed = CHECKSUM_NONE;
-   skb->dev = padapter->pnetdev;
-   skb->protocol = eth_type_trans(skb, padapter->pnetdev);
+   skb->dev = adapter->pnetdev;
+   skb->protocol = eth_type_trans(skb, adapter->pnetdev);
netif_rx(skb);
-   precv_frame->u.hdr.pkt = NULL; /* pointers to NULL before
+   recvframe->u.hdr.pkt = NULL; /* pointers to NULL before
* r8712_free_recvframe()
*/
-   r8712_free_recvframe(precv_frame, pfree_recv_queue);
+   r8712_free_recvframe(recvframe, free_recv_queue);
return;
 _recv_indicatepkt_drop:
 /*enqueue back to free_recv_queue*/
-   if (precv_frame)
-   r8712_free_recvframe(precv_frame, pfree_recv_queue);
-   precvpriv->rx_drop++;
+   if (recvframe)
+   r8712_free_recvframe(recvframe, free_recv_queue);
+   recvpriv->rx_drop++;
 }
 
 static void _r8712_reordering_ctrl_timeout_handler (struct timer_list *t)
 {
-   struct recv_reorder_ctrl *preorder_ctrl =
-from_timer(preorder_ctrl, t, reordering_ctrl_timer);
+   struct recv_reorder_ctrl *reorder_ctrl =
+from_timer(reorder_ctrl, t, reordering_ctrl_timer);
 
-   r8712_reordering_ctrl_timeout_handler(preorder_ctrl);
+   r8712_reordering_ctrl_timeout_handler(reorder_ctrl);
 }
 
 void r8712_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
-- 
2.19.1



linux-next: manual merge of the akpm-current tree with the net-next tree

2019-06-06 Thread Stephen Rothwell
Hi all,

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

  net/ipv6/sysctl_net_ipv6.c

between commit:

  323a53c41292 ("ipv6: tcp: enable flowlabel reflection in some RST packets")

from the net-next tree and commit:

  f4e7c821eda5 ("proc/sysctl: add shared variables for range check")

from the akpm-current tree.

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

-- 
Cheers,
Stephen Rothwell

diff --cc net/ipv6/sysctl_net_ipv6.c
index 6d86fac472e7,4c6adfccc3d2..
--- a/net/ipv6/sysctl_net_ipv6.c
+++ b/net/ipv6/sysctl_net_ipv6.c
@@@ -21,9 -21,6 +21,7 @@@
  #include 
  #endif
  
- static int zero;
- static int one = 1;
 +static int three = 3;
  static int auto_flowlabels_min;
  static int auto_flowlabels_max = IP6_AUTO_FLOW_LABEL_MAX;
  
@@@ -115,8 -112,6 +113,8 @@@ static struct ctl_table ipv6_table_temp
.maxlen = sizeof(int),
.mode   = 0644,
.proc_handler   = proc_dointvec,
-   .extra1 = ,
++  .extra1 = SYSCTL_ZERO,
 +  .extra2 = ,
},
{
.procname   = "max_dst_opts_number",


pgp_OwOQ6NKed.pgp
Description: OpenPGP digital signature


[PATCH] staging: rtl8712: hal_init.c: Remove leading p from variable names

2019-06-06 Thread Nishka Dasgupta
Remove the leading p from the following pointer variable names:
- padapter
- pusb_intf
- ppmappedfw
- praw
- pfwpriv
- pdvobj
- pregpriv
- pmappedfw (not in the same scope as ppmappedfw)
- ptmpchar
- ppayload
- ptx_desc
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta 
---
 drivers/staging/rtl8712/hal_init.c | 174 ++---
 1 file changed, 87 insertions(+), 87 deletions(-)

diff --git a/drivers/staging/rtl8712/hal_init.c 
b/drivers/staging/rtl8712/hal_init.c
index 401f0e442bcf..40145c0338e4 100644
--- a/drivers/staging/rtl8712/hal_init.c
+++ b/drivers/staging/rtl8712/hal_init.c
@@ -31,21 +31,21 @@
 
 static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context)
 {
-   struct _adapter *padapter = context;
+   struct _adapter *adapter = context;
 
-   complete(>rtl8712_fw_ready);
+   complete(>rtl8712_fw_ready);
if (!firmware) {
-   struct usb_device *udev = padapter->dvobjpriv.pusbdev;
-   struct usb_interface *pusb_intf = padapter->pusb_intf;
+   struct usb_device *udev = adapter->dvobjpriv.pusbdev;
+   struct usb_interface *usb_intf = adapter->pusb_intf;
 
dev_err(>dev, "r8712u: Firmware request failed\n");
usb_put_dev(udev);
-   usb_set_intfdata(pusb_intf, NULL);
+   usb_set_intfdata(usb_intf, NULL);
return;
}
-   padapter->fw = firmware;
+   adapter->fw = firmware;
/* firmware available - start netdev */
-   register_netdev(padapter->pnetdev);
+   register_netdev(adapter->pnetdev);
 }
 
 static const char firmware_file[] = "rtlwifi/rtl8712u.bin";
@@ -65,47 +65,47 @@ int rtl871x_load_fw(struct _adapter *padapter)
 }
 MODULE_FIRMWARE("rtlwifi/rtl8712u.bin");
 
-static u32 rtl871x_open_fw(struct _adapter *padapter, const u8 **ppmappedfw)
+static u32 rtl871x_open_fw(struct _adapter *adapter, const u8 **mappedfw)
 {
-   const struct firmware **praw = >fw;
+   const struct firmware **raw = >fw;
 
-   if (padapter->fw->size > 20) {
-   dev_err(>pnetdev->dev, "r8172u: Badfw->size of %d\n",
-   (int)padapter->fw->size);
+   if (adapter->fw->size > 20) {
+   dev_err(>pnetdev->dev, "r8172u: Badfw->size of %d\n",
+   (int)adapter->fw->size);
return 0;
}
-   *ppmappedfw = (*praw)->data;
-   return (*praw)->size;
+   *mappedfw = (*raw)->data;
+   return (*raw)->size;
 }
 
-static void fill_fwpriv(struct _adapter *padapter, struct fw_priv *pfwpriv)
+static void fill_fwpriv(struct _adapter *adapter, struct fw_priv *fwpriv)
 {
-   struct dvobj_priv *pdvobj = >dvobjpriv;
-   struct registry_priv *pregpriv = >registrypriv;
+   struct dvobj_priv *dvobj = >dvobjpriv;
+   struct registry_priv *regpriv = >registrypriv;
 
-   memset(pfwpriv, 0, sizeof(struct fw_priv));
+   memset(fwpriv, 0, sizeof(struct fw_priv));
/* todo: check if needs endian conversion */
-   pfwpriv->hci_sel =  RTL8712_HCI_TYPE_72USB;
-   pfwpriv->usb_ep_num = (u8)pdvobj->nr_endpoint;
-   pfwpriv->bw_40MHz_en = pregpriv->cbw40_enable;
-   switch (pregpriv->rf_config) {
+   fwpriv->hci_sel =  RTL8712_HCI_TYPE_72USB;
+   fwpriv->usb_ep_num = (u8)dvobj->nr_endpoint;
+   fwpriv->bw_40MHz_en = regpriv->cbw40_enable;
+   switch (regpriv->rf_config) {
case RTL8712_RF_1T1R:
-   pfwpriv->rf_config = RTL8712_RFC_1T1R;
+   fwpriv->rf_config = RTL8712_RFC_1T1R;
break;
case RTL8712_RF_2T2R:
-   pfwpriv->rf_config = RTL8712_RFC_2T2R;
+   fwpriv->rf_config = RTL8712_RFC_2T2R;
break;
case RTL8712_RF_1T2R:
default:
-   pfwpriv->rf_config = RTL8712_RFC_1T2R;
+   fwpriv->rf_config = RTL8712_RFC_1T2R;
}
-   pfwpriv->mp_mode = (pregpriv->mp_mode == 1) ? 1 : 0;
+   fwpriv->mp_mode = (regpriv->mp_mode == 1) ? 1 : 0;
/* 0:off 1:on 2:auto */
-   pfwpriv->vcs_type = pregpriv->vrtl_carrier_sense;
-   pfwpriv->vcs_mode = pregpriv->vcs_type; /* 1:RTS/CTS 2:CTS to self */
+   fwpriv->vcs_type = regpriv->vrtl_carrier_sense;
+   fwpriv->vcs_mode = regpriv->vcs_type; /* 1:RTS/CTS 2:CTS to self */
/* default enable turbo_mode */
-   pfwpriv->turbo_mode = ((pregpriv->wifi_test == 1) ? 0 : 1);
-   pfwpriv->low_power_mode = pregpriv->low_power;
+   fwpriv->turbo_mode = ((regpriv->wifi_test == 1) ? 0 : 1);
+   fwpriv->low_power_mode = regpriv->low_power;
 }
 
 static void update_fwhdr(struct fw_hdr *pfwhdr, const u8 *pmappedfw)
@@ -141,7 +141,7 @@ static u8 chk_fwhdr(struct fw_hdr *pfwhdr, u32 ulfilelength)
return _SUCCESS;
 }
 
-static u8 rtl8712_dl_fw(struct _adapter *padapter)
+static u8 rtl8712_dl_fw(struct _adapter *adapter)
 {
sint i;
u8 tmp8, tmp8_a;
@@ 

Re: [PATCH 08/15] x86/alternatives: Teach text_poke_bp() to emulate instructions

2019-06-06 Thread Nadav Amit
> On Jun 5, 2019, at 6:08 AM, Peter Zijlstra  wrote:
> 
> In preparation for static_call support, teach text_poke_bp() to
> emulate instructions, including CALL.
> 
> The current text_poke_bp() takes a @handler argument which is used as
> a jump target when the temporary INT3 is hit by a different CPU.
> 
> When patching CALL instructions, this doesn't work because we'd miss
> the PUSH of the return address. Instead, teach poke_int3_handler() to
> emulate an instruction, typically the instruction we're patching in.
> 
> This fits almost all text_poke_bp() users, except
> arch_unoptimize_kprobe() which restores random text, and for that site
> we have to build an explicit emulate instruction.
> 
> Cc: Daniel Bristot de Oliveira 
> Cc: Nadav Amit 
> Signed-off-by: Peter Zijlstra (Intel) 
> ---
> arch/x86/include/asm/text-patching.h |2 -
> arch/x86/kernel/alternative.c|   47 
> ++-
> arch/x86/kernel/jump_label.c |3 --
> arch/x86/kernel/kprobes/opt.c|   11 +---
> 4 files changed, 46 insertions(+), 17 deletions(-)
> 
> --- a/arch/x86/include/asm/text-patching.h
> +++ b/arch/x86/include/asm/text-patching.h
> @@ -37,7 +37,7 @@ extern void text_poke_early(void *addr,
> extern void *text_poke(void *addr, const void *opcode, size_t len);
> extern void *text_poke_kgdb(void *addr, const void *opcode, size_t len);
> extern int poke_int3_handler(struct pt_regs *regs);
> -extern void text_poke_bp(void *addr, const void *opcode, size_t len, void 
> *handler);
> +extern void text_poke_bp(void *addr, const void *opcode, size_t len, const 
> void *emulate);
> extern int after_bootmem;
> extern __ro_after_init struct mm_struct *poking_mm;
> extern __ro_after_init unsigned long poking_addr;
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -921,19 +921,25 @@ static void do_sync_core(void *info)
> }
> 
> static bool bp_patching_in_progress;
> -static void *bp_int3_handler, *bp_int3_addr;
> +static const void *bp_int3_opcode, *bp_int3_addr;
> 
> int poke_int3_handler(struct pt_regs *regs)
> {
> + long ip = regs->ip - INT3_INSN_SIZE + CALL_INSN_SIZE;
> + struct opcode {
> + u8 insn;
> + s32 rel;
> + } __packed opcode;
> +
>   /*
>* Having observed our INT3 instruction, we now must observe
>* bp_patching_in_progress.
>*
> -  *  in_progress = TRUE  INT3
> -  *  WMB RMB
> -  *  write INT3  if (in_progress)
> +  *  in_progress = TRUE  INT3
> +  *  WMB RMB
> +  *  write INT3  if (in_progress)

I don’t see what has changed in this chunk… Whitespaces?

>*
> -  * Idem for bp_int3_handler.
> +  * Idem for bp_int3_opcode.
>*/
>   smp_rmb();
> 
> @@ -943,8 +949,21 @@ int poke_int3_handler(struct pt_regs *re
>   if (user_mode(regs) || regs->ip != (unsigned long)bp_int3_addr)
>   return 0;
> 
> - /* set up the specified breakpoint handler */
> - regs->ip = (unsigned long) bp_int3_handler;
> + opcode = *(struct opcode *)bp_int3_opcode;
> +
> + switch (opcode.insn) {
> + case 0xE8: /* CALL */
> + int3_emulate_call(regs, ip + opcode.rel);
> + break;
> +
> + case 0xE9: /* JMP */
> + int3_emulate_jmp(regs, ip + opcode.rel);
> + break;

Consider using RELATIVECALL_OPCODE and RELATIVEJUMP_OPCODE instead of the
constants (0xE8, 0xE9), just as you do later in the patch.



[PATCH V3] i2c: busses: tegra: Add suspend-resume support

2019-06-06 Thread Bitan Biswas
Post suspend I2C registers have power on reset values. Before any
transfer initialize I2C registers to prevent I2C transfer timeout
and implement suspend and resume callbacks needed. Fix below errors
post suspend:

1) Tegra I2C transfer timeout during jetson tx2 resume:

[   27.520613] pca953x 1-0074: calling pca953x_resume+0x0/0x1b0 @ 2939, parent: 
i2c-1
[   27.633623] tegra-i2c 316.i2c: i2c transfer timed out
[   27.639162] pca953x 1-0074: Unable to sync registers 0x3-0x5. -110
[   27.645336] pca953x 1-0074: Failed to sync GPIO dir registers: -110
[   27.651596] PM: dpm_run_callback(): pca953x_resume+0x0/0x1b0 returns -110
[   27.658375] pca953x 1-0074: pca953x_resume+0x0/0x1b0 returned -110 after 
127152 usecs
[   27.666194] PM: Device 1-0074 failed to resume: error -110

2) Tegra I2C transfer timeout error on jetson Xavier post resume.

Remove i2c bus lock-unlock calls in resume callback as i2c_mark_adapter_*
(suspended-resumed) help ensure i2c core calls from client are not
executed before i2c-tegra resume.

Signed-off-by: Bitan Biswas 
---
 drivers/i2c/busses/i2c-tegra.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index ebaa78d..1dbba39 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -1687,7 +1687,31 @@ static int tegra_i2c_remove(struct platform_device *pdev)
 }
 
 #ifdef CONFIG_PM_SLEEP
+static int tegra_i2c_suspend(struct device *dev)
+{
+   struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
+
+   i2c_mark_adapter_suspended(_dev->adapter);
+
+   return 0;
+}
+
+static int tegra_i2c_resume(struct device *dev)
+{
+   struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
+   int err;
+
+   err = tegra_i2c_init(i2c_dev, false);
+   if (err)
+   return err;
+
+   i2c_mark_adapter_resumed(_dev->adapter);
+
+   return 0;
+}
+
 static const struct dev_pm_ops tegra_i2c_pm = {
+   SET_SYSTEM_SLEEP_PM_OPS(tegra_i2c_suspend, tegra_i2c_resume)
SET_RUNTIME_PM_OPS(tegra_i2c_runtime_suspend, tegra_i2c_runtime_resume,
   NULL)
 };
-- 
2.7.4



Re: [RFC PATCH v2 11/12] x86/mm/tlb: Use async and inline messages for flushing

2019-06-06 Thread Nadav Amit
> On May 31, 2019, at 3:07 PM, Nadav Amit  wrote:
> 
>> On May 31, 2019, at 2:47 PM, Andy Lutomirski  wrote:
>> 
>> 
>> On May 31, 2019, at 2:33 PM, Nadav Amit  wrote:
>> 
 On May 31, 2019, at 2:14 PM, Andy Lutomirski  wrote:
 
> On Thu, May 30, 2019 at 11:37 PM Nadav Amit  wrote:
> When we flush userspace mappings, we can defer the TLB flushes, as long
> the following conditions are met:
> 
> 1. No tables are freed, since otherwise speculative page walks might
> cause machine-checks.
> 
> 2. No one would access userspace before flush takes place. Specifically,
> NMI handlers and kprobes would avoid accessing userspace.
 
 I think I need to ask the big picture question.  When someone calls
 flush_tlb_mm_range() (or the other entry points), if no page tables
 were freed, they want the guarantee that future accesses (initiated
 observably after the flush returns) will not use paging entries that
 were replaced by stores ordered before flush_tlb_mm_range().  We also
 need the guarantee that any effects from any memory access using the
 old paging entries will become globally visible before
 flush_tlb_mm_range().
 
 I'm wondering if receipt of an IPI is enough to guarantee any of this.
 If CPU 1 sets a dirty bit and CPU 2 writes to the APIC to send an IPI
 to CPU 1, at what point is CPU 2 guaranteed to be able to observe the
 dirty bit?  An interrupt entry today is fully serializing by the time
 it finishes, but interrupt entries are epicly slow, and I don't know
 if the APIC waits long enough.  Heck, what if IRQs are off on the
 remote CPU?  There are a handful of places where we touch user memory
 with IRQs off, and it's (sadly) possible for user code to turn off
 IRQs with iopl().
 
 I *think* that Intel has stated recently that SMT siblings are
 guaranteed to stop speculating when you write to the APIC ICR to poke
 them, but SMT is very special.
 
 My general conclusion is that I think the code needs to document what
 is guaranteed and why.
>>> 
>>> I think I might have managed to confuse you with a bug I made (last minute
>>> bug when I was doing some cleanup). This bug does not affect the performance
>>> much, but it might led you to think that I use the APIC sending as
>>> synchronization.
>>> 
>>> The idea is not for us to rely on write to ICR as something serializing. The
>>> flow should be as follows:
>>> 
>>> 
>>>  CPU0CPU1
>>> 
>>> flush_tlb_mm_range()
>>> __smp_call_function_many()
>>> [ prepare call_single_data (csd) ]
>>> [ lock csd ] 
>>> [ send IPI ]
>>>  (*)
>>> [ wait for csd to be unlocked ]
>>>  [ interrupt ]
>>>  [ copy csd info to stack ]
>>>  [ csd unlock ]
>>> [ find csd is unlocked ]
>>> [ continue (**) ]
>>>  [ flush TLB ]
>>> 
>>> 
>>> At (**) the pages might be recycled, written-back to disk, etc. Note that
>>> during (*), CPU0 might do some local TLB flushes, making it very likely that
>>> CSD will be unlocked by the time it gets there.
>>> 
>>> As you can see, I don’t rely on any special micro-architectural behavior.
>>> The synchronization is done purely in software.
>>> 
>>> Does it make more sense now?
>> 
>> Yes.  Have you benchmarked this?
> 
> Partially. Numbers are indeed worse. Here are preliminary results, comparing
> to v1 (concurrent):
> 
>   n_threads   before  concurrent  +async
>   -   --  --  --
>   1   661 663 663
>   2   14361225 (-14%) 1115 (-22%)
>   4   15711421 (-10%) 1289 (-18%)
> 
> Note that the benefit of “async" would be greater if the initiator does not
> flush the TLB at all. This might happen in the case of kswapd, for example.
> Let me try some micro-optimizations first, run more benchmarks and get back
> to you.

So I ran some more benchmarking (my benchmark is not very suitable), and tried
more stuff that did not help (checking for more work before returning from the
IPI handler, and avoid redundant IPIs in such case).

Anyhow, with a fixed version, I ran a more standard benchmark on DAX:

$ mkfs.ext4 /dev/pmem0
$ mount -o dax /dev/pmem0 /mnt/mem
$ cd /mnt/mem
$ bash -c 'echo 0 > 
/sys/devices/platform/e820_pmem/ndbus0/region0/namespace0.0/block/pmem0/dax/write_cache’
$ sysbench fileio --file-total-size=3G --file-test-mode=rndwr   \
--file-io-mode=mmap --threads=4 --file-fsync-mode=fdatasync prepare
$ sysbench fileio --file-total-size=3G --file-test-mode=rndwr   \
--file-io-mode=mmap --threads=4 --file-fsync-mode=fdatasync run

( as you can see, I disabled the write-cache, since my machine does not have
  clwb/clflushopt and clflush appears to become a bottleneck otherwise )


The results are:
events 

[PATCH V5] drivers: i2c: tegra: fix warning/check/error

2019-06-06 Thread Bitan Biswas
Fix checkpatch.pl warning(s)/error(s)/check(s) in i2c-tegra.c

Ignore checkpatch WARNING for 80 character line limit at
places where renaming fields compromises readability.

Delay of approximately 1msec in flush i2c FIFO polling loop
achieved by usleep_range call as msleep can take 20msecs.

Remove redundant BUG_ON calls or replace with WARN_ON_ONCE
as needed. Replace BUG() with error handling code.
Define I2C_ERR_UNEXPECTED_STATUS for error handling.

Signed-off-by: Bitan Biswas 
---
 drivers/i2c/busses/i2c-tegra.c | 61 ++
 1 file changed, 32 insertions(+), 29 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 1dbba39..161eb28 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -67,17 +67,18 @@
 
 #define DVC_CTRL_REG1  0x000
 #define DVC_CTRL_REG1_INTR_EN  BIT(10)
-#define DVC_CTRL_REG2  0x004
-#define DVC_CTRL_REG3  0x008
+#define DVC_CTRL_REG2  BIT(2)
+#define DVC_CTRL_REG3  BIT(3)
 #define DVC_CTRL_REG3_SW_PROG  BIT(26)
 #define DVC_CTRL_REG3_I2C_DONE_INTR_EN BIT(30)
 #define DVC_STATUS 0x00c
 #define DVC_STATUS_I2C_DONE_INTR   BIT(30)
 
-#define I2C_ERR_NONE   0x00
-#define I2C_ERR_NO_ACK 0x01
-#define I2C_ERR_ARBITRATION_LOST   0x02
-#define I2C_ERR_UNKNOWN_INTERRUPT  0x04
+#define I2C_ERR_NONE   0x0
+#define I2C_ERR_NO_ACK BIT(0)
+#define I2C_ERR_ARBITRATION_LOST   BIT(1)
+#define I2C_ERR_UNKNOWN_INTERRUPT  BIT(2)
+#define I2C_ERR_UNEXPECTED_STATUS  BIT(3)
 
 #define PACKET_HEADER0_HEADER_SIZE_SHIFT   28
 #define PACKET_HEADER0_PACKET_ID_SHIFT 16
@@ -280,6 +281,7 @@ struct tegra_i2c_dev {
u32 bus_clk_rate;
u16 clk_divisor_non_hs_mode;
bool is_multimaster_mode;
+   /* xfer_lock: lock to serialize transfer submission and processing */
spinlock_t xfer_lock;
struct dma_chan *tx_dma_chan;
struct dma_chan *rx_dma_chan;
@@ -306,7 +308,7 @@ static u32 dvc_readl(struct tegra_i2c_dev *i2c_dev, 
unsigned long reg)
  * to the I2C block inside the DVC block
  */
 static unsigned long tegra_i2c_reg_addr(struct tegra_i2c_dev *i2c_dev,
-   unsigned long reg)
+   unsigned long reg)
 {
if (i2c_dev->is_dvc)
reg += (reg >= I2C_TX_FIFO) ? 0x10 : 0x40;
@@ -314,7 +316,7 @@ static unsigned long tegra_i2c_reg_addr(struct 
tegra_i2c_dev *i2c_dev,
 }
 
 static void i2c_writel(struct tegra_i2c_dev *i2c_dev, u32 val,
-   unsigned long reg)
+  unsigned long reg)
 {
writel(val, i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg));
 
@@ -329,13 +331,13 @@ static u32 i2c_readl(struct tegra_i2c_dev *i2c_dev, 
unsigned long reg)
 }
 
 static void i2c_writesl(struct tegra_i2c_dev *i2c_dev, void *data,
-   unsigned long reg, int len)
+   unsigned long reg, int len)
 {
writesl(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg), data, len);
 }
 
 static void i2c_readsl(struct tegra_i2c_dev *i2c_dev, void *data,
-   unsigned long reg, int len)
+  unsigned long reg, int len)
 {
readsl(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg), data, len);
 }
@@ -486,7 +488,7 @@ static int tegra_i2c_flush_fifos(struct tegra_i2c_dev 
*i2c_dev)
dev_warn(i2c_dev->dev, "timeout waiting for fifo 
flush\n");
return -ETIMEDOUT;
}
-   msleep(1);
+   usleep_range(1000, 2000);
}
return 0;
 }
@@ -525,7 +527,6 @@ static int tegra_i2c_empty_rx_fifo(struct tegra_i2c_dev 
*i2c_dev)
 * prevent overwriting past the end of buf
 */
if (rx_fifo_avail > 0 && buf_remaining > 0) {
-   BUG_ON(buf_remaining > 3);
val = i2c_readl(i2c_dev, I2C_RX_FIFO);
val = cpu_to_le32(val);
memcpy(buf, , buf_remaining);
@@ -533,7 +534,6 @@ static int tegra_i2c_empty_rx_fifo(struct tegra_i2c_dev 
*i2c_dev)
rx_fifo_avail--;
}
 
-   BUG_ON(rx_fifo_avail > 0 && buf_remaining > 0);
i2c_dev->msg_buf_remaining = buf_remaining;
i2c_dev->msg_buf = buf;
 
@@ -591,7 +591,6 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev 
*i2c_dev)
 * boundary and fault.
 */
if (tx_fifo_avail > 0 && buf_remaining > 0) {
-   BUG_ON(buf_remaining > 3);
memcpy(, buf, buf_remaining);
val = le32_to_cpu(val);
 
@@ -680,10 +679,11 @@ static int tegra_i2c_wait_for_config_load(struct 
tegra_i2c_dev *i2c_dev)

Re: Patches for v5.2-rc and v5.3 merge window

2019-06-06 Thread Paul Walmsley
+ Rob, devicetree@, Mark

On Wed, 5 Jun 2019, Kevin Hilman wrote:

> Paul Walmsley  writes:
> 
> > Palmer has asked me to collect patches for the v5.2-rc releases and v5.3 
> > merge window, so I'll be doing so.  This is just a heads-up so no one is 
> > surprised to see 'patch queued' responses from me.
> 
> Speaking of v5.2-rc, any chance your DT series will make it for v5.2?

Ideally it would be nice to get acks from the DT folks first for:

https://lore.kernel.org/linux-riscv/20190602080500.31700-3-paul.walms...@sifive.com/T/#u

https://lore.kernel.org/linux-riscv/20190602080500.31700-4-paul.walms...@sifive.com/T/#u

If those come soon, I'd be fine with submitting them for v5.2-rc.  But if 
that stretches much further into the v5.2-rc series, it seems best to 
schedule it for v5.3.


> I'm hoping to have upstream v5.2 ready for testing in kernelCI, and
> that's one of the last missing pieces.  I just tested it on v5.2-rc3 and
> it's working great with mainline u-boot.

OK, great.  Thanks again for your testing help.


- Paul


Re: [PATCH v3 0/5] arch: riscv: add board and SoC DT file support

2019-06-06 Thread Paul Walmsley
Hi Kevin,

On Wed, 5 Jun 2019, Kevin Hilman wrote:

> Paul Walmsley  writes:
> 
> > Add support for building flattened DT files from DT source files under
> > arch/riscv/boot/dts.  Follow existing kernel precedent from other SoC
> > architectures.  Start our board support by adding initial support for
> > the SiFive FU540 SoC and the first development board that uses it, the
> > SiFive HiFive Unleashed A00.
> 
> Tested this series on top of v5.2-rc3 on HiFive Unleashed board using
> OpenSBI + mainline u-boot (master branch as of today).
> 
> Tested-by: Kevin Hilman 

Thanks very much!

> > This patch series can be found, along with the PRCI patch set
> > and the DT macro prerequisite patch, at:
> >
> > https://github.com/sifive/riscv-linux/tree/dev/paulw/dts-v5.2-rc1
> 
> nit: I only see this series in that branch, not any of the prerequisite
> patches you mentioned, which made me assume I could this series alone on
> top of v5.2-rc3, which worked just fine.

Yep, just forgot to drop that part of the sentence from the series 
description.  Those prerequisite patches were already merged.


- Paul


Re: [PATCH v3 0/5] arch: riscv: add board and SoC DT file support

2019-06-06 Thread Paul Walmsley
On Tue, 4 Jun 2019, Loys Ollivier wrote:

> On Sun 02 Jun 2019 at 01:04, Paul Walmsley  wrote:
> 
> > Add support for building flattened DT files from DT source files under
> > arch/riscv/boot/dts.  Follow existing kernel precedent from other SoC
> > architectures.  Start our board support by adding initial support for
> > the SiFive FU540 SoC and the first development board that uses it, the
> > SiFive HiFive Unleashed A00.
> >
> > This third version of the patch set adds I2C data for the chip,
> > incorporates all remaining changes that riscv-pk was making
> > automatically, and addresses a comment from Rob Herring
> > .
> >
> > Boot-tested on v5.2-rc1 on a HiFive Unleashed A00 board, using the
> > BBL and open-source FSBL, with modifications to pass in the DTB
> > file generated by these patches.
> >
> > This patch series can be found, along with the PRCI patch set
> > and the DT macro prerequisite patch, at:
> >
> > https://github.com/sifive/riscv-linux/tree/dev/paulw/dts-v5.2-rc1
> 
> Tested patch 1, 4 and 5 using FSBL + OpenSBI + U-Boot on HiFive Unleashed.
> Tested-by: Loys Ollivier 

Thanks very much for your testing!


- Paul


Re: [PATCH v2 3/3] brcmfmac: sdio: Disable auto-tuning around commands expected to fail

2019-06-06 Thread Arend Van Spriel

On June 6, 2019 11:37:22 PM Doug Anderson  wrote:


In the case of dw_mmc, which I'm most familiar with, we don't have any
sort of automated or timed-based retuning.  ...so we'll only re-tune
when we see the CRC error.  If I'm understanding things correctly then
that for dw_mmc my solution and yours behave the same.  That means the
difference is how we deal with other retuning requests, either ones
that come about because of an interrupt that the host controller
provided or because of a timer.  Did I get that right?


Right.


...and I guess the reason we have to deal specially with these cases
is because any time that SDIO card is "sleeping" we don't want to
retune because it won't work.  Right?  NOTE: the solution that would
come to my mind first to solve this would be to hold the retuning for
the whole time that the card was sleeping and then release it once the
card was awake again.  ...but I guess we don't truly need to do that
because tuning only happens as a side effect of sending a command to
the card and the only command we send to the card is the "wake up"
command.  That's why your solution to hold tuning while sending the
"wake up" command works, right?


Yup.


---

OK, so assuming all the above is correct, I feel like we're actually
solving two problems and in fact I believe we actually need both our
approaches to solve everything correctly.  With just your patch in
place there's a problem because we will clobber any external retuning
requests that happened while we were waking up the card.  AKA, imagine
this:

A) brcmf_sdio_kso_control(on=True) gets called; need_retune starts as 0

B) We call sdio_retune_hold_now()

C) A retuning timer goes off or the SD Host controller tells us to retune

D) We get to the end of brcmf_sdio_kso_control() and clear the "retune
needed" since need_retune was 0 at the start.

...so we dropped the retuning request from C), right?


What we truly need is:

1. CRC errors shouldn't trigger a retuning request when we're in
brcmf_sdio_kso_control()

2. A separate patch that holds any retuning requests while the SDIO
card is off.  This patch _shouldn't_ do any clearing of retuning
requests, just defer them.


Does that make sense to you?  If so, I can try to code it up...


FWIW it does make sense to me. However, I am still not sure if our sdio 
hardware supports retuning. Have to track down an asic designer who can 
tell or dive into vhdl myself.


So I want to disable device sleep and trigger retuning through debugfs or 
some other hack.


Regards,
Arend




Re: [PATCH v3 1/5] arch: riscv: add support for building DTB files from DT source data

2019-06-06 Thread Paul Walmsley
On Tue, 4 Jun 2019, Loys Ollivier wrote:

> Always build it ?
> Any particular reason to drop ARCH_SIFIVE ?

Palmer had some reservations about it, so I dropped it for now.  But then 
as I was thinking about it, I remembered that I also had some reservations 
about it, years ago: that everyone should use CONFIG_SOC_* for this, 
rather than CONFIG_ARCH.  CONFIG_ARCH_* seems better reserved for 
CPU architectures.

If you agree, would you like to send a followup series, based on the DT 
patches, to make the SiFive DT file builds depend on CONFIG_SOC_* instead?

Thanks for the comment,

- Paul


Re: [PATCH v6 5/7] RISC-V: Parse cpu topology during boot.

2019-06-06 Thread Paul Walmsley
On Wed, 29 May 2019, Atish Patra wrote:

> Currently, there are no topology defined for RISC-V.
> Parse the cpu-map node from device tree and setup the
> cpu topology.
> 
> CPU topology after applying the patch.
> $cat /sys/devices/system/cpu/cpu2/topology/core_siblings_list
> 0-3
> $cat /sys/devices/system/cpu/cpu3/topology/core_siblings_list
> 0-3
> $cat /sys/devices/system/cpu/cpu3/topology/physical_package_id
> 0
> $cat /sys/devices/system/cpu/cpu3/topology/core_id
> 3
> 
> Signed-off-by: Atish Patra 
> Acked-by: Sudeep Holla 

Looks reasonable to me.

Acked-by: Paul Walmsley 

We're assuming, on the RISC-V side, that these patches will go in via 
another tree.


- Paul


Re: [PATCH] mtd: spi-nor: change "error reading JEDEC id" from dbg to err

2019-06-06 Thread Tudor.Ambarus


On 05/24/2019 05:45 PM, Flavio Suligoi wrote:
> External E-Mail
> 
> 
> In case of SPI error during the reading of the nor Id,
> the probe fails without any error message related to
> the JEDEC Id reading procedure.
> 
> Signed-off-by: Flavio Suligoi 
> ---
>  drivers/mtd/spi-nor/spi-nor.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git,
spi-nor/next branch.

Thanks,
ta


Re: [PATCH] mtd: spi-nor: Add Micron MT25QL02 support

2019-06-06 Thread Tudor.Ambarus


On 05/13/2019 06:33 AM, Andrey Smirnov wrote:
> External E-Mail
> 
> 
> Add an entry for Micron MT25QL02 which is a 3V variant of already
> supported MT25QU02.
> 
> Testing was done on a ZII VF610 Dev Board (rev. B).
> 
> Signed-off-by: Cory Tusar 
> Signed-off-by: Andrey Smirnov 
> Cc: Chris Healy 
> Cc: Marek Vasut 
> Cc: Tudor Ambarus 
> Cc: linux-...@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> ---
> 
> Previous verion of the patch: https://lore.kernel.org/patchwork/patch/577372/
> 
>  drivers/mtd/spi-nor/spi-nor.c | 1 +
>  1 file changed, 1 insertion(+)
> 

Ordered entry alphabetically, wrapped the entry to 80 chars limit and applied to
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git, spi-nor/next 
branch.

Thanks,
ta


Re: [PATCH] mtd: spi-nor: stm32: remove the driver as it was replaced by spi-stm32-qspi.c

2019-06-06 Thread Tudor.Ambarus


On 05/07/2019 12:16 PM, Ludovic Barre wrote:
> From: Ludovic Barre 
> 
> There's a new driver using the SPI memory interface of the
> SPI framework at spi/spi-stm32-qspi.c, which can be used
> together with m25p80.c to replace the functionality of
> this SPI NOR driver.
> 
> The "new" driver uses the same dt properties and not affects
> the legacy compatibility.
> 
> Signed-off-by: Ludovic Barre 
> ---
>  .../devicetree/bindings/mtd/stm32-quadspi.txt  |  43 --
>  drivers/mtd/spi-nor/Kconfig|   7 -
>  drivers/mtd/spi-nor/Makefile   |   1 -
>  drivers/mtd/spi-nor/stm32-quadspi.c| 720 
> -
>  4 files changed, 771 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/mtd/stm32-quadspi.txt
>  delete mode 100644 drivers/mtd/spi-nor/stm32-quadspi.c

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git,
spi-nor/next branch.

Thanks,
ta


[PATCH v4 15/15] drm/bridge: tc358767: Replace magic number in tc_main_link_enable()

2019-06-06 Thread Andrey Smirnov
We don't need 8 byte array, DP_LINK_STATUS_SIZE (6) should be
enough. This also gets rid of a magic number as a bonus.

Signed-off-by: Andrey Smirnov 
Cc: Andrzej Hajda 
Cc: Laurent Pinchart 
Cc: Tomi Valkeinen 
Cc: Andrey Gusakov 
Cc: Philipp Zabel 
Cc: Cory Tusar 
Cc: Chris Healy 
Cc: Lucas Stach 
Cc: dri-de...@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/gpu/drm/bridge/tc358767.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/tc358767.c 
b/drivers/gpu/drm/bridge/tc358767.c
index 4a245144aa83..05c5fab011f8 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -874,7 +874,7 @@ static int tc_main_link_enable(struct tc_data *tc)
u32 dp_phy_ctrl;
u32 value;
int ret;
-   u8 tmp[8];
+   u8 tmp[DP_LINK_STATUS_SIZE];
 
dev_dbg(tc->dev, "link enable\n");
 
-- 
2.21.0



RE: [PATCH v7 1/6] dt-bindings: add binding for USBSS-DRD controller.

2019-06-06 Thread Pawel Laszczak

>
>Pawel,
>
>On 05/06/2019 13:03, Pawel Laszczak wrote:
>> This patch aim at documenting USB related dt-bindings for the
>> Cadence USBSS-DRD controller.
>>
>> Signed-off-by: Pawel Laszczak 
>> Reviewed-by: Rob Herring 
>>
>> ---
>>  .../devicetree/bindings/usb/cdns-usb3.txt | 30 +++
>>  1 file changed, 30 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/usb/cdns-usb3.txt
>>
>> diff --git a/Documentation/devicetree/bindings/usb/cdns-usb3.txt 
>> b/Documentation/devicetree/bindings/usb/cdns-usb3.txt
>> new file mode 100644
>> index ..1d2b449e3cb4
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/usb/cdns-usb3.txt
>> @@ -0,0 +1,30 @@
>> +Binding for the Cadence USBSS-DRD controller
>> +
>> +Required properties:
>> +  - reg: Physical base address and size of the controller's register areas.
>> + Controller has 3 different regions:
>> + region 1 - HOST registers area
>> + region 2 - DEVICE registers area
>> + region 3 - OTG/DRD registers area
>> +  - reg-names - register memory area names:
>> +"xhci" - for HOST registers space
>> +"dev" - for DEVICE registers space
>> +"otg" - for OTG/DRD registers space
>> +  - compatible: Should contain: "cdns,usb3-1.0.0" or "cdns,usb3-1.0.1"
>> +  - interrupts: Interrupts used by cdns3 controller.
>
>Since we are requesting 3 separate named interrupts in code we need to
>mention them here.

Hi Roger, 

Yes, I know, but this code is Reviewed-by: Rob Herring, so I thought to add 
this as separate patch after putting this driver into kernel.

I assume that after making some change in this file I should remove statement
Reviewed-by: Rob Herring  from this patch to start reviving 
from the beginning.  

What do you think about such dt-binding:

Required properties:
  - reg: Physical base address and size of the controller's register areas.
 Controller has 3 different regions:
 region 1 - HOST registers area
 region 2 - DEVICE registers area
 region 3 - OTG/DRD registers area
  - reg-names - register memory area names:
"xhci" - for HOST registers space
"dev" - for DEVICE registers space
"otg" - for OTG/DRD registers space
  - compatible: Should contain:
"cdns,usb3-1.0.0" - for 0x00024502 controller version
"cdns,usb3-1.0.1" - for 0x00024509 controller version
"cdns,usb3-1.0.2" - for 0x0002450C controller version
"cdns,usb3-1.0.3" - for 0x0002450d controller version

- interrupts: Interrupts used by cdns3 controller:
"host" - interrupt used by XHCI driver.
"peripheral" - interrupt used by device driver
"otg" - interrupt used by DRD/OTG  part of driver

Optional properties:
 - maximum-speed : valid arguments are "super-speed", "high-speed" and
   "full-speed"; refer to usb/generic.txt
 - dr_mode: Should be one of "host", "peripheral" or "otg".
 - phys: reference to the USB PHY
 - on-chip-buff-size : size of memory intended as internal memory for endpoints
buffers expressed in KB

Example:
usb@f300 {
compatible = "cdns,usb3-1.0.1";
interrupts = 

;
interrupt-names = "host", "peripheral", "otg";
reg = <0xf300 0x1   /* memory area for HOST 
registers */
0xf301 0x1  /* memory area for DEVICE 
registers */
0xf302 0x1>;/* memory area for OTG/DRD 
registers */
reg-names = "xhci", "dev", "otg";
};

Is this correct now ?

Maybe I should add something additionally for phy ?

Regards,
Pawel

  
>
>> +
>> +Optional properties:
>> + - maximum-speed : valid arguments are "super-speed", "high-speed" and
>> +   "full-speed"; refer to usb/generic.txt
>> + - dr_mode: Should be one of "host", "peripheral" or "otg".
>> + - phys: reference to the USB PHY
>> +
>> +Example:
>> +usb@f300 {
>> +compatible = "cdns,usb3-1.0.1";
>> +interrupts = ;
>
>This example won't work as code requests for 3 separate interrupts.
>
>> +reg = <0xf300 0x1   /* memory area for HOST 
>> registers */
>> +0xf301 0x1  /* memory area for DEVICE 
>> registers */
>> +0xf302 0x1>;/* memory area for OTG/DRD 
>> registers */
>> +reg-names = "xhci", "dev", "otg";
>> +};
>>
>
>--
>cheers,
>-roger
>
>Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
>Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


[PATCH v4 06/15] drm/bridge: tc358767: Simplify AUX data read

2019-06-06 Thread Andrey Smirnov
Simplify AUX data read by removing index arithmetic and shifting with
a helper function that does two things:

1. Fetch data from up to 4 32-bit registers from the chip
2. Copy read data into user provided array.

Signed-off-by: Andrey Smirnov 
Reviewed-by: Andrzej Hajda 
Cc: Andrzej Hajda 
Cc: Laurent Pinchart 
Cc: Tomi Valkeinen 
Cc: Andrey Gusakov 
Cc: Philipp Zabel 
Cc: Cory Tusar 
Cc: Chris Healy 
Cc: Lucas Stach 
Cc: dri-de...@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/gpu/drm/bridge/tc358767.c | 31 ++-
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358767.c 
b/drivers/gpu/drm/bridge/tc358767.c
index 7b15caec2ce5..7152b44db8a3 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -321,6 +321,20 @@ static int tc_aux_get_status(struct tc_data *tc, u8 *reply)
return 0;
 }
 
+static int tc_aux_read_data(struct tc_data *tc, void *data, size_t size)
+{
+   u32 auxrdata[DP_AUX_MAX_PAYLOAD_BYTES / sizeof(u32)];
+   int ret, count = ALIGN(size, sizeof(u32));
+
+   ret = regmap_raw_read(tc->regmap, DP0_AUXRDATA(0), auxrdata, count);
+   if (ret)
+   return ret;
+
+   memcpy(data, auxrdata, size);
+
+   return size;
+}
+
 static ssize_t tc_aux_transfer(struct drm_dp_aux *aux,
   struct drm_dp_aux_msg *msg)
 {
@@ -379,19 +393,10 @@ static ssize_t tc_aux_transfer(struct drm_dp_aux *aux,
if (ret)
return ret;
 
-   if (request == DP_AUX_I2C_READ || request == DP_AUX_NATIVE_READ) {
-   /* Read data */
-   while (i < size) {
-   if ((i % 4) == 0) {
-   ret = regmap_read(tc->regmap,
- DP0_AUXRDATA(i >> 2), );
-   if (ret)
-   return ret;
-   }
-   buf[i] = tmp & 0xff;
-   tmp = tmp >> 8;
-   i++;
-   }
+   switch (request) {
+   case DP_AUX_NATIVE_READ:
+   case DP_AUX_I2C_READ:
+   return tc_aux_read_data(tc, msg->buffer, size);
}
 
return size;
-- 
2.21.0



Re: [PATCH] uapi: avoid namespace conflict in linux/posix_types.h

2019-06-06 Thread Florian Weimer
* Joseph Myers:

> What happened with this patch (posted 19 March)?  I found today that we 
> can't use Linux 5.1 headers in glibc testing because the namespace issues 
> are still present in the headers as of the release.

This regression fix still hasn't been merged into Linus' tree.  What is
going on here?

This might seem rather minor, but the namespace testing is actually
relevant in practice.  It prevents accidental clashes with C/C++
identifiers in user code.

If this fairly central UAPI header is not made namespace-clean again,
then we need to duplicate information from more UAPI headers in glibc,
and I don't think that's something we'd want to do.

Thanks,
Florian


Re: [PATCH v3 1/9] Documentation: Introduce EPT based Subpage Protection

2019-06-06 Thread Jidong Xiao
Hi, Weijiang,

Does this require some specific Intel processors or is it supported by
older processors as well?

-Jidong

On Thu, Jun 6, 2019 at 9:33 AM Yang Weijiang  wrote:
>
> Signed-off-by: Yang Weijiang 
> ---
>  Documentation/virtual/kvm/spp_kvm.txt | 216 ++
>  1 file changed, 216 insertions(+)
>  create mode 100644 Documentation/virtual/kvm/spp_kvm.txt
>
> diff --git a/Documentation/virtual/kvm/spp_kvm.txt 
> b/Documentation/virtual/kvm/spp_kvm.txt
> new file mode 100644
> index ..4b5edcaf48b6
> --- /dev/null
> +++ b/Documentation/virtual/kvm/spp_kvm.txt
> @@ -0,0 +1,216 @@
> +EPT-Based Sub-Page Protection (SPP) for KVM
> +=
> +
> +1. Overview
> +
> +EPT-based Sub-Page Protection (SPP) capability to allow Virtual Machine
> +Monitors to specify write-protection for guest physical memory at a
> +sub-page (128 byte) granularity. When this capability is utilized, the
> +CPU enforces write-access permissions for sub-page regions inside 4K pages
> +as specified by the VMI tools.
> +
> +2. Operation of SPP
> +
> +Sub-Page Protection Table (SPPT) is introduced to manage sub-page
> +write-access.
> +
> +SPPT is active when:
> +a) moddule parameter spp=on is configured for kvm-intel.ko
> +b) large paging is disabled on host
> +c) "sub-page write protection" VM-execution control bit is set
> +SPPT looks up the guest physical address to seek a 64-bit
> +bitmap indicating sub-page write permission in SPPT leaf entry.
> +
> +When the "sub-page write protection" VM-execution control is 1, the SPPT
> +is used to lookup write permission bits for the 128 byte sub-page regions
> +contained in the 4KB guest physical page. EPT specifies the 4KB page
> +write-protection privilege whereas SPPT defines the write permissions
> +at 128-byte granularity within one 4KB page. Write accesses
> +prevented due to sub-page permissions induces EPT violation VM exits.
> +Similar to EPT, a logical processor uses SPPT to lookup sub-page level
> +write permissions for guest-physical addresses only when those addresses
> +are used to access memory.
> +__
> +
> +How SPP hardware works:
> +__
> +
> +Guest write access --> GPA --> Walk EPT --> EPT leaf entry -|
> +|---|
> +|-> if VMexec_control.spp && ept_leaf_entry.spp_bit (bit 61)
> + |
> + |->  --> EPT legacy behavior
> + |
> + |
> + |->   --> if ept_leaf_entry.writable
> +  |
> +  |->   --> Ignore SPP
> +  |
> +  |->  --> GPA --> Walk SPP 4-level table--|
> +  |
> +|<--get-the-SPPT-point-from-VMCS-filed-<--|
> +|
> +Walk SPP L4E table
> +|
> +|---> if-entry-misconfiguration >---|---<-|
> + |  | |
> +else| |
> + |  | |
> + |   |--SPP VMexit<-| |
> + |   ||
> + |   |-> exit_qualification & sppt_misconfig --> sppt misconfig   |
> + |   ||
> + |   |-> exit_qualification & sppt_miss --> sppt miss |
> + |---||
> + ||
> +walk SPPT L3E--|--> if-entry-misconfiguration>|
> +   |  |
> +  else|
> +   |  |
> +   |  |
> +walk SPPT L2E --|--> if-entry-misconfiguration>---|
> +| |
> +   else   |
> +| |
> +| |
> + walk SPPT L1E --|-> if-entry-misconfiguration--->|
> + |
> +   else
> + |
> + |-> if sub-page writable
> + |->   allow, write access
> + |->  disallow, EPT violation
> 

Re: [PATCH V4] drivers: i2c: tegra: fix checkpatch defects

2019-06-06 Thread Bitan Biswas




On 6/6/19 1:45 PM, Peter Rosin wrote:

On 2019-06-06 09:35, Bitan Biswas wrote:

Fix checkpatch.pl warning(s)/error(s)/check(s) in i2c-tegra.c

Remove redundant BUG_ON calls or replace with WARN_ON_ONCE
as needed. Replace BUG() with error handling code.
Define I2C_ERR_UNEXPECTED_STATUS for error handling.

Signed-off-by: Bitan Biswas 
---
  drivers/i2c/busses/i2c-tegra.c | 67 +++---
  1 file changed, 37 insertions(+), 30 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 76b7926..55a5d87 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -78,6 +78,7 @@
  #define I2C_ERR_NO_ACK0x01
  #define I2C_ERR_ARBITRATION_LOST  0x02
  #define I2C_ERR_UNKNOWN_INTERRUPT 0x04
+#define I2C_ERR_UNEXPECTED_STATUS   0x08


Use tabs like the the surrounding code. And perhaps convert all
these flags to use the BIT() macro?
I shall correct the line and use tabs. I shall convert macros to BIT() 
if possible.




  
  #define PACKET_HEADER0_HEADER_SIZE_SHIFT	28

  #define PACKET_HEADER0_PACKET_ID_SHIFT16
@@ -112,7 +113,7 @@
  #define I2C_CLKEN_OVERRIDE0x090
  #define I2C_MST_CORE_CLKEN_OVRBIT(0)
  
-#define I2C_CONFIG_LOAD_TIMEOUT			100

+#define I2C_CONFIG_LOAD_TMOUT  100


Similar to xfer_tm already mentioned by Dmitry; just keep it as
..._TIMEOUT and ignore checkpatch on this issue. Or juggle the
code in some other way to pacify checkpatch. E.g. abbreviate
CONFIG instead? Or something. CONF is way easier to read than
TMOUT IMHO...
OK. Just for consistency planning to ignore checkpatch warning and shall 
keep current macro I2C_CONFIG_LOAD_TIMEOUT.


-Thanks,
 Bitan


Re: [PATCH v3 net-next 00/17] PTP support for the SJA1105 DSA driver

2019-06-06 Thread Richard Cochran
On Thu, Jun 06, 2019 at 04:40:19PM +0300, Vladimir Oltean wrote:
> Plain and simply because it doesn't work very well.
> Even phc2sys from the system clock to the hardware (no timestamps
> involved) has trouble staying put (under 1000 ns offset).
> And using the hardware-corrected timestamps triggers a lot of clockchecks.

It sounds like a bug in reading or adjusting the HW clock.  Is the HW
clock stable when you don't adjust its frequency?

Thanks,
Richard





Re: general protection fault in ip6_dst_lookup_tail (2)

2019-06-06 Thread syzbot

syzbot has bisected this bug to:

commit f40b6ae2b612446dc970d7b51eeec47bd1619f82
Author: David Ahern 
Date:   Thu May 23 03:27:55 2019 +

ipv6: Move pcpu cached routes to fib6_nh

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=13c969a6a0
start commit:   07c3bbdb samples: bpf: print a warning about headers_install
git tree:   bpf-next
final crash:https://syzkaller.appspot.com/x/report.txt?x=102969a6a0
console output: https://syzkaller.appspot.com/x/log.txt?x=17c969a6a0
kernel config:  https://syzkaller.appspot.com/x/.config?x=b7b54c66298f8420
dashboard link: https://syzkaller.appspot.com/bug?extid=58d8f704b86e4e3fb4d3
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=117f50e1a0

Reported-by: syzbot+58d8f704b86e4e3fb...@syzkaller.appspotmail.com
Fixes: f40b6ae2b612 ("ipv6: Move pcpu cached routes to fib6_nh")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection


Re: "locking/lockdep: Consolidate lock usage bit initialization" is buggy

2019-06-06 Thread Yuyang Du
Thanks for the report, but

On Fri, 7 Jun 2019 at 05:14, Qian Cai  wrote:
>
> The linux-next commit "locking/lockdep: Consolidate lock usage bit
> initialization" [1] will always generate a warning below.

I never had such warning.

> Looking through the
> commit that when mark_irqflags() returns 1 and check = 1, it will do one less
> mark_lock() call than it used to.

The four cases:

1. When check == 1 and mark_irqflags() returns 1;
2. When check == 1 and mark_irqflags() returns 0;
3. When check == 0 and mark_irqflags() returns 1;
4. When check == 0 and mark_irqflags() returns 0;

Before and after have exactly the same code to do.


Re: [PATCH] Powerpc/Watchpoint: Restore nvgprs while returning from exception

2019-06-06 Thread Ravi Bangoria



On 6/7/19 6:20 AM, Michael Neuling wrote:
> On Thu, 2019-06-06 at 12:59 +0530, Ravi Bangoria wrote:
>> Powerpc hw triggers watchpoint before executing the instruction.
>> To make trigger-after-execute behavior, kernel emulates the
>> instruction. If the instruction is 'load something into non-
>> volatile register', exception handler should restore emulated
>> register state while returning back, otherwise there will be
>> register state corruption. Ex, Adding a watchpoint on a list
>> can corrput the list:
>>
>>   # cat /proc/kallsyms | grep kthread_create_list
>>   c121c8b8 d kthread_create_list
>>
>> Add watchpoint on kthread_create_list->next:
>>
>>   # perf record -e mem:0xc121c8c0
>>
>> Run some workload such that new kthread gets invoked. Ex, I
>> just logged out from console:
>>
>>   list_add corruption. next->prev should be prev (c1214e00), \
>>  but was c121c8b8. (next=c121c8b8).
>>   WARNING: CPU: 59 PID: 309 at lib/list_debug.c:25 __list_add_valid+0xb4/0xc0
>>   CPU: 59 PID: 309 Comm: kworker/59:0 Kdump: loaded Not tainted 5.1.0-rc7+ 
>> #69
>>   ...
>>   NIP __list_add_valid+0xb4/0xc0
>>   LR __list_add_valid+0xb0/0xc0
>>   Call Trace:
>>   __list_add_valid+0xb0/0xc0 (unreliable)
>>   __kthread_create_on_node+0xe0/0x260
>>   kthread_create_on_node+0x34/0x50
>>   create_worker+0xe8/0x260
>>   worker_thread+0x444/0x560
>>   kthread+0x160/0x1a0
>>   ret_from_kernel_thread+0x5c/0x70
>>
>> Signed-off-by: Ravi Bangoria 
> 
> How long has this been around? Should we be CCing stable?

"bl .save_nvgprs" was added in the commit 5aae8a5370802 ("powerpc, 
hw_breakpoints:
Implement hw_breakpoints for 64-bit server processors"), which was merged in
v2.6.36.



[PATCH v1] clk: mediatek: mt8183: Register 13MHz clock earlier for clocksource

2019-06-06 Thread Weiyi Lu
The 13MHz clock should be registered before clocksource driver is
initialized. Use CLK_OF_DECLARE_DRIVER() to guarantee.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-mt8183.c | 49 ++-
 1 file changed, 38 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt8183.c 
b/drivers/clk/mediatek/clk-mt8183.c
index 9d86510..a8f50bc 100644
--- a/drivers/clk/mediatek/clk-mt8183.c
+++ b/drivers/clk/mediatek/clk-mt8183.c
@@ -25,9 +25,11 @@
FIXED_CLK(CLK_TOP_UNIVP_192M, "univpll_192m", "univpll", 19200),
 };
 
+static const struct mtk_fixed_factor top_early_divs[] = {
+   FACTOR(CLK_TOP_CLK13M, "clk13m", "clk26m", 1, 2),
+};
+
 static const struct mtk_fixed_factor top_divs[] = {
-   FACTOR(CLK_TOP_CLK13M, "clk13m", "clk26m", 1,
-   2),
FACTOR(CLK_TOP_F26M_CK_D2, "csw_f26m_ck_d2", "clk26m", 1,
2),
FACTOR(CLK_TOP_SYSPLL_CK, "syspll_ck", "mainpll", 1,
@@ -1167,37 +1169,62 @@ static int clk_mt8183_apmixed_probe(struct 
platform_device *pdev)
return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
 }
 
+static struct clk_onecell_data *top_clk_data;
+
+static void clk_mt8183_top_init_early(struct device_node *node)
+{
+   int i;
+
+   if (!top_clk_data) {
+   top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
+
+   for (i = 0; i < CLK_TOP_NR_CLK; i++)
+   top_clk_data->clks[i] = ERR_PTR(-EPROBE_DEFER);
+   }
+
+   mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs),
+   top_clk_data);
+
+   of_clk_add_provider(node, of_clk_src_onecell_get, top_clk_data);
+}
+
+CLK_OF_DECLARE_DRIVER(mt8183_topckgen, "mediatek,mt8183-topckgen",
+   clk_mt8183_top_init_early);
+
 static int clk_mt8183_top_probe(struct platform_device *pdev)
 {
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
void __iomem *base;
-   struct clk_onecell_data *clk_data;
struct device_node *node = pdev->dev.of_node;
 
base = devm_ioremap_resource(>dev, res);
if (IS_ERR(base))
return PTR_ERR(base);
 
-   clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
+   if (!top_clk_data)
+   top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
 
mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
-   clk_data);
+   top_clk_data);
+
+   mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs),
+   top_clk_data);
 
-   mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
+   mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data);
 
mtk_clk_register_muxes(top_muxes, ARRAY_SIZE(top_muxes),
-   node, _clk_lock, clk_data);
+   node, _clk_lock, top_clk_data);
 
mtk_clk_register_composites(top_aud_muxes, ARRAY_SIZE(top_aud_muxes),
-   base, _clk_lock, clk_data);
+   base, _clk_lock, top_clk_data);
 
mtk_clk_register_composites(top_aud_divs, ARRAY_SIZE(top_aud_divs),
-   base, _clk_lock, clk_data);
+   base, _clk_lock, top_clk_data);
 
mtk_clk_register_gates(node, top_clks, ARRAY_SIZE(top_clks),
-   clk_data);
+   top_clk_data);
 
-   return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+   return of_clk_add_provider(node, of_clk_src_onecell_get, top_clk_data);
 }
 
 static int clk_mt8183_infra_probe(struct platform_device *pdev)
-- 
1.8.1.1.dirty



[PATCH] staging: rtl8723bs: Fix Unneeded variable: "ret". Return "0"

2019-06-06 Thread Shobhit Kukreti
coccicheck reported Unneeded variable ret at rtl8723bs/core/rtw_ap.c:1400.
Function "rtw_acl_remove_sta" always returns 0. Modified return type of the
function to void.

Signed-off-by: Shobhit Kukreti 
---
 drivers/staging/rtl8723bs/core/rtw_ap.c| 4 +---
 drivers/staging/rtl8723bs/include/rtw_ap.h | 2 +-
 drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 3 ++-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index 7bebb41..87b201a 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -1394,10 +1394,9 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
return ret;
 }
 
-int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
+void rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
 {
struct list_head*plist, *phead;
-   int ret = 0;
struct rtw_wlan_acl_node *paclnode;
struct sta_priv *pstapriv = >stapriv;
struct wlan_acl_pool *pacl_list = >acl_list;
@@ -1438,7 +1437,6 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
 
DBG_871X("%s, acl_num =%d\n", __func__, pacl_list->num);
 
-   return ret;
 }
 
 u8 rtw_ap_set_pairwise_key(struct adapter *padapter, struct sta_info *psta)
diff --git a/drivers/staging/rtl8723bs/include/rtw_ap.h 
b/drivers/staging/rtl8723bs/include/rtw_ap.h
index d6f3a3a..4a1ed9e 100644
--- a/drivers/staging/rtl8723bs/include/rtw_ap.h
+++ b/drivers/staging/rtl8723bs/include/rtw_ap.h
@@ -19,7 +19,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, 
 int len);
 void rtw_ap_restore_network(struct adapter *padapter);
 void rtw_set_macaddr_acl(struct adapter *padapter, int mode);
 int rtw_acl_add_sta(struct adapter *padapter, u8 *addr);
-int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr);
+void rtw_acl_remove_sta(struct adapter *padapter, u8 *addr);
 
 u8 rtw_ap_set_pairwise_key(struct adapter *padapter, struct sta_info *psta);
 int rtw_ap_set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid);
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index 236a462..9da1fd2 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -4174,7 +4174,8 @@ static int rtw_ioctl_acl_remove_sta(struct net_device 
*dev, struct ieee_param *p
return -EINVAL;
}
 
-   return rtw_acl_remove_sta(padapter, param->sta_addr);
+   rtw_acl_remove_sta(padapter, param->sta_addr);
+   return 0;
 
 }
 
-- 
2.7.4



Re: [PATCH v2 4/7] cpufreq: add driver for Raspbery Pi

2019-06-06 Thread Viresh Kumar
On 06-06-19, 11:23, Stephen Boyd wrote:
> Yes, thanks. I see that largely follows the commit description so it
> looks OK to me.

Do you want to provide your Reviewed/Acked-by tag before I apply it ?

-- 
viresh


Re: [PATCH] cpufreq: pcc-cpufreq: Fail initialization if driver cannot be registered

2019-06-06 Thread Viresh Kumar
On 06-06-19, 14:50, David Arcari wrote:
> Make pcc_cpufreq_init() return error codes when the driver cannot be
> registered.  Otherwise the driver can shows up loaded via lsmod even
> though it failed initialization.  This is confusing to the user.
> 
> Signed-off-by: David Arcari 
> Cc: "Rafael J. Wysocki" 
> Cc: Viresh Kumar 
> ---
>  drivers/cpufreq/pcc-cpufreq.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
> index 1e5e64643c3a..fdc767fdbe6a 100644
> --- a/drivers/cpufreq/pcc-cpufreq.c
> +++ b/drivers/cpufreq/pcc-cpufreq.c
> @@ -582,10 +582,10 @@ static int __init pcc_cpufreq_init(void)
>  
>   /* Skip initialization if another cpufreq driver is there. */
>   if (cpufreq_get_current_driver())
> - return 0;
> + return -EEXIST;
>  
>   if (acpi_disabled)
> - return 0;
> + return -ENODEV;
>  
>   ret = pcc_cpufreq_probe();
>   if (ret) {

Acked-by: Viresh Kumar 

-- 
viresh


Re: [PATCH bpf] bpf: fix nested bpf tracepoints with per-cpu data

2019-06-06 Thread Andrii Nakryiko
On Thu, Jun 6, 2019 at 1:17 PM Matt Mullins  wrote:
>
> BPF_PROG_TYPE_RAW_TRACEPOINTs can be executed nested on the same CPU, as
> they do not increment bpf_prog_active while executing.
>
> This enables three levels of nesting, to support
>   - a kprobe or raw tp or perf event,
>   - another one of the above that irq context happens to call, and
>   - another one in nmi context

Can NMIs be nested?

> (at most one of which may be a kprobe or perf event).
>
> Fixes: 20b9d7ac4852 ("bpf: avoid excessive stack usage for perf_sample_data")
> ---
> This is more lines of code, but possibly less intrusive than the
> per-array-element approach.
>
> I don't necessarily like that I duplicated the nest_level logic in two
> places, but I don't see a way to unify them:
>   - kprobes' bpf_perf_event_output doesn't use bpf_raw_tp_regs, and does
> use the perf_sample_data,
>   - raw tracepoints' bpf_get_stackid uses bpf_raw_tp_regs, but not
> the perf_sample_data, and
>   - raw tracepoints' bpf_perf_event_output uses both...
>
>  kernel/trace/bpf_trace.c | 95 +---
>  1 file changed, 80 insertions(+), 15 deletions(-)
>
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index f92d6ad5e080..4f5419837ddd 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -410,8 +410,6 @@ static const struct bpf_func_proto 
> bpf_perf_event_read_value_proto = {
> .arg4_type  = ARG_CONST_SIZE,
>  };
>
> -static DEFINE_PER_CPU(struct perf_sample_data, bpf_trace_sd);
> -
>  static __always_inline u64
>  __bpf_perf_event_output(struct pt_regs *regs, struct bpf_map *map,
> u64 flags, struct perf_sample_data *sd)
> @@ -442,24 +440,47 @@ __bpf_perf_event_output(struct pt_regs *regs, struct 
> bpf_map *map,
> return perf_event_output(event, sd, regs);
>  }
>
> +/*
> + * Support executing tracepoints in normal, irq, and nmi context that each 
> call
> + * bpf_perf_event_output
> + */
> +struct bpf_trace_sample_data {
> +   struct perf_sample_data sds[3];
> +};
> +
> +static DEFINE_PER_CPU(struct bpf_trace_sample_data, bpf_trace_sds);
> +static DEFINE_PER_CPU(int, bpf_trace_nest_level);
>  BPF_CALL_5(bpf_perf_event_output, struct pt_regs *, regs, struct bpf_map *, 
> map,
>u64, flags, void *, data, u64, size)
>  {
> -   struct perf_sample_data *sd = this_cpu_ptr(_trace_sd);
> +   struct bpf_trace_sample_data *sds = this_cpu_ptr(_trace_sds);
> +   struct perf_sample_data *sd;
> +   int nest_level = this_cpu_inc_return(bpf_trace_nest_level);

reverse Christmas tree?

> struct perf_raw_record raw = {
> .frag = {
> .size = size,
> .data = data,
> },
> };
> +   int err = -EBUSY;
>
> +   if (WARN_ON_ONCE(nest_level > ARRAY_SIZE(sds->sds)))
> +   goto out;

consider this a nit, but I find it much simpler to follow when err is
set just before goto, so that it's clear what's going to be returned:

int err;

if (something_bad) {
err = -EBAD_ERR_CODE1;
goto out;
}


> +
> +   sd = >sds[nest_level - 1];
> +
> +   err = -EINVAL;
> if (unlikely(flags & ~(BPF_F_INDEX_MASK)))
> -   return -EINVAL;
> +   goto out;

Same here.

>
> perf_sample_data_init(sd, 0, 0);
> sd->raw = 
>
> -   return __bpf_perf_event_output(regs, map, flags, sd);
> +   err = __bpf_perf_event_output(regs, map, flags, sd);
> +
> +out:
> +   this_cpu_dec(bpf_trace_nest_level);
> +   return err;
>  }
>
>  static const struct bpf_func_proto bpf_perf_event_output_proto = {
> @@ -822,16 +843,48 @@ pe_prog_func_proto(enum bpf_func_id func_id, const 
> struct bpf_prog *prog)
>  /*
>   * bpf_raw_tp_regs are separate from bpf_pt_regs used from skb/xdp
>   * to avoid potential recursive reuse issue when/if tracepoints are added
> - * inside bpf_*_event_output, bpf_get_stackid and/or bpf_get_stack
> + * inside bpf_*_event_output, bpf_get_stackid and/or bpf_get_stack.
> + *
> + * Since raw tracepoints run despite bpf_prog_active, support concurrent 
> usage
> + * in normal, irq, and nmi context.
>   */
> -static DEFINE_PER_CPU(struct pt_regs, bpf_raw_tp_regs);
> +struct bpf_raw_tp_regs {
> +   struct pt_regs regs[3];
> +};
> +static DEFINE_PER_CPU(struct bpf_raw_tp_regs, bpf_raw_tp_regs);
> +static DEFINE_PER_CPU(int, bpf_raw_tp_nest_level);
> +static struct pt_regs *get_bpf_raw_tp_regs(void)
> +{
> +   struct bpf_raw_tp_regs *tp_regs = this_cpu_ptr(_raw_tp_regs);
> +   int nest_level = this_cpu_inc_return(bpf_raw_tp_nest_level);
> +
> +   if (WARN_ON_ONCE(nest_level > ARRAY_SIZE(tp_regs->regs))) {
> +   this_cpu_dec(bpf_raw_tp_nest_level);
> +   return ERR_PTR(-EBUSY);
> +   }
> +
> +   return _regs->regs[nest_level - 1];
> +}
> +
> +static void put_bpf_raw_tp_regs(void)
> +{
> +   

[PATCH] security/keys/request_key.c - fix kerneldoc

2019-06-06 Thread Valdis Klētnieks
When building with W=1, gcc complains due to a typo in a kerneldoc comment

  CC  security/keys/request_key.o
security/keys/request_key.c:35: warning: Function parameter or member 'authkey' 
not described in 'complete_request_key'
security/keys/request_key.c:35: warning: Excess function parameter 'auth_key' 
description in 'complete_request_key'

Fix it up to match the function

Signed-off-by: Valdis Kletnieks 

[PATCH] bpf/core.c - silence warning messages

2019-06-06 Thread Valdis Klētnieks
Compiling kernel/bpf/core.c with W=1 causes a flood of warnings:

kernel/bpf/core.c:1198:65: warning: initialized field overwritten 
[-Woverride-init]
 1198 | #define BPF_INSN_3_TBL(x, y, z) [BPF_##x | BPF_##y | BPF_##z] = true
  | ^~~~
kernel/bpf/core.c:1087:2: note: in expansion of macro 'BPF_INSN_3_TBL'
 1087 |  INSN_3(ALU, ADD,  X),   \
  |  ^~
kernel/bpf/core.c:1202:3: note: in expansion of macro 'BPF_INSN_MAP'
 1202 |   BPF_INSN_MAP(BPF_INSN_2_TBL, BPF_INSN_3_TBL),
  |   ^~~~
kernel/bpf/core.c:1198:65: note: (near initialization for 
'public_insntable[12]')
 1198 | #define BPF_INSN_3_TBL(x, y, z) [BPF_##x | BPF_##y | BPF_##z] = true
  | ^~~~
kernel/bpf/core.c:1087:2: note: in expansion of macro 'BPF_INSN_3_TBL'
 1087 |  INSN_3(ALU, ADD,  X),   \
  |  ^~
kernel/bpf/core.c:1202:3: note: in expansion of macro 'BPF_INSN_MAP'
 1202 |   BPF_INSN_MAP(BPF_INSN_2_TBL, BPF_INSN_3_TBL),
  |   ^~~~

98 copies of the above.

The attached patch silences the warnings, because we *know* we're overwriting
the default initializer. That leaves bpf/core.c with only 6 other warnings,
which become more visible in comparison.

Signed-off-by: Valdis Kletnieks 

diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
index 4c2fa3ac56f6..2606665f2cb5 100644
--- a/kernel/bpf/Makefile
+++ b/kernel/bpf/Makefile
@@ -21,3 +21,4 @@ obj-$(CONFIG_CGROUP_BPF) += cgroup.o
 ifeq ($(CONFIG_INET),y)
 obj-$(CONFIG_BPF_SYSCALL) += reuseport_array.o
 endif
+CFLAGS_core.o  += $(call cc-disable-warning, override-init)




[PATCH] fs/handle.c - fix up kerneldoc

2019-06-06 Thread Valdis Klētnieks
When building with W=1, gcc complains about kerneldoc issues:

  CC  fs/fhandle.o
fs/fhandle.c:259: warning: Function parameter or member 'flags' not described 
in 'sys_open_by_handle_at'
fs/fhandle.c:259: warning: Excess function parameter 'flag' description in 
'sys_open_by_handle_at'

Fix typo in the kerneldoc

Signed-off-by: Valdis Kletnieks 

diff --git a/fs/fhandle.c b/fs/fhandle.c
index 0ee727485615..01263ffbc4c0 100644
--- a/fs/fhandle.c
+++ b/fs/fhandle.c
@@ -246,7 +246,7 @@ static long do_handle_open(int mountdirfd, struct 
file_handle __user *ufh,
  * sys_open_by_handle_at: Open the file handle
  * @mountdirfd: directory file descriptor
  * @handle: file handle to be opened
- * @flag: open flags.
+ * @flags: open flags.
  *
  * @mountdirfd indicate the directory file descriptor
  * of the mount point. file handle is decoded relative




Re: [PATCH] Documentation: coresight: Update the generic device names

2019-06-06 Thread Leo Yan
Hi Suzuki,

On Thu, Jun 06, 2019 at 05:21:19PM +0100, Suzuki K Poulose wrote:
> Hi Mathieu,
> 
> On 03/06/2019 20:01, Mathieu Poirier wrote:
> > Hi Suzuki,
> > 
> > On Thu, May 30, 2019 at 04:11:17PM +0100, Suzuki K Poulose wrote:
> > > Update the documentation to reflect the new naming scheme with
> > > latest changes.
> > > 
> > > Reported-by: Leo Yan 
> > > Cc: Mathieu Poirier 
> > > Cc: Jonathan Corbet 
> > > Signed-off-by: Suzuki K Poulose 
> > > ---
> > >   Documentation/trace/coresight.txt | 34 
> > > +++---
> > >   1 file changed, 19 insertions(+), 15 deletions(-)
> > > 
> > > diff --git a/Documentation/trace/coresight.txt 
> > > b/Documentation/trace/coresight.txt
> > > index efbc832..7b427cf 100644
> > > --- a/Documentation/trace/coresight.txt
> > > +++ b/Documentation/trace/coresight.txt
> > > @@ -326,16 +326,20 @@ amount of processor cores), the "cs_etm" PMU will 
> > > be listed only once.
> > >   A Coresight PMU works the same way as any other PMU, i.e the name of 
> > > the PMU is
> > >   listed along with configuration options within forward slashes '/'.  
> > > Since a
> > >   Coresight system will typically have more than one sink, the name of 
> > > the sink to
> > > -work with needs to be specified as an event option.  Names for sink to 
> > > choose
> > > -from are listed in sysFS under ($SYSFS)/bus/coresight/devices:
> > > +work with needs to be specified as an event option.
> > > +On newer kernels the available sinks are listed in sysFS under:
> > > +($SYSFS)/bus/event_source/devices/cs_etm/sinks/
> > > - root@linaro-nano:~# ls /sys/bus/coresight/devices/
> > > - 2001.etf   2004.funnel  2010.stm  2204.etm
> > > - 2214.etm  230c.funnel  2324.etm 2003.tpiu
> > > - 2007.etr 2012.replicator  220c.funnel
> > > - 2304.etm  2314.etm 2334.etm
> > > + root@localhost:/sys/bus/event_source/devices/cs_etm/sinks# ls
> > > + tmc_etf0  tmc_etr0  tpiu0
> > > - root@linaro-nano:~# perf record -e cs_etm/@2007.etr/u --per-thread 
> > > program
> > > +On older kernels, this may need to be found from the list of coresight 
> > > devices,
> > > +available under ($SYSFS)/bus/coresight/devices/:
> > > +
> > > + root@localhost:/sys/bus/coresight/devices# ls
> > > + etm0  etm1  etm2  etm3  etm4  etm5  funnel0  funnel1  funnel2  
> > > replicator0  stm0 tmc_etf0  tmc_etr0  tpiu0
> > > +
> > > + root@linaro-nano:~# perf record -e cs_etm/@tmc_etr0/u --per-thread 
> > > program
> > 
> > On the "older" kernels you are referring to one would find the original 
> > naming
> > convention.  Everything else looks good to me.
> 
> True, but do we care what we see there ? All we care about is the location,
> where to find them. I could fix it, if you think thats needed.

IIUC, either the old kernel or newer kernel, both we can find the event
from ($SYSFS)/bus/event_source/devices/cs_etm/sinks/; the only
difference between them is the naming convention.

So the doc can use the same location to find event for both new and
old kernel, and explain the naming convention difference?

Thanks,
Leo Yan


Re: [BUG 4.4.178] x86_64 compat mode futexes broken

2019-06-06 Thread Nathan Chancellor
On Fri, Jun 07, 2019 at 01:01:36AM +, Joe Korty wrote:
> Hi Nathan,
> I started with 4.4.179-rt181 and worked backwards from there.  Per your
> suggestion, I tried 4.4.180 and it does work properly.
> 
> Thanks,
> Joe

Great, thank you for testing and sorry for the breakage in the first
place, I missed those commits in my series :(

Cheers,
Nathan


[PATCH V2 net-next 08/12] net: hns3: small changes for magic numbers

2019-06-06 Thread Huazhong Tan
From: Jian Shen 

In order to improve readability, this patch uses macros to
replace some magic numbers, and adds some comments for some
others.

Signed-off-by: Jian Shen 
Signed-off-by: Peng Li 
Signed-off-by: Huazhong Tan 
---
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 118 +++--
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h|  24 +++--
 2 files changed, 79 insertions(+), 63 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 9fe00a8..36a92a1 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -4490,19 +4490,19 @@ static bool hclge_fd_convert_tuple(u32 tuple_bit, u8 
*key_x, u8 *key_y,
case 0:
return false;
case BIT(INNER_DST_MAC):
-   for (i = 0; i < 6; i++) {
-   calc_x(key_x[5 - i], rule->tuples.dst_mac[i],
+   for (i = 0; i < ETH_ALEN; i++) {
+   calc_x(key_x[ETH_ALEN - 1 - i], rule->tuples.dst_mac[i],
   rule->tuples_mask.dst_mac[i]);
-   calc_y(key_y[5 - i], rule->tuples.dst_mac[i],
+   calc_y(key_y[ETH_ALEN - 1 - i], rule->tuples.dst_mac[i],
   rule->tuples_mask.dst_mac[i]);
}
 
return true;
case BIT(INNER_SRC_MAC):
-   for (i = 0; i < 6; i++) {
-   calc_x(key_x[5 - i], rule->tuples.src_mac[i],
+   for (i = 0; i < ETH_ALEN; i++) {
+   calc_x(key_x[ETH_ALEN - 1 - i], rule->tuples.src_mac[i],
   rule->tuples.src_mac[i]);
-   calc_y(key_y[5 - i], rule->tuples.src_mac[i],
+   calc_y(key_y[ETH_ALEN - 1 - i], rule->tuples.src_mac[i],
   rule->tuples.src_mac[i]);
}
 
@@ -4538,19 +4538,19 @@ static bool hclge_fd_convert_tuple(u32 tuple_bit, u8 
*key_x, u8 *key_y,
 
return true;
case BIT(INNER_SRC_IP):
-   calc_x(tmp_x_l, rule->tuples.src_ip[3],
-  rule->tuples_mask.src_ip[3]);
-   calc_y(tmp_y_l, rule->tuples.src_ip[3],
-  rule->tuples_mask.src_ip[3]);
+   calc_x(tmp_x_l, rule->tuples.src_ip[IPV4_INDEX],
+  rule->tuples_mask.src_ip[IPV4_INDEX]);
+   calc_y(tmp_y_l, rule->tuples.src_ip[IPV4_INDEX],
+  rule->tuples_mask.src_ip[IPV4_INDEX]);
*(__le32 *)key_x = cpu_to_le32(tmp_x_l);
*(__le32 *)key_y = cpu_to_le32(tmp_y_l);
 
return true;
case BIT(INNER_DST_IP):
-   calc_x(tmp_x_l, rule->tuples.dst_ip[3],
-  rule->tuples_mask.dst_ip[3]);
-   calc_y(tmp_y_l, rule->tuples.dst_ip[3],
-  rule->tuples_mask.dst_ip[3]);
+   calc_x(tmp_x_l, rule->tuples.dst_ip[IPV4_INDEX],
+  rule->tuples_mask.dst_ip[IPV4_INDEX]);
+   calc_y(tmp_y_l, rule->tuples.dst_ip[IPV4_INDEX],
+  rule->tuples_mask.dst_ip[IPV4_INDEX]);
*(__le32 *)key_x = cpu_to_le32(tmp_x_l);
*(__le32 *)key_y = cpu_to_le32(tmp_y_l);
 
@@ -4799,6 +4799,7 @@ static int hclge_fd_check_spec(struct hclge_dev *hdev,
*unused |= BIT(INNER_SRC_MAC) | BIT(INNER_DST_MAC) |
BIT(INNER_IP_TOS);
 
+   /* check whether src/dst ip address used */
if (!tcp_ip6_spec->ip6src[0] && !tcp_ip6_spec->ip6src[1] &&
!tcp_ip6_spec->ip6src[2] && !tcp_ip6_spec->ip6src[3])
*unused |= BIT(INNER_SRC_IP);
@@ -4823,6 +4824,7 @@ static int hclge_fd_check_spec(struct hclge_dev *hdev,
BIT(INNER_IP_TOS) | BIT(INNER_SRC_PORT) |
BIT(INNER_DST_PORT);
 
+   /* check whether src/dst ip address used */
if (!usr_ip6_spec->ip6src[0] && !usr_ip6_spec->ip6src[1] &&
!usr_ip6_spec->ip6src[2] && !usr_ip6_spec->ip6src[3])
*unused |= BIT(INNER_SRC_IP);
@@ -4966,14 +4968,14 @@ static int hclge_fd_get_tuple(struct hclge_dev *hdev,
case SCTP_V4_FLOW:
case TCP_V4_FLOW:
case UDP_V4_FLOW:
-   rule->tuples.src_ip[3] =
+   rule->tuples.src_ip[IPV4_INDEX] =
be32_to_cpu(fs->h_u.tcp_ip4_spec.ip4src);
-   rule->tuples_mask.src_ip[3] =
+   rule->tuples_mask.src_ip[IPV4_INDEX] =
be32_to_cpu(fs->m_u.tcp_ip4_spec.ip4src);
 
-   rule->tuples.dst_ip[3] =
+   rule->tuples.dst_ip[IPV4_INDEX] =
be32_to_cpu(fs->h_u.tcp_ip4_spec.ip4dst);
-   

[PATCH V2 net-next 10/12] net: hns3: refactor PF/VF RSS hash key configuration

2019-06-06 Thread Huazhong Tan
From: Yufeng Mo 

In order to make it more readable, this patch modifies PF/VF's
RSS hash key configuring function.

Signed-off-by: Yufeng Mo 
Signed-off-by: Jian Shen 
Signed-off-by: Weihang Li 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c   | 15 +++
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 15 +++
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 755cc43..ee4e163 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -3609,28 +3609,27 @@ static int hclge_set_rss_algo_key(struct hclge_dev 
*hdev,
 {
struct hclge_rss_config_cmd *req;
struct hclge_desc desc;
-   int key_offset;
+   int key_offset = 0;
+   int key_counts;
int key_size;
int ret;
 
+   key_counts = HCLGE_RSS_KEY_SIZE;
req = (struct hclge_rss_config_cmd *)desc.data;
 
-   for (key_offset = 0; key_offset < 3; key_offset++) {
+   while (key_counts) {
hclge_cmd_setup_basic_desc(, HCLGE_OPC_RSS_GENERIC_CONFIG,
   false);
 
req->hash_config |= (hfunc & HCLGE_RSS_HASH_ALGO_MASK);
req->hash_config |= (key_offset << HCLGE_RSS_HASH_KEY_OFFSET_B);
 
-   if (key_offset == 2)
-   key_size =
-   HCLGE_RSS_KEY_SIZE - HCLGE_RSS_HASH_KEY_NUM * 2;
-   else
-   key_size = HCLGE_RSS_HASH_KEY_NUM;
-
+   key_size = min(HCLGE_RSS_HASH_KEY_NUM, key_counts);
memcpy(req->hash_key,
   key + key_offset * HCLGE_RSS_HASH_KEY_NUM, key_size);
 
+   key_counts -= key_size;
+   key_offset++;
ret = hclge_cmd_send(>hw, , 1);
if (ret) {
dev_err(>pdev->dev,
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 7fd25ab..c448774 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -539,13 +539,15 @@ static int hclgevf_set_rss_algo_key(struct hclgevf_dev 
*hdev,
 {
struct hclgevf_rss_config_cmd *req;
struct hclgevf_desc desc;
-   int key_offset;
+   int key_offset = 0;
+   int key_counts;
int key_size;
int ret;
 
+   key_counts = HCLGEVF_RSS_KEY_SIZE;
req = (struct hclgevf_rss_config_cmd *)desc.data;
 
-   for (key_offset = 0; key_offset < 3; key_offset++) {
+   while (key_counts) {
hclgevf_cmd_setup_basic_desc(,
 HCLGEVF_OPC_RSS_GENERIC_CONFIG,
 false);
@@ -554,15 +556,12 @@ static int hclgevf_set_rss_algo_key(struct hclgevf_dev 
*hdev,
req->hash_config |=
(key_offset << HCLGEVF_RSS_HASH_KEY_OFFSET_B);
 
-   if (key_offset == 2)
-   key_size =
-   HCLGEVF_RSS_KEY_SIZE - HCLGEVF_RSS_HASH_KEY_NUM * 2;
-   else
-   key_size = HCLGEVF_RSS_HASH_KEY_NUM;
-
+   key_size = min(HCLGEVF_RSS_HASH_KEY_NUM, key_counts);
memcpy(req->hash_key,
   key + key_offset * HCLGEVF_RSS_HASH_KEY_NUM, key_size);
 
+   key_counts -= key_size;
+   key_offset++;
ret = hclgevf_cmd_send(>hw, , 1);
if (ret) {
dev_err(>pdev->dev,
-- 
2.7.4



[PATCH V2 net-next 04/12] net: hns3: replace numa_node_id with numa_mem_id for buffer reusing

2019-06-06 Thread Huazhong Tan
From: Yunsheng Lin 

This patch replaces numa_node_id with numa_mem_id when doing buffer
reusing checking, because the buffer still can be reused when the
buffer is from the nearest node and the local node has no memory
attached.

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

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index c37509e..969d4c1 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2367,7 +2367,7 @@ static void hns3_nic_reuse_page(struct sk_buff *skb, int 
i,
/* Avoid re-using remote pages, or the stack is still using the page
 * when page_offset rollback to zero, flag default unreuse
 */
-   if (unlikely(page_to_nid(desc_cb->priv) != numa_node_id()) ||
+   if (unlikely(page_to_nid(desc_cb->priv) != numa_mem_id()) ||
(!desc_cb->page_offset && page_count(desc_cb->priv) > 1))
return;
 
@@ -2583,7 +2583,7 @@ static int hns3_alloc_skb(struct hns3_enet_ring *ring, 
int length,
memcpy(__skb_put(skb, length), va, ALIGN(length, sizeof(long)));
 
/* We can reuse buffer as-is, just make sure it is local */
-   if (likely(page_to_nid(desc_cb->priv) == numa_node_id()))
+   if (likely(page_to_nid(desc_cb->priv) == numa_mem_id()))
desc_cb->reuse_flag = 1;
else /* This page cannot be reused so discard it */
put_page(desc_cb->priv);
-- 
2.7.4



[PATCH V2 net-next 02/12] net: hns3: fix wrong size of mailbox responding data

2019-06-06 Thread Huazhong Tan
From: Zhongzhu Liu 

According to user manual, the maximum size of mailbox responding
data is 8 bytes, the macro HCLGE_MBX_MAX_RESP_DATA_SIZE
should be defined as 8 instead of 16.

Fixes: 9194d18b0577 ("net: hns3: fix the problem that the supported port is 
empty")
Signed-off-by: Zhongzhu Liu 
Signed-off-by: Peng Li 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h 
b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
index 83e19c6..8ad5292 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
@@ -69,7 +69,7 @@ enum hclge_mbx_vlan_cfg_subcode {
 };
 
 #define HCLGE_MBX_MAX_MSG_SIZE 16
-#define HCLGE_MBX_MAX_RESP_DATA_SIZE   16
+#define HCLGE_MBX_MAX_RESP_DATA_SIZE   8
 #define HCLGE_MBX_RING_MAP_BASIC_MSG_NUM   3
 #define HCLGE_MBX_RING_NODE_VARIABLE_NUM   3
 
-- 
2.7.4



[PATCH V2 net-next 07/12] net: hns3: delete the redundant user NIC codes

2019-06-06 Thread Huazhong Tan
From: Yonglong Liu 

Since HNAE3_CLIENT_UNIC and HNAE3_DEV_UNIC is not used any more,
this patch removes the redundant codes.

Signed-off-by: Yonglong Liu 
Signed-off-by: Peng Li 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.c| 21 -
 drivers/net/ethernet/hisilicon/hns3/hnae3.h|  7 -
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c|  1 -
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 34 --
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c  | 16 --
 5 files changed, 10 insertions(+), 69 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c 
b/drivers/net/ethernet/hisilicon/hns3/hnae3.c
index 738e013..0de3d6b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c
@@ -16,14 +16,10 @@ static LIST_HEAD(hnae3_ae_dev_list);
  */
 static DEFINE_MUTEX(hnae3_common_lock);
 
-static bool hnae3_client_match(enum hnae3_client_type client_type,
-  enum hnae3_dev_type dev_type)
+static bool hnae3_client_match(enum hnae3_client_type client_type)
 {
-   if ((dev_type == HNAE3_DEV_KNIC) && (client_type == HNAE3_CLIENT_KNIC ||
-client_type == HNAE3_CLIENT_ROCE))
-   return true;
-
-   if (dev_type == HNAE3_DEV_UNIC && client_type == HNAE3_CLIENT_UNIC)
+   if (client_type == HNAE3_CLIENT_KNIC ||
+   client_type == HNAE3_CLIENT_ROCE)
return true;
 
return false;
@@ -39,9 +35,6 @@ void hnae3_set_client_init_flag(struct hnae3_client *client,
case HNAE3_CLIENT_KNIC:
hnae3_set_bit(ae_dev->flag, HNAE3_KNIC_CLIENT_INITED_B, inited);
break;
-   case HNAE3_CLIENT_UNIC:
-   hnae3_set_bit(ae_dev->flag, HNAE3_UNIC_CLIENT_INITED_B, inited);
-   break;
case HNAE3_CLIENT_ROCE:
hnae3_set_bit(ae_dev->flag, HNAE3_ROCE_CLIENT_INITED_B, inited);
break;
@@ -61,10 +54,6 @@ static int hnae3_get_client_init_flag(struct hnae3_client 
*client,
inited = hnae3_get_bit(ae_dev->flag,
   HNAE3_KNIC_CLIENT_INITED_B);
break;
-   case HNAE3_CLIENT_UNIC:
-   inited = hnae3_get_bit(ae_dev->flag,
-  HNAE3_UNIC_CLIENT_INITED_B);
-   break;
case HNAE3_CLIENT_ROCE:
inited = hnae3_get_bit(ae_dev->flag,
   HNAE3_ROCE_CLIENT_INITED_B);
@@ -82,7 +71,7 @@ static int hnae3_init_client_instance(struct hnae3_client 
*client,
int ret;
 
/* check if this client matches the type of ae_dev */
-   if (!(hnae3_client_match(client->type, ae_dev->dev_type) &&
+   if (!(hnae3_client_match(client->type) &&
  hnae3_get_bit(ae_dev->flag, HNAE3_DEV_INITED_B))) {
return 0;
}
@@ -99,7 +88,7 @@ static void hnae3_uninit_client_instance(struct hnae3_client 
*client,
 struct hnae3_ae_dev *ae_dev)
 {
/* check if this client matches the type of ae_dev */
-   if (!(hnae3_client_match(client->type, ae_dev->dev_type) &&
+   if (!(hnae3_client_match(client->type) &&
  hnae3_get_bit(ae_dev->flag, HNAE3_DEV_INITED_B)))
return;
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h 
b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 2e478d9..63cdc18 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -102,15 +102,9 @@ enum hnae3_loop {
 
 enum hnae3_client_type {
HNAE3_CLIENT_KNIC,
-   HNAE3_CLIENT_UNIC,
HNAE3_CLIENT_ROCE,
 };
 
-enum hnae3_dev_type {
-   HNAE3_DEV_KNIC,
-   HNAE3_DEV_UNIC,
-};
-
 /* mac media type */
 enum hnae3_media_type {
HNAE3_MEDIA_TYPE_UNKNOWN,
@@ -220,7 +214,6 @@ struct hnae3_ae_dev {
struct list_head node;
u32 flag;
u8 override_pci_need_reset; /* fix to stop multiple reset happening */
-   enum hnae3_dev_type dev_type;
enum hnae3_reset_type reset_type;
void *priv;
 };
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 0ef4470..07e7c3a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1837,7 +1837,6 @@ static int hns3_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 
ae_dev->pdev = pdev;
ae_dev->flag = ent->driver_data;
-   ae_dev->dev_type = HNAE3_DEV_KNIC;
ae_dev->reset_type = HNAE3_NONE_RESET;
hns3_get_dev_capability(pdev, ae_dev);
pci_set_drvdata(pdev, ae_dev);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 35d2a45..9fe00a8 

[PATCH V2 net-next 01/12] net: hns3: log detail error info of ROCEE ECC and AXI errors

2019-06-06 Thread Huazhong Tan
From: Xiaofei Tan 

This patch logs detail error info of ROCEE ECC and AXI errors for
debug purpose, and remove unnecessary reset for ROCEE overflow
errors.

Signed-off-by: Xiaofei Tan 
Signed-off-by: Huazhong Tan 
---
V1->V2: fixes comments from David Miller
---
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h |  2 +
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c | 81 --
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_err.h |  1 +
 3 files changed, 77 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
index 61cb10d..5e6c749 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
@@ -268,6 +268,8 @@ enum hclge_opcode_type {
HCLGE_CONFIG_ROCEE_RAS_INT_EN   = 0x1580,
HCLGE_QUERY_CLEAR_ROCEE_RAS_INT = 0x1581,
HCLGE_ROCEE_PF_RAS_INT_CMD  = 0x1584,
+   HCLGE_QUERY_ROCEE_ECC_RAS_INFO_CMD  = 0x1585,
+   HCLGE_QUERY_ROCEE_AXI_RAS_INFO_CMD  = 0x1586,
HCLGE_IGU_EGU_TNL_INT_EN= 0x1803,
HCLGE_IGU_COMMON_INT_EN = 0x1806,
HCLGE_TM_QCN_MEM_INT_CFG= 0x1A14,
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
index 784512d..4f2af3d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
@@ -1388,6 +1388,66 @@ static int hclge_handle_all_ras_errors(struct hclge_dev 
*hdev)
return ret;
 }
 
+static int hclge_log_rocee_axi_error(struct hclge_dev *hdev)
+{
+   struct device *dev = >pdev->dev;
+   struct hclge_desc desc[3];
+   int ret;
+
+   hclge_cmd_setup_basic_desc([0], HCLGE_QUERY_ROCEE_AXI_RAS_INFO_CMD,
+  true);
+   hclge_cmd_setup_basic_desc([1], HCLGE_QUERY_ROCEE_AXI_RAS_INFO_CMD,
+  true);
+   hclge_cmd_setup_basic_desc([2], HCLGE_QUERY_ROCEE_AXI_RAS_INFO_CMD,
+  true);
+   desc[0].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT);
+   desc[1].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT);
+
+   ret = hclge_cmd_send(>hw, [0], 3);
+   if (ret) {
+   dev_err(dev, "failed(%d) to query ROCEE AXI error sts\n", ret);
+   return ret;
+   }
+
+   dev_info(dev, "AXI1: %08X %08X %08X %08X %08X %08X\n",
+le32_to_cpu(desc[0].data[0]), le32_to_cpu(desc[0].data[1]),
+le32_to_cpu(desc[0].data[2]), le32_to_cpu(desc[0].data[3]),
+le32_to_cpu(desc[0].data[4]), le32_to_cpu(desc[0].data[5]));
+   dev_info(dev, "AXI2: %08X %08X %08X %08X %08X %08X\n",
+le32_to_cpu(desc[1].data[0]), le32_to_cpu(desc[1].data[1]),
+le32_to_cpu(desc[1].data[2]), le32_to_cpu(desc[1].data[3]),
+le32_to_cpu(desc[1].data[4]), le32_to_cpu(desc[1].data[5]));
+   dev_info(dev, "AXI3: %08X %08X %08X %08X\n",
+le32_to_cpu(desc[2].data[0]), le32_to_cpu(desc[2].data[1]),
+le32_to_cpu(desc[2].data[2]), le32_to_cpu(desc[2].data[3]));
+
+   return 0;
+}
+
+static int hclge_log_rocee_ecc_error(struct hclge_dev *hdev)
+{
+   struct device *dev = >pdev->dev;
+   struct hclge_desc desc[2];
+   int ret;
+
+   ret = hclge_cmd_query_error(hdev, [0],
+   HCLGE_QUERY_ROCEE_ECC_RAS_INFO_CMD,
+   HCLGE_CMD_FLAG_NEXT, 0, 0);
+   if (ret) {
+   dev_err(dev, "failed(%d) to query ROCEE ECC error sts\n", ret);
+   return ret;
+   }
+
+   dev_info(dev, "ECC1: %08X %08X %08X %08X %08X %08X\n",
+le32_to_cpu(desc[0].data[0]), le32_to_cpu(desc[0].data[1]),
+le32_to_cpu(desc[0].data[2]), le32_to_cpu(desc[0].data[3]),
+le32_to_cpu(desc[0].data[4]), le32_to_cpu(desc[0].data[5]));
+   dev_info(dev, "ECC2: %08X %08X %08X\n", le32_to_cpu(desc[1].data[0]),
+le32_to_cpu(desc[1].data[1]), le32_to_cpu(desc[1].data[2]));
+
+   return 0;
+}
+
 static int hclge_log_rocee_ovf_error(struct hclge_dev *hdev)
 {
struct device *dev = >pdev->dev;
@@ -1456,19 +1516,27 @@ hclge_log_and_clear_rocee_ras_error(struct hclge_dev 
*hdev)
 
status = le32_to_cpu(desc[0].data[0]);
 
-   if (status & HCLGE_ROCEE_RERR_INT_MASK) {
-   dev_warn(dev, "ROCEE RAS AXI rresp error\n");
-   reset_type = HNAE3_FUNC_RESET;
-   }
+   if (status & HCLGE_ROCEE_AXI_ERR_INT_MASK) {
+   if (status & HCLGE_ROCEE_RERR_INT_MASK)
+   dev_warn(dev, "ROCEE RAS AXI rresp error\n");
+
+   if (status & HCLGE_ROCEE_BERR_INT_MASK)
+   dev_warn(dev, "ROCEE RAS AXI bresp error\n");
 
-   if (status & 

[PATCH V2 net-next 03/12] net: hns3: make HW GRO handling compliant with SW GRO

2019-06-06 Thread Huazhong Tan
From: Yunsheng Lin 

Currently when a GRO packet is assembled by HW, the checksum is
modified to reflect the entire packet by HW and skb->ip_summed is
set to CHECKSUM_UNNECESSARY, which is not compliant with SW GRO.

This patch sets up skb's network and transport header, sets the
GRO packet's checksum according to pseudo header and set the
skb->ip_summed to CHECKSUM_PARTIAL.

This patch also use gso_size to distinguish GRO packet from
normal packet, use eth_type_vlan to check the VLAN type and set
the SKB_GSO_TCP_FIXEDID according to BD info during HW GRO info
processing.

Signed-off-by: Yunsheng Lin 
Signed-off-by: Peng Li 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 44 +
 1 file changed, 30 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 0501b78..c37509e 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2384,13 +2385,13 @@ static void hns3_nic_reuse_page(struct sk_buff *skb, 
int i,
}
 }
 
-static int hns3_gro_complete(struct sk_buff *skb)
+static int hns3_gro_complete(struct sk_buff *skb, u32 l234info)
 {
__be16 type = skb->protocol;
struct tcphdr *th;
int depth = 0;
 
-   while (type == htons(ETH_P_8021Q)) {
+   while (eth_type_vlan(type)) {
struct vlan_hdr *vh;
 
if ((depth + VLAN_HLEN) > skb_headlen(skb))
@@ -2401,10 +2402,24 @@ static int hns3_gro_complete(struct sk_buff *skb)
depth += VLAN_HLEN;
}
 
+   skb_set_network_header(skb, depth);
+
if (type == htons(ETH_P_IP)) {
+   const struct iphdr *iph = ip_hdr(skb);
+
depth += sizeof(struct iphdr);
+   skb_set_transport_header(skb, depth);
+   th = tcp_hdr(skb);
+   th->check = ~tcp_v4_check(skb->len - depth, iph->saddr,
+ iph->daddr, 0);
} else if (type == htons(ETH_P_IPV6)) {
+   const struct ipv6hdr *iph = ipv6_hdr(skb);
+
depth += sizeof(struct ipv6hdr);
+   skb_set_transport_header(skb, depth);
+   th = tcp_hdr(skb);
+   th->check = ~tcp_v6_check(skb->len - depth, >saddr,
+ >daddr, 0);
} else {
netdev_err(skb->dev,
   "Error: FW GRO supports only IPv4/IPv6, not 0x%04x, 
depth: %d\n",
@@ -2412,13 +2427,16 @@ static int hns3_gro_complete(struct sk_buff *skb)
return -EFAULT;
}
 
-   th = (struct tcphdr *)(skb->data + depth);
skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
if (th->cwr)
skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;
 
-   skb->ip_summed = CHECKSUM_UNNECESSARY;
+   if (l234info & BIT(HNS3_RXD_GRO_FIXID_B))
+   skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_FIXEDID;
 
+   skb->csum_start = (unsigned char *)th - skb->head;
+   skb->csum_offset = offsetof(struct tcphdr, check);
+   skb->ip_summed = CHECKSUM_PARTIAL;
return 0;
 }
 
@@ -2656,18 +2674,20 @@ static int hns3_set_gro_and_checksum(struct 
hns3_enet_ring *ring,
 struct sk_buff *skb, u32 l234info,
 u32 bd_base_info, u32 ol_info)
 {
-   u16 gro_count;
u32 l3_type;
 
-   gro_count = hnae3_get_field(l234info, HNS3_RXD_GRO_COUNT_M,
-   HNS3_RXD_GRO_COUNT_S);
+   skb_shinfo(skb)->gso_size = hnae3_get_field(bd_base_info,
+   HNS3_RXD_GRO_SIZE_M,
+   HNS3_RXD_GRO_SIZE_S);
/* if there is no HW GRO, do not set gro params */
-   if (!gro_count) {
+   if (!skb_shinfo(skb)->gso_size) {
hns3_rx_checksum(ring, skb, l234info, bd_base_info, ol_info);
return 0;
}
 
-   NAPI_GRO_CB(skb)->count = gro_count;
+   NAPI_GRO_CB(skb)->count = hnae3_get_field(l234info,
+ HNS3_RXD_GRO_COUNT_M,
+ HNS3_RXD_GRO_COUNT_S);
 
l3_type = hnae3_get_field(l234info, HNS3_RXD_L3ID_M,
  HNS3_RXD_L3ID_S);
@@ -2678,11 +2698,7 @@ static int hns3_set_gro_and_checksum(struct 
hns3_enet_ring *ring,
else
return -EFAULT;
 
-   skb_shinfo(skb)->gso_size = hnae3_get_field(bd_base_info,
-   HNS3_RXD_GRO_SIZE_M,
-   HNS3_RXD_GRO_SIZE_S);
-
-   return  hns3_gro_complete(skb);
+   return  

[PATCH V2 net-next 06/12] net: hns3: trigger VF reset if a VF has an over_8bd_nfe_err

2019-06-06 Thread Huazhong Tan
From: Weihang Li 

We trigger PF reset when a RAS error of NIC named over_8bd_nfe_err
occurred before. But it is possible that a VF causes that error, it's
reasonable to trigger VF reset instead of PF reset in this case.
This patch add detection of vf_id if a over_8bd_nfe_err occurs, if
vf_id is 0, we trigger PF reset. Otherwise, we will trigger VF reset
on the VF with error.

Signed-off-by: Weihang Li 
Signed-off-by: Peng Li 
Signed-off-by: Huazhong Tan 
---
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 17 +
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c | 79 ++
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_err.h |  3 +-
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c |  2 +-
 4 files changed, 99 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
index 5e6c749..7d78b5a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
@@ -180,6 +180,9 @@ enum hclge_opcode_type {
HCLGE_OPC_CFG_COM_TQP_QUEUE = 0x0B20,
HCLGE_OPC_RESET_TQP_QUEUE   = 0x0B22,
 
+   /* PPU commands */
+   HCLGE_OPC_PPU_PF_OTHER_INT_DFX  = 0x0B4A,
+
/* TSO command */
HCLGE_OPC_TSO_GENERIC_CONFIG= 0x0C01,
HCLGE_OPC_GRO_GENERIC_CONFIG= 0x0C10,
@@ -980,6 +983,20 @@ struct hclge_get_m7_bd_cmd {
u8 rsv[20];
 };
 
+struct hclge_query_ppu_pf_other_int_dfx_cmd {
+   __le16 over_8bd_no_fe_qid;
+   __le16 over_8bd_no_fe_vf_id;
+   __le16 tso_mss_cmp_min_err_qid;
+   __le16 tso_mss_cmp_min_err_vf_id;
+   __le16 tso_mss_cmp_max_err_qid;
+   __le16 tso_mss_cmp_max_err_vf_id;
+   __le16 tx_rd_fbd_poison_qid;
+   __le16 tx_rd_fbd_poison_vf_id;
+   __le16 rx_rd_fbd_poison_qid;
+   __le16 rx_rd_fbd_poison_vf_id;
+   u8 rsv[4];
+};
+
 int hclge_cmd_init(struct hclge_dev *hdev);
 static inline void hclge_write_reg(void __iomem *base, u32 reg, u32 value)
 {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
index 4f2af3d..cb6ed8c 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c
@@ -1687,6 +1687,81 @@ pci_ers_result_t hclge_handle_hw_ras_error(struct 
hnae3_ae_dev *ae_dev)
return PCI_ERS_RESULT_RECOVERED;
 }
 
+/* hclge_query_8bd_info: query information about over_8bd_nfe_err
+ * @hdev: pointer to struct hclge_dev
+ * @vf_id: Index of the virtual function with error
+ * @q_id: Physical index of the queue with error
+ *
+ * This function get specific index of queue and function which causes
+ * over_8bd_nfe_err by using command. If vf_id is 0, it means error is
+ * caused by PF instead of VF.
+ */
+static int hclge_query_over_8bd_err_info(struct hclge_dev *hdev, u16 *vf_id,
+u16 *q_id)
+{
+   struct hclge_query_ppu_pf_other_int_dfx_cmd *req;
+   struct hclge_desc desc;
+   int ret;
+
+   hclge_cmd_setup_basic_desc(, HCLGE_OPC_PPU_PF_OTHER_INT_DFX, true);
+   ret = hclge_cmd_send(>hw, , 1);
+   if (ret)
+   return ret;
+
+   req = (struct hclge_query_ppu_pf_other_int_dfx_cmd *)desc.data;
+   *vf_id = le16_to_cpu(req->over_8bd_no_fe_vf_id);
+   *q_id = le16_to_cpu(req->over_8bd_no_fe_qid);
+
+   return 0;
+}
+
+/* hclge_handle_over_8bd_err: handle MSI-X error named over_8bd_nfe_err
+ * @hdev: pointer to struct hclge_dev
+ * @reset_requests: reset level that we need to trigger later
+ *
+ * over_8bd_nfe_err is a special MSI-X because it may caused by a VF, in
+ * that case, we need to trigger VF reset. Otherwise, a PF reset is needed.
+ */
+static void hclge_handle_over_8bd_err(struct hclge_dev *hdev,
+ unsigned long *reset_requests)
+{
+   struct device *dev = >pdev->dev;
+   u16 vf_id;
+   u16 q_id;
+   int ret;
+
+   ret = hclge_query_over_8bd_err_info(hdev, _id, _id);
+   if (ret) {
+   dev_err(dev, "fail(%d) to query over_8bd_no_fe info\n",
+   ret);
+   return;
+   }
+
+   dev_warn(dev, "PPU_PF_ABNORMAL_INT_ST over_8bd_no_fe found, vf_id(%d), 
queue_id(%d)\n",
+vf_id, q_id);
+
+   if (vf_id) {
+   if (vf_id >= hdev->num_alloc_vport) {
+   dev_err(dev, "invalid vf id(%d)\n", vf_id);
+   return;
+   }
+
+   /* If we need to trigger other reset whose level is higher
+* than HNAE3_VF_FUNC_RESET, no need to trigger a VF reset
+* here.
+*/
+   if (*reset_requests != 0)
+   return;
+
+   ret = hclge_inform_reset_assert_to_vf(>vport[vf_id]);
+   if (ret)
+   

[PATCH V2 net-next 05/12] net: hns3: refactor hns3_get_new_int_gl function

2019-06-06 Thread Huazhong Tan
From: Yunsheng Lin 

This patch adds a new hns3_get_new_flow_lvl function to calculate
the packet flow level, which is used to decide the interrupt
coalescence parameter, in order to make the flow level calculation
code more readable and make the future calculation ajdustment easier.

Signed-off-by: Yunsheng Lin 
Signed-off-by: Peng Li 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 77 +++--
 1 file changed, 45 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 969d4c1..0ef4470 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2938,36 +2938,20 @@ int hns3_clean_rx_ring(
return recv_pkts;
 }
 
-static bool hns3_get_new_int_gl(struct hns3_enet_ring_group *ring_group)
+static bool hns3_get_new_flow_lvl(struct hns3_enet_ring_group *ring_group)
 {
-   struct hns3_enet_tqp_vector *tqp_vector =
-   ring_group->ring->tqp_vector;
+#define HNS3_RX_LOW_BYTE_RATE 1
+#define HNS3_RX_MID_BYTE_RATE 2
+#define HNS3_RX_ULTRA_PACKET_RATE 40
+
enum hns3_flow_level_range new_flow_level;
-   int packets_per_msecs;
-   int bytes_per_msecs;
+   struct hns3_enet_tqp_vector *tqp_vector;
+   int packets_per_msecs, bytes_per_msecs;
u32 time_passed_ms;
-   u16 new_int_gl;
-
-   if (!tqp_vector->last_jiffies)
-   return false;
-
-   if (ring_group->total_packets == 0) {
-   ring_group->coal.int_gl = HNS3_INT_GL_50K;
-   ring_group->coal.flow_level = HNS3_FLOW_LOW;
-   return true;
-   }
 
-   /* Simple throttlerate management
-* 0-10MB/s   lower (5 ints/s)
-* 10-20MB/s   middle(2 ints/s)
-* 20-1249MB/s high  (18000 ints/s)
-* > 4pps  ultra (8000 ints/s)
-*/
-   new_flow_level = ring_group->coal.flow_level;
-   new_int_gl = ring_group->coal.int_gl;
+   tqp_vector = ring_group->ring->tqp_vector;
time_passed_ms =
jiffies_to_msecs(jiffies - tqp_vector->last_jiffies);
-
if (!time_passed_ms)
return false;
 
@@ -2977,9 +2961,14 @@ static bool hns3_get_new_int_gl(struct 
hns3_enet_ring_group *ring_group)
do_div(ring_group->total_bytes, time_passed_ms);
bytes_per_msecs = ring_group->total_bytes;
 
-#define HNS3_RX_LOW_BYTE_RATE 1
-#define HNS3_RX_MID_BYTE_RATE 2
+   new_flow_level = ring_group->coal.flow_level;
 
+   /* Simple throttlerate management
+* 0-10MB/s   lower (5 ints/s)
+* 10-20MB/s   middle(2 ints/s)
+* 20-1249MB/s high  (18000 ints/s)
+* > 4pps  ultra (8000 ints/s)
+*/
switch (new_flow_level) {
case HNS3_FLOW_LOW:
if (bytes_per_msecs > HNS3_RX_LOW_BYTE_RATE)
@@ -2999,13 +2988,40 @@ static bool hns3_get_new_int_gl(struct 
hns3_enet_ring_group *ring_group)
break;
}
 
-#define HNS3_RX_ULTRA_PACKET_RATE 40
-
if (packets_per_msecs > HNS3_RX_ULTRA_PACKET_RATE &&
_vector->rx_group == ring_group)
new_flow_level = HNS3_FLOW_ULTRA;
 
-   switch (new_flow_level) {
+   ring_group->total_bytes = 0;
+   ring_group->total_packets = 0;
+   ring_group->coal.flow_level = new_flow_level;
+
+   return true;
+}
+
+static bool hns3_get_new_int_gl(struct hns3_enet_ring_group *ring_group)
+{
+   struct hns3_enet_tqp_vector *tqp_vector;
+   u16 new_int_gl;
+
+   if (!ring_group->ring)
+   return false;
+
+   tqp_vector = ring_group->ring->tqp_vector;
+   if (!tqp_vector->last_jiffies)
+   return false;
+
+   if (ring_group->total_packets == 0) {
+   ring_group->coal.int_gl = HNS3_INT_GL_50K;
+   ring_group->coal.flow_level = HNS3_FLOW_LOW;
+   return true;
+   }
+
+   if (!hns3_get_new_flow_lvl(ring_group))
+   return false;
+
+   new_int_gl = ring_group->coal.int_gl;
+   switch (ring_group->coal.flow_level) {
case HNS3_FLOW_LOW:
new_int_gl = HNS3_INT_GL_50K;
break;
@@ -3022,9 +3038,6 @@ static bool hns3_get_new_int_gl(struct 
hns3_enet_ring_group *ring_group)
break;
}
 
-   ring_group->total_bytes = 0;
-   ring_group->total_packets = 0;
-   ring_group->coal.flow_level = new_flow_level;
if (new_int_gl != ring_group->coal.int_gl) {
ring_group->coal.int_gl = new_int_gl;
return true;
-- 
2.7.4



[PATCH V2 net-next 11/12] net: hns3: some modifications to simplify and optimize code

2019-06-06 Thread Huazhong Tan
From: Yufeng Mo 

This patch deletes some redundant code and refactors some bloated
functions.

Signed-off-by: Yufeng Mo 
Signed-off-by: Weihang Li 
Signed-off-by: Yonglong Liu 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 32 +++
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 82 +++---
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c |  2 +-
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c  | 99 --
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c  | 25 +++---
 5 files changed, 130 insertions(+), 110 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 22526ba..49b4072 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -436,7 +436,7 @@ static void hns3_get_strings(struct net_device *netdev, u32 
stringset, u8 *data)
switch (stringset) {
case ETH_SS_STATS:
buff = hns3_get_strings_tqps(h, buff);
-   h->ae_algo->ops->get_strings(h, stringset, (u8 *)buff);
+   ops->get_strings(h, stringset, (u8 *)buff);
break;
case ETH_SS_TEST:
ops->get_strings(h, stringset, data);
@@ -511,6 +511,11 @@ static void hns3_get_drvinfo(struct net_device *netdev,
struct hns3_nic_priv *priv = netdev_priv(netdev);
struct hnae3_handle *h = priv->ae_handle;
 
+   if (!h->ae_algo->ops->get_fw_version) {
+   netdev_err(netdev, "could not get fw version!\n");
+   return;
+   }
+
strncpy(drvinfo->version, hns3_driver_version,
sizeof(drvinfo->version));
drvinfo->version[sizeof(drvinfo->version) - 1] = '\0';
@@ -531,7 +536,7 @@ static u32 hns3_get_link(struct net_device *netdev)
 {
struct hnae3_handle *h = hns3_get_handle(netdev);
 
-   if (h->ae_algo && h->ae_algo->ops && h->ae_algo->ops->get_status)
+   if (h->ae_algo->ops->get_status)
return h->ae_algo->ops->get_status(h);
else
return 0;
@@ -561,7 +566,7 @@ static void hns3_get_pauseparam(struct net_device *netdev,
 {
struct hnae3_handle *h = hns3_get_handle(netdev);
 
-   if (h->ae_algo && h->ae_algo->ops && h->ae_algo->ops->get_pauseparam)
+   if (h->ae_algo->ops->get_pauseparam)
h->ae_algo->ops->get_pauseparam(h, >autoneg,
>rx_pause, >tx_pause);
 }
@@ -611,9 +616,6 @@ static int hns3_get_link_ksettings(struct net_device 
*netdev,
u8 media_type;
u8 link_stat;
 
-   if (!h->ae_algo || !h->ae_algo->ops)
-   return -EOPNOTSUPP;
-
ops = h->ae_algo->ops;
if (ops->get_media_type)
ops->get_media_type(h, _type, _type);
@@ -741,8 +743,7 @@ static u32 hns3_get_rss_key_size(struct net_device *netdev)
 {
struct hnae3_handle *h = hns3_get_handle(netdev);
 
-   if (!h->ae_algo || !h->ae_algo->ops ||
-   !h->ae_algo->ops->get_rss_key_size)
+   if (!h->ae_algo->ops->get_rss_key_size)
return 0;
 
return h->ae_algo->ops->get_rss_key_size(h);
@@ -752,8 +753,7 @@ static u32 hns3_get_rss_indir_size(struct net_device 
*netdev)
 {
struct hnae3_handle *h = hns3_get_handle(netdev);
 
-   if (!h->ae_algo || !h->ae_algo->ops ||
-   !h->ae_algo->ops->get_rss_indir_size)
+   if (!h->ae_algo->ops->get_rss_indir_size)
return 0;
 
return h->ae_algo->ops->get_rss_indir_size(h);
@@ -764,7 +764,7 @@ static int hns3_get_rss(struct net_device *netdev, u32 
*indir, u8 *key,
 {
struct hnae3_handle *h = hns3_get_handle(netdev);
 
-   if (!h->ae_algo || !h->ae_algo->ops || !h->ae_algo->ops->get_rss)
+   if (!h->ae_algo->ops->get_rss)
return -EOPNOTSUPP;
 
return h->ae_algo->ops->get_rss(h, indir, key, hfunc);
@@ -775,7 +775,7 @@ static int hns3_set_rss(struct net_device *netdev, const 
u32 *indir,
 {
struct hnae3_handle *h = hns3_get_handle(netdev);
 
-   if (!h->ae_algo || !h->ae_algo->ops || !h->ae_algo->ops->set_rss)
+   if (!h->ae_algo->ops->set_rss)
return -EOPNOTSUPP;
 
if ((h->pdev->revision == 0x20 &&
@@ -800,9 +800,6 @@ static int hns3_get_rxnfc(struct net_device *netdev,
 {
struct hnae3_handle *h = hns3_get_handle(netdev);
 
-   if (!h->ae_algo || !h->ae_algo->ops)
-   return -EOPNOTSUPP;
-
switch (cmd->cmd) {
case ETHTOOL_GRXRINGS:
cmd->data = h->kinfo.num_tqps;
@@ -916,9 +913,6 @@ static int hns3_set_rxnfc(struct net_device *netdev, struct 
ethtool_rxnfc *cmd)
 {
struct hnae3_handle *h = hns3_get_handle(netdev);
 
-   if (!h->ae_algo || !h->ae_algo->ops)
-   return -EOPNOTSUPP;
-
switch (cmd->cmd) {
case ETHTOOL_SRXFH:
if 

[PATCH V2 net-next 12/12] net: hns3: fix some coding style issues

2019-06-06 Thread Huazhong Tan
From: Weihang Li 

This patch fixes some coding style issues reported by some static code
analysis tools and code review, such as modify some comments, rename
some variables, log some errors in detail, and fixes some alignment
errors.

BTW, these cleanups do not change the logic of code.

Signed-off-by: Weihang Li 
Signed-off-by: Peng Li 
Signed-off-by: Yonglong Liu 
Signed-off-by: HuiSong Li 
Signed-off-by: Jian Shen 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c   | 12 ++--
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c| 73 +-
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c |  6 ++
 .../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 10 +--
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c | 15 +++--
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 70 -
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c  | 22 ---
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c  | 18 ++
 8 files changed, 96 insertions(+), 130 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c
index b6fabbb..d2ec4c5 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c
@@ -4,8 +4,7 @@
 #include "hnae3.h"
 #include "hns3_enet.h"
 
-static
-int hns3_dcbnl_ieee_getets(struct net_device *ndev, struct ieee_ets *ets)
+static int hns3_dcbnl_ieee_getets(struct net_device *ndev, struct ieee_ets 
*ets)
 {
struct hnae3_handle *h = hns3_get_handle(ndev);
 
@@ -18,8 +17,7 @@ int hns3_dcbnl_ieee_getets(struct net_device *ndev, struct 
ieee_ets *ets)
return -EOPNOTSUPP;
 }
 
-static
-int hns3_dcbnl_ieee_setets(struct net_device *ndev, struct ieee_ets *ets)
+static int hns3_dcbnl_ieee_setets(struct net_device *ndev, struct ieee_ets 
*ets)
 {
struct hnae3_handle *h = hns3_get_handle(ndev);
 
@@ -32,8 +30,7 @@ int hns3_dcbnl_ieee_setets(struct net_device *ndev, struct 
ieee_ets *ets)
return -EOPNOTSUPP;
 }
 
-static
-int hns3_dcbnl_ieee_getpfc(struct net_device *ndev, struct ieee_pfc *pfc)
+static int hns3_dcbnl_ieee_getpfc(struct net_device *ndev, struct ieee_pfc 
*pfc)
 {
struct hnae3_handle *h = hns3_get_handle(ndev);
 
@@ -46,8 +43,7 @@ int hns3_dcbnl_ieee_getpfc(struct net_device *ndev, struct 
ieee_pfc *pfc)
return -EOPNOTSUPP;
 }
 
-static
-int hns3_dcbnl_ieee_setpfc(struct net_device *ndev, struct ieee_pfc *pfc)
+static int hns3_dcbnl_ieee_setpfc(struct net_device *ndev, struct ieee_pfc 
*pfc)
 {
struct hnae3_handle *h = hns3_get_handle(ndev);
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 07e7c3a..fe2c2c5 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -139,8 +139,7 @@ static int hns3_nic_init_irq(struct hns3_nic_priv *priv)
tqp_vectors->name[HNAE3_INT_NAME_LEN - 1] = '\0';
 
ret = request_irq(tqp_vectors->vector_irq, hns3_irq_handle, 0,
- tqp_vectors->name,
-  tqp_vectors);
+ tqp_vectors->name, tqp_vectors);
if (ret) {
netdev_err(priv->netdev, "request irq(%d) fail\n",
   tqp_vectors->vector_irq);
@@ -277,8 +276,7 @@ static int hns3_nic_set_real_num_queue(struct net_device 
*netdev)
ret = netif_set_real_num_tx_queues(netdev, queue_size);
if (ret) {
netdev_err(netdev,
-  "netif_set_real_num_tx_queues fail, ret=%d!\n",
-  ret);
+  "netif_set_real_num_tx_queues fail, ret=%d!\n", ret);
return ret;
}
 
@@ -373,7 +371,7 @@ static int hns3_nic_net_up(struct net_device *netdev)
/* get irq resource for all vectors */
ret = hns3_nic_init_irq(priv);
if (ret) {
-   netdev_err(netdev, "hns init irq failed! ret=%d\n", ret);
+   netdev_err(netdev, "init irq failed! ret=%d\n", ret);
goto free_rmap;
}
 
@@ -449,16 +447,13 @@ static int hns3_nic_net_open(struct net_device *netdev)
 
ret = hns3_nic_net_up(netdev);
if (ret) {
-   netdev_err(netdev,
-  "hns net up fail, ret=%d!\n", ret);
+   netdev_err(netdev, "net up fail, ret=%d!\n", ret);
return ret;
}
 
kinfo = >kinfo;
-   for (i = 0; i < HNAE3_MAX_USER_PRIO; i++) {
-   netdev_set_prio_tc_map(netdev, i,
-  kinfo->prio_tc[i]);
-   }
+   for (i = 0; i < HNAE3_MAX_USER_PRIO; i++)
+   netdev_set_prio_tc_map(netdev, i, kinfo->prio_tc[i]);
 
if (h->ae_algo->ops->set_timer_task)

[PATCH V2 net-next 00/12] net: hns3: some code optimizations & cleanups & bugfixes

2019-06-06 Thread Huazhong Tan
This patch-set includes code optimizations, cleanups and bugfixes for
the HNS3 ethernet controller driver.

[patch 1/12] logs more detail error info for ROCE RAS errors.

[patch 2/12] fixes a wrong size issue for mailbox responding.

[patch 3/12] makes HW GRO handing compliant with SW one.

[patch 4/12] refactors hns3_get_new_int_gl.

[patch 5/12] adds handling for VF's over_8bd_nfe_err.

[patch 6/12 - 12/12] adds some code optimizations and cleanups, to
make the code more readable and compliant with some static code
analysis tools, these modifications do not change the logic of
the code.

Change log:
V1->V2: fixes comment from David Miller.

Jian Shen (1):
  net: hns3: small changes for magic numbers

Weihang Li (2):
  net: hns3: trigger VF reset if a VF has an over_8bd_nfe_err
  net: hns3: fix some coding style issues

Xiaofei Tan (1):
  net: hns3: log detail error info of ROCEE ECC and AXI errors

Yonglong Liu (1):
  net: hns3: delete the redundant user NIC codes

Yufeng Mo (3):
  net: hns3: use macros instead of magic numbers
  net: hns3: refactor PF/VF RSS hash key configuration
  net: hns3: some modifications to simplify and optimize code

Yunsheng Lin (3):
  net: hns3: make HW GRO handling compliant with SW GRO
  net: hns3: replace numa_node_id with numa_mem_id for buffer reusing
  net: hns3: refactor hns3_get_new_int_gl function

Zhongzhu Liu (1):
  net: hns3: fix wrong size of mailbox responding data

 drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h|   2 +-
 drivers/net/ethernet/hisilicon/hns3/hnae3.c|  21 +-
 drivers/net/ethernet/hisilicon/hns3/hnae3.h|   7 -
 drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c   |  12 +-
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c| 199 ++-
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c |  43 +--
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h |  24 ++
 .../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c |  20 +-
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c | 175 +-
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_err.h |   4 +-
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 372 ++---
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h|  26 +-
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c |   4 +-
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c  | 141 
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c  |  85 ++---
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h  |   3 +
 16 files changed, 658 insertions(+), 480 deletions(-)

-- 
2.7.4



[PATCH V2 net-next 09/12] net: hns3: use macros instead of magic numbers

2019-06-06 Thread Huazhong Tan
From: Yufeng Mo 

This patch adds some macros instead of magic numbers in serval places

Signed-off-by: Yufeng Mo 
Signed-off-by: Weihang Li 
Signed-off-by: Yunsheng Lin 
Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c |  5 +-
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h |  5 ++
 .../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 10 ++--
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 53 ++
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h|  2 +
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c  | 20 +---
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c  | 11 +++--
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h  |  3 ++
 8 files changed, 75 insertions(+), 34 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index d1588ea..22526ba 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -60,6 +60,7 @@ static const struct hns3_stats hns3_rxq_stats[] = {
 #define HNS3_NIC_LB_TEST_PKT_NUM   1
 #define HNS3_NIC_LB_TEST_RING_ID   0
 #define HNS3_NIC_LB_TEST_PACKET_SIZE   128
+#define HNS3_NIC_LB_SETUP_USEC 1
 
 /* Nic loopback test err  */
 #define HNS3_NIC_LB_TEST_NO_MEM_ERR1
@@ -117,7 +118,7 @@ static int hns3_lp_up(struct net_device *ndev, enum 
hnae3_loop loop_mode)
return ret;
 
ret = hns3_lp_setup(ndev, loop_mode, true);
-   usleep_range(1, 2);
+   usleep_range(HNS3_NIC_LB_SETUP_USEC, HNS3_NIC_LB_SETUP_USEC * 2);
 
return ret;
 }
@@ -132,7 +133,7 @@ static int hns3_lp_down(struct net_device *ndev, enum 
hnae3_loop loop_mode)
return ret;
}
 
-   usleep_range(1, 2);
+   usleep_range(HNS3_NIC_LB_SETUP_USEC, HNS3_NIC_LB_SETUP_USEC * 2);
 
return 0;
 }
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
index 7d78b5a..c9fd730 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
@@ -649,6 +649,11 @@ enum hclge_mac_vlan_tbl_opcode {
HCLGE_MAC_VLAN_LKUP,/* Lookup a entry through mac_vlan key */
 };
 
+enum hclge_mac_vlan_add_resp_code {
+   HCLGE_ADD_UC_OVERFLOW = 2,  /* ADD failed for UC overflow */
+   HCLGE_ADD_MC_OVERFLOW,  /* ADD failed for MC overflow */
+};
+
 #define HCLGE_MAC_VLAN_BIT0_EN_B   0
 #define HCLGE_MAC_VLAN_BIT1_EN_B   1
 #define HCLGE_MAC_EPORT_SW_EN_B12
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
index e1007d9..c2844e1 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
@@ -64,6 +64,8 @@ static void hclge_dbg_dump_reg_common(struct hclge_dev *hdev,
  char *cmd_buf, int msg_num, int offset,
  enum hclge_opcode_type cmd)
 {
+#define BD_DATA_NUM   6
+
struct hclge_desc *desc_src;
struct hclge_desc *desc;
int bd_num, buf_len;
@@ -92,14 +94,16 @@ static void hclge_dbg_dump_reg_common(struct hclge_dev 
*hdev,
return;
}
 
-   max = (bd_num * 6) <= msg_num ? (bd_num * 6) : msg_num;
+   max = (bd_num * BD_DATA_NUM) <= msg_num ?
+   (bd_num * BD_DATA_NUM) : msg_num;
 
desc = desc_src;
for (i = 0; i < max; i++) {
-   (((i / 6) > 0) && ((i % 6) == 0)) ? desc++ : desc;
+   ((i > 0) && ((i % BD_DATA_NUM) == 0)) ? desc++ : desc;
if (dfx_message->flag)
dev_info(>pdev->dev, "%s: 0x%x\n",
-dfx_message->message, desc->data[i % 6]);
+dfx_message->message,
+desc->data[i % BD_DATA_NUM]);
 
dfx_message++;
}
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 36a92a1..755cc43 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -28,6 +28,8 @@
 #define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f))
 
 #define HCLGE_BUF_SIZE_UNIT256
+#define HCLGE_BUF_MUL_BY   2
+#define HCLGE_BUF_DIV_BY   2
 
 static int hclge_set_mac_mtu(struct hclge_dev *hdev, int new_mps);
 static int hclge_init_vlan_config(struct hclge_dev *hdev);
@@ -728,6 +730,8 @@ static int hclge_parse_func_status(struct hclge_dev *hdev,
 
 static int hclge_query_function_status(struct hclge_dev *hdev)
 {
+#define HCLGE_QUERY_MAX_CNT5
+
struct hclge_func_status_cmd *req;
struct hclge_desc 

Re: Oase Fair Streams O-S: The Philosophy Behind - To Those It May Concern

2019-06-06 Thread Ywe Cærlyn
That linked moved: https://www.youtube.com/watch?v=siIbXbanIMw

So indeed that should be a good OS, and Linus probably is a paedophile to be 
honest.

So get that shit out of your ears and do this.

Sent with ProtonMail Secure Email.

‐‐‐ Original Message ‐‐‐
On Monday 3. June 2019 kl. 17:02, Ywe Cærlyn  wrote:

> Came across this aswell: Krokodil Psychosis seems to be a proper name of 
> Stallmanic dances, LSD speeches, one-line religion, and all this a "god". 
> https://www.youtube.com/watch?v=AlpiNsyO7pg Enjoy!
>
> Sent with ProtonMail Secure Email.
>
> ‐‐‐ Original Message ‐‐‐
> On Sunday 2. June 2019 kl. 15:57, Ywe Cærlyn ywe...@protonmail.com wrote:
>
> > I think I´ve said most things about what I am doing to LKML now.
> > A correctly experienced will know much about his system and the design will 
> > not go much from original idea.
> > Which is what we see with Unix. I think this was the point of its original 
> > developers aswell, and a commentary on corporate mismanagement being "Plan 
> > 9 from Outer Space".
> > And Irix was an early desktop version, that influenced extremely popular 
> > computers like CBM, and one may want to go somewhere between, aiming for a 
> > replacement of the CBM LSD-god, that also was its demise, which we ofcourse 
> > still see in difficult persons like Richard Stallman, who claimed the 
> > Available Source of Unix, was his invention, and started his own project 
> > "GNU Is Not Unix", dancing lsd-god dances, and iterating one-line 
> > pseudo-religion. Psychosis ofcourse really is this, prolonged use of 
> > narcotics, such as Amanita, Opiates, or other hallucinatory drugs, and even 
> > worse claim it is a religious god! So not surprisingly "Psychosis". Also 
> > known as "The Difficult Wino Problem". Psychiatry cannot reform such 
> > persons though, and it is vanity to think so. Rather the punishments of 
> > Islam, seems more appropriate, where false gods is the capital crime.
> > And why the now little succesful Linux, compared to the original Unix 
> > derivative BSD as now used in MacOS for quite a while. Why not just take 
> > BSD further, and the original Unix source, instead of being with the "Linux 
> > zealots", with discussed behavioural problems - the KNU (Krazy GNU User). I 
> > am sure any experienced person here easily could apply his patching on BSD 
> > aswell, coming to more fruitition here, and Mac OS. And such solve any 
> > forthcoming debate, after the Stallmanic fog, when it lifts ofcourse his 
> > dances and "GNU Is Not Unix" nonsense and claims of having something to do 
> > with Available Source would seem problematic.
> > With his claims of "hackership", and being a "programmer", questionable 
> > since he claimed this for a very long time but never managed to make a 
> > kernel himself. The original hackers on Bell Labs, did ofcourse make the 
> > original Unix kernel also, and he is clearly not a "hacker" in this sense. 
> > And "his" compiler, have options like "wait for pop" on, even though 
> > "ricer" (unecessary optimization options) have been discussed with 
> > supposedly concluding that such things are not necessary. With the "GNU" 
> > brainwashed putting 10ms timers into sched.c, for measuring CPU use, when 
> > at 10ms point, most in the computer has already happened! And Linus 
> > suggests 1000hz timer, when I myself find 90hz timer to be optimal, more 
> > like modest BSD settings. Hacker really referring the hacking sound of a 
> > typewriter, rather than any maniac GNU LSD version. To not speak of the 
> > horrible pointer variables in LADSPA. Did Linux even come much beyond 
> > Soundblaster mindset of the early 90s? Here the BSD based Mac OS, has 
> > modern hardware and Logic Audio - a fully professional platform used by 
> > actual artists, rather than "noisebient artists" in Linux crowds.
> > And to be honest, on the windows side things are still the same, it has 
> > similar problems as it had since Windows 95, and never really got good did 
> > it. It even still does not have proper priorities of threads! And the 
> > multimedia crowd always found it to be obscure. Here ofcourse also vanity 
> > in claiming a different design than the original Unix, that already did 
> > design the groundwork for modern OS's. A good thing is ofcourse Microsoft 
> > in these days, opening up to more of Unix.
> > As indeed Mac did. Running in 4K, with Itunes and Mini formfactor. If 
> > everyone goes well with Mac, one might aswell just do the Mac thing, with 
> > Logic Audio and all. Maybe they would make OS-X Oasis? We are there if it 
> > slows down and becomes Windows like.
> > Indie composition goes all the way back to C64 as a midi sequencer. The 
> > acidhouse phenomena was big on computers, and pop-culture and CBM-culture 
> > seemed intertwined in the 90s, where a Trance musician might just be a 
> > researcher otherwise. That is a long time with music and thinking. I myself 
> > have concluded with 

Re: "lib: rework bitmap_parse()" triggers invalid access errors

2019-06-06 Thread Yury Norov
On Thu, Jun 06, 2019 at 12:09:46PM -0400, Qian Cai wrote:
> On Wed, 2019-06-05 at 08:01 +, Yuri Norov wrote:
> > (Sorry for top-posting)
> > 
> > I can reproduce this on next-20190604. Is it new trace, or like one you've
> > posted before?
> 
> Same thing, "nbits" causes an invalid access.
> 
> # ./scripts/faddr2line vmlinux bitmap_parse+0x20c/0x2d8
> bitmap_parse+0x20c/0x2d8:
> __bitmap_clear at lib/bitmap.c:280
> (inlined by) bitmap_clear at include/linux/bitmap.h:390
> (inlined by) bitmap_parse at lib/bitmap.c:662
> 
> This line,
> 
> while (len - bits_to_clear >= 0) {

[...]

The problem is in my code, and the fix is:

diff --git a/lib/bitmap.c b/lib/bitmap.c
index ebcf4700ebed..6b3e921f4e91 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -664,7 +664,7 @@ int bitmap_parse(const char *start, unsigned int buflen,
 
unset_bit = (BITS_TO_U32(nmaskbits) - chunks) * 32;
if (unset_bit < nmaskbits) {
-   bitmap_clear(maskp, unset_bit, nmaskbits);
+   bitmap_clear(maskp, unset_bit, nmaskbits - unset_bit);
return 0;
}
 
I'll add a test for this case and submit v3 soon.

Yury


[Patch v2] USB: sisusbvga: Remove unneeded variable

2019-06-06 Thread Hariprasad Kelam
fix below warning reported by coccicheck

drivers/usb/misc/sisusbvga/sisusb.c:1753:5-8: Unneeded variable: "ret".
Return "0" on line 1877

Signed-off-by: Hariprasad Kelam 
-
changes in v2: Change return type of sisusb_set_default_mode from int to void
   as it never fails.
---
 drivers/usb/misc/sisusbvga/sisusb.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/misc/sisusbvga/sisusb.c 
b/drivers/usb/misc/sisusbvga/sisusb.c
index ea06f1f..2ab9600 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -1747,10 +1747,10 @@ static int sisusb_setup_screen(struct sisusb_usb_data 
*sisusb,
return ret;
 }
 
-static int sisusb_set_default_mode(struct sisusb_usb_data *sisusb,
+static void sisusb_set_default_mode(struct sisusb_usb_data *sisusb,
int touchengines)
 {
-   int ret = 0, i, j, modex, bpp, du;
+   int i, j, modex, bpp, du;
u8 sr31, cr63, tmp8;
static const char attrdata[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
@@ -1873,8 +1873,6 @@ static int sisusb_set_default_mode(struct sisusb_usb_data 
*sisusb,
}
 
SETIREG(SISCR, 0x34, 0x44); /* we just set std mode #44 */
-
-   return ret;
 }
 
 static int sisusb_init_gfxcore(struct sisusb_usb_data *sisusb)
@@ -2019,7 +2017,7 @@ static int sisusb_init_gfxcore(struct sisusb_usb_data 
*sisusb)
 
ret |= SETIREG(SISCR, 0x83, 0x00);
 
-   ret |= sisusb_set_default_mode(sisusb, 0);
+   sisusb_set_default_mode(sisusb, 0);
 
ret |= SETIREGAND(SISSR, 0x21, 0xdf);
ret |= SETIREGOR(SISSR, 0x01, 0x20);
@@ -2246,7 +2244,7 @@ static int sisusb_init_gfxdevice(struct sisusb_usb_data 
*sisusb, int initscreen)
if (sisusb_init_gfxcore(sisusb) == 0) {
sisusb->gfxinit = 1;
sisusb_get_ramconfig(sisusb);
-   ret |= sisusb_set_default_mode(sisusb, 1);
+   sisusb_set_default_mode(sisusb, 1);
ret |= sisusb_setup_screen(sisusb, 1, initscreen);
}
}
-- 
2.7.4



[no subject]

2019-06-06 Thread 15050101
unsubscribe



Re: [PATCH] clk: fix a missing-free bug in clk_cpy_name()

2019-06-06 Thread Gen Zhang
On Thu, Jun 06, 2019 at 01:16:45PM -0700, Stephen Boyd wrote:
> Quoting Gen Zhang (2019-06-05 09:00:43)
> > On Wed, Jun 05, 2019 at 08:38:00AM +0200, Jiri Slaby wrote:
> > > On 31. 05. 19, 3:14, Gen Zhang wrote:
> > > > In clk_cpy_name(), '*dst_p'('parent->name'and 'parent->fw_name') and 
> > > > 'dst' are allcoted by kstrdup_const(). According to doc: "Strings 
> > > > allocated by kstrdup_const should be freed by kfree_const". So 
> > > > 'parent->name', 'parent->fw_name' and 'dst' should be freed.
> > > > 
> > > > Signed-off-by: Gen Zhang 
> > > > ---
> > > > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> > > > index aa51756..85c4d3f 100644
> > > > --- a/drivers/clk/clk.c
> > > > +++ b/drivers/clk/clk.c
> > > > @@ -3435,6 +3435,7 @@ static int clk_cpy_name(const char **dst_p, const 
> > > > char *src, bool must_exist)
> > > > if (!dst)
> > > > return -ENOMEM;
> > > >  
> > > > +   kfree_const(dst);
> > > 
> > > So you are now returning a freed pointer in dst_p?
> > Thanks for your reply. I re-examined the code, and this kfree is 
> > incorrect and it should be deleted.
> > > 
> > > > return 0;
> > > >  }
> > > >  
> > > > @@ -3491,6 +3492,8 @@ static int clk_core_populate_parent_map(struct 
> > > > clk_core *core)
> > > > kfree_const(parents[i].name);
> > > > kfree_const(parents[i].fw_name);
> > > > } while (--i >= 0);
> > > > +   kfree_const(parent->name);
> > > > +   kfree_const(parent->fw_name);
> > > 
> > > Both of them were just freed in the loop above, no?
> > for (i = 0, parent = parents; i < num_parents; i++, parent++)
> > Is 'parent' the same as the one from the loop above?
> 
> Yes. Did it change somehow?
parent++?
> 
> > 
> > Moreover, should 'parents[i].name' and 'parents[i].fw_name' be freed by
> > kfree_const()?
> > 
> 
> Yes? They're allocated with kstrdup_const() in clk_cpy_name(), or
> they're NULL by virtue of the kcalloc and then kfree_const() does
> nothing.
I re-examined clk_cpy_name(). They are the second parameter of 
clk_cpy_name(). The first parameter is allocated, not the second one.
So 'parent->name' and 'parent->fw_name' should be freed, not 
'parents[i].name' or 'parents[i].fw_name'. Am I totally misunderstanding
this clk_cpy_name()? :-(

Thanks
Gen
> 
> I'm having a hard time following what this patch is trying to fix. It
> looks unnecessary though so I'm going to drop it from the clk review
> queue.
> 


Re: [BUG 4.4.178] x86_64 compat mode futexes broken

2019-06-06 Thread Joe Korty
On Thu, Jun 06, 2019 at 04:11:30PM -0700, Nathan Chancellor wrote:
> On Thu, Jun 06, 2019 at 09:11:43PM +, Joe Korty wrote:
> > Starting with 4.4.178, the LTP test
> > 
> >   pthread_cond_wait/2-3
> > 
> > when compiled on x86_64 with 'gcc -m32', started failing.  It generates 
> > this log output:
> > 
> >   [16:18:38]Implementation supports the MONOTONIC CLOCK but option is 
> > disabled in test.   
> >   [16:18:38]Test starting
> >   [16:18:38] Process-shared primitive will be tested
> >   [16:18:38] Alternative clock for cond will be tested
> >   [16:18:38]Test 2-3.c FAILED: The child did not own the mutex inside the 
> > cleanup handler
> > 
> 
> What is the exact build command + test case command? I'd like to
> reproduce this myself.
> 
> > A git bisection between 4.4.177..178 shows that this commit is the culprit:
> > 
> >   Git-Commit: 79739ad2d0ac5787a15a1acf7caaf34cd95bbf3c
> >   Author: Alistair Strachan 
> >   Subject: [PATCH] x86: vdso: Use $LD instead of $CC to link
> > 
> 
> Have you tested 4.4.180? There were two subsequent fixes to this patch
> in 4.4:

Hi Nathan,
I started with 4.4.179-rt181 and worked backwards from there.  Per your
suggestion, I tried 4.4.180 and it does work properly.

Thanks,
Joe




> 485d15db01ca ("kbuild: simplify ld-option implementation")
> 07d35512e494 ("x86/vdso: Pass --eh-frame-hdr to the linker")
> 
> > And, indeed, when I back this patch out of 4.4.178 proper, the above test
> > passes again.
> > 
> > Please consider backing this patch out of linux-4.4.y, and from master, and 
> > from
> > any other linux branch it has been backported to.
> > 
> 
> So this is broken in mainline too?
> 
> > PS: In backing it out of 4.4.178, I first backed out
> > 
> >7c45b45fd6e928c9ce275c32f6fa98d317e6f5ee
> >
> > This is a follow-on vdso patch which collides with the
> > patch we are interested in removing.  As it claims to be
> > only removing redundant code, it probably should never
> > have been backported in the first place.
> 
> While it is redundant for ld.bfd, it causes a build failure with the
> release version of ld.lld:
> 
> https://github.com/ClangBuiltLinux/linux/issues/31
> 
> Cheers,
> Nathan


Re: [PATCH] Powerpc/Watchpoint: Restore nvgprs while returning from exception

2019-06-06 Thread Michael Neuling
On Thu, 2019-06-06 at 12:59 +0530, Ravi Bangoria wrote:
> Powerpc hw triggers watchpoint before executing the instruction.
> To make trigger-after-execute behavior, kernel emulates the
> instruction. If the instruction is 'load something into non-
> volatile register', exception handler should restore emulated
> register state while returning back, otherwise there will be
> register state corruption. Ex, Adding a watchpoint on a list
> can corrput the list:
> 
>   # cat /proc/kallsyms | grep kthread_create_list
>   c121c8b8 d kthread_create_list
> 
> Add watchpoint on kthread_create_list->next:
> 
>   # perf record -e mem:0xc121c8c0
> 
> Run some workload such that new kthread gets invoked. Ex, I
> just logged out from console:
> 
>   list_add corruption. next->prev should be prev (c1214e00), \
>   but was c121c8b8. (next=c121c8b8).
>   WARNING: CPU: 59 PID: 309 at lib/list_debug.c:25 __list_add_valid+0xb4/0xc0
>   CPU: 59 PID: 309 Comm: kworker/59:0 Kdump: loaded Not tainted 5.1.0-rc7+ #69
>   ...
>   NIP __list_add_valid+0xb4/0xc0
>   LR __list_add_valid+0xb0/0xc0
>   Call Trace:
>   __list_add_valid+0xb0/0xc0 (unreliable)
>   __kthread_create_on_node+0xe0/0x260
>   kthread_create_on_node+0x34/0x50
>   create_worker+0xe8/0x260
>   worker_thread+0x444/0x560
>   kthread+0x160/0x1a0
>   ret_from_kernel_thread+0x5c/0x70
> 
> Signed-off-by: Ravi Bangoria 

How long has this been around? Should we be CCing stable?

Mikey

> ---
>  arch/powerpc/kernel/exceptions-64s.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/exceptions-64s.S
> b/arch/powerpc/kernel/exceptions-64s.S
> index 9481a11..96de0d1 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -1753,7 +1753,7 @@ handle_dabr_fault:
>   ld  r5,_DSISR(r1)
>   addir3,r1,STACK_FRAME_OVERHEAD
>   bl  do_break
> -12:  b   ret_from_except_lite
> +12:  b   ret_from_except
>  
>  
>  #ifdef CONFIG_PPC_BOOK3S_64



RE: [PATCH V3 3/4] clk: imx: Add support for i.MX8MN clock driver

2019-06-06 Thread Anson Huang
Hi, Stephen

> -Original Message-
> From: Stephen Boyd 
> Sent: Friday, June 7, 2019 12:26 AM
> To: Anson Huang ; Abel Vesa
> ; Aisheng Dong ;
> bjorn.anders...@linaro.org; catalin.mari...@arm.com;
> devicet...@vger.kernel.org; dingu...@kernel.org;
> enric.balle...@collabora.com; feste...@gmail.com;
> horms+rene...@verge.net.au; ja...@amarulasolutions.com;
> ker...@pengutronix.de; l.st...@pengutronix.de; Leonard Crestez
> ; linux-arm-ker...@lists.infradead.org; linux-
> c...@vger.kernel.org; linux-kernel@vger.kernel.org; mark.rutl...@arm.com;
> maxime.rip...@bootlin.com; mturque...@baylibre.com; o...@lixom.net;
> Jacky Bai ; robh...@kernel.org;
> s.ha...@pengutronix.de; shawn...@kernel.org; will.dea...@arm.com
> Cc: dl-linux-imx 
> Subject: Re: [PATCH V3 3/4] clk: imx: Add support for i.MX8MN clock driver
> 
> Quoting anson.hu...@nxp.com (2019-06-03 18:59:27)
> > From: Anson Huang 
> >
> > This patch adds i.MX8MN clock driver support.
> >
> > Signed-off-by: Anson Huang 
> > ---
> > Changes since V2:
> > - use platform driver model for this clock driver;
> 
> Can you also use platform device APIs like platform_*(),
> devm_ioremap_resource() and devmified clk registration?

I will use devm_platform_ioremap_resource() instead of ioremap(),
and can you be more specific about devmified clk registration?

Thanks,
Anson


Re: [PATCH v8 0/9] EDAC drivers for Armada XP L2 and DDR

2019-06-06 Thread Chris Packham
Hi All,

On 10/05/19 10:15 PM, Chris Packham wrote:
> The Reviews/Acks have been given so this should be good to go in via the ARM
> tree as planned.
> 
> http://lists.infradead.org/pipermail/linux-arm-kernel/2017-August/525561.html
> 
> This series adds drivers for the L2 cache and DDR RAM ECC functionality as
> found on the MV78230/MV78x60 SoCs. Jan has tested these changes with the
> MV78460 (on a custom board with a DDR3 ECC DIMM), Chris has tested these
> changes with 88F6820 and 98dx3236 (both a custom boards with fixed DDR3 + 
> ECC).
> 
> Also contained in this series is an additional debugfs wrapper.

Ping?

> 
> Compared to the previous v7 series this has been rebased against 5.1 requiring
> some changes in the devicetree binding documentation.
> 
> Compared to the previous v6 series I've dropped the marvell,ecc-disable
> property.
> 
> Compared to the previous v5 series I've split the dt-binding documentation 
> into
> its own patch and updated armada_xp_edac.c to use a SPDX license.
> 
> Compared to the previous v4 series I've added my s-o-b to some of Jan's
> patches and rebased against v4.19.0.
> 
> Compared to the previous v3 series, the following changes have been made:
> - Use shorter names for the AURORA ECC and parity registers
> - Numerous formatting changes to edac/armada_xp.c (as requested by Boris)
> - Added support for Armada-38x and 98dx3236 SoCs
> 
> Compared to the previous v2 series, the following changes have been made:
> - Allocate EDAC structures later during probing and drop devres support
>patches (requested by Boris)
> - Make drvdata->width usage consistent according to the comment (suggested by
>Chris)
> 
> Compared to the previous v1 series, the following changes have been made:
> - Add the aurora-l2 register defines earlier in the series (suggested by
>Russell King and Gregory CLEMENT )
> - Changed the DT vendor prefix from "arm" to "marvell" for the 
> ecc-enable/disable
>properties on the aurora-l2 (suggested by Russell King)
> - Fix some warnings reported by checkpatch
> 
> Compared to the original RFC series, the following changes have been made:
> - Integrated Chris' patches for parity and ECC configuration via DT
> - Merged the DDR RAM and L2 cache drivers (as requested by Boris, analogous
>to fsl_ddr_edac.c and mpc85xx_edac.c)
> - Added myself to MAINTAINERS (requested by Boris)
> - L2 cache: Track the msg size and use snprintf (review comment by Chris)
> - L2 cache: Split error injection from the check function (review comment by
>Chris)
> - DDR RAM: Allow 16 bit width in addition to 32 and 64 bit (review comment by
>Chris)
> - Use of_match_ptr() (review comments by Chris)
> - Minor checkpatch cleanups
> 
> 
> Chris Packham (4):
>ARM: l2x0: support parity-enable/disable on aurora
>dt-bindings: ARM: document marvell,ecc-enable binding
>ARM: l2x0: add marvell,ecc-enable property for aurora
>EDAC: armada_xp: Add support for more SoCs
> 
> Jan Luebbe (5):
>ARM: l2c: move cache-aurora-l2.h to asm/hardware
>ARM: aurora-l2: add prefix to MAX_RANGE_SIZE
>ARM: aurora-l2: add defines for parity and ECC registers
>EDAC: Add missing debugfs_create_x32 wrapper
>EDAC: Add driver for the Marvell Armada XP SDRAM and L2 cache ECC
> 
>   .../devicetree/bindings/arm/l2c2x0.yaml   |   4 +
>   MAINTAINERS   |   6 +
>   .../asm/hardware}/cache-aurora-l2.h   |  50 +-
>   arch/arm/mm/cache-l2x0.c  |  18 +-
>   drivers/edac/Kconfig  |   7 +
>   drivers/edac/Makefile |   1 +
>   drivers/edac/armada_xp_edac.c | 635 ++
>   drivers/edac/debugfs.c|  11 +
>   drivers/edac/edac_module.h|   5 +
>   9 files changed, 733 insertions(+), 4 deletions(-)
>   rename arch/arm/{mm => include/asm/hardware}/cache-aurora-l2.h (50%)
>   create mode 100644 drivers/edac/armada_xp_edac.c
> 



Re: [PATCH 2/5] mm/hmm: Clean up some coding style and comments

2019-06-06 Thread Ralph Campbell



On 6/6/19 8:57 AM, Jason Gunthorpe wrote:

On Mon, May 06, 2019 at 04:29:39PM -0700, rcampb...@nvidia.com wrote:

@@ -924,6 +922,7 @@ int hmm_range_register(struct hmm_range *range,
   unsigned page_shift)
  {
unsigned long mask = ((1UL << page_shift) - 1UL);
+   struct hmm *hmm;
  
  	range->valid = false;

range->hmm = NULL;


I was finishing these patches off and noticed that 'hmm' above is
never initialized.

I added the below to this patch:

diff --git a/mm/hmm.c b/mm/hmm.c
index 678873eb21930a..8e7403f081f44a 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -932,19 +932,20 @@ int hmm_range_register(struct hmm_range *range,
range->start = start;
range->end = end;
  
-	range->hmm = hmm_get_or_create(mm);

-   if (!range->hmm)
+   hmm = hmm_get_or_create(mm);
+   if (!hmm)
return -EFAULT;
  
  	/* Check if hmm_mm_destroy() was call. */

-   if (range->hmm->mm == NULL || range->hmm->dead) {
-   hmm_put(range->hmm);
+   if (hmm->mm == NULL || hmm->dead) {
+   hmm_put(hmm);
return -EFAULT;
}
  
  	/* Initialize range to track CPU page table updates. */

-   mutex_lock(>hmm->lock);
+   mutex_lock(>lock);
  
+	range->hmm = hmm;

list_add_rcu(>list, >ranges);
  
  	/*


Which I think was the intent of adding the 'struct hmm *'. I prefer
this arrangement as it does not set an leave an invalid hmm pointer in
the range if there is a failure..

Most probably the later patches fixed this up?

Please confirm, thanks

Regards,
Jason



Yes, you understand correctly. That was the intended clean up.
I must have split my original patch set incorrectly.


Re: [RESEND v2 00/18] clk: imx: Switch the imx6 and imx7 to clk_hw based API

2019-06-06 Thread Shawn Guo
On Thu, Jun 06, 2019 at 11:29:40AM -0700, Stephen Boyd wrote:
> Quoting Abel Vesa (2019-05-29 05:26:38)
> > Resend for the following:
> > 
> > https://lkml.org/lkml/2019/5/2/170
> 
> What's left after this series to convert over to clk_hw based APIs? I'm
> happy to see this merge as long as we eventually delete the clk based
> versions of the code in the imx driver so that we can complete the task.
> 
> I took a look over everything and nothing stuck out, so:
> 
> Reviewed-by: Stephen Boyd 
> 
> for the series.

I just applied the series to my for-next branch, so that it can be
pulled into linux-next for testing.

Shawn


Re: [PATCH v2] drivers: scsi: remove unnecessary #ifdef MODULE

2019-06-06 Thread James Bottomley
On Thu, 2019-06-06 at 17:04 +0200, Enrico Weigelt, metux IT consult
wrote:
> From: Enrico Weigelt 
> 
> The MODULE_DEVICE_TABLE() macro already checks for MODULE defined,
> so the extra check here is not necessary.
> 
> Changes v2:
> * make dptids const to fix warning on unused variable

I don't think this works; in my version of gcc, const does not defeat
the unused variable warning if I try with a test programme:

jejb@jarvis:~> gcc -Wunused-variable -c test1.c
test1.c:3:18: warning: ‘i’ defined but not used [-Wunused-cons
t-variable=]
 static const int i[] = { 1, 2, 3};

James



[GIT PULL] apparmor bug fixes for v5.3-rc4

2019-06-06 Thread John Johansen
Hi Linus,


Can you please pull the following bug fixes for apparmor
Thanks!

- John


The following changes since commit b8a5afa418c1f5c8d7814ef829a88e60ae52f618:

  net: correct zerocopy refcnt with udp MSG_MORE (2019-05-31 06:40:10 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor 
tags/apparmor-pr-2019-06-06

for you to fetch changes up to dd60c38193b1cd8bc1cbde1425881cd5227ef466:

  apparmor: enforce nullbyte at end of tag string (2019-05-31 06:50:00 -0700)


+ Bug Fixes
  - Fix PROFILE_MEDIATES for untrusted input
  - enforce nullbyte at end of tag string


Jann Horn (1):
  apparmor: enforce nullbyte at end of tag string

John Johansen (1):
  apparmor: fix PROFILE_MEDIATES for untrusted input

 security/apparmor/include/policy.h | 11 ++-
 security/apparmor/policy_unpack.c  |  2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)




[PATCH] power: Do not clear events_check_enabled in pm_wakeup_pending()

2019-06-06 Thread Ravi Chandra Sadineni
events_check_enabled bool is set when wakeup_count sysfs attribute
is written. User level daemon is expected to write this attribute
just before suspend.

When this boolean is set, calls to pm_wakeup_event() will result in
increment of per device and global wakeup count that helps in
identifying the wake source. global wakeup count is also used by
pm_wakeup_pending() to identify if there are any pending events that
should result in an suspend abort.

Currently calls to pm_wakeup_pending() also clears events_check_enabled.
This can be a problem when there are multiple wake events or when the
suspend is aborted due to an interrupt on a shared interrupt line.
For example an Mfd device can create several platform devices which
might fetch the state on resume in the driver resume method and increment
the wakeup count if needed. But if events_check_enabled is cleared before
resume methods get to execute, wakeup count will not be incremented. Thus
let us not reset the bool here.

Note that events_check_enabled is also cleared in suspend.c/enter_state()
on every resume at the end.

Signed-off-by: Ravi Chandra Sadineni 
---
 drivers/base/power/wakeup.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index 5b2b6a05a4f3..88aade871589 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -838,7 +838,6 @@ bool pm_wakeup_pending(void)
 
split_counters(, );
ret = (cnt != saved_count || inpr > 0);
-   events_check_enabled = !ret;
}
raw_spin_unlock_irqrestore(_lock, flags);
 
-- 
2.20.1



[PATCH linux-next v2] mpls: don't build sysctl related code when sysctl is disabled

2019-06-06 Thread Matteo Croce
Some sysctl related code and data structures is never referenced
when CONFIG_SYSCTL is not set.
While this is usually harmless, it produces a build failure since sysctl
shared variables exists, due to missing sysctl_vals symbol:

ld: net/mpls/af_mpls.o: in function `mpls_platform_labels':
af_mpls.c:(.text+0x162a): undefined reference to `sysctl_vals'
ld: net/mpls/af_mpls.o:(.rodata+0x830): undefined reference to `sysctl_vals'
ld: net/mpls/af_mpls.o:(.rodata+0x838): undefined reference to `sysctl_vals'
ld: net/mpls/af_mpls.o:(.rodata+0x870): undefined reference to `sysctl_vals'

Fix this by moving all sysctl related code under #ifdef CONFIG_SYSCTL

Reported-by: Randy Dunlap 
Signed-off-by: Matteo Croce 
---

v1 -> v2: fix a crash on netns destroy

 net/mpls/af_mpls.c | 393 -
 1 file changed, 207 insertions(+), 186 deletions(-)

diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index c312741df2ce..c53da5a8bb6d 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -37,9 +37,6 @@
 
 #define MPLS_NEIGH_TABLE_UNSPEC (NEIGH_LINK_TABLE + 1)
 
-static int label_limit = (1 << 20) - 1;
-static int ttl_max = 255;
-
 #if IS_ENABLED(CONFIG_NET_IP_TUNNEL)
 static size_t ipgre_mpls_encap_hlen(struct ip_tunnel_encap *e)
 {
@@ -1179,31 +1176,6 @@ static int mpls_netconf_msgsize_devconf(int type)
return size;
 }
 
-static void mpls_netconf_notify_devconf(struct net *net, int event,
-   int type, struct mpls_dev *mdev)
-{
-   struct sk_buff *skb;
-   int err = -ENOBUFS;
-
-   skb = nlmsg_new(mpls_netconf_msgsize_devconf(type), GFP_KERNEL);
-   if (!skb)
-   goto errout;
-
-   err = mpls_netconf_fill_devconf(skb, mdev, 0, 0, event, 0, type);
-   if (err < 0) {
-   /* -EMSGSIZE implies BUG in mpls_netconf_msgsize_devconf() */
-   WARN_ON(err == -EMSGSIZE);
-   kfree_skb(skb);
-   goto errout;
-   }
-
-   rtnl_notify(skb, net, 0, RTNLGRP_MPLS_NETCONF, NULL, GFP_KERNEL);
-   return;
-errout:
-   if (err < 0)
-   rtnl_set_sk_err(net, RTNLGRP_MPLS_NETCONF, err);
-}
-
 static const struct nla_policy devconf_mpls_policy[NETCONFA_MAX + 1] = {
[NETCONFA_IFINDEX]  = { .len = sizeof(int) },
 };
@@ -1362,6 +1334,36 @@ static int mpls_netconf_dump_devconf(struct sk_buff *skb,
 #define MPLS_PERDEV_SYSCTL_OFFSET(field)   \
(&((struct mpls_dev *)0)->field)
 
+#ifdef CONFIG_SYSCTL
+
+static int label_limit = (1 << 20) - 1;
+static int ttl_max = 255;
+
+static void mpls_netconf_notify_devconf(struct net *net, int event,
+   int type, struct mpls_dev *mdev)
+{
+   struct sk_buff *skb;
+   int err = -ENOBUFS;
+
+   skb = nlmsg_new(mpls_netconf_msgsize_devconf(type), GFP_KERNEL);
+   if (!skb)
+   goto errout;
+
+   err = mpls_netconf_fill_devconf(skb, mdev, 0, 0, event, 0, type);
+   if (err < 0) {
+   /* -EMSGSIZE implies BUG in mpls_netconf_msgsize_devconf() */
+   WARN_ON(err == -EMSGSIZE);
+   kfree_skb(skb);
+   goto errout;
+   }
+
+   rtnl_notify(skb, net, 0, RTNLGRP_MPLS_NETCONF, NULL, GFP_KERNEL);
+   return;
+errout:
+   if (err < 0)
+   rtnl_set_sk_err(net, RTNLGRP_MPLS_NETCONF, err);
+}
+
 static int mpls_conf_proc(struct ctl_table *ctl, int write,
  void __user *buffer,
  size_t *lenp, loff_t *ppos)
@@ -1445,6 +1447,173 @@ static void mpls_dev_sysctl_unregister(struct 
net_device *dev,
mpls_netconf_notify_devconf(net, RTM_DELNETCONF, 0, mdev);
 }
 
+static int resize_platform_label_table(struct net *net, size_t limit)
+{
+   size_t size = sizeof(struct mpls_route *) * limit;
+   size_t old_limit;
+   size_t cp_size;
+   struct mpls_route __rcu **labels = NULL, **old;
+   struct mpls_route *rt0 = NULL, *rt2 = NULL;
+   unsigned index;
+
+   if (size) {
+   labels = kvzalloc(size, GFP_KERNEL);
+   if (!labels)
+   goto nolabels;
+   }
+
+   /* In case the predefined labels need to be populated */
+   if (limit > MPLS_LABEL_IPV4NULL) {
+   struct net_device *lo = net->loopback_dev;
+   rt0 = mpls_rt_alloc(1, lo->addr_len, 0);
+   if (IS_ERR(rt0))
+   goto nort0;
+   RCU_INIT_POINTER(rt0->rt_nh->nh_dev, lo);
+   rt0->rt_protocol = RTPROT_KERNEL;
+   rt0->rt_payload_type = MPT_IPV4;
+   rt0->rt_ttl_propagate = MPLS_TTL_PROP_DEFAULT;
+   rt0->rt_nh->nh_via_table = NEIGH_LINK_TABLE;
+   rt0->rt_nh->nh_via_alen = lo->addr_len;
+   memcpy(__mpls_nh_via(rt0, rt0->rt_nh), lo->dev_addr,
+  lo->addr_len);
+   }
+   if (limit > MPLS_LABEL_IPV6NULL) {

Re: [PATCH linux-next] mpls: don't build sysctl related code when sysctl is disabled

2019-06-06 Thread Randy Dunlap
On 6/6/19 4:57 PM, Matteo Croce wrote:
> Some sysctl related code and data structures are never referenced
> when CONFIG_SYSCTL is not set.
> While this is usually harmless, it produces a build failure since sysctl
> shared variables exist, due to missing sysctl_vals symbol:
> 
> ld: net/mpls/af_mpls.o: in function `mpls_platform_labels':
> af_mpls.c:(.text+0x162a): undefined reference to `sysctl_vals'
> ld: net/mpls/af_mpls.o:(.rodata+0x830): undefined reference to 
> `sysctl_vals'
> ld: net/mpls/af_mpls.o:(.rodata+0x838): undefined reference to 
> `sysctl_vals'
> ld: net/mpls/af_mpls.o:(.rodata+0x870): undefined reference to 
> `sysctl_vals'
> 
> Fix this by moving all sysctl related code under #ifdef CONFIG_SYSCTL
> 
> Reported-by: Randy Dunlap 
> Signed-off-by: Matteo Croce 

Builds for me.  Thanks.

Acked-by: Randy Dunlap  # build-tested

> ---
>  net/mpls/af_mpls.c | 389 -
>  1 file changed, 204 insertions(+), 185 deletions(-)
> 
> diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
> index c312741df2ce..5aacbf129ec5 100644
> --- a/net/mpls/af_mpls.c
> +++ b/net/mpls/af_mpls.c
> @@ -37,9 +37,6 @@
>  
>  #define MPLS_NEIGH_TABLE_UNSPEC (NEIGH_LINK_TABLE + 1)
>  
> -static int label_limit = (1 << 20) - 1;
> -static int ttl_max = 255;
> -
>  #if IS_ENABLED(CONFIG_NET_IP_TUNNEL)
>  static size_t ipgre_mpls_encap_hlen(struct ip_tunnel_encap *e)
>  {
> @@ -1179,31 +1176,6 @@ static int mpls_netconf_msgsize_devconf(int type)
>   return size;
>  }
>  
> -static void mpls_netconf_notify_devconf(struct net *net, int event,
> - int type, struct mpls_dev *mdev)
> -{
> - struct sk_buff *skb;
> - int err = -ENOBUFS;
> -
> - skb = nlmsg_new(mpls_netconf_msgsize_devconf(type), GFP_KERNEL);
> - if (!skb)
> - goto errout;
> -
> - err = mpls_netconf_fill_devconf(skb, mdev, 0, 0, event, 0, type);
> - if (err < 0) {
> - /* -EMSGSIZE implies BUG in mpls_netconf_msgsize_devconf() */
> - WARN_ON(err == -EMSGSIZE);
> - kfree_skb(skb);
> - goto errout;
> - }
> -
> - rtnl_notify(skb, net, 0, RTNLGRP_MPLS_NETCONF, NULL, GFP_KERNEL);
> - return;
> -errout:
> - if (err < 0)
> - rtnl_set_sk_err(net, RTNLGRP_MPLS_NETCONF, err);
> -}
> -
>  static const struct nla_policy devconf_mpls_policy[NETCONFA_MAX + 1] = {
>   [NETCONFA_IFINDEX]  = { .len = sizeof(int) },
>  };
> @@ -1362,6 +1334,36 @@ static int mpls_netconf_dump_devconf(struct sk_buff 
> *skb,
>  #define MPLS_PERDEV_SYSCTL_OFFSET(field) \
>   (&((struct mpls_dev *)0)->field)
>  
> +#ifdef CONFIG_SYSCTL
> +
> +static int label_limit = (1 << 20) - 1;
> +static int ttl_max = 255;
> +
> +static void mpls_netconf_notify_devconf(struct net *net, int event,
> + int type, struct mpls_dev *mdev)
> +{
> + struct sk_buff *skb;
> + int err = -ENOBUFS;
> +
> + skb = nlmsg_new(mpls_netconf_msgsize_devconf(type), GFP_KERNEL);
> + if (!skb)
> + goto errout;
> +
> + err = mpls_netconf_fill_devconf(skb, mdev, 0, 0, event, 0, type);
> + if (err < 0) {
> + /* -EMSGSIZE implies BUG in mpls_netconf_msgsize_devconf() */
> + WARN_ON(err == -EMSGSIZE);
> + kfree_skb(skb);
> + goto errout;
> + }
> +
> + rtnl_notify(skb, net, 0, RTNLGRP_MPLS_NETCONF, NULL, GFP_KERNEL);
> + return;
> +errout:
> + if (err < 0)
> + rtnl_set_sk_err(net, RTNLGRP_MPLS_NETCONF, err);
> +}
> +
>  static int mpls_conf_proc(struct ctl_table *ctl, int write,
> void __user *buffer,
> size_t *lenp, loff_t *ppos)
> @@ -1445,6 +1447,173 @@ static void mpls_dev_sysctl_unregister(struct 
> net_device *dev,
>   mpls_netconf_notify_devconf(net, RTM_DELNETCONF, 0, mdev);
>  }
>  
> +static int resize_platform_label_table(struct net *net, size_t limit)
> +{
> + size_t size = sizeof(struct mpls_route *) * limit;
> + size_t old_limit;
> + size_t cp_size;
> + struct mpls_route __rcu **labels = NULL, **old;
> + struct mpls_route *rt0 = NULL, *rt2 = NULL;
> + unsigned index;
> +
> + if (size) {
> + labels = kvzalloc(size, GFP_KERNEL);
> + if (!labels)
> + goto nolabels;
> + }
> +
> + /* In case the predefined labels need to be populated */
> + if (limit > MPLS_LABEL_IPV4NULL) {
> + struct net_device *lo = net->loopback_dev;
> + rt0 = mpls_rt_alloc(1, lo->addr_len, 0);
> + if (IS_ERR(rt0))
> + goto nort0;
> + RCU_INIT_POINTER(rt0->rt_nh->nh_dev, lo);
> + rt0->rt_protocol = RTPROT_KERNEL;
> + rt0->rt_payload_type = MPT_IPV4;
> + rt0->rt_ttl_propagate = MPLS_TTL_PROP_DEFAULT;
> + rt0->rt_nh->nh_via_table = NEIGH_LINK_TABLE;

Re: [PATCH net-next 01/12] net: hns3: log detail error info of ROCEE ECC and AXI errors

2019-06-06 Thread tanhuazhong




On 2019/6/7 1:36, David Miller wrote:

From: Huazhong Tan 
Date: Thu, 6 Jun 2019 16:20:56 +0800


+static int hclge_log_rocee_axi_error(struct hclge_dev *hdev)
+{

  ...

+   ret = hclge_cmd_send(>hw, [0], 3);
+   if (ret) {
+   dev_err(dev, "failed(%d) to query ROCEE AXI error sts\n", ret);
+   return ret;
+   }

  ...

+   ret = hclge_log_rocee_axi_error(hdev);
+   if (ret) {
+   dev_err(dev, "failed(%d) to process axi error\n", ret);


You log the error twice which is unnecessary.



ok, thanks.


.





Re: mmotm 2019-05-29-20-52 uploaded (mpls) +linux-next

2019-06-06 Thread Matteo Croce
On Wed, Jun 5, 2019 at 12:29 AM Randy Dunlap  wrote:
>
> On 5/30/19 3:28 PM, Randy Dunlap wrote:
> > On 5/29/19 8:53 PM, a...@linux-foundation.org wrote:
> >> The mm-of-the-moment snapshot 2019-05-29-20-52 has been uploaded to
> >>
> >>http://www.ozlabs.org/~akpm/mmotm/
> >>
> >> mmotm-readme.txt says
> >>
> >> README for mm-of-the-moment:
> >>
> >> http://www.ozlabs.org/~akpm/mmotm/
> >>
> >> This is a snapshot of my -mm patch queue.  Uploaded at random hopefully
> >> more than once a week.
> >>
> >> You will need quilt to apply these patches to the latest Linus release (5.x
> >> or 5.x-rcY).  The series file is in broken-out.tar.gz and is duplicated in
> >> http://ozlabs.org/~akpm/mmotm/series
> >>
> >> The file broken-out.tar.gz contains two datestamp files: .DATE and
> >> .DATE--mm-dd-hh-mm-ss.  Both contain the string -mm-dd-hh-mm-ss,
> >> followed by the base kernel version against which this patch series is to
> >> be applied.
> >>
> >
> > on i386 or x86_64:
> >
> > when CONFIG_PROC_SYSCTL is not set/enabled:
> >
> > ld: net/mpls/af_mpls.o: in function `mpls_platform_labels':
> > af_mpls.c:(.text+0x162a): undefined reference to `sysctl_vals'
> > ld: net/mpls/af_mpls.o:(.rodata+0x830): undefined reference to `sysctl_vals'
> > ld: net/mpls/af_mpls.o:(.rodata+0x838): undefined reference to `sysctl_vals'
> > ld: net/mpls/af_mpls.o:(.rodata+0x870): undefined reference to `sysctl_vals'
> >
>
> Hi,
> This now happens in linux-next 20190604.
>
>
> --
> ~Randy

Hi,
I've just sent a patch to fix it.

It seems that there is a lot of sysctl related code is built
regardless of the CONFIG_SYSCTL value, but produces a build error only
with my patch because I add a reference to sysctl_vals which is in
kernel/sysctl.c.

And it seems also that the compiler is unable to optimize out the
unused code, which gets somehow in the final binary:

$ grep PROC_SYSCTL .config
# CONFIG_PROC_SYSCTL is not set
$ readelf vmlinux -x .rodata |grep -A 2 platform_lab
  0x81b09180 2e630070 6c617466 6f726d5f 6c616265 .c.platform_labe
  0x81b09190 6c730069 705f7474 6c5f7072 6f706167 ls.ip_ttl_propag
  0x81b091a0 61746500 64656661 756c745f 74746c00 ate.default_ttl.

If the purpose of disabling sysctl is to save space, probably this
code and definitions should all go under an #ifdef

Regards,
-- 
Matteo Croce
per aspera ad upstream


[PATCH v7 0/3] add new ima hook ima_kexec_cmdline to measure kexec boot cmdline args

2019-06-06 Thread Prakhar Srivastava
The motive behind the patch series is to measure the boot cmdline args
used for soft reboot/kexec case.

For secure boot attestation, it is necessary to measure the kernel
command line and the kernel version. For cold boot, the boot loader
can be enhanced to measure these parameters.
(https://mjg59.dreamwidth.org/48897.html)
However, for attestation across soft reboot boundary, these values 
also need to be measured during kexec_file_load.

Currently for Kexec(kexec_file_load)/soft reboot scenario the boot cmdline
args for the next kernel are not measured. For 
normal case of boot/hardreboot the cmdline args are measured into the TPM.
The hash of boot command line is calculated and added to the current 
running kernel's measurement list.
On a soft reboot like kexec, no cmdline arguments measurement takes place.

To achive the above the patch series does the following
  -adds a new ima hook: ima_kexec_cmdline which measures the cmdline args
   into the ima log, behind a new ima policy entry KEXEC_CMDLINE.
  -since the cmldine args cannot be appraised, a new template field(buf) is
   added. The template field contains the buffer passed(cmldine args), which
   can be used to appraise/attest at a later stage.
  -call the ima_kexec_cmdline(...) hook from kexec_file_load call.

The ima logs need to be carried over to the next kernel, which will be followed
up by other patchsets for x86_64 and arm64.

The kexec cmdline hash can be verified using
sudo cat /sys/kernel/security/integrity/ima/ascii_runtime_measurements | 
  grep  kexec-cmdline | cut -d' ' -f 6 | xxd -r -p | sha256sum

Changelog:
V7:
  - rebased to next-queued-testing
  
https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git/log/?h=next-queued-testing

V6:
  -add a new ima hook and policy to measure the cmdline
args(ima_kexec_cmdline)
  -add a new template field buf to contain the buffer measured.
  [suggested by Mimi Zohar]
   add new fields to ima_event_data to store/read buffer data.
  [suggested by Roberto]
  -call ima_kexec_cmdline from kexec_file_load path

v5:
  -add a new ima hook and policy to measure the cmdline
args(ima_kexec_cmdline)
  -add a new template field buf to contain the buffer measured.
[suggested by Mimi Zohar]
  -call ima_kexec_cmdline from kexec_file_load path

v4:
  - per feedback from LSM community, removed the LSM hook and renamed the
IMA policy to KEXEC_CMDLINE

v3: (rebase changes to next-general)
  - Add policy checks for buffer[suggested by Mimi Zohar]
  - use the IMA_XATTR to add buffer
  - Add kexec_cmdline used for kexec file load
  - Add an LSM hook to allow usage by other LSM.[suggestd by Mimi Zohar]

v2:
  - Add policy checks for buffer[suggested by Mimi Zohar]
  - Add an LSM hook to allow usage by other LSM.[suggestd by Mimi Zohar]
  - use the IMA_XATTR to add buffer instead of sig template

v1:
  -Add kconfigs to control the ima_buffer_check
  -measure the cmdline args suffixed with the kernel file name
  -add the buffer to the template sig field.

Prakhar Srivastava (3):
  Add a new ima hook ima_kexec_cmdline to measure cmdline args
  add a new ima template field buf
  call ima_kexec_cmdline to measure the cmdline args

 Documentation/ABI/testing/ima_policy  |  1 +
 Documentation/security/IMA-templates.rst  |  2 +-
 include/linux/ima.h   |  2 +
 kernel/kexec_file.c   |  8 ++-
 security/integrity/ima/ima.h  |  3 +
 security/integrity/ima/ima_api.c  |  5 +-
 security/integrity/ima/ima_init.c |  2 +-
 security/integrity/ima/ima_main.c | 80 +++
 security/integrity/ima/ima_policy.c   |  9 +++
 security/integrity/ima/ima_template.c |  2 +
 security/integrity/ima/ima_template_lib.c | 20 ++
 security/integrity/ima/ima_template_lib.h |  4 ++
 12 files changed, 131 insertions(+), 7 deletions(-)

-- 
2.17.1



[PATCH v7 2/3] add a new ima template field buf

2019-06-06 Thread Prakhar Srivastava
A buffer(kexec cmdline args) measured into ima cannot be
appraised without already being aware of the buffer contents.
Since hashes are non-reversible, raw buffer is needed for
validation or regenerating hash for appraisal/attestation.

This patch adds support to ima to allow store/read the
buffer contents in HEX.

- Add two new fields to ima_event_data to hold the buf and
buf_len [Suggested by Roberto]
- Add a new temaplte field 'buf' to be used to store/read
the buffer data.[Suggested by Mimi]
- Updated process_buffer_meaurement to add the buffer to
ima_event_data. process_buffer_measurement added in
"Add a new ima hook ima_kexec_cmdline to measure cmdline args"

Signed-off-by: Prakhar Srivastava 
Reviewed-by: Roberto Sassu 
---
 Documentation/security/IMA-templates.rst  |  4 ++--
 security/integrity/ima/ima.h  |  2 ++
 security/integrity/ima/ima_api.c  |  4 ++--
 security/integrity/ima/ima_init.c |  2 +-
 security/integrity/ima/ima_main.c |  2 ++
 security/integrity/ima/ima_template.c |  2 ++
 security/integrity/ima/ima_template_lib.c | 20 
 security/integrity/ima/ima_template_lib.h |  4 
 8 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/Documentation/security/IMA-templates.rst 
b/Documentation/security/IMA-templates.rst
index 2cd0e273cc9a..3e78ce3591db 100644
--- a/Documentation/security/IMA-templates.rst
+++ b/Documentation/security/IMA-templates.rst
@@ -69,8 +69,8 @@ descriptors by adding their identifier to the format string
algorithm (field format: [:]digest, where the digest
prefix is shown only if the hash algorithm is not SHA1 or MD5);
  - 'n-ng': the name of the event, without size limitations;
- - 'sig': the file signature.
-
+ - 'sig': the file signature;
+ - 'buf': the buffer data that was used to generate the hash without size 
limitations;
 
 Below, there is the list of defined template descriptors:
 
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
index a4ad1270bffa..16110180545c 100644
--- a/security/integrity/ima/ima.h
+++ b/security/integrity/ima/ima.h
@@ -65,6 +65,8 @@ struct ima_event_data {
struct evm_ima_xattr_data *xattr_value;
int xattr_len;
const char *violation;
+   const void *buf;
+   int buf_len;
 };
 
 /* IMA template field data definition */
diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
index ea7d8cbf712f..83ca99d65e4b 100644
--- a/security/integrity/ima/ima_api.c
+++ b/security/integrity/ima/ima_api.c
@@ -140,7 +140,7 @@ void ima_add_violation(struct file *file, const unsigned 
char *filename,
struct ima_template_entry *entry;
struct inode *inode = file_inode(file);
struct ima_event_data event_data = {iint, file, filename, NULL, 0,
-   cause};
+   cause, NULL, 0};
int violation = 1;
int result;
 
@@ -296,7 +296,7 @@ void ima_store_measurement(struct integrity_iint_cache 
*iint,
struct inode *inode = file_inode(file);
struct ima_template_entry *entry;
struct ima_event_data event_data = {iint, file, filename, xattr_value,
-   xattr_len, NULL};
+   xattr_len, NULL, NULL, 0};
int violation = 0;
 
if (iint->measured_pcrs & (0x1 << pcr))
diff --git a/security/integrity/ima/ima_init.c 
b/security/integrity/ima/ima_init.c
index 993d0f1915ff..c8591406c0e2 100644
--- a/security/integrity/ima/ima_init.c
+++ b/security/integrity/ima/ima_init.c
@@ -50,7 +50,7 @@ static int __init ima_add_boot_aggregate(void)
struct ima_template_entry *entry;
struct integrity_iint_cache tmp_iint, *iint = _iint;
struct ima_event_data event_data = {iint, NULL, boot_aggregate_name,
-   NULL, 0, NULL};
+   NULL, 0, NULL, NULL, 0};
int result = -ENOMEM;
int violation = 0;
struct {
diff --git a/security/integrity/ima/ima_main.c 
b/security/integrity/ima/ima_main.c
index e4f301381ffb..9308d664f074 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -641,6 +641,8 @@ static void process_buffer_measurement(const void *buf, int 
size,
memset(, 0, sizeof(hash));
 
event_data.filename = eventname;
+   event_data.buf = buf;
+   event_data.buf_len = size;
 
iint->ima_hash = 
iint->ima_hash->algo = ima_hash_algo;
diff --git a/security/integrity/ima/ima_template.c 
b/security/integrity/ima/ima_template.c
index e6e892f31cbd..8c40de18a0aa 100644
--- a/security/integrity/ima/ima_template.c
+++ b/security/integrity/ima/ima_template.c
@@ -43,6 +43,8 @@ static const struct ima_template_field supported_fields[] = {
 .field_show = ima_show_template_string},
{.field_id = "sig", .field_init = 

[PATCH v7 1/3] Add a new ima hook ima_kexec_cmdline to measure cmdline args

2019-06-06 Thread Prakhar Srivastava
This patch adds support in ima to measure kexec cmdline args
during soft reboot kexec_file_load.

- A new ima hook ima_kexec_cmdline is defined to be called by the
kexec code.
- A new function process_buffer_measurement is defined to measure
the buffer hash into the ima log.
- A new func policy KEXEC_CMDLINE is defined to control the
 measurement.[Suggested by Mimi]

Hash computation can be tested using
sudo cat /sys/kernel/security/integrity/ima/ascii_runtime_measurements | 
  grep  kexec-cmdline | cut -d' ' -f 6 | xxd -r -p | sha256sum

Signed-off-by: Prakhar Srivastava 
---
 Documentation/ABI/testing/ima_policy |  1 +
 include/linux/ima.h  |  2 +
 security/integrity/ima/ima.h |  1 +
 security/integrity/ima/ima_api.c |  1 +
 security/integrity/ima/ima_main.c| 77 
 security/integrity/ima/ima_policy.c  |  9 
 6 files changed, 91 insertions(+)

diff --git a/Documentation/ABI/testing/ima_policy 
b/Documentation/ABI/testing/ima_policy
index b383c1763610..fc376a323908 100644
--- a/Documentation/ABI/testing/ima_policy
+++ b/Documentation/ABI/testing/ima_policy
@@ -28,6 +28,7 @@ Description:
base:   func:= 
[BPRM_CHECK][MMAP_CHECK][CREDS_CHECK][FILE_CHECK][MODULE_CHECK]
[FIRMWARE_CHECK]
[KEXEC_KERNEL_CHECK] [KEXEC_INITRAMFS_CHECK]
+   [KEXEC_CMDLINE]
mask:= [[^]MAY_READ] [[^]MAY_WRITE] [[^]MAY_APPEND]
   [[^]MAY_EXEC]
fsmagic:= hex value
diff --git a/include/linux/ima.h b/include/linux/ima.h
index fd9f7cf4cdf5..b42f5a006042 100644
--- a/include/linux/ima.h
+++ b/include/linux/ima.h
@@ -26,6 +26,7 @@ extern int ima_read_file(struct file *file, enum 
kernel_read_file_id id);
 extern int ima_post_read_file(struct file *file, void *buf, loff_t size,
  enum kernel_read_file_id id);
 extern void ima_post_path_mknod(struct dentry *dentry);
+extern void ima_kexec_cmdline(const void *buf, int size);
 
 #ifdef CONFIG_IMA_KEXEC
 extern void ima_add_kexec_buffer(struct kimage *image);
@@ -92,6 +93,7 @@ static inline void ima_post_path_mknod(struct dentry *dentry)
return;
 }
 
+static inline void ima_kexec_cmdline(const void *buf, int size) {}
 #endif /* CONFIG_IMA */
 
 #ifndef CONFIG_IMA_KEXEC
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
index 18b48a6d0b80..a4ad1270bffa 100644
--- a/security/integrity/ima/ima.h
+++ b/security/integrity/ima/ima.h
@@ -185,6 +185,7 @@ static inline unsigned long ima_hash_key(u8 *digest)
hook(KEXEC_KERNEL_CHECK)\
hook(KEXEC_INITRAMFS_CHECK) \
hook(POLICY_CHECK)  \
+   hook(KEXEC_CMDLINE) \
hook(MAX_CHECK)
 #define __ima_hook_enumify(ENUM)   ENUM,
 
diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
index 78eb11c7ac07..ea7d8cbf712f 100644
--- a/security/integrity/ima/ima_api.c
+++ b/security/integrity/ima/ima_api.c
@@ -176,6 +176,7 @@ void ima_add_violation(struct file *file, const unsigned 
char *filename,
  * subj=, obj=, type=, func=, mask=, fsmagic=
  * subj,obj, and type: are LSM specific.
  * func: FILE_CHECK | BPRM_CHECK | CREDS_CHECK | MMAP_CHECK | MODULE_CHECK
+ * | KEXEC_CMDLINE
  * mask: contains the permission mask
  * fsmagic: hex value
  *
diff --git a/security/integrity/ima/ima_main.c 
b/security/integrity/ima/ima_main.c
index af341a80118f..e4f301381ffb 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -605,6 +605,83 @@ int ima_load_data(enum kernel_load_data_id id)
return 0;
 }
 
+/*
+ * process_buffer_measurement - Measure the buffer to ima log.
+ * @buf: pointer to the buffer that needs to be added to the log.
+ * @size: size of buffer(in bytes).
+ * @eventname: event name to be used for the buffer entry.
+ * @cred: a pointer to a credentials structure for user validation.
+ * @secid: the secid of the task to be validated.
+ *
+ * Based on policy, the buffer is measured into the ima log.
+ */
+static void process_buffer_measurement(const void *buf, int size,
+   const char *eventname, const struct cred *cred,
+   u32 secid)
+{
+   int ret = 0;
+   struct ima_template_entry *entry = NULL;
+   struct integrity_iint_cache tmp_iint, *iint = _iint;
+   struct ima_event_data event_data = {.iint = iint};
+   struct ima_template_desc *template_desc = NULL;
+   struct {
+   struct ima_digest_data hdr;
+   char digest[IMA_MAX_DIGEST_SIZE];
+   } hash;
+   int violation = 0;
+   int pcr = CONFIG_IMA_MEASURE_PCR_IDX;
+   int action = 0;
+
+   action = ima_get_action(NULL, cred, secid, 0, KEXEC_CMDLINE, ,
+   _desc);
+   if (!(action & 

[PATCH v7 3/3] call ima_kexec_cmdline to measure the cmdline args

2019-06-06 Thread Prakhar Srivastava
During soft reboot(kexec_file_load) boot cmdline args
are not measured.Thus the new kernel on load boots with
an assumption of cold reboot.

This patch makes a call to the ima hook ima_kexec_cmdline,
added in "Add a new ima hook ima_kexec_cmdline to measure
cmdline args"
to measure the boot cmdline args into the ima log.

- call ima_kexec_cmdline from kexec_file_load.
- move the call ima_add_kexec_buffer after the cmdline
args have been measured.

Signed-off-by: Prakhar Srivastava 
---
 kernel/kexec_file.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index 072b6ee55e3f..ed4727586fc3 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -198,9 +198,6 @@ kimage_file_prepare_segments(struct kimage *image, int 
kernel_fd, int initrd_fd,
return ret;
image->kernel_buf_len = size;
 
-   /* IMA needs to pass the measurement list to the next kernel. */
-   ima_add_kexec_buffer(image);
-
/* Call arch image probe handlers */
ret = arch_kexec_kernel_image_probe(image, image->kernel_buf,
image->kernel_buf_len);
@@ -241,8 +238,13 @@ kimage_file_prepare_segments(struct kimage *image, int 
kernel_fd, int initrd_fd,
ret = -EINVAL;
goto out;
}
+
+   ima_kexec_cmdline(image->cmdline_buf, image->cmdline_buf_len - 
1);
}
 
+   /* IMA needs to pass the measurement list to the next kernel. */
+   ima_add_kexec_buffer(image);
+
/* Call arch image load handlers */
ldata = arch_kexec_kernel_image_load(image);
 
-- 
2.19.1



Re: linux-next: Fixes tag needs some work in the imx-mxs tree

2019-06-06 Thread Shawn Guo
On Fri, Jun 07, 2019 at 07:46:52AM +1000, Stephen Rothwell wrote:
> Hi all,
> 
> In commit
> 
>   f6a8ff82ce68 ("clk: imx: imx8mm: correct audio_pll2_clk to audio_pll2_out")
> 
> Fixes tag
> 
>   Fixes: ba5625c3e27 ("clk: imx: Add clock driver support for imx8mm")
> 
> has these problem(s):
> 
>   - SHA1 should be at least 12 digits long
> Can be fixed by setting core.abbrev to 12 (or more) or (for git v2.11
> or later) just making sure it is not set (or set to "auto").

Hi Stephen,

Thanks for reporting.  I just got it fixed, will be more careful about
that in the future.

@Peng, please check your git configuration as suggested above, thanks.

Shawn


RE: [PATCH net-next v6 2/5] net: stmmac: introducing support for DWC xPCS logics

2019-06-06 Thread Ong, Boon Leong
>-Original Message-
>From: Jose Abreu [mailto:jose.ab...@synopsys.com]
>Sent: Wednesday, June 5, 2019 9:13 PM
>To: Florian Fainelli ; Voon, Weifeng
>; David S. Miller ;
>Maxime Coquelin ; Russell King
>
>Cc: net...@vger.kernel.org; linux-kernel@vger.kernel.org; Giuseppe
>Cavallaro ; Andrew Lunn ;
>Alexandre Torgue ; biao huang
>; Ong, Boon Leong
>; Kweh, Hock Leong
>
>Subject: RE: [PATCH net-next v6 2/5] net: stmmac: introducing support for
>DWC xPCS logics
>
>From: Florian Fainelli 
>
>> +Russell,
>>
>> On 6/4/2019 11:58 AM, Voon Weifeng wrote:
>> > From: Ong Boon Leong 
>> >
>> > xPCS is DWC Ethernet Physical Coding Sublayer that may be integrated
>> > into a GbE controller that uses DWC EQoS MAC controller. An example of
>> > HW configuration is shown below:-
>> >
>> >   <-GBE Controller-->|<--External PHY chip-->
>> >
>> >   +--+ +++---+   +--+
>> >   |   EQoS   | <-GMII->| DW |<-->|PHY| <-- SGMII --> | External GbE |
>> >   |   MAC| |xPCS||IF |   | PHY Chip |
>> >   +--+ +++---+   +--+
>> >  ^   ^  ^
>> >  |   |  |
>> >  +-MDIO-+
>> >
>> > xPCS is a Clause-45 MDIO Manageable Device (MMD) and we need a way
>to
>> > differentiate it from external PHY chip that is discovered over MDIO.
>> > Therefore, xpcs_phy_addr is introduced in stmmac platform data
>> > (plat_stmmacenet_data) for differentiating xPCS from 'phy_addr' that
>> > belongs to external PHY.
>>
>> Assuming this DW xPCS can be found with designs other than STMMAC
>would
>> not it make sense to model this as some kind of PHY/MDIO bridge? A
>> little bit like what drivers/net/phy/xilinx_gmii2rgmii.c tries to do?
>
>Yes, DW XPCS is a separate IP that can be sold without the MAC.

Hi Florian, thanks for pointing out the PHY driver for GMII to RGMII converter
implementation. It seems like community would like dwxpcs to take the
converter phy driver direction. 

We would like to check with community what is the MAC controller that is
using above PHY driver so that we can dig deeper into the PHY & MAC driver
architecture. We would like to map the existing usage of dwxpcs.c in 3/5 of
this series is architecturally ready for PHY driver framework or new APIs
would need to be defined. 

Thanks
Boon Leong


Re: [PATCH bpf-next] bpf: allow CGROUP_SKB programs to use bpf_skb_cgroup_id() helper

2019-06-06 Thread Roman Gushchin
On Fri, Jun 07, 2019 at 02:00:20AM +0200, Daniel Borkmann wrote:
> On 06/06/2019 10:30 PM, Roman Gushchin wrote:
> > Currently bpf_skb_cgroup_id() is not supported for CGROUP_SKB
> > programs. An attempt to load such a program generates an error
> > like this:
> > 
> > libbpf:
> > 0: (b7) r6 = 0
> > ...
> > 9: (85) call bpf_skb_cgroup_id#79
> > unknown func bpf_skb_cgroup_id#79
> > 
> > There are no particular reasons for denying it, and we have some
> > use cases where it might be useful.
> > 
> > So let's add it to the list of allowed helpers.
> > 
> > Signed-off-by: Roman Gushchin 
> > Cc: Yonghong Song 
> > Cc: Alexei Starovoitov 
> > Cc: Daniel Borkmann 
> 
> Applied, thanks!

Thank you, Daniel!


Re: [PATCH bpf-next] bpf: allow CGROUP_SKB programs to use bpf_skb_cgroup_id() helper

2019-06-06 Thread Daniel Borkmann
On 06/06/2019 10:30 PM, Roman Gushchin wrote:
> Currently bpf_skb_cgroup_id() is not supported for CGROUP_SKB
> programs. An attempt to load such a program generates an error
> like this:
> 
> libbpf:
> 0: (b7) r6 = 0
> ...
> 9: (85) call bpf_skb_cgroup_id#79
> unknown func bpf_skb_cgroup_id#79
> 
> There are no particular reasons for denying it, and we have some
> use cases where it might be useful.
> 
> So let's add it to the list of allowed helpers.
> 
> Signed-off-by: Roman Gushchin 
> Cc: Yonghong Song 
> Cc: Alexei Starovoitov 
> Cc: Daniel Borkmann 

Applied, thanks!


Re: Getting empty callchain from perf_callchain_kernel()

2019-06-06 Thread Josh Poimboeuf
On Thu, Jun 06, 2019 at 04:04:48PM +, Song Liu wrote:
> >> Here's a tentative BPF fix for the JIT frame pointer issue.  It was a
> >> bit harder than I expected.  Encoding r12 as a base register requires a
> >> SIB byte, so I had to add support for encoding that.  I also simplified
> >> the prologue to resemble a GCC prologue, which decreases the prologue
> >> size quite a bit.
> >> 
> >> Next week I can work on the corresponding ORC change.  Then I can clean
> >> all the patches up and submit them properly.
> 
> Hi Josh, 
> 
> Have you got luck fixing the ORC side?

Sorry, I've been traveling this week and I haven't had a chance to work
on it.  It's at the top of my TODO list for next week.

-- 
Josh


[PATCH linux-next] mpls: don't build sysctl related code when sysctl is disabled

2019-06-06 Thread Matteo Croce
Some sysctl related code and data structures are never referenced
when CONFIG_SYSCTL is not set.
While this is usually harmless, it produces a build failure since sysctl
shared variables exist, due to missing sysctl_vals symbol:

ld: net/mpls/af_mpls.o: in function `mpls_platform_labels':
af_mpls.c:(.text+0x162a): undefined reference to `sysctl_vals'
ld: net/mpls/af_mpls.o:(.rodata+0x830): undefined reference to `sysctl_vals'
ld: net/mpls/af_mpls.o:(.rodata+0x838): undefined reference to `sysctl_vals'
ld: net/mpls/af_mpls.o:(.rodata+0x870): undefined reference to `sysctl_vals'

Fix this by moving all sysctl related code under #ifdef CONFIG_SYSCTL

Reported-by: Randy Dunlap 
Signed-off-by: Matteo Croce 
---
 net/mpls/af_mpls.c | 389 -
 1 file changed, 204 insertions(+), 185 deletions(-)

diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index c312741df2ce..5aacbf129ec5 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -37,9 +37,6 @@
 
 #define MPLS_NEIGH_TABLE_UNSPEC (NEIGH_LINK_TABLE + 1)
 
-static int label_limit = (1 << 20) - 1;
-static int ttl_max = 255;
-
 #if IS_ENABLED(CONFIG_NET_IP_TUNNEL)
 static size_t ipgre_mpls_encap_hlen(struct ip_tunnel_encap *e)
 {
@@ -1179,31 +1176,6 @@ static int mpls_netconf_msgsize_devconf(int type)
return size;
 }
 
-static void mpls_netconf_notify_devconf(struct net *net, int event,
-   int type, struct mpls_dev *mdev)
-{
-   struct sk_buff *skb;
-   int err = -ENOBUFS;
-
-   skb = nlmsg_new(mpls_netconf_msgsize_devconf(type), GFP_KERNEL);
-   if (!skb)
-   goto errout;
-
-   err = mpls_netconf_fill_devconf(skb, mdev, 0, 0, event, 0, type);
-   if (err < 0) {
-   /* -EMSGSIZE implies BUG in mpls_netconf_msgsize_devconf() */
-   WARN_ON(err == -EMSGSIZE);
-   kfree_skb(skb);
-   goto errout;
-   }
-
-   rtnl_notify(skb, net, 0, RTNLGRP_MPLS_NETCONF, NULL, GFP_KERNEL);
-   return;
-errout:
-   if (err < 0)
-   rtnl_set_sk_err(net, RTNLGRP_MPLS_NETCONF, err);
-}
-
 static const struct nla_policy devconf_mpls_policy[NETCONFA_MAX + 1] = {
[NETCONFA_IFINDEX]  = { .len = sizeof(int) },
 };
@@ -1362,6 +1334,36 @@ static int mpls_netconf_dump_devconf(struct sk_buff *skb,
 #define MPLS_PERDEV_SYSCTL_OFFSET(field)   \
(&((struct mpls_dev *)0)->field)
 
+#ifdef CONFIG_SYSCTL
+
+static int label_limit = (1 << 20) - 1;
+static int ttl_max = 255;
+
+static void mpls_netconf_notify_devconf(struct net *net, int event,
+   int type, struct mpls_dev *mdev)
+{
+   struct sk_buff *skb;
+   int err = -ENOBUFS;
+
+   skb = nlmsg_new(mpls_netconf_msgsize_devconf(type), GFP_KERNEL);
+   if (!skb)
+   goto errout;
+
+   err = mpls_netconf_fill_devconf(skb, mdev, 0, 0, event, 0, type);
+   if (err < 0) {
+   /* -EMSGSIZE implies BUG in mpls_netconf_msgsize_devconf() */
+   WARN_ON(err == -EMSGSIZE);
+   kfree_skb(skb);
+   goto errout;
+   }
+
+   rtnl_notify(skb, net, 0, RTNLGRP_MPLS_NETCONF, NULL, GFP_KERNEL);
+   return;
+errout:
+   if (err < 0)
+   rtnl_set_sk_err(net, RTNLGRP_MPLS_NETCONF, err);
+}
+
 static int mpls_conf_proc(struct ctl_table *ctl, int write,
  void __user *buffer,
  size_t *lenp, loff_t *ppos)
@@ -1445,6 +1447,173 @@ static void mpls_dev_sysctl_unregister(struct 
net_device *dev,
mpls_netconf_notify_devconf(net, RTM_DELNETCONF, 0, mdev);
 }
 
+static int resize_platform_label_table(struct net *net, size_t limit)
+{
+   size_t size = sizeof(struct mpls_route *) * limit;
+   size_t old_limit;
+   size_t cp_size;
+   struct mpls_route __rcu **labels = NULL, **old;
+   struct mpls_route *rt0 = NULL, *rt2 = NULL;
+   unsigned index;
+
+   if (size) {
+   labels = kvzalloc(size, GFP_KERNEL);
+   if (!labels)
+   goto nolabels;
+   }
+
+   /* In case the predefined labels need to be populated */
+   if (limit > MPLS_LABEL_IPV4NULL) {
+   struct net_device *lo = net->loopback_dev;
+   rt0 = mpls_rt_alloc(1, lo->addr_len, 0);
+   if (IS_ERR(rt0))
+   goto nort0;
+   RCU_INIT_POINTER(rt0->rt_nh->nh_dev, lo);
+   rt0->rt_protocol = RTPROT_KERNEL;
+   rt0->rt_payload_type = MPT_IPV4;
+   rt0->rt_ttl_propagate = MPLS_TTL_PROP_DEFAULT;
+   rt0->rt_nh->nh_via_table = NEIGH_LINK_TABLE;
+   rt0->rt_nh->nh_via_alen = lo->addr_len;
+   memcpy(__mpls_nh_via(rt0, rt0->rt_nh), lo->dev_addr,
+  lo->addr_len);
+   }
+   if (limit > MPLS_LABEL_IPV6NULL) {
+   struct net_device *lo = 

Re: [RFC]: Convention for naming syscall revisions

2019-06-06 Thread Theodore Ts'o
On Thu, Jun 06, 2019 at 05:42:25PM +0200, Christian Brauner wrote:
> Hey everyone,
> 
> I hope this is not going to start a trash fire.
> 
> While working on a new clone version I tried to find out what the
> current naming conventions for syscall revisions is. I was told and
> seemed to be able to confirm through the syscall list that revisions of
> syscalls are for the most part (for examples see [1]) named after the
> number of arguments and not for the number of revisions. But some also
> seem to escape that logic (e.g. clone2).

There are also examples which show that it's a revision number:

  preadv2, pwritev2, mlock2, sync_file_range2

immediately come to mind.  It's also important to note that in some
cases, we do something very different (look aht the stat and fstat
variants), and that in some cases the number of parameters for a
system call vary between architectures (because of system call
argument passing limitations), and this gets papered over by glibc.

So we can define what the historical pattern, but there might be a big
difference between what might make sense as an internal naming
convention, and the names that we want to expose to userspace
application programmers --- especially if the number of arguments at
the syscall level might be different (on some architectures) than at
the C library level.

- Ted


[PATCH] arm64: Fix comment after #endif

2019-06-06 Thread Odin Ugedal
The config value used in the if was changed in
b433dce056d3814dc4b33e5a8a533d6401ffcfb0, but the comment on the
corresponding end was not changed.

Signed-off-by: Odin Ugedal 
---
 arch/arm64/mm/mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index a1bfc4413982..7babf9728e9e 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -776,7 +776,7 @@ int __meminit vmemmap_populate(unsigned long start, 
unsigned long end, int node,
 
return 0;
 }
-#endif /* CONFIG_ARM64_64K_PAGES */
+#endif /* !ARM64_SWAPPER_USES_SECTION_MAPS */
 void vmemmap_free(unsigned long start, unsigned long end,
struct vmem_altmap *altmap)
 {
-- 
2.21.0



Re: [RFC PATCH] kbuild: Add option to generate a Compilation Database

2019-06-06 Thread Nick Desaulniers
On Thu, Jun 6, 2019 at 1:54 PM Tom Roeder  wrote:
>
> On Thu, Jun 06, 2019 at 02:30:03PM -0600, Raul E Rangel wrote:
> > Clang tooling requires a compilation database to figure out the build
> > options for each file. This enables tools like clang-tidy and
> > clang-check.
> >
> > See https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html for more
> > information.

I'm also super happy to see this!
https://nickdesaulniers.github.io/blog/2017/05/31/running-clang-tidy-on-the-linux-kernel/
I don't know enough about GNU Make/Kbuild to answer the questions, but
hopefully Masahiro can help there.

> I'm glad to see someone adding this to the Makefile directly. I added
> scripts/gen_compile_commands.py in b302046 (in Dec 2018) when I was

Heh, cool.  I had a script that basically did this; we recently
dropped it from the Android trees when doing an audit of out of tree
patches.

> working on using clang-check to look for bugs in KVM. That script

I'm very interested in this work; my summer intern is looking into
static analyses of the Linux kernel.  Can you maybe reach out to me
off thread to tell me more about what you found (or didn't)?

> > Normally cmake is used to generate the compilation database, but the
> > linux kernel uses make. Another option is using
> > [BEAR](https://github.com/rizsotto/Bear) which instruments
> > exec to find clang invocations and generate the database that way.

It's probably possible to get this to work w/ GCC if the additional
dependency of bear exists on the host's system (and may reduce the
number of implementations).  Downside is the additional host
dependency.

Sounds like it may also be possible to just run
scripts/gen_compile_commands.py at build time if this config is
enabled?

Maybe a comparison of the output of Tom's script and your patch might
reveal if one approach is incomplete?
-- 
Thanks,
~Nick Desaulniers


Re: [PATCH 2/2] ARM: dts: rockchip: Configure BT_HOST_WAKE as wake-up signal on veyron

2019-06-06 Thread Doug Anderson
Hi,

On Thu, Jun 6, 2019 at 10:56 AM Matthias Kaehlcke  wrote:
>
> On Thu, Jun 06, 2019 at 12:46:03PM +0200, Heiko Stuebner wrote:
> > Am Mittwoch, 5. Juni 2019, 23:52:00 CEST schrieb Heiko Stübner:
> > > Am Mittwoch, 5. Juni 2019, 23:24:27 CEST schrieb Matthias Kaehlcke:
> > > > On Wed, Jun 05, 2019 at 11:11:12PM +0200, Heiko Stübner wrote:
> > > > > Am Mittwoch, 5. Juni 2019, 22:43:20 CEST schrieb Matthias Kaehlcke:
> > > > > > This enables wake up on Bluetooth activity when the device is
> > > > > > suspended. The BT_HOST_WAKE signal is only connected on devices
> > > > > > with BT module that are connected through UART.
> > > > > >
> > > > > > Signed-off-by: Douglas Anderson 
> > > > > > Signed-off-by: Matthias Kaehlcke 
> > > > >
> > > > > Housekeeping question, with the two Signed-off-by lines, is Doug the
> > > > > original author, or was this Co-developer-by?
> > > >
> > > > Good question, it's derived from Doug's patch for CrOS 3.14 and
> > > > https://crrev.com/c/1575556 also from Doug. Let's say I did the
> > > > porting to upstream, but I'm pretty sure Doug spent more time on it.
> > > >
> > > > Maybe I should resend it with Doug as author and include the original
> > > > commit message, which has more information.
> > >
> > > It's just that the first Signed-off should be from the original author.
> > > (And the sender the second)
> > > In the co-developed-by case (see Kernel documentation) the order
> > > doesn't matter.
> >
> > Holding off on this patch till we could clarify the authorship.
>
> I'd say let's attribute the authorship to Doug. FTR, the original
> downstream Chrome OS patch is https://crrev.com/c/278190.
>
> Not sure if the information in the commit message of the original
> patch is relevant for the upstream version, in the end it seems LPM
> was never implemented, so it should be sufficient to say what is
> actually done today.
>
> In summary, I propose to take the patch with the current commit
> message, with Doug as the author. Heiko, can you change the authorship
> or should I send a new version?
>
> Doug if you have objections or want updates in the commit message
> (yours tend to be more verbose ;-), holler.

It's fine with me.

-Doug


Re: [PATCH 2/2] ARM: dts: rockchip: Configure BT_HOST_WAKE as wake-up signal on veyron

2019-06-06 Thread Doug Anderson
Hi,

On Wed, Jun 5, 2019 at 1:43 PM Matthias Kaehlcke  wrote:
>
> This enables wake up on Bluetooth activity when the device is
> suspended. The BT_HOST_WAKE signal is only connected on devices
> with BT module that are connected through UART.
>
> Signed-off-by: Douglas Anderson 
> Signed-off-by: Matthias Kaehlcke 
> ---
>  arch/arm/boot/dts/rk3288-veyron.dtsi | 29 
>  1 file changed, 29 insertions(+)
>
> diff --git a/arch/arm/boot/dts/rk3288-veyron.dtsi 
> b/arch/arm/boot/dts/rk3288-veyron.dtsi
> index cc4c3595f145..145cac7c0847 100644
> --- a/arch/arm/boot/dts/rk3288-veyron.dtsi
> +++ b/arch/arm/boot/dts/rk3288-veyron.dtsi
> @@ -23,6 +23,31 @@
> reg = <0x0 0x0 0x0 0x8000>;
> };
>
> +   bt_activity: bt-activity {
> +   compatible = "gpio-keys";
> +   pinctrl-names = "default";
> +   pinctrl-0 = <_host_wake>;
> +
> +   /*
> +* HACK: until we have an LPM driver, we'll use an
> +* ugly GPIO key to allow Bluetooth to wake from S3.
> +* This is expected to only be used by BT modules that
> +* use UART for comms.  For BT modules that talk over
> +* SDIO we should use a wakeup mechanism related to SDIO.
> +*
> +* Use KEY_RESERVED here since that will work as a wakeup but
> +* doesn't get reported to higher levels (so doesn't confuse
> +* Chrome).
> +*/
> +   bt-wake {
> +   label = "BT Wakeup";
> +   gpios = < RK_PD7 GPIO_ACTIVE_HIGH>;
> +   linux,code = ;
> +   wakeup-source;
> +   };
> +
> +   };
> +
> power_button: power-button {
> compatible = "gpio-keys";
> pinctrl-names = "default";
> @@ -555,6 +580,10 @@
> rockchip,pins = <4 RK_PD5 RK_FUNC_GPIO 
> _pull_none>;
> };
>
> +   bt_host_wake: bt-host-wake {
> +   rockchip,pins = <4 31 RK_FUNC_GPIO _pull_down>;

nit: s/31/RK_PD7

Other than that, feel free to add my Reviewed-by assuming that this
isn't too hacky for mainline to accept while we wait for someone to
come up with a better solution.

-Doug


Re: [PATCH v4 1/6] dt-bindings: clock: Document external clocks for MSM8998 gcc

2019-06-06 Thread Stephen Boyd
Quoting Jeffrey Hugo (2019-05-21 07:46:33)
> The global clock controller on MSM8998 can consume a number of external
> clocks.  Document them.
> 
> Signed-off-by: Jeffrey Hugo 
> Reviewed-by: Bjorn Andersson 
> Reviewed-by: Rob Herring 
> ---
>  Documentation/devicetree/bindings/clock/qcom,gcc.txt | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/clock/qcom,gcc.txt 
> b/Documentation/devicetree/bindings/clock/qcom,gcc.txt
> index 8661c3c..7d45323 100644
> --- a/Documentation/devicetree/bindings/clock/qcom,gcc.txt
> +++ b/Documentation/devicetree/bindings/clock/qcom,gcc.txt
> @@ -28,6 +28,16 @@ Required properties :
>  - #clock-cells : shall contain 1
>  - #reset-cells : shall contain 1
>  
> +For MSM8998 only:

It would be nice to get the rest of the SoCs supported by this binding
to start listing clocks. But this is OK for now.


Re: [PATCH 1/3] dt-bindings: clock: Document gpucc for msm8998

2019-06-06 Thread Stephen Boyd
Quoting Jeffrey Hugo (2019-05-28 09:47:40)
> The GPU for msm8998 has its own clock controller.  Document it.
> 
> Signed-off-by: Jeffrey Hugo 
> ---

Applied to clk-next



[PATCH 1/1] irqchip/gic: Add support for Amazon Graviton variant of GICv3+GICv2m

2019-06-06 Thread Zeev Zilberman
The patch adds support for Amazon Graviton custom variant of GICv2m, where
hw irq is encoded using the MSI message address, as opposed to standard
GICv2m, where hw irq is encoded in the MSI message data.
In addition, the Graviton flavor of GICv2m is used along GICv3 (and not
GICv2).

Signed-off-by: Zeev Zilberman 
Signed-off-by: Benjamin Herrenschmidt 
---
diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index 3c77ab6..eeed19f 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -56,6 +56,7 @@
 
 /* List of flags for specific v2m implementation */
 #define GICV2M_NEEDS_SPI_OFFSET0x0001
+#define GICV2M_GRAVITON_ADDRESS_ONLY   0x0002
 
 static LIST_HEAD(v2m_nodes);
 static DEFINE_SPINLOCK(v2m_lock);
@@ -98,15 +99,26 @@ static struct msi_domain_info gicv2m_msi_domain_info = {
.chip   = _msi_irq_chip,
 };
 
+static phys_addr_t gicv2m_get_msi_addr(struct v2m_data *v2m, int hwirq)
+{
+   if (v2m->flags & GICV2M_GRAVITON_ADDRESS_ONLY)
+   return v2m->res.start | ((hwirq - 32) << 3);
+   else
+   return v2m->res.start + V2M_MSI_SETSPI_NS;
+}
+
 static void gicv2m_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
 {
struct v2m_data *v2m = irq_data_get_irq_chip_data(data);
-   phys_addr_t addr = v2m->res.start + V2M_MSI_SETSPI_NS;
+   phys_addr_t addr = gicv2m_get_msi_addr(v2m, data->hwirq);
 
msg->address_hi = upper_32_bits(addr);
msg->address_lo = lower_32_bits(addr);
-   msg->data = data->hwirq;
 
+   if (v2m->flags & GICV2M_GRAVITON_ADDRESS_ONLY)
+   msg->data = 0;
+   else
+   msg->data = data->hwirq;
if (v2m->flags & GICV2M_NEEDS_SPI_OFFSET)
msg->data -= v2m->spi_offset;
 
@@ -188,7 +200,7 @@ static int gicv2m_irq_domain_alloc(struct irq_domain 
*domain, unsigned int virq,
hwirq = v2m->spi_start + offset;
 
err = iommu_dma_prepare_msi(info->desc,
-   v2m->res.start + V2M_MSI_SETSPI_NS);
+   gicv2m_get_msi_addr(v2m, hwirq));
if (err)
return err;
 
@@ -307,7 +319,7 @@ static int gicv2m_allocate_domains(struct irq_domain 
*parent)
 
 static int __init gicv2m_init_one(struct fwnode_handle *fwnode,
  u32 spi_start, u32 nr_spis,
- struct resource *res)
+ struct resource *res, u32 flags)
 {
int ret;
struct v2m_data *v2m;
@@ -320,6 +332,7 @@ static int __init gicv2m_init_one(struct fwnode_handle 
*fwnode,
 
INIT_LIST_HEAD(>entry);
v2m->fwnode = fwnode;
+   v2m->flags = flags;
 
memcpy(>res, res, sizeof(struct resource));
 
@@ -334,7 +347,14 @@ static int __init gicv2m_init_one(struct fwnode_handle 
*fwnode,
v2m->spi_start = spi_start;
v2m->nr_spis = nr_spis;
} else {
-   u32 typer = readl_relaxed(v2m->base + V2M_MSI_TYPER);
+   u32 typer;
+
+   /* Graviton should always have explicit spi_start/nr_spis */
+   if (v2m->flags & GICV2M_GRAVITON_ADDRESS_ONLY) {
+   ret = -EINVAL;
+   goto err_iounmap;
+   }
+   typer = readl_relaxed(v2m->base + V2M_MSI_TYPER);
 
v2m->spi_start = V2M_MSI_TYPER_BASE_SPI(typer);
v2m->nr_spis = V2M_MSI_TYPER_NUM_SPI(typer);
@@ -355,18 +375,21 @@ static int __init gicv2m_init_one(struct fwnode_handle 
*fwnode,
 *
 * Broadom NS2 GICv2m implementation has an erratum where the MSI data
 * is 'spi_number - 32'
+*
+* Reading that register fails on the Graviton implementation
 */
-   switch (readl_relaxed(v2m->base + V2M_MSI_IIDR)) {
-   case XGENE_GICV2M_MSI_IIDR:
-   v2m->flags |= GICV2M_NEEDS_SPI_OFFSET;
-   v2m->spi_offset = v2m->spi_start;
-   break;
-   case BCM_NS2_GICV2M_MSI_IIDR:
-   v2m->flags |= GICV2M_NEEDS_SPI_OFFSET;
-   v2m->spi_offset = 32;
-   break;
+   if (!(v2m->flags & GICV2M_GRAVITON_ADDRESS_ONLY)) {
+   switch (readl_relaxed(v2m->base + V2M_MSI_IIDR)) {
+   case XGENE_GICV2M_MSI_IIDR:
+   v2m->flags |= GICV2M_NEEDS_SPI_OFFSET;
+   v2m->spi_offset = v2m->spi_start;
+   break;
+   case BCM_NS2_GICV2M_MSI_IIDR:
+   v2m->flags |= GICV2M_NEEDS_SPI_OFFSET;
+   v2m->spi_offset = 32;
+   break;
+   }
}
-
v2m->bm = kcalloc(BITS_TO_LONGS(v2m->nr_spis), sizeof(long),
  GFP_KERNEL);
if (!v2m->bm) {
@@ -419,7 +442,8 @@ static int __init gicv2m_of_init(struct fwnode_handle 
*parent_handle,

Re: [PATCH v3 0/5] arch: riscv: add board and SoC DT file support

2019-06-06 Thread Atish Patra

On 6/5/19 10:37 AM, Kevin Hilman wrote:

Hi Paul,

Paul Walmsley  writes:


Add support for building flattened DT files from DT source files under
arch/riscv/boot/dts.  Follow existing kernel precedent from other SoC
architectures.  Start our board support by adding initial support for
the SiFive FU540 SoC and the first development board that uses it, the
SiFive HiFive Unleashed A00.

This third version of the patch set adds I2C data for the chip,
incorporates all remaining changes that riscv-pk was making
automatically, and addresses a comment from Rob Herring
.

Boot-tested on v5.2-rc1 on a HiFive Unleashed A00 board, using the
BBL and open-source FSBL, with modifications to pass in the DTB
file generated by these patches.


Tested this series on top of v5.2-rc3 on HiFive Unleashed board using
OpenSBI + mainline u-boot (master branch as of today).

Tested-by: Kevin Hilman 


This patch series can be found, along with the PRCI patch set
and the DT macro prerequisite patch, at:

https://github.com/sifive/riscv-linux/tree/dev/paulw/dts-v5.2-rc1


nit: I only see this series in that branch, not any of the prerequisite
patches you mentioned, which made me assume I could this series alone on
top of v5.2-rc3, which worked just fine.



I tried only this series on top of v5.2-rc3. Kernel boots file with DT 
updated via U-Boot. But networking didn't come up.


Do you have networking up after the boot? If yes, can you please share 
the config.



Kevin

___
linux-riscv mailing list
linux-ri...@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv




--
Regards,
Atish


Re: general protection fault in ip6_dst_lookup_tail (2)

2019-06-06 Thread syzbot

syzbot has found a reproducer for the following crash on:

HEAD commit:07c3bbdb samples: bpf: print a warning about headers_install
git tree:   bpf-next
console output: https://syzkaller.appspot.com/x/log.txt?x=14424e2ea0
kernel config:  https://syzkaller.appspot.com/x/.config?x=b7b54c66298f8420
dashboard link: https://syzkaller.appspot.com/bug?extid=58d8f704b86e4e3fb4d3
compiler:   gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=117f50e1a0

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+58d8f704b86e4e3fb...@syzkaller.appspotmail.com

kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault:  [#1] PREEMPT SMP KASAN
CPU: 1 PID: 14003 Comm: syz-executor.4 Not tainted 5.2.0-rc2+ #14
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

RIP: 0010:ip6_route_get_saddr include/net/ip6_route.h:120 [inline]
RIP: 0010:ip6_dst_lookup_tail+0xf0e/0x1b30 net/ipv6/ip6_output.c:1032
Code: e6 07 e8 75 66 55 fb 48 85 db 0f 84 83 08 00 00 e8 67 66 55 fb 48 8d  
7b 7c 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48  
89 f8 83 e0 07 83 c0 03 38 d0 7c 08 84 d2 0f 85 07

RSP: 0018:888079027480 EFLAGS: 00010a07
RAX: dc00 RBX: ff8880990716c000 RCX: 
RDX: 1ff1101320e2d80f RSI: 861b3f59 RDI: ff8880990716c07c
RBP: 8880790275d8 R08: 8880855b43c0 R09: ed1015d26be8
R10: ed1015d26be7 R11: 8880ae935f3b R12: 888079027740
R13:  R14:  R15: 888079027768
FS:  7f7158009700() GS:8880ae90() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 7ffd85cf4eb8 CR3: a96aa000 CR4: 001406e0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 ip6_dst_lookup_flow+0xa8/0x220 net/ipv6/ip6_output.c:1155
 tcp_v6_connect+0xda3/0x20a0 net/ipv6/tcp_ipv6.c:282
 __inet_stream_connect+0x834/0xe90 net/ipv4/af_inet.c:659
 tcp_sendmsg_fastopen net/ipv4/tcp.c:1143 [inline]
 tcp_sendmsg_locked+0x2318/0x3920 net/ipv4/tcp.c:1185
 tcp_sendmsg+0x30/0x50 net/ipv4/tcp.c:1419
 inet_sendmsg+0x141/0x5d0 net/ipv4/af_inet.c:802
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:671
 ___sys_sendmsg+0x803/0x920 net/socket.c:2292
 __sys_sendmsg+0x105/0x1d0 net/socket.c:2330
 __do_sys_sendmsg net/socket.c:2339 [inline]
 __se_sys_sendmsg net/socket.c:2337 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2337
 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x459279
Code: fd b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 0f 83 cb b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00

RSP: 002b:7f7158008c78 EFLAGS: 0246 ORIG_RAX: 002e
RAX: ffda RBX: 0003 RCX: 00459279
RDX: 20008844 RSI: 2240 RDI: 0005
RBP: 0075bfc0 R08:  R09: 
R10:  R11: 0246 R12: 7f71580096d4
R13: 004c6ccc R14: 004dbb30 R15: 
Modules linked in:
---[ end trace c968f232eacd4c70 ]---
RIP: 0010:ip6_route_get_saddr include/net/ip6_route.h:120 [inline]
RIP: 0010:ip6_dst_lookup_tail+0xf0e/0x1b30 net/ipv6/ip6_output.c:1032
Code: e6 07 e8 75 66 55 fb 48 85 db 0f 84 83 08 00 00 e8 67 66 55 fb 48 8d  
7b 7c 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 14 02 48  
89 f8 83 e0 07 83 c0 03 38 d0 7c 08 84 d2 0f 85 07

RSP: 0018:888079027480 EFLAGS: 00010a07
RAX: dc00 RBX: ff8880990716c000 RCX: 
RDX: 1ff1101320e2d80f RSI: 861b3f59 RDI: ff8880990716c07c
RBP: 8880790275d8 R08: 8880855b43c0 R09: ed1015d26be8
R10: ed1015d26be7 R11: 8880ae935f3b R12: 888079027740
R13:  R14:  R15: 888079027768
FS:  7f7158009700() GS:8880ae80() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 015523b8 CR3: a96aa000 CR4: 001406f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400



linux-next: manual merge of the clk tree with Linus' tree

2019-06-06 Thread Stephen Rothwell
Hi all,

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

  drivers/clk/bcm/Kconfig

between commit:

  ec8f24b7faaf ("treewide: Add SPDX license identifier - Makefile/Kconfig")

from Linus' tree and commit:

  5d59f12a19e6 ("clk: bcm: Make BCM2835 clock drivers selectable")

from the clk tree.

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

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/clk/bcm/Kconfig
index 29ee7b776cd4,0eb281d597fc..
--- a/drivers/clk/bcm/Kconfig
+++ b/drivers/clk/bcm/Kconfig
@@@ -1,4 -1,12 +1,14 @@@
 +# SPDX-License-Identifier: GPL-2.0-only
++
+ config CLK_BCM2835
+   bool "Broadcom BCM2835 clock support"
+   depends on ARCH_BCM2835 || ARCH_BRCMSTB || COMPILE_TEST
+   depends on COMMON_CLK
+   default ARCH_BCM2835 || ARCH_BRCMSTB
+   help
+ Enable common clock framework support for Broadcom BCM2835
+ SoCs.
+ 
  config CLK_BCM_63XX
bool "Broadcom BCM63xx clock support"
depends on ARCH_BCM_63XX || COMPILE_TEST


pgpqbrRsZ0nMq.pgp
Description: OpenPGP digital signature


[PATCH v2] pinctrl: tb10x: Use flexible-array member and struct_size() helper

2019-06-06 Thread Gustavo A. R. Silva
Update the code to use a flexible array member instead of a pointer in
structure tb10x_pinctrl and use the struct_size() helper:

struct tb10x_pinctrl {
...
struct tb10x_of_pinfunc pinfuncs[];
};

Also, make use of the struct_size() helper instead of an open-coded
version in order to avoid any potential type mistakes.

So, replace the following form:

sizeof(struct tb10x_pinctrl) + of_get_child_count(of_node) * sizeof(struct 
tb10x_of_pinfunc)

with:

struct_size(state, pinfuncs, of_get_child_count(of_node))

This code was detected with the help of Coccinelle.

Reviewed-by: Kees Cook 
Signed-off-by: Gustavo A. R. Silva 
---
Changes in v2:
 - Update changelog text.
 - Add Kees' Reviewed-by tag.

 drivers/pinctrl/pinctrl-tb10x.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-tb10x.c b/drivers/pinctrl/pinctrl-tb10x.c
index 2e90a6d8fb3b..a32badf3f118 100644
--- a/drivers/pinctrl/pinctrl-tb10x.c
+++ b/drivers/pinctrl/pinctrl-tb10x.c
@@ -483,22 +483,22 @@ struct tb10x_port {
  * @base: register set base address.
  * @pingroups: pointer to an array of the pin groups this driver manages.
  * @pinfuncgrpcnt: number of pingroups in @pingroups.
- * @pinfuncs: pointer to an array of pin functions this driver manages.
  * @pinfuncnt: number of pin functions in @pinfuncs.
  * @mutex: mutex for exclusive access to a pin controller's state.
  * @ports: current state of each port.
  * @gpios: Indicates if a given pin is currently used as GPIO (1) or not (0).
+ * @pinfuncs: flexible array of pin functions this driver manages.
  */
 struct tb10x_pinctrl {
struct pinctrl_dev *pctl;
void *base;
const struct tb10x_pinfuncgrp *pingroups;
unsigned int pinfuncgrpcnt;
-   struct tb10x_of_pinfunc *pinfuncs;
unsigned int pinfuncnt;
struct mutex mutex;
struct tb10x_port ports[TB10X_PORTS];
DECLARE_BITMAP(gpios, MAX_PIN + 1);
+   struct tb10x_of_pinfunc pinfuncs[];
 };
 
 static inline void tb10x_pinctrl_set_config(struct tb10x_pinctrl *state,
@@ -771,15 +771,13 @@ static int tb10x_pinctrl_probe(struct platform_device 
*pdev)
return -EINVAL;
}
 
-   state = devm_kzalloc(dev, sizeof(struct tb10x_pinctrl) +
-   of_get_child_count(of_node)
-   * sizeof(struct tb10x_of_pinfunc),
-   GFP_KERNEL);
+   state = devm_kzalloc(dev, struct_size(state, pinfuncs,
+ of_get_child_count(of_node)),
+GFP_KERNEL);
if (!state)
return -ENOMEM;
 
platform_set_drvdata(pdev, state);
-   state->pinfuncs = (struct tb10x_of_pinfunc *)(state + 1);
mutex_init(>mutex);
 
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-- 
2.21.0



Re: [BUG 4.4.178] x86_64 compat mode futexes broken

2019-06-06 Thread Nathan Chancellor
On Thu, Jun 06, 2019 at 09:11:43PM +, Joe Korty wrote:
> Starting with 4.4.178, the LTP test
> 
>   pthread_cond_wait/2-3
> 
> when compiled on x86_64 with 'gcc -m32', started failing.  It generates this 
> log output:
> 
>   [16:18:38]Implementation supports the MONOTONIC CLOCK but option is 
> disabled in test.   
>   [16:18:38]Test starting
>   [16:18:38] Process-shared primitive will be tested
>   [16:18:38] Alternative clock for cond will be tested
>   [16:18:38]Test 2-3.c FAILED: The child did not own the mutex inside the 
> cleanup handler
> 

What is the exact build command + test case command? I'd like to
reproduce this myself.

> A git bisection between 4.4.177..178 shows that this commit is the culprit:
> 
>   Git-Commit: 79739ad2d0ac5787a15a1acf7caaf34cd95bbf3c
>   Author: Alistair Strachan 
>   Subject: [PATCH] x86: vdso: Use $LD instead of $CC to link
> 

Have you tested 4.4.180? There were two subsequent fixes to this patch
in 4.4:

485d15db01ca ("kbuild: simplify ld-option implementation")
07d35512e494 ("x86/vdso: Pass --eh-frame-hdr to the linker")

> And, indeed, when I back this patch out of 4.4.178 proper, the above test
> passes again.
> 
> Please consider backing this patch out of linux-4.4.y, and from master, and 
> from
> any other linux branch it has been backported to.
> 

So this is broken in mainline too?

> PS: In backing it out of 4.4.178, I first backed out
> 
>7c45b45fd6e928c9ce275c32f6fa98d317e6f5ee
>
> This is a follow-on vdso patch which collides with the
> patch we are interested in removing.  As it claims to be
> only removing redundant code, it probably should never
> have been backported in the first place.

While it is redundant for ld.bfd, it causes a build failure with the
release version of ld.lld:

https://github.com/ClangBuiltLinux/linux/issues/31

Cheers,
Nathan


Re: [PATCH v2 2/3] media: imx7-media-csi: add i.MX6UL support

2019-06-06 Thread Randy Dunlap
On 6/6/19 8:38 AM, Sébastien Szymanski wrote:
> i.MX7 and i.MX6UL/L have the same CSI controller. So add i.MX6UL/L support
> to imx7-media-csi driver.
> 
> Signed-off-by: Sébastien Szymanski 
> ---
> 
> Changes for v2:
>  - rebase on top of linuxtv/master
>  - mention i.MX6UL/L in header and Kconfig help text
>  - rename csi_type to csi_soc_id
> 
>  drivers/staging/media/imx/Kconfig  |  4 +-
>  drivers/staging/media/imx/imx7-media-csi.c | 62 --
>  2 files changed, 49 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/staging/media/imx/Kconfig 
> b/drivers/staging/media/imx/Kconfig
> index ad3d7df6bb3c..8b6dc42c39e0 100644
> --- a/drivers/staging/media/imx/Kconfig
> +++ b/drivers/staging/media/imx/Kconfig
> @@ -22,11 +22,11 @@ config VIDEO_IMX_CSI
> A video4linux camera sensor interface driver for i.MX5/6.
>  
>  config VIDEO_IMX7_CSI
> - tristate "i.MX7 Camera Sensor Interface driver"
> + tristate "i.MX6UL/L / i.MX7 Camera Sensor Interface driver"
>   depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C
>   default y

Hi,
I realize that this "default y" is not part of this patch set, but we have
pretty strong guidance that a driver should not default to 'y' unless it is
needed for a system to boot.  If this driver is optional, then please drop
the 2 occurrences of "default y" in this Kconfig file.

thanks.
>   help
> Enable support for video4linux camera sensor interface driver for
> -   i.MX7.
> +   i.MX6UL/L or i.MX7.
>  endmenu
>  endif


-- 
~Randy


linux-next: manual merge of the sunxi tree with the imx-xms tree

2019-06-06 Thread Stephen Rothwell
Hi all,

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

  arch/arm64/configs/defconfig

between commits:

  0a64ef2d28d1 ("arm64: defconfig: NVMEM_IMX_OCOTP=y for imx8m")
  c6b1ccce88ae ("defconfig: arm64: enable i.MX8 SCU octop driver")

from the imx-xms tree and commit:

  296bcfa05640 ("arm64: defconfig: add allwinner sid support")

from the sunxi tree.

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

-- 
Cheers,
Stephen Rothwell

diff --cc arch/arm64/configs/defconfig
index fa5752a950eb,0dc34e0d4cbc..
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@@ -426,8 -420,8 +426,9 @@@ CONFIG_UNIPHIER_THERMAL=
  CONFIG_WATCHDOG=y
  CONFIG_ARM_SP805_WATCHDOG=y
  CONFIG_S3C2410_WATCHDOG=y
+ CONFIG_SUNXI_WATCHDOG=m
  CONFIG_IMX2_WDT=y
 +CONFIG_IMX_SC_WDT=m
  CONFIG_MESON_GXBB_WATCHDOG=m
  CONFIG_MESON_WATCHDOG=m
  CONFIG_RENESAS_WDT=y
@@@ -757,8 -742,7 +758,9 @@@ CONFIG_PHY_TEGRA_XUSB=
  CONFIG_HISI_PMU=y
  CONFIG_QCOM_L2_PMU=y
  CONFIG_QCOM_L3_PMU=y
 +CONFIG_NVMEM_IMX_OCOTP=y
 +CONFIG_NVMEM_IMX_OCOTP_SCU=y
+ CONFIG_NVMEM_SUNXI_SID=y
  CONFIG_QCOM_QFPROM=y
  CONFIG_ROCKCHIP_EFUSE=y
  CONFIG_UNIPHIER_EFUSE=y


pgpj8toMtGB74.pgp
Description: OpenPGP digital signature


[RFC/RFT PATCH] Revert "ASoC: fsl_esai: ETDR and TX0~5 registers are non volatile"

2019-06-06 Thread Nicolin Chen
This reverts commit 8973112aa41b8ad956a5b47f2fe17bc2a5cf2645.

ETDR and TX0~5 are TX data registers. There are a couple of reasons
to revert the change:
1) Though ETDR and TX0~5 are not volatile but write-only registers,
   they should not be cached either. According to the definition of
   "volatile_reg", one should be put in the volatile list if it can
   not be cached.
2) When doing regcache_sync(), the operation may accidentally write
   some "dirty" data into these registers, in case that cached data
   happen to be different from the default ones. It may also result
   in a channel shift/swap situation since the number of write-via-
   sync operations at ETDR would unlikely match the channel number.

Note: this revert is not a complete revert as it keeps those macros
of registers remaining in the default value list while the original
commit also changed other entries in the list. And this patch isn't
very necessary to Cc stable tree since there has been always a FIFO
reset operation around the regcache_sync() call, even prior to this
reverted commit.

Signed-off-by: Nicolin Chen 
Cc: Shengjiu Wang 
---
Hi Mark,
In case there's no objection against the patch, I'd still like to
wait for a Tested-by from NXP folks before submitting it. Thanks!

 sound/soc/fsl/fsl_esai.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
index 10d2210c91ef..8f0a86335f73 100644
--- a/sound/soc/fsl/fsl_esai.c
+++ b/sound/soc/fsl/fsl_esai.c
@@ -652,16 +652,9 @@ static const struct snd_soc_component_driver 
fsl_esai_component = {
 };
 
 static const struct reg_default fsl_esai_reg_defaults[] = {
-   {REG_ESAI_ETDR,  0x},
{REG_ESAI_ECR,   0x},
{REG_ESAI_TFCR,  0x},
{REG_ESAI_RFCR,  0x},
-   {REG_ESAI_TX0,   0x},
-   {REG_ESAI_TX1,   0x},
-   {REG_ESAI_TX2,   0x},
-   {REG_ESAI_TX3,   0x},
-   {REG_ESAI_TX4,   0x},
-   {REG_ESAI_TX5,   0x},
{REG_ESAI_TSR,   0x},
{REG_ESAI_SAICR, 0x},
{REG_ESAI_TCR,   0x},
@@ -711,10 +704,17 @@ static bool fsl_esai_readable_reg(struct device *dev, 
unsigned int reg)
 static bool fsl_esai_volatile_reg(struct device *dev, unsigned int reg)
 {
switch (reg) {
+   case REG_ESAI_ETDR:
case REG_ESAI_ERDR:
case REG_ESAI_ESR:
case REG_ESAI_TFSR:
case REG_ESAI_RFSR:
+   case REG_ESAI_TX0:
+   case REG_ESAI_TX1:
+   case REG_ESAI_TX2:
+   case REG_ESAI_TX3:
+   case REG_ESAI_TX4:
+   case REG_ESAI_TX5:
case REG_ESAI_RX0:
case REG_ESAI_RX1:
case REG_ESAI_RX2:
-- 
2.17.1



Re: [PATCH 2/3] clk: qcom: Add MSM8998 GPU Clock Controller (GPUCC) driver

2019-06-06 Thread Stephen Boyd
Quoting Jeffrey Hugo (2019-05-28 09:48:03)
> diff --git a/drivers/clk/qcom/gpucc-msm8998.c 
> b/drivers/clk/qcom/gpucc-msm8998.c
> new file mode 100644
> index ..e45062e40718
> --- /dev/null
> +++ b/drivers/clk/qcom/gpucc-msm8998.c
> +
> +static int gpucc_msm8998_probe(struct platform_device *pdev)
> +{
> +   struct regmap *regmap;
> +   struct clk *xo;
> +
> +   /*
> +* We must have a valid XO to continue until orphan probe defer is
> +* implemented.
> +*/
> +   xo = clk_get(>dev, "xo");

Why is this necessary?

> +   if (IS_ERR(xo))
> +   return PTR_ERR(xo);
> +   clk_put(xo);
> +
> +   regmap = qcom_cc_map(pdev, _msm8998_desc);
> +   if (IS_ERR(regmap))
> +   return PTR_ERR(regmap);
> +
> +   /* force periph logic on to acoid perf counter corruption */

avoid?

> +   regmap_write_bits(regmap, gfx3d_clk.clkr.enable_reg, BIT(13), 
> BIT(13));
> +   /* tweak droop detector (GPUCC_GPU_DD_WRAP_CTRL) to reduce leakage */
> +   regmap_write_bits(regmap, gfx3d_clk.clkr.enable_reg, BIT(0), BIT(0));
> +
> +   return qcom_cc_really_probe(pdev, _msm8998_desc, regmap);
> +}
> +


  1   2   3   4   5   6   7   8   9   10   >