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

2019-10-09 Thread Jason Wang



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

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

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

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

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

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

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

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

return true;
  
  	while (len > s) {

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

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

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

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



Reviewed-by: Jason Wang 




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

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

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

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

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

-- 
With Best Regards,
Andy Shevchenko


Re: Potential NULL pointer deference in spi

2019-10-09 Thread Eric Dumazet



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


Many of your reports are completely bogus.

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

Thanks.


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

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

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

> > +   bool pds;

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

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

.

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



-- 
With Best Regards,
Andy Shevchenko


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

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

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

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

unsigned int retries = 125; // 1250 ms

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

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

-- 
With Best Regards,
Andy Shevchenko


Potential NULL pointer deference in spi

2019-10-09 Thread Yizhuo Zhai
Hi All:

drivers/spi/spi.c:

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

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


-- 
Kind Regards,

Yizhuo Zhai

Computer Science, Graduate Student
University of California, Riverside


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

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

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

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

Signed-off-by: Christophe Leroy 

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

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



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

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

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

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

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

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

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

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

2019-10-09 Thread Julia Lawall



On Wed, 9 Oct 2019, Joe Perches wrote:

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

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

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

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

thanks,
julia

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


Potential NULL pointer deference inata: sata_rcar

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

-- 
Kind Regards,

Yizhuo Zhai

Computer Science, Graduate Student
University of California, Riverside


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

2019-10-09 Thread Andreas Kemnade
Hi Jonathan,

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

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

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

Regards,
Andreas

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


Re: string.h: Mark 34 functions with __must_check

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

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

-- 
With Best Regards,
Andy Shevchenko


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

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

How can hub ever not be valid?

thanks,

greg k-h


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

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

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

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

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

serial8250_console_write()
 serial8250_modem_status()
  wake_up_interruptible()

And so on.

-ss


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

2019-10-09 Thread Ramuthevar, Vadivel MuruganX

Hi Vignesh,

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


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

HI Vignesh,

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

Hi,

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

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

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

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

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

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

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

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


Great, appreciate the effort!


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


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

yes, understood now, Thanks!

what is your opinion on DMA related stuff?

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


---
With Regards
Vadivel


Regards
Vignesh


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

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

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



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

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

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



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

2019-10-09 Thread Murphy Zhou
Hi,

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

Got it. Thanks for noticing!

>
> --
> Catalin


Potential NULL pointer deference in iwlwifi: mvm

2019-10-09 Thread Yizhuo Zhai
Hi All:

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

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



-- 
Kind Regards,

Yizhuo Zhai

Computer Science, Graduate Student
University of California, Riverside


Potential NULL pointer deference in mm/memcontrol.c

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

Yizhuo Zhai

Computer Science, Graduate Student
University of California, Riverside


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

-- 
2.23.0



Potential NULL pointer deference in RDMA

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


-- 
Kind Regards,

Yizhuo Zhai

Computer Science, Graduate Student
University of California, Riverside


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

2019-10-09 Thread Ravi Bangoria




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



Getting the following :

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



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

-Ravi



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

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

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

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

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

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



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

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

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

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



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

2019-10-09 Thread Tanwar, Rahul


Hi Linus,

Thanks for taking time out to review.

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

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

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

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

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

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

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

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

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

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

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

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

[git pull] dcache_readdir() fixes

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

The following changes since commit 4d856f72c10ecb060868ed10ff1b1453943fc6c8:

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

are available in the git repository at:

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

for you to fetch changes up to 26b6c984338474b7032a3f1ee28e9d7590c225db:

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


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

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


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

2019-10-09 Thread Vignesh Raghavendra



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

Great, appreciate the effort!

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

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

> what is your opinion on DMA related stuff? 

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

Regards
Vignesh

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

-- 
Regards
Vignesh


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

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

Why doesn't it work?



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

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

Applied, thanks


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

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

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

This looks good to me, thanks Paul.


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

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

Applied, thanks


[PATCH] sock_get_timeout: drop unnecessary return variable

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

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

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



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

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

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

Thank you, patches applied.

Regards,
Bjorn


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

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

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

Oops, we may leave this to Andrew.

>-- 
>Mike Kravetz

-- 
Wei Yang
Help you, Help me


[PATCH] af_unix: __unix_find_socket_byname() cleanup

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

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

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

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



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

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

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

> Signed-off-by: YueHaibing 

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

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

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

-- 
Mike Kravetz


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

-- 
2.23.0



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

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

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

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

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

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

2019-10-09 Thread Martin K. Petersen


Thomas,

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

Applied to 5.4/scsi-fixes, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: sni_53c710 fix compilation error

2019-10-09 Thread Martin K. Petersen


Thomas,

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

Applied to 5.4/scsi-fixes, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


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

2019-10-09 Thread Jianxin Pan
Hi Rob,

Thanks for your review.

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

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



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

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

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

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

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

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

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

>-- 
>Mike Kravetz

-- 
Wei Yang
Help you, Help me


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

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

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

Regards,
Candle


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

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

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

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

Thanx, Paul



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

rcu: Avoid data-race in rcu_gp_fqs_check_wake()

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

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

BUG: KCSAN: data-race in rcu_gp_fqs_check_wake / 
rcu_preempt_deferred_qs_irqrestore

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

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

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

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

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

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

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

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

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

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

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

-- 
Wei Yang
Help you, Help me


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

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

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

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



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

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

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

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



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

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

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

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



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

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

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

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



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

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

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

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



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

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

Good catch, queued for review and testing.

Thanx, Paul

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

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

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

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

Candle

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

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

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

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

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

[0.001734]   5 base 40 mask 60 write-combining

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

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

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



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

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

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

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

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

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



[git pull] a couple of mount fixes

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

The following changes since commit a3bc18a48e2e678efe62f1f9989902f9cd19e0ff:

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

are available in the git repository at:

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

for you to fetch changes up to 6fcf0c72e4b9360768cf5ef543c4f14c34800ee8:

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


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

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

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


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

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

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

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

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

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

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


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


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics


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

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

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

Because it is not necessary.

-- 
James Morris




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

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

Applied, thanks.


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

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

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

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

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

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



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

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


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

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

If you add on the kernel command line:

 ftrace=function ftrace_filter=schedule

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



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


-- Steve


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

2019-10-09 Thread Martin K. Petersen


Paul,

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

Yep, that's great. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


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

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

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

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

It triggered this:

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

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

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

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

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

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

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

Thanks for testing.

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

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

Thanks a lot :-)

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

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

2019-10-09 Thread Martin K. Petersen


Masahiro,

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

Applied to 5.5/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


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

2019-10-09 Thread Martin K. Petersen


Allen,

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

Applied to 5.4/scsi-fixes, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


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

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

+1

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

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



If you want to see more examples from other parts,


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


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


-- 
Best Regards
Masahiro Yamada


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

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

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

-- 
Mike Kravetz


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

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

Reviewed-by: Masahiro Yamada 



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


-- 
Best Regards
Masahiro Yamada


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

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

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

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


linux-next: build failure after merge of the tip tree

2019-10-09 Thread Stephen Rothwell
Hi all,

After merging the tip tree, today's linux-next build (x86_64 allmodconfig)
failed like this:

drivers/gpu/drm/i915/gt/intel_gt_pm.c: In function 'intel_gt_resume':
drivers/gpu/drm/i915/gt/intel_gt_pm.c:183:54: error: macro "mutex_release" 
passed 3 arguments, but takes just 2
  183 |mutex_release(>pin_mutex.dep_map, 0, _THIS_IP_);
  |  ^
In file included from include/linux/spinlock_types.h:18,
 from include/linux/spinlock.h:83,
 from include/linux/mmzone.h:8,
 from include/linux/gfp.h:6,
 from include/linux/slab.h:15,
 from include/linux/io-mapping.h:10,
 from drivers/gpu/drm/i915/i915_drv.h:36,
 from drivers/gpu/drm/i915/gt/intel_gt_pm.c:7:
include/linux/lockdep.h:605: note: macro "mutex_release" defined here
  605 | #define mutex_release(l, i)   lock_release(l, i)
  | 
drivers/gpu/drm/i915/gt/intel_lrc.c: In function '__context_pin_release':
drivers/gpu/drm/i915/gt/intel_lrc.c:245:51: error: macro "mutex_release" passed 
3 arguments, but takes just 2
  245 |  mutex_release(>pin_mutex.dep_map, 0, _RET_IP_);
  |   ^
In file included from include/linux/hardirq.h:6,
 from include/linux/interrupt.h:11,
 from drivers/gpu/drm/i915/gt/intel_lrc.c:134:
include/linux/lockdep.h:605: note: macro "mutex_release" defined here
  605 | #define mutex_release(l, i)   lock_release(l, i)
  | 

Caused by commit

  5facae4f3549 ("locking/lockdep: Remove unused @nested argument from 
lock_release()")

interacting with commits

  dffa8feb3084 ("drm/i915/perf: Assert locking for i915_init_oa_perf_state()")
  fcde8c7eea60 ("drm/i915/selftests: Exercise potential false lite-restore")
  b1e3177bd1d8 ("drm/i915: Coordinate i915_active with its own mutex")

from the drm tree.

I added the following merge fix patch for today:

From: Stephen Rothwell 
Date: Thu, 10 Oct 2019 13:08:43 +1100
Subject: [PATCH] drm/i915: update for mutex_release API change

Signed-off-by: Stephen Rothwell 
---
 drivers/gpu/drm/i915/gt/intel_gt_pm.c | 2 +-
 drivers/gpu/drm/i915/gt/intel_lrc.c   | 2 +-
 drivers/gpu/drm/i915/i915_active.c| 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.c 
b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
index b52e2ba3d092..d195e05a701f 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_pm.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
@@ -180,7 +180,7 @@ int intel_gt_resume(struct intel_gt *gt)
GEM_BUG_ON(!intel_context_is_pinned(ce));
mutex_acquire(>pin_mutex.dep_map, 0, 0, _THIS_IP_);
ce->ops->reset(ce);
-   mutex_release(>pin_mutex.dep_map, 0, _THIS_IP_);
+   mutex_release(>pin_mutex.dep_map, _THIS_IP_);
}
 
engine->serial++; /* kernel context lost */
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c 
b/drivers/gpu/drm/i915/gt/intel_lrc.c
index a2155d6bcdd2..aa61b0101bf8 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.c
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
@@ -242,7 +242,7 @@ static void __context_pin_acquire(struct intel_context *ce)
 
 static void __context_pin_release(struct intel_context *ce)
 {
-   mutex_release(>pin_mutex.dep_map, 0, _RET_IP_);
+   mutex_release(>pin_mutex.dep_map, _RET_IP_);
 }
 
 static void mark_eio(struct i915_request *rq)
diff --git a/drivers/gpu/drm/i915/i915_active.c 
b/drivers/gpu/drm/i915/i915_active.c
index aa37c07004b9..a47387174434 100644
--- a/drivers/gpu/drm/i915/i915_active.c
+++ b/drivers/gpu/drm/i915/i915_active.c
@@ -385,7 +385,7 @@ void i915_active_set_exclusive(struct i915_active *ref, 
struct dma_fence *f)
mutex_acquire(>mutex.dep_map, 0, 0, _THIS_IP_);
if (!__i915_active_fence_set(>excl, f))
atomic_inc(>count);
-   mutex_release(>mutex.dep_map, 0, _THIS_IP_);
+   mutex_release(>mutex.dep_map, _THIS_IP_);
 }
 
 bool i915_active_acquire_if_busy(struct i915_active *ref)
-- 
2.23.0

-- 
Cheers,
Stephen Rothwell


pgpt8jE0Zti51.pgp
Description: OpenPGP digital signature


Re: [PATCH] xtensa: fix {get,put}_user() for 64bit values

2019-10-09 Thread Max Filippov
On Wed, Oct 9, 2019 at 6:56 PM Al Viro  wrote:
>
> On Wed, Oct 09, 2019 at 06:38:12PM -0700, Max Filippov wrote:
>
> > There's also the following code in the callers of this macro, e.g. in
> > __get_user_nocheck:
> >
> > long __gu_err, __gu_val;\
> > __get_user_size(__gu_val, (ptr), (size), __gu_err); \
> > (x) = (__force __typeof__(*(ptr)))__gu_val; \
> >
> > the last line is important for sizes 1..4, because it takes care of
> > sign extension of the value loaded by the assembly.
> > At the same time the first line doesn't make sense for the size 8
> > as it will result in value truncation.
>
> Right you are...
>
> > +   long __gu_err;  \
> > +   __typeof__(*(ptr) + 0) __gu_val;\
>
> What would __u64 __gu_val; end up with for smaller sizes?

It does good job with little endian cores, i.e. the generated code is
the same in both cases, but on big endian it looks into wrong register
of the register pair that represents __gu_val. E.g.:

foo_in_s8_out_s8:
entry   sp, 32  #
mov.n   a7, sp  # a5,
# 
/home/jcmvbkbc/ws/tensilica/linux/linux-xtensa/arch/xtensa/kernel/signal.c:518:
gen_outs(8)
movi.n  a8, 0   # __gu_err,
#APP
# 518 
"/home/jcmvbkbc/ws/tensilica/linux/linux-xtensa/arch/xtensa/kernel/signal.c"
1
1: l8ui  a10, a2, 0 # __gu_val, p
2:
   .section  .fixup,"ax"
   .align 4
   .literal_position
5:
   movi   a2, 2b# __cb
   movi   a10, 0# __gu_val
   movi   a8, -14   # __gu_err,
   jx a2# __cb
   .previous
   .section  __ex_table,"a"
   .long1b, 5b
   .previous
# 0 "" 2
#NO_APP
extui   a2, a11, 0, 8   #, __gu_val
retw.n

> I don't have
> xtensa cross-toolchain at the moment, so I can't check it easily;
> what does =r constraint generate in such case?

Lower register of the register pair.

> Another thing is, you want to zero it on failure, to avoid an uninitialized
> value ending up someplace interesting

Ok, this?

diff --git a/arch/xtensa/include/asm/uaccess.h
b/arch/xtensa/include/asm/uaccess.h
index 6792928ba84a..0bdaadf1636e 100644
--- a/arch/xtensa/include/asm/uaccess.h
+++ b/arch/xtensa/include/asm/uaccess.h
@@ -100,7 +100,7 @@ do {
 \
case 4: __put_user_asm(x, ptr, retval, 4, "s32i", __cb); break; \
case 8: {   \
 __typeof__(*ptr) __v64 = x;\
-retval = __copy_to_user(ptr, &__v64, 8);   \
+retval = __copy_to_user(ptr, &__v64, 8) ? -EFAULT
: 0; \
 break; \
}   \
default: __put_user_bad();  \
@@ -172,7 +172,8 @@ __asm__ __volatile__(
 \

 #define __get_user_nocheck(x, ptr, size)   \
 ({ \
-   long __gu_err, __gu_val;\
+   long __gu_err;  \
+   __typeof__(*(ptr) + 0) __gu_val = 0;\
__get_user_size(__gu_val, (ptr), (size), __gu_err); \
(x) = (__force __typeof__(*(ptr)))__gu_val; \
__gu_err;   \
@@ -180,7 +181,8 @@ __asm__ __volatile__(
 \

 #define __get_user_check(x, ptr, size) \
 ({ \
-   long __gu_err = -EFAULT, __gu_val = 0;  \
+   long __gu_err = -EFAULT;\
+   __typeof__(*(ptr) + 0) __gu_val = 0;\
const __typeof__(*(ptr)) *__gu_addr = (ptr);\
if (access_ok(__gu_addr, size)) \
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
@@ -198,7 +200,7 @@ do {
 \
case 1: __get_user_asm(x, ptr, retval, 1, "l8ui", __cb);  break;\
case 2: __get_user_asm(x, ptr, retval, 2, "l16ui", __cb); break;\
case 4: __get_user_asm(x, ptr, retval, 4, "l32i", __cb);  break;\
-   case 8: retval = __copy_from_user(, ptr, 8);break;\
+   case 8: retval = __copy_from_user(, ptr, 8) ? -EFAULT : 0;
 break;  \
default: (x) = __get_user_bad();\
}   \
 } while (0)


-- 
Thanks.
-- Max


Re: [PATCH 1/1] mm/vmalloc: remove preempt_disable/enable when do preloading

2019-10-09 Thread Steven Rostedt
On Wed, 9 Oct 2019 15:19:01 -0700
Andrew Morton  wrote:

> On Wed,  9 Oct 2019 18:49:34 +0200 "Uladzislau Rezki (Sony)" 
>  wrote:
> 
> > Get rid of preempt_disable() and preempt_enable() when the
> > preload is done for splitting purpose. The reason is that
> > calling spin_lock() with disabled preemtion is forbidden in
> > CONFIG_PREEMPT_RT kernel.
> > 
> > Therefore, we do not guarantee that a CPU is preloaded, instead
> > we minimize the case when it is not with this change.
> > 
> > For example i run the special test case that follows the preload
> > pattern and path. 20 "unbind" threads run it and each does
> > 100 allocations. Only 3.5 times among 100 a CPU was
> > not preloaded thus. So it can happen but the number is rather
> > negligible.
> >
> > ...
> >  
> 
> A few questions about the resulting alloc_vmap_area():
> 
> : static struct vmap_area *alloc_vmap_area(unsigned long size,
> : unsigned long align,
> : unsigned long vstart, unsigned long vend,
> : int node, gfp_t gfp_mask)
> : {
> : struct vmap_area *va, *pva;
> : unsigned long addr;
> : int purged = 0;
> : 
> : BUG_ON(!size);
> : BUG_ON(offset_in_page(size));
> : BUG_ON(!is_power_of_2(align));
> : 
> : if (unlikely(!vmap_initialized))
> : return ERR_PTR(-EBUSY);
> : 
> : might_sleep();
> : 
> : va = kmem_cache_alloc_node(vmap_area_cachep,
> : gfp_mask & GFP_RECLAIM_MASK, node);
> 
> Why does this use GFP_RECLAIM_MASK?  Please add a comment explaining
> this.
> 
> : if (unlikely(!va))
> : return ERR_PTR(-ENOMEM);
> : 
> : /*
> :  * Only scan the relevant parts containing pointers to other objects
> :  * to avoid false negatives.
> :  */
> : kmemleak_scan_area(>rb_node, SIZE_MAX, gfp_mask & GFP_RECLAIM_MASK);
> : 
> : retry:
> : /*
> :  * Preload this CPU with one extra vmap_area object. It is used
> :  * when fit type of free area is NE_FIT_TYPE. Please note, it
> :  * does not guarantee that an allocation occurs on a CPU that
> :  * is preloaded, instead we minimize the case when it is not.
> :  * It can happen because of migration, because there is a race
> :  * until the below spinlock is taken.
> :  *
> :  * The preload is done in non-atomic context, thus it allows us
> :  * to use more permissive allocation masks to be more stable under
> :  * low memory condition and high memory pressure.
> :  *
> :  * Even if it fails we do not really care about that. Just proceed
> :  * as it is. "overflow" path will refill the cache we allocate from.
> :  */
> : if (!this_cpu_read(ne_fit_preload_node)) {
> 
> Readability nit: local `pva' should be defined here, rather than having
> function-wide scope.
> 
> : pva = kmem_cache_alloc_node(vmap_area_cachep, GFP_KERNEL, node);
> 
> Why doesn't this honour gfp_mask?  If it's not a bug, please add
> comment explaining this.
> 
> The kmem_cache_alloc() in adjust_va_to_fit_type() omits the caller's
> gfp_mask also.  If not a bug, please document the unexpected behaviour.
> 

These questions appear to be for the code that this patch touches, not
for the patch itself.

> : 
> : if (this_cpu_cmpxchg(ne_fit_preload_node, NULL,
> pva)) { : if (pva)
> : kmem_cache_free(vmap_area_cachep,
> pva); :   }
> : }
> : 
> : spin_lock(_area_lock);
> : 
> : /*
> :  * If an allocation fails, the "vend" address is
> :  * returned. Therefore trigger the overflow path.
> :  */
> 
> As for the intent of this patch, why not preallocate the vmap_area
> outside the spinlock and use it within the spinlock?  Does spin_lock()
> disable preemption on RT?  I forget, but it doesn't matter much anyway

spin_lock() does not disable preemption on RT. But it does disable
migration (thus the task should remain on the current CPU).

> - doing this will make the code better in the regular kernel I think? 
> Something like this:
> 
>   struct vmap_area *pva = NULL;
> 
>   ...
> 
>   if (!this_cpu_read(ne_fit_preload_node))
>   pva = kmem_cache_alloc_node(vmap_area_cachep, ...);
> 
>   spin_lock(_area_lock);
> 
>   if (pva && __this_cpu_cmpxchg(ne_fit_preload_node, NULL, pva))
>   kmem_cache_free(vmap_area_cachep, pva);
> 


This looks fine to me.

-- Steve


[PATCH v2 3/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs

2019-10-09 Thread Andrew Jeffery
The 50MHz RCLK has to be enabled before the RMII interface will function.

Signed-off-by: Andrew Jeffery 
---
v2: Mainly a rework of error case handling, some changes to comments

 drivers/net/ethernet/faraday/ftgmac100.c | 50 +++-
 1 file changed, 40 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c 
b/drivers/net/ethernet/faraday/ftgmac100.c
index 9b7af94a40bb..824310253099 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -90,6 +90,9 @@ struct ftgmac100 {
struct mii_bus *mii_bus;
struct clk *clk;
 
+   /* AST2500/AST2600 RMII ref clock gate */
+   struct clk *rclk;
+
/* Link management */
int cur_speed;
int cur_duplex;
@@ -1718,20 +1721,41 @@ static void ftgmac100_ncsi_handler(struct ncsi_dev *nd)
   nd->link_up ? "up" : "down");
 }
 
-static void ftgmac100_setup_clk(struct ftgmac100 *priv)
+static int ftgmac100_setup_clk(struct ftgmac100 *priv)
 {
-   priv->clk = devm_clk_get(priv->dev, NULL);
-   if (IS_ERR(priv->clk))
-   return;
+   struct clk *clk;
+   int rc;
 
-   clk_prepare_enable(priv->clk);
+   clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
+   if (IS_ERR(clk))
+   return PTR_ERR(clk);
+   priv->clk = clk;
+   rc = clk_prepare_enable(priv->clk);
+   if (rc)
+   return rc;
 
/* Aspeed specifies a 100MHz clock is required for up to
 * 1000Mbit link speeds. As NCSI is limited to 100Mbit, 25MHz
 * is sufficient
 */
-   clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
-   FTGMAC_100MHZ);
+   rc = clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
+ FTGMAC_100MHZ);
+   if (rc)
+   goto cleanup_clk;
+
+   /* RCLK is for RMII, typically used for NCSI. Optional because its not
+* necessary if it's the AST2400 MAC, or the MAC is configured for
+* RGMII, or the controller is not an ASPEED-based controller.
+*/
+   priv->rclk = devm_clk_get_optional(priv->dev, "RCLK");
+   rc = clk_prepare_enable(priv->rclk);
+   if (!rc)
+   return 0;
+
+cleanup_clk:
+   clk_disable_unprepare(priv->clk);
+
+   return rc;
 }
 
 static int ftgmac100_probe(struct platform_device *pdev)
@@ -1853,8 +1877,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
goto err_setup_mdio;
}
 
-   if (priv->is_aspeed)
-   ftgmac100_setup_clk(priv);
+   if (priv->is_aspeed) {
+   err = ftgmac100_setup_clk(priv);
+   if (err)
+   goto err_ncsi_dev;
+   }
 
/* Default ring sizes */
priv->rx_q_entries = priv->new_rx_q_entries = DEF_RX_QUEUE_ENTRIES;
@@ -1886,8 +1913,10 @@ static int ftgmac100_probe(struct platform_device *pdev)
 
return 0;
 
-err_ncsi_dev:
 err_register_netdev:
+   clk_disable_unprepare(priv->rclk);
+   clk_disable_unprepare(priv->clk);
+err_ncsi_dev:
ftgmac100_destroy_mdio(netdev);
 err_setup_mdio:
iounmap(priv->base);
@@ -1909,6 +1938,7 @@ static int ftgmac100_remove(struct platform_device *pdev)
 
unregister_netdev(netdev);
 
+   clk_disable_unprepare(priv->rclk);
clk_disable_unprepare(priv->clk);
 
/* There's a small chance the reset task will have been re-queued,
-- 
2.20.1



[PATCH v2 0/3] net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs

2019-10-09 Thread Andrew Jeffery
Hello,

This series slightly extends the devicetree binding and driver for the
FTGMAC100 to describe an optional RMII RCLK gate in the clocks property.
Currently it's necessary for the kernel to ungate RCLK on the AST2600 in NCSI
configurations as u-boot does not yet support NCSI (which uses the
R(educed)MII).

v2:
* Clear up Reduced vs Reversed MII in the cover letter
* Mitigate anxiety in the commit message for 1/3 
* Clarify that AST2500 is also affected in the clocks property description in
  2/3
* Rework the error paths and update some comments in 3/3

v1 can be found here: 
https://lore.kernel.org/netdev/20191008115143.14149-1-and...@aj.id.au/

Please review!

Andrew

Andrew Jeffery (3):
  dt-bindings: net: ftgmac100: Document AST2600 compatible
  dt-bindings: net: ftgmac100: Describe clock properties
  net: ftgmac100: Ungate RCLK for RMII on ASPEED MACs

 .../devicetree/bindings/net/ftgmac100.txt |  8 +++
 drivers/net/ethernet/faraday/ftgmac100.c  | 50 +++
 2 files changed, 48 insertions(+), 10 deletions(-)

-- 
2.20.1



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

2019-10-09 Thread Linus Torvalds
On Wed, Oct 9, 2019 at 6:10 PM Thomas Hellström (VMware)
 wrote:
>
> Your original patch does exactly the same!

Oh, no. You misread my original patch.

Look again.

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

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

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

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

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

Notice the difference?

So instead of looking at the return value of the pmd_entry() function,
the approach of that suggested patch was to basically say that if the
pmd_entry function wants us to go another level deeper and it was a
hugepmd, it needed to split the pmd to make that happen.

That's actually very different from what your patch did. My original
patch never tried to walk the pte level without having one - either it
*checked* that it had one, or it split.

But I see where you might have misread the patch, particularly if you
only looked at it as a patch, not as the end result of the patch.

The end result of that patch was this:

if (ops->pmd_entry) {
err = ops->pmd_entry(pmd, addr, next, walk);
if (err)
break;
/* No pte level walking? */
if (!ops->pte_entry)
continue;
/* No pte level at all? */
if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd)
|| pmd_devmap(*pmd))
continue;
} else {
if (!ops->pte_entry)
continue;

split_huge_pmd(walk->vma, pmd, addr);
if (pmd_trans_unstable(pmd))
goto again;
}
err = walk_pte_range(pmd, addr, next, walk);

and look at thew two different sides of the if-statement: if they get
to "walk_pte_range()", both cases wil have verified that there
actually _is_ a pte level. They will just have done it differently. -
the "we didn't have a pmd function" will have split the pmd if it was
a hugepmd, while the "we do have a pmd_entry" case will just check
whether it's still a huge-pmd, and done a "continue" if it was and
never even tried to walk the ptes.

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

So I liked that part of your patch.

   Linus


[PATCH v2 2/2] clk: ast2600: Add RMII RCLK gates for all four MACs

2019-10-09 Thread Andrew Jeffery
RCLK is a fixed 50MHz clock derived from HPLL/HCLK that is described by a
single gate for each MAC.

Signed-off-by: Andrew Jeffery 
---
 drivers/clk/clk-ast2600.c | 47 ++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-ast2600.c b/drivers/clk/clk-ast2600.c
index 1c1bb39bb04e..85acc7cdc83c 100644
--- a/drivers/clk/clk-ast2600.c
+++ b/drivers/clk/clk-ast2600.c
@@ -15,7 +15,7 @@
 
 #include "clk-aspeed.h"
 
-#define ASPEED_G6_NUM_CLKS 67
+#define ASPEED_G6_NUM_CLKS 71
 
 #define ASPEED_G6_SILICON_REV  0x004
 
@@ -40,6 +40,9 @@
 
 #define ASPEED_G6_STRAP1   0x500
 
+#define ASPEED_MAC12_CLK_DLY   0x340
+#define ASPEED_MAC34_CLK_DLY   0x350
+
 /* Globally visible clocks */
 static DEFINE_SPINLOCK(aspeed_g6_clk_lock);
 
@@ -485,6 +488,11 @@ static int aspeed_g6_clk_probe(struct platform_device 
*pdev)
return PTR_ERR(hw);
aspeed_g6_clk_data->hws[ASPEED_CLK_SDIO] = hw;
 
+   /* MAC1/2 RMII 50MHz RCLK */
+   hw = clk_hw_register_fixed_rate(dev, "mac12rclk", "hpll", 0, 5000);
+   if (IS_ERR(hw))
+   return PTR_ERR(hw);
+
/* MAC1/2 AHB bus clock divider */
hw = clk_hw_register_divider_table(dev, "mac12", "hpll", 0,
scu_g6_base + ASPEED_G6_CLK_SELECTION1, 16, 3, 0,
@@ -494,6 +502,27 @@ static int aspeed_g6_clk_probe(struct platform_device 
*pdev)
return PTR_ERR(hw);
aspeed_g6_clk_data->hws[ASPEED_CLK_MAC12] = hw;
 
+   /* RMII1 50MHz (RCLK) output enable */
+   hw = clk_hw_register_gate(dev, "mac1rclk", "mac12rclk", 0,
+   scu_g6_base + ASPEED_MAC12_CLK_DLY, 29, 0,
+   _g6_clk_lock);
+   if (IS_ERR(hw))
+   return PTR_ERR(hw);
+   aspeed_g6_clk_data->hws[ASPEED_CLK_MAC1RCLK] = hw;
+
+   /* RMII2 50MHz (RCLK) output enable */
+   hw = clk_hw_register_gate(dev, "mac2rclk", "mac12rclk", 0,
+   scu_g6_base + ASPEED_MAC12_CLK_DLY, 30, 0,
+   _g6_clk_lock);
+   if (IS_ERR(hw))
+   return PTR_ERR(hw);
+   aspeed_g6_clk_data->hws[ASPEED_CLK_MAC2RCLK] = hw;
+
+   /* MAC1/2 RMII 50MHz RCLK */
+   hw = clk_hw_register_fixed_rate(dev, "mac34rclk", "hclk", 0, 5000);
+   if (IS_ERR(hw))
+   return PTR_ERR(hw);
+
/* MAC3/4 AHB bus clock divider */
hw = clk_hw_register_divider_table(dev, "mac34", "hpll", 0,
scu_g6_base + 0x310, 24, 3, 0,
@@ -503,6 +532,22 @@ static int aspeed_g6_clk_probe(struct platform_device 
*pdev)
return PTR_ERR(hw);
aspeed_g6_clk_data->hws[ASPEED_CLK_MAC34] = hw;
 
+   /* RMII3 50MHz (RCLK) output enable */
+   hw = clk_hw_register_gate(dev, "mac3rclk", "mac34rclk", 0,
+   scu_g6_base + ASPEED_MAC34_CLK_DLY, 29, 0,
+   _g6_clk_lock);
+   if (IS_ERR(hw))
+   return PTR_ERR(hw);
+   aspeed_g6_clk_data->hws[ASPEED_CLK_MAC3RCLK] = hw;
+
+   /* RMII4 50MHz (RCLK) output enable */
+   hw = clk_hw_register_gate(dev, "mac4rclk", "mac34rclk", 0,
+   scu_g6_base + ASPEED_MAC34_CLK_DLY, 30, 0,
+   _g6_clk_lock);
+   if (IS_ERR(hw))
+   return PTR_ERR(hw);
+   aspeed_g6_clk_data->hws[ASPEED_CLK_MAC4RCLK] = hw;
+
/* LPC Host (LHCLK) clock divider */
hw = clk_hw_register_divider_table(dev, "lhclk", "hpll", 0,
scu_g6_base + ASPEED_G6_CLK_SELECTION1, 20, 3, 0,
-- 
2.20.1



[PATCH v2 1/3] dt-bindings: net: ftgmac100: Document AST2600 compatible

2019-10-09 Thread Andrew Jeffery
The AST2600 contains an FTGMAC100-compatible MAC, although the MDIO
controller previously embedded in the MAC has been moved out to a
dedicated MDIO block.

Signed-off-by: Andrew Jeffery 
Acked-by: Joel Stanley 
---
 Documentation/devicetree/bindings/net/ftgmac100.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt 
b/Documentation/devicetree/bindings/net/ftgmac100.txt
index 72e7aaf7242e..04cc0191b7dd 100644
--- a/Documentation/devicetree/bindings/net/ftgmac100.txt
+++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
@@ -9,6 +9,7 @@ Required properties:
 
  - "aspeed,ast2400-mac"
  - "aspeed,ast2500-mac"
+ - "aspeed,ast2600-mac"
 
 - reg: Address and length of the register set for the device
 - interrupts: Should contain ethernet controller interrupt
-- 
2.20.1



[PATCH v2 2/3] dt-bindings: net: ftgmac100: Describe clock properties

2019-10-09 Thread Andrew Jeffery
Critically, the AST2600 requires ungating the RMII RCLK if e.g. NCSI is
in use.

Signed-off-by: Andrew Jeffery 
Acked-by: Joel Stanley 
---
 Documentation/devicetree/bindings/net/ftgmac100.txt | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt 
b/Documentation/devicetree/bindings/net/ftgmac100.txt
index 04cc0191b7dd..f878c1103463 100644
--- a/Documentation/devicetree/bindings/net/ftgmac100.txt
+++ b/Documentation/devicetree/bindings/net/ftgmac100.txt
@@ -24,6 +24,13 @@ Optional properties:
 - no-hw-checksum: Used to disable HW checksum support. Here for backward
   compatibility as the driver now should have correct defaults based on
   the SoC.
+- clocks: In accordance with the generic clock bindings. Must describe the MAC
+  IP clock, and optionally an RMII RCLK gate for the AST2500/AST2600. The
+  required MAC clock must be the first cell.
+- clock-names:
+
+  - "MACCLK": The MAC IP clock
+  - "RCLK": Clock gate for the RMII RCLK
 
 Example:
 
-- 
2.20.1



[PATCH v2 0/2] clk: ast2600: Expose RMII RCLK for MACs 1-4

2019-10-09 Thread Andrew Jeffery
Hello,

This series is similar to that for the AST2500 but I've split the patches out
as the AST2600 driver is new for 5.4 and I'm hoping we have a chance of
slipping them in. Maybe we can get both series in, but I thought decoupling
them might make it more manageable if not.

Regardless, the blurb:

This series is two small changes enable kernel support for controlling the RMII
RCLK gate on AST2600-based systems. RMII is commonly used for NCSI, which
itself is commonly used for BMC-based designs to reduce cabling requirements
for the platform. NCSI support for the AST2600 is not yet implemented in
u-boot and so unlike the AST2500 the kernel can't rely on RCLK already being
ungated.

v2: Rename some macros and clocks based on feedback from Joel

v1 can be found here: 
https://lore.kernel.org/linux-clk/20191008113553.13662-1-and...@aj.id.au/

Please review!

Andrew

Andrew Jeffery (2):
  dt-bindings: clock: Add AST2600 RMII RCLK gate definitions
  clk: ast2600: Add RMII RCLK gates for all four MACs

 drivers/clk/clk-ast2600.c | 47 ++-
 include/dt-bindings/clock/ast2600-clock.h |  4 ++
 2 files changed, 50 insertions(+), 1 deletion(-)

-- 
2.20.1



[PATCH v2 1/2] dt-bindings: clock: Add AST2600 RMII RCLK gate definitions

2019-10-09 Thread Andrew Jeffery
The AST2600 has an explicit gate for the RMII RCLK for each of the four
MACs.

Signed-off-by: Andrew Jeffery 
---
 include/dt-bindings/clock/ast2600-clock.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/dt-bindings/clock/ast2600-clock.h 
b/include/dt-bindings/clock/ast2600-clock.h
index 38074a5f7296..62b9520a00fd 100644
--- a/include/dt-bindings/clock/ast2600-clock.h
+++ b/include/dt-bindings/clock/ast2600-clock.h
@@ -83,6 +83,10 @@
 #define ASPEED_CLK_MAC12   64
 #define ASPEED_CLK_MAC34   65
 #define ASPEED_CLK_USBPHY_40M  66
+#define ASPEED_CLK_MAC1RCLK67
+#define ASPEED_CLK_MAC2RCLK68
+#define ASPEED_CLK_MAC3RCLK69
+#define ASPEED_CLK_MAC4RCLK70
 
 /* Only list resets here that are not part of a gate */
 #define ASPEED_RESET_ADC   55
-- 
2.20.1



[PATCH v2 2/2] clk: aspeed: Add RMII RCLK gates for both AST2500 MACs

2019-10-09 Thread Andrew Jeffery
RCLK is a fixed 50MHz clock derived from HPLL that is described by a
single gate for each MAC.

Signed-off-by: Andrew Jeffery 
---
v2: Drop "-gate" from clock names

 drivers/clk/clk-aspeed.c | 27 ++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-aspeed.c b/drivers/clk/clk-aspeed.c
index abf06fb6453e..411ff5fb2c07 100644
--- a/drivers/clk/clk-aspeed.c
+++ b/drivers/clk/clk-aspeed.c
@@ -14,7 +14,7 @@
 
 #include "clk-aspeed.h"
 
-#define ASPEED_NUM_CLKS36
+#define ASPEED_NUM_CLKS38
 
 #define ASPEED_RESET2_OFFSET   32
 
@@ -28,6 +28,7 @@
 #define  AST2400_HPLL_BYPASS_ENBIT(17)
 #define ASPEED_MISC_CTRL   0x2c
 #define  UART_DIV13_EN BIT(12)
+#define ASPEED_MAC_CLK_DLY 0x48
 #define ASPEED_STRAP   0x70
 #define  CLKIN_25MHZ_ENBIT(23)
 #define  AST2400_CLK_SOURCE_SELBIT(18)
@@ -462,6 +463,30 @@ static int aspeed_clk_probe(struct platform_device *pdev)
return PTR_ERR(hw);
aspeed_clk_data->hws[ASPEED_CLK_MAC] = hw;
 
+   if (of_device_is_compatible(pdev->dev.of_node, "aspeed,ast2500-scu")) {
+   /* RMII 50MHz RCLK */
+   hw = clk_hw_register_fixed_rate(dev, "mac12rclk", "hpll", 0,
+   5000);
+   if (IS_ERR(hw))
+   return PTR_ERR(hw);
+
+   /* RMII1 50MHz (RCLK) output enable */
+   hw = clk_hw_register_gate(dev, "mac1rclk", "mac12rclk", 0,
+   scu_base + ASPEED_MAC_CLK_DLY, 29, 0,
+   _clk_lock);
+   if (IS_ERR(hw))
+   return PTR_ERR(hw);
+   aspeed_clk_data->hws[ASPEED_CLK_MAC1RCLK] = hw;
+
+   /* RMII2 50MHz (RCLK) output enable */
+   hw = clk_hw_register_gate(dev, "mac2rclk", "mac12rclk", 0,
+   scu_base + ASPEED_MAC_CLK_DLY, 30, 0,
+   _clk_lock);
+   if (IS_ERR(hw))
+   return PTR_ERR(hw);
+   aspeed_clk_data->hws[ASPEED_CLK_MAC2RCLK] = hw;
+   }
+
/* LPC Host (LHCLK) clock divider */
hw = clk_hw_register_divider_table(dev, "lhclk", "hpll", 0,
scu_base + ASPEED_CLK_SELECTION, 20, 3, 0,
-- 
2.20.1



[PATCH v2 0/2] clk: aspeed: Expose RMII RCLK gate for MACs 1-2 on AST2500

2019-10-09 Thread Andrew Jeffery
Hello,

This series is two small changes enable kernel support for controlling the RMII
RCLK gate on AST2500-based systems. Previously the kernel has assumed u-boot
has ungated RCLK for networking to function.

RMII is commonly used for NCSI, which itself is commonly used for BMC-based
designs to reduce cabling requirements for the platform.

v2:
* Rename macros and clock names based on Joel's feedback.

v1 can be found here: 
https://lore.kernel.org/linux-clk/20191008113523.13601-1-and...@aj.id.au/

Please review!

Andrew

Andrew Jeffery (2):
  dt-bindings: clock: Add AST2500 RMII RCLK definitions
  clk: aspeed: Add RMII RCLK gates for both AST2500 MACs

 drivers/clk/clk-aspeed.c | 27 +++-
 include/dt-bindings/clock/aspeed-clock.h |  2 ++
 2 files changed, 28 insertions(+), 1 deletion(-)

-- 
2.20.1



[PATCH v2 1/2] dt-bindings: clock: Add AST2500 RMII RCLK definitions

2019-10-09 Thread Andrew Jeffery
The AST2500 has an explicit gate for the RMII RCLK for each of the two
MACs.

Signed-off-by: Andrew Jeffery 
---
v2: Drop "_GATE" from symbol names

 include/dt-bindings/clock/aspeed-clock.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/dt-bindings/clock/aspeed-clock.h 
b/include/dt-bindings/clock/aspeed-clock.h
index f43738607d77..9ff4f6e4558c 100644
--- a/include/dt-bindings/clock/aspeed-clock.h
+++ b/include/dt-bindings/clock/aspeed-clock.h
@@ -39,6 +39,8 @@
 #define ASPEED_CLK_BCLK33
 #define ASPEED_CLK_MPLL34
 #define ASPEED_CLK_24M 35
+#define ASPEED_CLK_MAC1RCLK36
+#define ASPEED_CLK_MAC2RCLK37
 
 #define ASPEED_RESET_XDMA  0
 #define ASPEED_RESET_MCTP  1
-- 
2.20.1



Re: [PATCH] xtensa: fix {get,put}_user() for 64bit values

2019-10-09 Thread Al Viro
On Wed, Oct 09, 2019 at 06:38:12PM -0700, Max Filippov wrote:

> There's also the following code in the callers of this macro, e.g. in
> __get_user_nocheck:
> 
> long __gu_err, __gu_val;\
> __get_user_size(__gu_val, (ptr), (size), __gu_err); \
> (x) = (__force __typeof__(*(ptr)))__gu_val; \
> 
> the last line is important for sizes 1..4, because it takes care of
> sign extension of the value loaded by the assembly.
> At the same time the first line doesn't make sense for the size 8
> as it will result in value truncation.

Right you are...

> +   long __gu_err;  \
> +   __typeof__(*(ptr) + 0) __gu_val;\

What would __u64 __gu_val; end up with for smaller sizes?  I don't have
xtensa cross-toolchain at the moment, so I can't check it easily;
what does =r constraint generate in such case?

Another thing is, you want to zero it on failure, to avoid an uninitialized
value ending up someplace interesting

> @@ -198,7 +200,7 @@ do {
>  \
> case 1: __get_user_asm(x, ptr, retval, 1, "l8ui", __cb);  break;\
> case 2: __get_user_asm(x, ptr, retval, 2, "l16ui", __cb); break;\
> case 4: __get_user_asm(x, ptr, retval, 4, "l32i", __cb);  break;\
> -   case 8: retval = __copy_from_user(, ptr, 8);break;\
> +   case 8: retval = __copy_from_user(, ptr, 8) ? -EFAULT : 0;
>  break;  \
> default: (x) = __get_user_bad();\
> }   \
>  } while (0)
> 
> Here __typeof__(*(ptr) + 0) makes enough room for all cases
> in the __get_user_size and the "+0" part takes care of pointers
> to const data.


Re: [PATCH] xtensa: fix {get,put}_user() for 64bit values

2019-10-09 Thread Max Filippov
On Wed, Oct 9, 2019 at 12:21 PM Al Viro  wrote:
>
> First of all, on short copies __copy_{to,from}_user() return the amount
> of bytes left uncopied, *not* -EFAULT.  get_user() and put_user() are
> expected to return -EFAULT on failure.
>
> Another problem is get_user(v32, (__u64 __user *)p); that should
> fetch 64bit value and the assign it to v32, truncating it in process.
> Current code, OTOH, reads 8 bytes of data and stores them at the
> address of v32, stomping on the 4 bytes that follow v32 itself.
>
> Signed-off-by: Al Viro 
> --
> diff --git a/arch/xtensa/include/asm/uaccess.h 
> b/arch/xtensa/include/asm/uaccess.h
> index 6792928ba84a..155174ddb7ae 100644
> --- a/arch/xtensa/include/asm/uaccess.h
> +++ b/arch/xtensa/include/asm/uaccess.h
> @@ -100,7 +100,7 @@ do {  
>   \
> case 4: __put_user_asm(x, ptr, retval, 4, "s32i", __cb); break; \
> case 8: {   \
>  __typeof__(*ptr) __v64 = x;\
> -retval = __copy_to_user(ptr, &__v64, 8);   \
> +retval = __copy_to_user(ptr, &__v64, 8) ? -EFAULT : 0;   
>   \

Sure, I agree with that.

>  break; \
> }   \
> default: __put_user_bad();  \
> @@ -198,7 +198,12 @@ do { 
>   \
> case 1: __get_user_asm(x, ptr, retval, 1, "l8ui", __cb);  break;\
> case 2: __get_user_asm(x, ptr, retval, 2, "l16ui", __cb); break;\
> case 4: __get_user_asm(x, ptr, retval, 4, "l32i", __cb);  break;\
> -   case 8: retval = __copy_from_user(, ptr, 8);break;\
> +   case 8: {   \
> +   __u64 __x = 0;  \
> +   retval = __copy_from_user(&__x, ptr, 8) ? -EFAULT : 0;  \
> +   (x) = *(__force __typeof__(*(ptr)) *) &__x; \
> +   break;  \
> +   }   \

There's also the following code in the callers of this macro, e.g. in
__get_user_nocheck:

long __gu_err, __gu_val;\
__get_user_size(__gu_val, (ptr), (size), __gu_err); \
(x) = (__force __typeof__(*(ptr)))__gu_val; \

the last line is important for sizes 1..4, because it takes care of
sign extension of the value loaded by the assembly.
At the same time the first line doesn't make sense for the size 8
as it will result in value truncation.

How about the following change instead:

diff --git a/arch/xtensa/include/asm/uaccess.h
b/arch/xtensa/include/asm/uaccess.h
index 6792928ba84a..c54893651d69 100644
--- a/arch/xtensa/include/asm/uaccess.h
+++ b/arch/xtensa/include/asm/uaccess.h
@@ -100,7 +100,7 @@ do {
 \
case 4: __put_user_asm(x, ptr, retval, 4, "s32i", __cb); break; \
case 8: {   \
 __typeof__(*ptr) __v64 = x;\
-retval = __copy_to_user(ptr, &__v64, 8);   \
+retval = __copy_to_user(ptr, &__v64, 8) ? -EFAULT
: 0; \
 break; \
}   \
default: __put_user_bad();  \
@@ -172,7 +172,8 @@ __asm__ __volatile__(
 \

 #define __get_user_nocheck(x, ptr, size)   \
 ({ \
-   long __gu_err, __gu_val;\
+   long __gu_err;  \
+   __typeof__(*(ptr) + 0) __gu_val;\
__get_user_size(__gu_val, (ptr), (size), __gu_err); \
(x) = (__force __typeof__(*(ptr)))__gu_val; \
__gu_err;   \
@@ -180,7 +181,8 @@ __asm__ __volatile__(
 \

 #define __get_user_check(x, ptr, size) \
 ({ \
-   long __gu_err = -EFAULT, __gu_val = 0;  \
+   long __gu_err = -EFAULT;\
+   __typeof__(*(ptr) + 0) __gu_val = 0;\
const __typeof__(*(ptr)) *__gu_addr = (ptr);\
if (access_ok(__gu_addr, size)) \
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
@@ 

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

2019-10-09 Thread Ramuthevar, Vadivel MuruganX

HI Vignesh,

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

Hi,

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

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

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

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

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

[1]
https://bootlin.com/blog/spi-mem-bringing-some-consistency-to-the-spi-memory-ecosystem/
[2] https://www.youtube.com/watch?v=PkWbuLM_gmU
As per Mark Brown and your suggestion,  I have started adapting 
cadence-qaudspi driver with spi_mem_ops framework to work
QSPI-NAND/NOR as a generic driver(completely removed the legacy 
SPI-XFERS),  is in progress on Intel LGM SoC.
QSPI-IP on Intel LGM  do not have DMA  support and also not part of QSPI 
IP, so couldn't able to validate DMA related.

will adapt the DMA things which are existing in cadence-quadspi.c as it is.

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

confirmed through device tree entry.

what is your opinion on DMA related stuff? also using macronix(QSPI-NOR) 
flash/Micron(QSPI-NAND).

---
With Regards
Vadivel

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

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



Re: [PATCH] ocfs2:fix potential Null Ptr Dereference

2019-10-09 Thread Joseph Qi



On 19/10/10 09:07, Yizhuo wrote:
> Inside function o2hb_region_blocks_store(), to_o2hb_region()
> could return NULL but there's no check before its dereference,
> which is potentially unsafe.

As I described before, this won't happen IMHO.
configfs item is initialized after loading module, so region should
be valid here.


Thanks,
Joseph

> 
> Signed-off-by: Yizhuo 
> ---
>  fs/ocfs2/cluster/heartbeat.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
> index a368350d4c27..93f2b540f245 100644
> --- a/fs/ocfs2/cluster/heartbeat.c
> +++ b/fs/ocfs2/cluster/heartbeat.c
> @@ -1628,7 +1628,7 @@ static ssize_t o2hb_region_blocks_store(struct 
> config_item *item,
>   unsigned long tmp;
>   char *p = (char *)page;
>  
> - if (reg->hr_bdev)
> + if (!reg || reg->hr_bdev)
>   return -EINVAL;
>  
>   tmp = simple_strtoul(p, , 0);
> 


[PATCH] clk: bcm2835: Fix memory leak in bcm2835_register_pll

2019-10-09 Thread Navid Emamdoost
In the implementation of bcm2835_register_pll(), the allocated memory
for pll should be released if devm_clk_hw_register() fails.

Fixes: b19f009d4510 ("clk: bcm2835: Migrate to clk_hw based registration and OF 
APIs")
Signed-off-by: Navid Emamdoost 
---
 drivers/clk/bcm/clk-bcm2835.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 802e488fd3c3..99549642110a 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -1320,8 +1320,10 @@ static struct clk_hw *bcm2835_register_pll(struct 
bcm2835_cprman *cprman,
pll->hw.init = 
 
ret = devm_clk_hw_register(cprman->dev, >hw);
-   if (ret)
+   if (ret) {
+   kfree(pll);
return NULL;
+   }
return >hw;
 }
 
-- 
2.17.1



Re: [PATCH] iommu/vt-d: Return the correct dma mask when we are bypassing the IOMMU

2019-10-09 Thread Lu Baolu

Hi,

On 10/8/19 10:33 PM, Arvind Sankar wrote:

We must return a mask covering the full physical RAM when bypassing the
IOMMU mapping. Also, in iommu_need_mapping, we need to check using
dma_direct_get_required_mask to ensure that the device's dma_mask can
cover physical RAM before deciding to bypass IOMMU mapping.

Fixes: 249baa547901 ("dma-mapping: provide a better default 
->get_required_mask")
Reported-by: Arvind Sankar 
Tested-by: Arvind Sankar 
Originally-by: Christoph Hellwig 
Signed-off-by: Christoph Hellwig 
Fixed-by: Arvind Sankar 
Signed-off-by: Arvind Sankar 


This patch looks good to me.

Reviewed-by: Lu Baolu 


---
  drivers/iommu/intel-iommu.c | 10 +-
  1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 3f974919d3bd..79e35b3180ac 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -3471,7 +3471,7 @@ static bool iommu_need_mapping(struct device *dev)
if (dev->coherent_dma_mask && dev->coherent_dma_mask < dma_mask)
dma_mask = dev->coherent_dma_mask;
  
-		if (dma_mask >= dma_get_required_mask(dev))

+   if (dma_mask >= dma_direct_get_required_mask(dev))
return false;
  
  		/*

@@ -3775,6 +3775,13 @@ static int intel_map_sg(struct device *dev, struct 
scatterlist *sglist, int nele
return nelems;
  }
  
+static u64 intel_get_required_mask(struct device *dev)

+{
+   if (!iommu_need_mapping(dev))
+   return dma_direct_get_required_mask(dev);
+   return DMA_BIT_MASK(32);
+}
+
  static const struct dma_map_ops intel_dma_ops = {
.alloc = intel_alloc_coherent,
.free = intel_free_coherent,
@@ -3787,6 +3794,7 @@ static const struct dma_map_ops intel_dma_ops = {
.dma_supported = dma_direct_supported,
.mmap = dma_common_mmap,
.get_sgtable = dma_common_get_sgtable,
+   .get_required_mask = intel_get_required_mask,
  };
  
  static void




Re: [PATCH v7 4/7] KVM: VMX: Load Guest CET via VMCS when CET is enabled in Guest

2019-10-09 Thread Yang Weijiang
On Wed, Oct 09, 2019 at 04:08:50PM -0700, Jim Mattson wrote:
> On Tue, Oct 8, 2019 at 11:41 PM Yang Weijiang  wrote:
> >
> > On Wed, Oct 02, 2019 at 11:54:26AM -0700, Jim Mattson wrote:
> > > On Thu, Sep 26, 2019 at 7:17 PM Yang Weijiang  
> > > wrote:
> > > > +   if (cet_on)
> > > > +   vmcs_set_bits(VM_ENTRY_CONTROLS,
> > > > + VM_ENTRY_LOAD_GUEST_CET_STATE);
> > >
> > > Have we ensured that this VM-entry control is supported on the platform?
> > >
> > If all the checks pass, is it enought to ensure the control bit supported?
> 
> I don't think so. The only way to check to see if a VM-entry control
> is supported is to check the relevant VMX capability MSR.
>
It's a bit odd, there's no relevant CET bit in VMX cap. MSR, so I have
to check like this.

> BTW, what about the corresponding VM-exit control?
The kernel supervisor mode CET is not implemented yet, so I don't load host CET
states on VM-exit, in future, I'll add it.


Re: [PATCH] iommu/vt-d: Return the correct dma mask when we are bypassing the IOMMU

2019-10-09 Thread Lu Baolu

Hi Christoph,

On 10/9/19 2:51 PM, Christoph Hellwig wrote:

On Wed, Oct 09, 2019 at 10:45:15AM +0800, Lu Baolu wrote:

Do you mind explaining why we always return 32 bit here?


See the comment in dma_get_required_mask().



Got it. Thank you.

Best regards,
Baolu


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

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

If I am correct, this is removed in a recent patch.

>-- 
>Mike Kravetz

-- 
Wei Yang
Help you, Help me


  1   2   3   4   5   6   7   8   9   10   >