Re: [PATCH v2] Convert struct pid count to refcount_t

2019-07-01 Thread Jann Horn
On Fri, Jun 28, 2019 at 9:35 PM Joel Fernandes (Google)
 wrote:
> struct pid's count is an atomic_t field used as a refcount. Use
> refcount_t for it which is basically atomic_t but does additional
> checking to prevent use-after-free bugs.
[...]
>  struct pid
>  {
> -   atomic_t count;
> +   refcount_t count;
[...]
> diff --git a/kernel/pid.c b/kernel/pid.c
> index 20881598bdfa..89c4849fab5d 100644
> --- a/kernel/pid.c
> +++ b/kernel/pid.c
> @@ -37,7 +37,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>
> @@ -106,8 +106,7 @@ void put_pid(struct pid *pid)

init_struct_pid is defined as follows:

struct pid init_struct_pid = {
.count  = ATOMIC_INIT(1),
[...]
};

This should be changed to REFCOUNT_INIT(1).

You should have received a compiler warning about this; I get the
following when trying to build with your patch applied:

jannh@jannh2:~/git/foreign/linux$ make kernel/pid.o
  CALLscripts/checksyscalls.sh
  CALLscripts/atomic/check-atomics.sh
  DESCEND  objtool
  CC  kernel/pid.o
kernel/pid.c:44:30: warning: missing braces around initializer
[-Wmissing-braces]
 struct pid init_struct_pid = {
  ^
kernel/pid.c:44:30: warning: missing braces around initializer
[-Wmissing-braces]
kernel/pid.c:44:30: warning: missing braces around initializer
[-Wmissing-braces]
kernel/pid.c:44:30: warning: missing braces around initializer
[-Wmissing-braces]
kernel/pid.c:44:30: warning: missing braces around initializer
[-Wmissing-braces]


Re: [PATCH net-next v2 00/10] net: stmmac: 10GbE using XGMAC

2019-07-01 Thread David Miller
From: Jose Abreu 
Date: Mon, 1 Jul 2019 10:19:55 +

> From: David Miller 
> 
>> About the Kconfig change, maybe it just doesn't make sense to list all
>> of the various speeds the chip supports... just a thought.
> 
> What about: "STMicroelectronics Multi-Gigabit Ethernet driver" ?
> 
> Or, just "STMicroelectronics Ethernet driver" ?

Maybe the first one is better, I don't know.  What are the chances of there
being more STMicroelectronics ethernet NICs? :-)



kernel BUG at include/linux/kvm_host.h:LINE!

2019-07-01 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:6fbc7275 Linux 5.2-rc7
git tree:   upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16d8d2cda0
kernel config:  https://syzkaller.appspot.com/x/.config?x=f6451f0da3d42d53
dashboard link: https://syzkaller.appspot.com/bug?extid=bfdba32e6c49af090931
compiler:   gcc (GCC) 9.0.0 20181231 (experimental)

Unfortunately, I don't have any reproducer for this crash yet.

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

[ cut here ]
kernel BUG at include/linux/kvm_host.h:579!
invalid opcode:  [#1] PREEMPT SMP KASAN
CPU: 0 PID: 5546 Comm: syz-executor.4 Not tainted 5.2.0-rc7 #65
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

RIP: 0010:kvm_vcpu_get_idx include/linux/kvm_host.h:579 [inline]
RIP: 0010:kvm_vcpu_get_idx include/linux/kvm_host.h:571 [inline]
RIP: 0010:kvm_hv_set_msr arch/x86/kvm/hyperv.c:1082 [inline]
RIP: 0010:kvm_hv_set_msr_common+0x241d/0x2ab0 arch/x86/kvm/hyperv.c:1303
Code: fa 48 c1 ea 03 80 3c 02 00 0f 85 c6 03 00 00 48 8b 85 28 ff ff ff 45  
31 e4 49 89 87 20 2e 00 00 e9 10 dd ff ff e8 53 aa 58 00 <0f> 0b 4c 89 ff  
e8 29 58 91 00 e9 8d de ff ff 4c 89 ff e8 1c 58 91

RSP: 0018:88804f8a73d8 EFLAGS: 00010216
RAX: 0004 RBX:  RCX: c9000e83e000
RDX: 1051 RSI: 811818ed RDI: 0004
RBP: 88804f8a74f0 R08: 888061eda0c0 R09: f52002c4bb3b
R10: f52002c4bb3a R11: c9001625d9d3 R12: dc00
R13:  R14: c9001625d9d0 R15: 888057209980
FS:  7f8cdaf27700() GS:8880ae80() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 7fd93ee22db8 CR3: 993e9000 CR4: 001426f0
Call Trace:
 kvm_set_msr_common+0xb8f/0x2570 arch/x86/kvm/x86.c:2662
 vmx_set_msr+0x710/0x21d0 arch/x86/kvm/vmx/vmx.c:2030
 kvm_set_msr+0x18a/0x370 arch/x86/kvm/x86.c:1359
 do_set_msr+0xa6/0xf0 arch/x86/kvm/x86.c:1388
 __msr_io arch/x86/kvm/x86.c:2975 [inline]
 msr_io+0x1ad/0x2e0 arch/x86/kvm/x86.c:3011
 kvm_arch_vcpu_ioctl+0x12be/0x3000 arch/x86/kvm/x86.c:4032
 kvm_vcpu_ioctl+0x8f6/0xf90 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2905
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:509 [inline]
 do_vfs_ioctl+0xd5f/0x1380 fs/ioctl.c:696
 ksys_ioctl+0xab/0xd0 fs/ioctl.c:713
 __do_sys_ioctl fs/ioctl.c:720 [inline]
 __se_sys_ioctl fs/ioctl.c:718 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x459519
Code: fd b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7  
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff  
ff 0f 83 cb b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00

RSP: 002b:7f8cdaf26c78 EFLAGS: 0246 ORIG_RAX: 0010
RAX: ffda RBX: 0003 RCX: 00459519
RDX: 2280 RSI: 4008ae89 RDI: 0005
RBP: 0075bfc8 R08:  R09: 
R10:  R11: 0246 R12: 7f8cdaf276d4
R13: 004c249d R14: 004d5708 R15: 
Modules linked in:
---[ end trace 4d93e12c89ced131 ]---
RIP: 0010:kvm_vcpu_get_idx include/linux/kvm_host.h:579 [inline]
RIP: 0010:kvm_vcpu_get_idx include/linux/kvm_host.h:571 [inline]
RIP: 0010:kvm_hv_set_msr arch/x86/kvm/hyperv.c:1082 [inline]
RIP: 0010:kvm_hv_set_msr_common+0x241d/0x2ab0 arch/x86/kvm/hyperv.c:1303
Code: fa 48 c1 ea 03 80 3c 02 00 0f 85 c6 03 00 00 48 8b 85 28 ff ff ff 45  
31 e4 49 89 87 20 2e 00 00 e9 10 dd ff ff e8 53 aa 58 00 <0f> 0b 4c 89 ff  
e8 29 58 91 00 e9 8d de ff ff 4c 89 ff e8 1c 58 91

RSP: 0018:88804f8a73d8 EFLAGS: 00010216
RAX: 0004 RBX:  RCX: c9000e83e000
RDX: 1051 RSI: 811818ed RDI: 0004
RBP: 88804f8a74f0 R08: 888061eda0c0 R09: f52002c4bb3b
R10: f52002c4bb3a R11: c9001625d9d3 R12: dc00
R13:  R14: c9001625d9d0 R15: 888057209980
FS:  7f8cdaf27700() GS:8880ae80() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 7ffdcaa36dec CR3: 993e9000 CR4: 001426f0


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkal...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.


Re: [PATCH 2/2] MIPS: don't select ARCH_HAS_PTE_SPECIAL

2019-07-01 Thread Guenter Roeck
On Mon, Jul 01, 2019 at 05:18:18PM +0200, Christoph Hellwig wrote:
> MIPS doesn't really have a proper pte_special implementation, just
> stubs.  It turns out they were not enough to make get_user_pages_fast
> work, so drop the select.  This means get_user_pages_fast won't
> actually use the fast path for non-hugepage mappings, so someone who
> actually knows about mips page table management should look into
> adding real pte_special support.
> 
> Fixes: eb9488e58bbc ("MIPS: use the generic get_user_pages_fast code")
> Reported-by: Guenter Roeck 
> Signed-off-by: Christoph Hellwig 

Tested-by: Guenter Roeck 

> ---
>  arch/mips/Kconfig | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index b1e42f0e4ed0..7957d3457156 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -6,7 +6,6 @@ config MIPS
>   select ARCH_BINFMT_ELF_STATE if MIPS_FP_SUPPORT
>   select ARCH_CLOCKSOURCE_DATA
>   select ARCH_HAS_ELF_RANDOMIZE
> - select ARCH_HAS_PTE_SPECIAL
>   select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
>   select ARCH_HAS_UBSAN_SANITIZE_ALL
>   select ARCH_SUPPORTS_UPROBES
> -- 
> 2.20.1
> 


Re: [PATCH 1/2] sh: stub out pud_page

2019-07-01 Thread Guenter Roeck
On Mon, Jul 01, 2019 at 05:18:17PM +0200, Christoph Hellwig wrote:
> There wasn't any actual need to add a real pud_page, as pud_huge
> always returns false on sh.  Just stub it out to fix the sh3
> compile failure.
> 
> Fixes: 937b4e1d6471 ("sh: add the missing pud_page definition")
> Reported-by: Guenter Roeck 
> Signed-off-by: Christoph Hellwig 

Tested-by: Guenter Roeck 

> ---
>  arch/sh/include/asm/pgtable-3level.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/sh/include/asm/pgtable-3level.h 
> b/arch/sh/include/asm/pgtable-3level.h
> index 3c7ff20f3f94..779260b721ca 100644
> --- a/arch/sh/include/asm/pgtable-3level.h
> +++ b/arch/sh/include/asm/pgtable-3level.h
> @@ -37,7 +37,9 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
>  {
>   return pud_val(pud);
>  }
> -#define pud_page(pud)pfn_to_page(pud_pfn(pud))
> +
> +/* only used by the stubbed out hugetlb gup code, should never be called */
> +#define pud_page(pud)NULL
>  
>  #define pmd_index(address)   (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
>  static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
> -- 
> 2.20.1
> 


Re: [PATCH v3] Staging: most: fix coding style issues

2019-07-01 Thread kbuild test robot
Hi Gabriel,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v5.2-rc6 next-20190625]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Gabriel-Beauchamp/Staging-most-fix-coding-style-issues/20190701-203804
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-rc1-7-g2b96cd8-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot 


sparse warnings: (new ones prefixed by >>)


vim +308 drivers/staging/most/core.c

   296  
   297  static ssize_t set_datatype_show(struct device *dev,
   298   struct device_attribute *attr,
   299   char *buf)
   300  {
   301  int i;
   302  char *type = "unconfigured\n";
   303  
   304  struct most_channel *c = to_channel(dev);
   305  
   306  for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
   307  if (c->cfg.data_type & 
ch_data_type[i].most_ch_data_type) {
 > 308  type = ch_data_type[i].name;
   309  break;
   310  }
   311  }
   312  return snprintf(buf, PAGE_SIZE, "%s", type);
   313  }
   314  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


Re: [PATCH] soc: ti: fix irq-ti-sci link error

2019-07-01 Thread santosh . shilimkar

On 6/17/19 6:01 AM, Arnd Bergmann wrote:

The irqchip driver depends on the SoC specific driver, but we want
to be able to compile-test it elsewhere:

WARNING: unmet direct dependencies detected for TI_SCI_INTA_MSI_DOMAIN
   Depends on [n]: SOC_TI [=n]
   Selected by [y]:
   - TI_SCI_INTA_IRQCHIP [=y] && TI_SCI_PROTOCOL [=y]

drivers/irqchip/irq-ti-sci-inta.o: In function `ti_sci_inta_irq_domain_probe':
irq-ti-sci-inta.c:(.text+0x204): undefined reference to 
`ti_sci_inta_msi_create_irq_domain'

Rearrange the Kconfig and Makefile so we build the soc driver whenever
its users are there, regardless of the SOC_TI option.

Fixes: 49b323157bf1 ("soc: ti: Add MSI domain bus support for Interrupt 
Aggregator")
Fixes: f011df6179bd ("irqchip/ti-sci-inta: Add msi domain support")
Signed-off-by: Arnd Bergmann 
---

Thanks Arnd. Will you be able to add it to your fixes queue.

FWIW, Acked-by: Santosh Shilimkar 


[PATCH] x86/ldt: Initialize the context lock for init_mm

2019-07-01 Thread Sebastian Andrzej Siewior
The mutex mm->context->lock for init_mm is not initialized for init_mm.
This wasn't a problem because it remained unused. This changed however
since commit
4fc19708b165c ("x86/alternatives: Initialize temporary mm for patching")

Initialize the mutex for init_mm.

Fixes: 4fc19708b165c ("x86/alternatives: Initialize temporary mm for patching")
Signed-off-by: Sebastian Andrzej Siewior 
---

The rwsem `ldt_usr_sem' is also not initialized for init_mm. No idea if
we want this.

 arch/x86/include/asm/mmu.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
index 5ff3e8af2c205..e78c7db878018 100644
--- a/arch/x86/include/asm/mmu.h
+++ b/arch/x86/include/asm/mmu.h
@@ -59,6 +59,7 @@ typedef struct {
 #define INIT_MM_CONTEXT(mm)\
.context = {\
.ctx_id = 1,\
+   .lock = __MUTEX_INITIALIZER(mm.context.lock),   \
}
 
 void leave_mm(int cpu);
-- 
2.20.1



Re: [PATCH] ceph: fix end offset in truncate_inode_pages_range call

2019-07-01 Thread Jeff Layton
On Mon, 2019-07-01 at 18:16 +0100, Luis Henriques wrote:
> Commit e450f4d1a5d6 ("ceph: pass inclusive lend parameter to
> filemap_write_and_wait_range()") fixed the end offset parameter used to
> call filemap_write_and_wait_range and invalidate_inode_pages2_range.
> Unfortunately it missed truncate_inode_pages_range, introducing a
> regression that is easily detected by xfstest generic/130.
> 
> The problem is that when doing direct IO it is possible that an extra page
> is truncated from the page cache when the end offset is page aligned.
> This can cause data loss if that page hasn't been sync'ed to the OSDs.
> 
> While there, change code to use PAGE_ALIGN macro instead.
> 
> Fixes: e450f4d1a5d6 ("ceph: pass inclusive lend parameter to 
> filemap_write_and_wait_range()")
> Signed-off-by: Luis Henriques 
> ---
>  fs/ceph/file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index 183c37c0a8fc..7a57db8e2fa9 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -1007,7 +1007,7 @@ (struct kiocb *iocb, struct iov_iter *iter,
>* may block.
>*/
>   truncate_inode_pages_range(inode->i_mapping, pos,
> - (pos+len) | (PAGE_SIZE - 1));
> +PAGE_ALIGN(pos + len) - 1);
>  
>   req->r_mtime = mtime;
>   }

Reviewed-by: Jeff Layton 



[PATCH] mm/z3fold: Fix z3fold_buddy_slots use after free

2019-07-01 Thread Henry Burns
Running z3fold stress testing with address sanitization
showed zhdr->slots was being used after it was freed.

z3fold_free(z3fold_pool, handle)
  free_handle(handle)
kmem_cache_free(pool->c_handle, zhdr->slots)
  release_z3fold_page_locked_list(kref)
__release_z3fold_page(zhdr, true)
  zhdr_to_pool(zhdr)
slots_to_pool(zhdr->slots)  *BOOM*

Instead we split free_handle into two functions, release_handle()
and free_slots(). We use release_handle() in place of free_handle(),
and use free_slots() to call kmem_cache_free() after
__release_z3fold_page() is done.

Fixes: 7c2b8baa61fe  ("mm/z3fold.c: add structure for buddy handles")
Signed-off-by: Henry Burns 
---
 mm/z3fold.c | 33 ++---
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/mm/z3fold.c b/mm/z3fold.c
index f7993ff778df..e174d1549734 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -213,31 +213,24 @@ static inline struct z3fold_buddy_slots 
*handle_to_slots(unsigned long handle)
return (struct z3fold_buddy_slots *)(handle & ~(SLOTS_ALIGN - 1));
 }
 
-static inline void free_handle(unsigned long handle)
+static inline void release_handle(unsigned long handle)
 {
-   struct z3fold_buddy_slots *slots;
-   int i;
-   bool is_free;
-
if (handle & (1 << PAGE_HEADLESS))
return;
 
WARN_ON(*(unsigned long *)handle == 0);
*(unsigned long *)handle = 0;
-   slots = handle_to_slots(handle);
-   is_free = true;
-   for (i = 0; i <= BUDDY_MASK; i++) {
-   if (slots->slot[i]) {
-   is_free = false;
-   break;
-   }
-   }
+}
 
-   if (is_free) {
-   struct z3fold_pool *pool = slots_to_pool(slots);
+/* At this point all of the slots should be empty */
+static inline void free_slots(struct z3fold_buddy_slots *slots)
+{
+   struct z3fold_pool *pool = slots_to_pool(slots);
+   int i;
 
-   kmem_cache_free(pool->c_handle, slots);
-   }
+   for (i = 0; i <= BUDDY_MASK; i++)
+   VM_BUG_ON(slots->slot[i]);
+   kmem_cache_free(pool->c_handle, slots);
 }
 
 static struct dentry *z3fold_do_mount(struct file_system_type *fs_type,
@@ -431,7 +424,8 @@ static inline struct z3fold_pool *zhdr_to_pool(struct 
z3fold_header *zhdr)
 static void __release_z3fold_page(struct z3fold_header *zhdr, bool locked)
 {
struct page *page = virt_to_page(zhdr);
-   struct z3fold_pool *pool = zhdr_to_pool(zhdr);
+   struct z3fold_buddy_slots *slots = zhdr->slots;
+   struct z3fold_pool *pool = slots_to_pool(slots);
 
WARN_ON(!list_empty(>buddy));
set_bit(PAGE_STALE, >private);
@@ -442,6 +436,7 @@ static void __release_z3fold_page(struct z3fold_header 
*zhdr, bool locked)
spin_unlock(>lock);
if (locked)
z3fold_page_unlock(zhdr);
+   free_slots(slots);
spin_lock(>stale_lock);
list_add(>buddy, >stale);
queue_work(pool->release_wq, >work);
@@ -1009,7 +1004,7 @@ static void z3fold_free(struct z3fold_pool *pool, 
unsigned long handle)
return;
}
 
-   free_handle(handle);
+   release_handle(handle);
if (kref_put(>refcount, release_z3fold_page_locked_list)) {
atomic64_dec(>pages_nr);
return;
-- 
2.22.0.410.gd8fdbe21b5-goog



Re: [Kernel BUG?] SMSW operation get success on UMIP KVM guest

2019-07-01 Thread Paolo Bonzini
On 01/07/19 16:53, Ricardo Neri wrote:
>>
>> (*) before the x86 people jump at me, this won't happen unless you
>> explicitly pass an option to QEMU, such as "-cpu host,+umip". :)  The
>> incorrect emulation of SMSW when CR4.UMIP=1 is why.
> Paolo, what do you mean by the incorrect emulation of SMSW?

When KVM tries to emulate UMIP on a system that doesn't have it, SMSW
won't cause a #GP.  The processor is simply not able to trap to the
hypervisor on SMSW (unlike SGDT/SIDT/SLDT/STR), so it's impossible to do
better.

Paolo


[PATCH v3] ALSA: hda: Fix widget_mutex incomplete protection

2019-07-01 Thread Evan Green
The widget_mutex was introduced to serialize callers to
hda_widget_sysfs_{re}init. However, its protection of the sysfs widget array
is incomplete. For example, it is acquired around the call to
hda_widget_sysfs_reinit(), which actually creates the new array, but isn't
still acquired when codec->num_nodes and codec->start_nid is updated. So
the lock ensures one thread sets up the new array at a time, but doesn't
ensure which thread's value will end up in codec->num_nodes. If a larger
num_nodes wins but a smaller array was set up, the next call to
refresh_widgets() will touch free memory as it iterates over codec->num_nodes
that aren't there.

The widget_lock really protects both the tree as well as codec->num_nodes,
start_nid, and end_nid, so make sure it's held across that update. It should
also be held during snd_hdac_get_sub_nodes(), so that a very old read from that
function doesn't end up clobbering a later update.

Fixes: ed180abba7f1 ("ALSA: hda: Fix race between creating and refreshing sysfs 
entries")

Signed-off-by: Evan Green 

---

Changes in v3:
- Moved locking back into callers (Takashi)
- Combined update_widgets exit flow (Takashi)

Changes in v2:
- Introduced widget_mutex relocation

 sound/hda/hdac_device.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c
index 6907dbefd08c..3842f9d34b7c 100644
--- a/sound/hda/hdac_device.c
+++ b/sound/hda/hdac_device.c
@@ -400,27 +400,33 @@ static void setup_fg_nodes(struct hdac_device *codec)
 int snd_hdac_refresh_widgets(struct hdac_device *codec, bool sysfs)
 {
hda_nid_t start_nid;
-   int nums, err;
+   int nums, err = 0;
 
+   /*
+* Serialize against multiple threads trying to update the sysfs
+* widgets array.
+*/
+   mutex_lock(>widget_lock);
nums = snd_hdac_get_sub_nodes(codec, codec->afg, _nid);
if (!start_nid || nums <= 0 || nums >= 0xff) {
dev_err(>dev, "cannot read sub nodes for FG 0x%02x\n",
codec->afg);
-   return -EINVAL;
+   err = -EINVAL;
+   goto unlock;
}
 
if (sysfs) {
-   mutex_lock(>widget_lock);
err = hda_widget_sysfs_reinit(codec, start_nid, nums);
-   mutex_unlock(>widget_lock);
if (err < 0)
-   return err;
+   goto unlock;
}
 
codec->num_nodes = nums;
codec->start_nid = start_nid;
codec->end_nid = start_nid + nums;
-   return 0;
+unlock:
+   mutex_unlock(>widget_lock);
+   return err;
 }
 EXPORT_SYMBOL_GPL(snd_hdac_refresh_widgets);
 
-- 
2.20.1



Re: [PATCH v2] mdev: Send uevents around parent device registration

2019-07-01 Thread Alex Williamson
On Mon, 1 Jul 2019 22:43:10 +0530
Kirti Wankhede  wrote:

> On 7/1/2019 8:24 PM, Alex Williamson wrote:
> > This allows udev to trigger rules when a parent device is registered
> > or unregistered from mdev.
> > 
> > Signed-off-by: Alex Williamson 
> > ---
> > 
> > v2: Don't remove the dev_info(), Kirti requested they stay and
> > removing them is only tangential to the goal of this change.
> >   
> 
> Thanks.
> 
> 
> >  drivers/vfio/mdev/mdev_core.c |8 
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
> > index ae23151442cb..7fb268136c62 100644
> > --- a/drivers/vfio/mdev/mdev_core.c
> > +++ b/drivers/vfio/mdev/mdev_core.c
> > @@ -146,6 +146,8 @@ int mdev_register_device(struct device *dev, const 
> > struct mdev_parent_ops *ops)
> >  {
> > int ret;
> > struct mdev_parent *parent;
> > +   char *env_string = "MDEV_STATE=registered";
> > +   char *envp[] = { env_string, NULL };
> >  
> > /* check for mandatory ops */
> > if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups)
> > @@ -197,6 +199,8 @@ int mdev_register_device(struct device *dev, const 
> > struct mdev_parent_ops *ops)
> > mutex_unlock(_list_lock);
> >  
> > dev_info(dev, "MDEV: Registered\n");
> > +   kobject_uevent_env(>kobj, KOBJ_CHANGE, envp);
> > +
> > return 0;
> >  
> >  add_dev_err:
> > @@ -220,6 +224,8 @@ EXPORT_SYMBOL(mdev_register_device);
> >  void mdev_unregister_device(struct device *dev)
> >  {
> > struct mdev_parent *parent;
> > +   char *env_string = "MDEV_STATE=unregistered";
> > +   char *envp[] = { env_string, NULL };
> >  
> > mutex_lock(_list_lock);
> > parent = __find_parent_device(dev);
> > @@ -243,6 +249,8 @@ void mdev_unregister_device(struct device *dev)
> > up_write(>unreg_sem);
> >  
> > mdev_put_parent(parent);
> > +
> > +   kobject_uevent_env(>kobj, KOBJ_CHANGE, envp);  
> 
> mdev_put_parent() calls put_device(dev). If this is the last instance
> holding device, then on put_device(dev) dev would get freed.
> 
> This event should be before mdev_put_parent()

So you're suggesting the vendor driver is calling
mdev_unregister_device() without a reference to the struct device that
it's passing to unregister?  Sounds bogus to me.  We take a
reference to the device so that it can't disappear out from under us,
the caller cannot rely on our reference and the caller provided the
struct device.  Thanks,

Alex


Re: [PATCH net v2] ipv4: don't set IPv6 only flags to IPv4 addresses

2019-07-01 Thread David Ahern
On 7/1/19 11:01 AM, Matteo Croce wrote:
> Avoid the situation where an IPV6 only flag is applied to an IPv4 address:
> 
> # ip addr add 192.0.2.1/24 dev dummy0 nodad home mngtmpaddr noprefixroute
> # ip -4 addr show dev dummy0
> 2: dummy0:  mtu 1500 qdisc noqueue state 
> UNKNOWN group default qlen 1000
> inet 192.0.2.1/24 scope global noprefixroute dummy0
>valid_lft forever preferred_lft forever
> 
> Or worse, by sending a malicious netlink command:
> 
> # ip -4 addr show dev dummy0
> 2: dummy0:  mtu 1500 qdisc noqueue state 
> UNKNOWN group default qlen 1000
> inet 192.0.2.1/24 scope global nodad optimistic dadfailed home 
> tentative mngtmpaddr noprefixroute stable-privacy dummy0
>valid_lft forever preferred_lft forever
> 
> Signed-off-by: Matteo Croce 
> ---
>  net/ipv4/devinet.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> index c6bd0f7a020a..c5ebfa199794 100644
> --- a/net/ipv4/devinet.c
> +++ b/net/ipv4/devinet.c
> @@ -62,6 +62,11 @@
>  #include 
>  #include 
>  
> +#define IPV6ONLY_FLAGS   \
> + (IFA_F_NODAD | IFA_F_OPTIMISTIC | IFA_F_DADFAILED | \
> +  IFA_F_HOMEADDRESS | IFA_F_TENTATIVE | \
> +  IFA_F_MANAGETEMPADDR | IFA_F_STABLE_PRIVACY)
> +
>  static struct ipv4_devconf ipv4_devconf = {
>   .data = {
>   [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 1,
> @@ -468,6 +473,9 @@ static int __inet_insert_ifa(struct in_ifaddr *ifa, 
> struct nlmsghdr *nlh,
>   ifa->ifa_flags &= ~IFA_F_SECONDARY;
>   last_primary = _dev->ifa_list;
>  
> + /* Don't set IPv6 only flags to IPv4 addresses */
> + ifa->ifa_flags &= ~IPV6ONLY_FLAGS;
> +
>   for (ifap = _dev->ifa_list; (ifa1 = *ifap) != NULL;
>ifap = >ifa_next) {
>   if (!(ifa1->ifa_flags & IFA_F_SECONDARY) &&
> 

I guess at this point we can fail the address add, so this is the best
option. rtm_to_ifaddr could set a message in extack about invalid flags
- not fail the change, just warn the user that flags will be ignored.

Reviewed-by: David Ahern 



[PATCH] ceph: fix end offset in truncate_inode_pages_range call

2019-07-01 Thread Luis Henriques
Commit e450f4d1a5d6 ("ceph: pass inclusive lend parameter to
filemap_write_and_wait_range()") fixed the end offset parameter used to
call filemap_write_and_wait_range and invalidate_inode_pages2_range.
Unfortunately it missed truncate_inode_pages_range, introducing a
regression that is easily detected by xfstest generic/130.

The problem is that when doing direct IO it is possible that an extra page
is truncated from the page cache when the end offset is page aligned.
This can cause data loss if that page hasn't been sync'ed to the OSDs.

While there, change code to use PAGE_ALIGN macro instead.

Fixes: e450f4d1a5d6 ("ceph: pass inclusive lend parameter to 
filemap_write_and_wait_range()")
Signed-off-by: Luis Henriques 
---
 fs/ceph/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 183c37c0a8fc..7a57db8e2fa9 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1007,7 +1007,7 @@ ceph_direct_read_write(struct kiocb *iocb, struct 
iov_iter *iter,
 * may block.
 */
truncate_inode_pages_range(inode->i_mapping, pos,
-   (pos+len) | (PAGE_SIZE - 1));
+  PAGE_ALIGN(pos + len) - 1);
 
req->r_mtime = mtime;
}


Re: [PATCH v2] mdev: Send uevents around parent device registration

2019-07-01 Thread Kirti Wankhede



On 7/1/2019 8:24 PM, Alex Williamson wrote:
> This allows udev to trigger rules when a parent device is registered
> or unregistered from mdev.
> 
> Signed-off-by: Alex Williamson 
> ---
> 
> v2: Don't remove the dev_info(), Kirti requested they stay and
> removing them is only tangential to the goal of this change.
> 

Thanks.


>  drivers/vfio/mdev/mdev_core.c |8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
> index ae23151442cb..7fb268136c62 100644
> --- a/drivers/vfio/mdev/mdev_core.c
> +++ b/drivers/vfio/mdev/mdev_core.c
> @@ -146,6 +146,8 @@ int mdev_register_device(struct device *dev, const struct 
> mdev_parent_ops *ops)
>  {
>   int ret;
>   struct mdev_parent *parent;
> + char *env_string = "MDEV_STATE=registered";
> + char *envp[] = { env_string, NULL };
>  
>   /* check for mandatory ops */
>   if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups)
> @@ -197,6 +199,8 @@ int mdev_register_device(struct device *dev, const struct 
> mdev_parent_ops *ops)
>   mutex_unlock(_list_lock);
>  
>   dev_info(dev, "MDEV: Registered\n");
> + kobject_uevent_env(>kobj, KOBJ_CHANGE, envp);
> +
>   return 0;
>  
>  add_dev_err:
> @@ -220,6 +224,8 @@ EXPORT_SYMBOL(mdev_register_device);
>  void mdev_unregister_device(struct device *dev)
>  {
>   struct mdev_parent *parent;
> + char *env_string = "MDEV_STATE=unregistered";
> + char *envp[] = { env_string, NULL };
>  
>   mutex_lock(_list_lock);
>   parent = __find_parent_device(dev);
> @@ -243,6 +249,8 @@ void mdev_unregister_device(struct device *dev)
>   up_write(>unreg_sem);
>  
>   mdev_put_parent(parent);
> +
> + kobject_uevent_env(>kobj, KOBJ_CHANGE, envp);

mdev_put_parent() calls put_device(dev). If this is the last instance
holding device, then on put_device(dev) dev would get freed.

This event should be before mdev_put_parent()

Thanks,
Kirti

>  }
>  EXPORT_SYMBOL(mdev_unregister_device);
>  
> 


Re: [PATCH v2 0/3] vsock/virtio: several fixes in the .probe() and .remove()

2019-07-01 Thread Stefano Garzarella
On Mon, Jul 01, 2019 at 04:11:13PM +0100, Stefan Hajnoczi wrote:
> On Fri, Jun 28, 2019 at 02:36:56PM +0200, Stefano Garzarella wrote:
> > During the review of "[PATCH] vsock/virtio: Initialize core virtio vsock
> > before registering the driver", Stefan pointed out some possible issues
> > in the .probe() and .remove() callbacks of the virtio-vsock driver.
> > 
> > This series tries to solve these issues:
> > - Patch 1 adds RCU critical sections to avoid use-after-free of
> >   'the_virtio_vsock' pointer.
> > - Patch 2 stops workers before to call vdev->config->reset(vdev) to
> >   be sure that no one is accessing the device.
> > - Patch 3 moves the works flush at the end of the .remove() to avoid
> >   use-after-free of 'vsock' object.
> > 
> > v2:
> > - Patch 1: use RCU to protect 'the_virtio_vsock' pointer
> > - Patch 2: no changes
> > - Patch 3: flush works only at the end of .remove()
> > - Removed patch 4 because virtqueue_detach_unused_buf() returns all the 
> > buffers
> >   allocated.
> > 
> > v1: https://patchwork.kernel.org/cover/10964733/
> 
> This looks good to me.

Thanks for the review!

> 
> Did you run any stress tests?  For example an SMP guest constantly
> connecting and sending packets together with a script that
> hotplug/unplugs vhost-vsock-pci from the host side.

Yes, I started an SMP guest (-smp 4 -monitor tcp:127.0.0.1:1234,server,nowait)
and I run these scripts to stress the .probe()/.remove() path:

- guest
  while true; do
  cat /dev/urandom | nc-vsock -l 4321 > /dev/null &
  cat /dev/urandom | nc-vsock -l 5321 > /dev/null &
  cat /dev/urandom | nc-vsock -l 6321 > /dev/null &
  cat /dev/urandom | nc-vsock -l 7321 > /dev/null &
  wait
  done

- host
  while true; do
  cat /dev/urandom | nc-vsock 3 4321 > /dev/null &
  cat /dev/urandom | nc-vsock 3 5321 > /dev/null &
  cat /dev/urandom | nc-vsock 3 6321 > /dev/null &
  cat /dev/urandom | nc-vsock 3 7321 > /dev/null &
  sleep 2
  echo "device_del v1" | nc 127.0.0.1 1234
  sleep 1
  echo "device_add vhost-vsock-pci,id=v1,guest-cid=3" | nc 127.0.0.1 1234
  sleep 1
  done

Do you think is enough or is better to have a test more accurate?

Thanks,
Stefano


[PATCH net v2] ipv4: don't set IPv6 only flags to IPv4 addresses

2019-07-01 Thread Matteo Croce
Avoid the situation where an IPV6 only flag is applied to an IPv4 address:

# ip addr add 192.0.2.1/24 dev dummy0 nodad home mngtmpaddr noprefixroute
# ip -4 addr show dev dummy0
2: dummy0:  mtu 1500 qdisc noqueue state 
UNKNOWN group default qlen 1000
inet 192.0.2.1/24 scope global noprefixroute dummy0
   valid_lft forever preferred_lft forever

Or worse, by sending a malicious netlink command:

# ip -4 addr show dev dummy0
2: dummy0:  mtu 1500 qdisc noqueue state 
UNKNOWN group default qlen 1000
inet 192.0.2.1/24 scope global nodad optimistic dadfailed home 
tentative mngtmpaddr noprefixroute stable-privacy dummy0
   valid_lft forever preferred_lft forever

Signed-off-by: Matteo Croce 
---
 net/ipv4/devinet.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index c6bd0f7a020a..c5ebfa199794 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -62,6 +62,11 @@
 #include 
 #include 
 
+#define IPV6ONLY_FLAGS \
+   (IFA_F_NODAD | IFA_F_OPTIMISTIC | IFA_F_DADFAILED | \
+IFA_F_HOMEADDRESS | IFA_F_TENTATIVE | \
+IFA_F_MANAGETEMPADDR | IFA_F_STABLE_PRIVACY)
+
 static struct ipv4_devconf ipv4_devconf = {
.data = {
[IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 1,
@@ -468,6 +473,9 @@ static int __inet_insert_ifa(struct in_ifaddr *ifa, struct 
nlmsghdr *nlh,
ifa->ifa_flags &= ~IFA_F_SECONDARY;
last_primary = _dev->ifa_list;
 
+   /* Don't set IPv6 only flags to IPv4 addresses */
+   ifa->ifa_flags &= ~IPV6ONLY_FLAGS;
+
for (ifap = _dev->ifa_list; (ifa1 = *ifap) != NULL;
 ifap = >ifa_next) {
if (!(ifa1->ifa_flags & IFA_F_SECONDARY) &&
-- 
2.21.0



[PATCH][next] clk: Si5341/Si5340: remove redundant assignment to n_den

2019-07-01 Thread Colin King
From: Colin Ian King 

The variable n_den is initialized however that value is never read
as n_den is re-assigned a little later in the two paths of a
following if-statement.  Remove the redundant assignment.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King 
---
 drivers/clk/clk-si5341.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/clk/clk-si5341.c b/drivers/clk/clk-si5341.c
index 72424eb7e5f8..6e780c2a9e6b 100644
--- a/drivers/clk/clk-si5341.c
+++ b/drivers/clk/clk-si5341.c
@@ -547,7 +547,6 @@ static int si5341_synth_clk_set_rate(struct clk_hw *hw, 
unsigned long rate,
bool is_integer;
 
n_num = synth->data->freq_vco;
-   n_den = rate;
 
/* see if there's an integer solution */
r = do_div(n_num, rate);
-- 
2.20.1



Re: [PATCH 03/10] sched,fair: redefine runnable_load_avg as the sum of task_h_load

2019-07-01 Thread Rik van Riel
On Mon, 2019-07-01 at 12:29 -0400, Josef Bacik wrote:
> On Fri, Jun 28, 2019 at 04:49:06PM -0400, Rik van Riel wrote:
> > The runnable_load magic is used to quickly propagate information
> > about
> > runnable tasks up the hierarchy of runqueues. The runnable_load_avg
> > is
> > mostly used for the load balancing code, which only examines the
> > value at
> > the root cfs_rq.
> > 
> > Redefine the root cfs_rq runnable_load_avg to be the sum of
> > task_h_loads
> > of the runnable tasks. This works because the hierarchical
> > runnable_load of
> > a task is already equal to the task_se_h_load today. This provides
> > enough
> > information to the load balancer.
> > 
> > The runnable_load_avg of the cgroup cfs_rqs does not appear to be
> > used for anything, so don't bother calculating those.
> > 
> > This removes one of the things that the code currently traverses
> > the
> > cgroup hierarchy for, and getting rid of it brings us one step
> > closer
> > to a flat runqueue for the CPU controller.
> > 
> 
> My memory on this stuff is very hazy, but IIRC we had the
> runnable_sum and the
> runnable_avg separated out because you could have the avg lag behind
> the sum.
> So like you enqueue a bunch of new entities who's avg may have
> decayed a bunch
> and so their overall load is not felt on the CPU until they start
> running, and
> now you've overloaded that CPU.  The sum was there to make sure new
> things
> coming onto the CPU added actual load to the queue instead of looking
> like there
> was no load.
> 
> Is this going to be a problem now with this new code?

That is a good question!

On the one hand, you may well be right.

On the other hand, while I see the old code calculating
runnable_sum, I don't really see it _using_ it to drive
scheduling decisions.

It would be easy to define the CPU cfs_rq->runnable_load_sum
as being the sum of task_se_h_weight() of each runnable task
on the CPU (for example), but what would we use it for?

What am I missing?

> +static inline void
> > +update_runnable_load_avg(struct sched_entity *se)
> > +{
> > +   struct cfs_rq *root_cfs_rq = _rq_of(se)->rq->cfs;
> > +   long new_h_load, delta;
> > +
> > +   SCHED_WARN_ON(!entity_is_task(se));
> > +
> > +   if (!se->on_rq)
> > +   return;
> >  
> > -   sub_positive(_rq->avg.runnable_load_avg, se-
> > >avg.runnable_load_avg);
> > -   sub_positive(_rq->avg.runnable_load_sum,
> > -se_runnable(se) * se->avg.runnable_load_sum);
> > +   new_h_load = task_se_h_load(se);
> > +   delta = new_h_load - se->enqueued_h_load;
> > +   root_cfs_rq->avg.runnable_load_avg += delta;
> 
> Should we use add_positive here?  Thanks,

Yes, we should use add_positive. I'll do that for v3.

-- 
All Rights Reversed.


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


[GIT PULL] LED updates for 5.3-rc1

2019-07-01 Thread Jacek Anaszewski
Hi Linus,

I'm sending early LED pull request for 5.3-rc1 since I will not
have access to the Internet for most part of the next week.
Please pull.

This time we move lm3697 backlight support from MFD to LED subsystem
and on top of that we add support for LED cell of LM36274 to the ti-lmu MFD
driver. All these, supplemented by the need for changes in lm363x-regulator.c,
required by LM36274, entailed the need for immutable branch between
LED, MFD and REGULATOR subsystems:

Merge tag 'ti-lmu-led-drivers' into for-next
leds: lm36274: Introduce the TI LM36274 LED driver
dt-bindings: leds: Add LED bindings for the LM36274
regulator: lm363x: Add support for LM36274
mfd: ti-lmu: Add LM36274 support to the ti-lmu
dt-bindings: mfd: Add lm36274 bindings to ti-lmu
leds: lm3697: Introduce the lm3697 driver
mfd: ti-lmu: Remove support for LM3697
dt-bindings: ti-lmu: Modify dt bindings for the LM3697
leds: TI LMU: Add common code for TI LMU devices
dt-bindings: mfd: LMU: Add ti,brightness-resolution
dt-bindings: mfd: LMU: Add the ramp up/down property

And here is the summary of this LED development cycle:

1) Add a new LED common module for ti-lmu driver family

2) Modify MFD ti-lmu bindings
- add ti,brightness-resolution
- add the ramp up/down property

3) Add regulator support for LM36274 driver to lm363x-regulator.c

4) New LED class drivers with DT bindings:
- leds-spi-byte
- leds-lm36274
- leds-lm3697 (move the support from MFD to LED subsystem)

5) Simplify getting the I2C adapter of a client:
- leds-tca6507
- leds-pca955x

6) Convert LED documentation to ReST


There is also the following in the diffstat:

- leds: avoid flush_work in atomic context,

but it was sent as a fix for 5.2-rc3, and I just didn't want to rebase
onto that because of the immutable branch that is based on 5.2-rc1.


The following changes since commit a188339ca5a396acc588e5851ed7e19f66b0ebd9:

  Linux 5.2-rc1 (2019-05-19 15:47:09 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git 
tags/leds-for-5.3-rc1

for you to fetch changes up to 2605085fba22792f3d4a6b856c7c5a05492d1fde:

  dt: leds-lm36274.txt: fix a broken reference to ti-lmu.txt (2019-06-28 
20:57:36 +0200)

Thanks,
Jacek Anaszewski


LED updates for 5.3-rc1

Christian Mauderer (2):
  dt-bindings: leds: Add binding for spi-byte LED.
  leds: spi-byte: add single byte SPI LED driver

Dan Murphy (11):
  dt-bindings: mfd: LMU: Add the ramp up/down property
  dt-bindings: mfd: LMU: Add ti,brightness-resolution
  leds: TI LMU: Add common code for TI LMU devices
  dt-bindings: ti-lmu: Modify dt bindings for the LM3697
  mfd: ti-lmu: Remove support for LM3697
  leds: lm3697: Introduce the lm3697 driver
  dt-bindings: mfd: Add lm36274 bindings to ti-lmu
  mfd: ti-lmu: Add LM36274 support to the ti-lmu
  regulator: lm363x: Add support for LM36274
  dt-bindings: leds: Add LED bindings for the LM36274
  leds: lm36274: Introduce the TI LM36274 LED driver

Jacek Anaszewski (1):
  Merge tag 'ti-lmu-led-drivers' into for-next

Mauro Carvalho Chehab (2):
  docs: leds: convert to ReST
  dt: leds-lm36274.txt: fix a broken reference to ti-lmu.txt

Pavel Machek (1):
  leds: avoid flush_work in atomic context

Wolfram Sang (2):
  leds: leds-pca955x: simplify getting the adapter of a client
  leds: leds-tca6507: simplify getting the adapter of a client

YueHaibing (1):
  leds: max77650: Remove set but not used variable 'parent'

 .../devicetree/bindings/leds/leds-lm36274.txt  |  85 +
 .../devicetree/bindings/leds/leds-lm3697.txt   |  73 
 .../devicetree/bindings/leds/leds-spi-byte.txt |  44 +++
 Documentation/devicetree/bindings/mfd/ti-lmu.txt   |  88 +++--
 Documentation/laptops/thinkpad-acpi.txt|   4 +-
 Documentation/leds/index.rst   |  25 ++
 .../leds/{leds-blinkm.txt => leds-blinkm.rst}  |  64 ++--
 .../{leds-class-flash.txt => leds-class-flash.rst} |  49 ++-
 .../leds/{leds-class.txt => leds-class.rst}|  15 +-
 .../leds/{leds-lm3556.txt => leds-lm3556.rst}  | 100 --
 .../leds/{leds-lp3944.txt => leds-lp3944.rst}  |  23 +-
 Documentation/leds/leds-lp5521.rst | 115 ++
 Documentation/leds/leds-lp5521.txt | 101 --
 Documentation/leds/leds-lp5523.rst | 147 
 Documentation/leds/leds-lp5523.txt | 130 ---
 Documentation/leds/leds-lp5562.rst | 137 +++
 Documentation/leds/leds-lp5562.txt | 120 ---
 Documentation/leds/leds-lp55xx.rst | 224 
 Documentation/leds/leds-lp55xx.txt | 194 --
 Documentation/leds/leds-mlxcpld.rst

Re: [PATCH 3/4] net: dsa: vsc73xx: add support for parallel mode

2019-07-01 Thread Florian Fainelli
On 7/1/19 8:27 AM, Pawel Dembicki wrote:
> This patch add platform part of vsc73xx driver.
> It allows to use chip connected by PI interface.
> 
> Signed-off-by: Pawel Dembicki 
> ---

[snip]

> + struct vsc73xx_platform *vsc_platform = vsc->priv;
> + u32 offset;
> +
> + if (!vsc73xx_is_addr_valid(block, subblock))
> + return -EINVAL;
> +
> + offset = vsc73xx_make_addr(block, subblock, reg);
> +
> + mutex_lock(>lock);
> + iowrite32be(val, vsc_platform->base_addr + offset);
> + mutex_unlock(>lock);

Similar question from Andrew, why is the locking done in the platform
layer, should not that be done in the core I/O operation instead?

> +
> + return 0;
> +}
> +
> +static int vsc73xx_platform_probe(struct platform_device *pdev)
> +{
> + struct device *dev = >dev;
> + struct vsc73xx_platform *vsc_platform;
> + struct resource *res = NULL;
> + int ret;
> +
> + vsc_platform = devm_kzalloc(dev, sizeof(*vsc_platform), GFP_KERNEL);
> + if (!vsc_platform)
> + return -ENOMEM;
> +
> + platform_set_drvdata(pdev, vsc_platform);
> + vsc_platform->pdev = pdev;
> + vsc_platform->vsc.dev = dev;
> + vsc_platform->vsc.priv = vsc_platform;
> + vsc_platform->vsc.ops = _platform_ops;
> +
> + /* obtain I/O memory space */
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res) {
> + dev_err(>dev, "cannot obtain I/O memory space\n");
> + ret = -ENXIO;
> + return ret;
> + }
> +
> + vsc_platform->base_addr = devm_ioremap_resource(>dev, res);

devm_ioremap_resource takes care of checking that the resource pointer
is valid, no need to do that here.

> + if (!vsc_platform->base_addr) {

if (IS_ERR(vsc_platform->base_addr))
-- 
Florian


Re: [PATCH] vfs: move_mount: reject moving kernel internal mounts

2019-07-01 Thread Eric Biggers
On Sat, Jun 29, 2019 at 01:27:44PM -0700, Eric Biggers wrote:
> 
> Reproducer:
> 
> #include 
> 
> #define __NR_move_mount 429
> #define MOVE_MOUNT_F_EMPTY_PATH 0x0004
> 
> int main()
> {
> int fds[2];
> 
> pipe(fds);
> syscall(__NR_move_mount, fds[0], "", -1, "/", 
> MOVE_MOUNT_F_EMPTY_PATH);
> }

David, I'd like to add this as a regression test somewhere.

Can you point me to the tests for the new mount syscalls?

I checked LTP, kselftests, and xfstests, but nothing to be found.

- Eric


Re: [PATCH 1/4] net: dsa: Change DT bindings for Vitesse VSC73xx switches

2019-07-01 Thread Florian Fainelli
On 7/1/19 8:27 AM, Pawel Dembicki wrote:
> This commit document changes after split vsc73xx driver into core and
> spi part. The change of DT bindings is required for support the same
> vsc73xx chip, which need PI bus to communicate with CPU. It also
> introduce how to use vsc73xx platform driver.
> 
> Signed-off-by: Pawel Dembicki 
> ---
>  .../bindings/net/dsa/vitesse,vsc73xx.txt  | 74 ---
>  1 file changed, 64 insertions(+), 10 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.txt 
> b/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.txt
> index ed4710c40641..c6a4cd85891c 100644
> --- a/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.txt
> +++ b/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.txt
> @@ -2,8 +2,8 @@ Vitesse VSC73xx Switches
>  
>  
>  This defines device tree bindings for the Vitesse VSC73xx switch chips.
> -The Vitesse company has been acquired by Microsemi and Microsemi in turn
> -acquired by Microchip but retains this vendor branding.
> +The Vitesse company has been acquired by Microsemi and Microsemi has
> +been acquired Microchip but retains this vendor branding.
>  
>  The currently supported switch chips are:
>  Vitesse VSC7385 SparX-G5 5+1-port Integrated Gigabit Ethernet Switch
> @@ -11,16 +11,26 @@ Vitesse VSC7388 SparX-G8 8-port Integrated Gigabit 
> Ethernet Switch
>  Vitesse VSC7395 SparX-G5e 5+1-port Integrated Gigabit Ethernet Switch
>  Vitesse VSC7398 SparX-G8e 8-port Integrated Gigabit Ethernet Switch
>  
> -The device tree node is an SPI device so it must reside inside a SPI bus
> -device tree node, see spi/spi-bus.txt
> +This switch could have two different management interface.
> +
> +If SPI interface is used, the device tree node is an SPI device so it must
> +reside inside a SPI bus device tree node, see spi/spi-bus.txt
> +
> +If Platform driver is used, the device tree node is an platform device so it
> +must reside inside a platform bus device tree node.

That should not be required because the device remains the same and how
it connects to the host is entirely described by the Device Tree topology.

Take b53 for instance which supports MDIO and SPI by default, and
optionally memory mapped and SRAB (indirect memory map) accesses, they
all have the same compatible strings. Whether the switches will appear
as spi_device, platform_device, or something else is entirely based on
how the Device Tree is laid out.
-- 
Florian


[no subject]

2019-07-01 Thread UT-Bank ATM MANAGER Togo
Dear Friend,
Can i trust you with investment money???looking someone from your
region to help us receive it,reply for more details.
Regards
Mr.Koffi Edward
Private email:


Re: [PATCH v8 4/5] x86/xsave: Make XSAVE check the base CPUID features before enabling

2019-07-01 Thread Andi Kleen
> So if it is unlikely to have XSAVE but no FXSR I would suggest to add
> "fpu__xstate_clear_all_cpu_caps()" to nofxsr and behave like "nofxsr
> noxsave".

Thanks for the analysis Sebastian. Makes sense.

This would likely work, but I think I would rather just remove the option.

-Andi


Re: [PATCH v8 4/5] x86/xsave: Make XSAVE check the base CPUID features before enabling

2019-07-01 Thread Andi Kleen
> 
> The commit for this patch in mainline
> (ccb18db2ab9d923df07e7495123fe5fb02329713) causes the kernel to hang on
> boot when passing the "nofxsr" option:

Thanks.

Hmm, I'm not sure nofxsr ever worked on 64bit. Certainly SSE cannot be
saved/restored in any other way during the context switch. 

So even if you pass it successfully I doubt user space will really work
for very long.  64bit binaries require SSE.

AFAIK it is only useful on systems without SSE, presumably
running 32bit kernels.

Should check that case.

My recommended solution would be to just get rid of the option.

Presumably it's just some old chicken bit.

-Anfi



Re: Perf framework : Cluster based counter support

2019-07-01 Thread Mark Rutland
On Mon, Jul 01, 2019 at 09:09:33PM +0530, Mukesh Ojha wrote:
> 
> On 6/28/2019 10:29 PM, Mark Rutland wrote:
> > On Fri, Jun 28, 2019 at 10:23:10PM +0530, Mukesh Ojha wrote:
> > > Hi All,
> > Hi Mukesh,
> > 
> > > Is it looks considerable to add cluster based event support to add in
> > > current perf event framework and later in userspace perf to support
> > > such events ?
> > Could you elaborate on what you mean by "cluster based event"?
> > 
> > I assume you mean something like events for a cluster-affine shared
> > resource like some level of cache?
> > 
> > If so, there's a standard pattern for supporting such system/uncore
> > PMUs, see drivers/perf/qcom_l2_pmu.c and friends for examples.
> 
> Thanks Mark for pointing it out.
> Also What is stopping us in adding cluster based event e.g L2 cache hit/miss
> or some other type raw events  in core framework ?

That depends on how the event is exposed.

If it's exposed via the architectural PMU, then it's already accessible
as a raw (cpu-affine) event, regardless of whether that makes sense.

If it's a separate PMU (as I suspect is the case), then it simply has to
be a separate PMU driver.

Thanks,
Mark.


Re: [PATCH] Revert "x86/build: Move _etext to actual end of .text"

2019-07-01 Thread Guenter Roeck
On Mon, Jul 1, 2019 at 8:52 AM Ross Zwisler  wrote:
>
> This reverts commit 392bef709659abea614abfe53cf228e7a59876a4.
>
> Per the discussion here:
>
> https://lkml.org/lkml/2019/6/20/830
>
> the above referenced commit breaks kernel compilation with old GCC
> toolchains as well as current versions of the Gold linker.  Revert it so
> we don't regress and lose the ability to compile the kernel with these
> tools.
>
> Signed-off-by: Ross Zwisler 

Reviewed-by: Guenter Roeck 

> ---
>  arch/x86/kernel/vmlinux.lds.S | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
> index 0850b5149345..4d1517022a14 100644
> --- a/arch/x86/kernel/vmlinux.lds.S
> +++ b/arch/x86/kernel/vmlinux.lds.S
> @@ -141,10 +141,10 @@ SECTIONS
> *(.text.__x86.indirect_thunk)
> __indirect_thunk_end = .;
>  #endif
> -   } :text = 0x9090
>
> -   /* End of text section */
> -   _etext = .;
> +   /* End of text section */
> +   _etext = .;
> +   } :text = 0x9090
>
> NOTES :text :note
>
> --
> 2.20.1


Re: [PATCH 03/10] sched,fair: redefine runnable_load_avg as the sum of task_h_load

2019-07-01 Thread Josef Bacik
On Fri, Jun 28, 2019 at 04:49:06PM -0400, Rik van Riel wrote:
> The runnable_load magic is used to quickly propagate information about
> runnable tasks up the hierarchy of runqueues. The runnable_load_avg is
> mostly used for the load balancing code, which only examines the value at
> the root cfs_rq.
> 
> Redefine the root cfs_rq runnable_load_avg to be the sum of task_h_loads
> of the runnable tasks. This works because the hierarchical runnable_load of
> a task is already equal to the task_se_h_load today. This provides enough
> information to the load balancer.
> 
> The runnable_load_avg of the cgroup cfs_rqs does not appear to be
> used for anything, so don't bother calculating those.
> 
> This removes one of the things that the code currently traverses the
> cgroup hierarchy for, and getting rid of it brings us one step closer
> to a flat runqueue for the CPU controller.
> 

My memory on this stuff is very hazy, but IIRC we had the runnable_sum and the
runnable_avg separated out because you could have the avg lag behind the sum.
So like you enqueue a bunch of new entities who's avg may have decayed a bunch
and so their overall load is not felt on the CPU until they start running, and
now you've overloaded that CPU.  The sum was there to make sure new things
coming onto the CPU added actual load to the queue instead of looking like there
was no load.

Is this going to be a problem now with this new code?



> +static inline void
> +update_runnable_load_avg(struct sched_entity *se)
> +{
> + struct cfs_rq *root_cfs_rq = _rq_of(se)->rq->cfs;
> + long new_h_load, delta;
> +
> + SCHED_WARN_ON(!entity_is_task(se));
> +
> + if (!se->on_rq)
> + return;
>  
> - sub_positive(_rq->avg.runnable_load_avg, se->avg.runnable_load_avg);
> - sub_positive(_rq->avg.runnable_load_sum,
> -  se_runnable(se) * se->avg.runnable_load_sum);
> + new_h_load = task_se_h_load(se);
> + delta = new_h_load - se->enqueued_h_load;
> + root_cfs_rq->avg.runnable_load_avg += delta;

Should we use add_positive here?  Thanks,

Josef


[PATCH][next] iwlwifi: mvm: fix comparison of u32 variable with less than zero

2019-07-01 Thread Colin King
From: Colin Ian King 

The comparison of the u32 variable wgds_tbl_idx with less than zero is
always going to be false because it is unsigned.  Fix this by making
wgds_tbl_idx a plain signed int.

Addresses-Coverity: ("Unsigned compared against 0")
Fixes: 4fd445a2c855 ("iwlwifi: mvm: Add log information about SAR status")
Signed-off-by: Colin Ian King 
---
 drivers/net/wireless/intel/iwlwifi/mvm/nvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
index 719f793b3487..a9bb43a2f27b 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
@@ -620,7 +620,7 @@ void iwl_mvm_rx_chub_update_mcc(struct iwl_mvm *mvm,
enum iwl_mcc_source src;
char mcc[3];
struct ieee80211_regdomain *regd;
-   u32 wgds_tbl_idx;
+   int wgds_tbl_idx;
 
lockdep_assert_held(>mutex);
 
-- 
2.20.1



Re: [PATCH] fork: return proper negative error code

2019-07-01 Thread Al Viro
On Mon, Jul 01, 2019 at 04:48:08PM +0200, Christian Brauner wrote:
> Make sure to return a proper negative error code from copy_process()
> when anon_inode_getfile() fails with CLONE_PIDFD.

Acked-by: Al Viro 


Re: [PATCH v2 0/5] PM: PCI/ACPI: Hibernation handling fixes

2019-07-01 Thread Mika Westerberg
On Mon, Jul 01, 2019 at 12:42:14PM +0200, Rafael J. Wysocki wrote:
> Hi All,
> 
> This series of patches addresses a few issues related to the handling of
> hibernation in the PCI bus type and the ACPI PM domain and ACPI LPSS driver.
> 
> The v2 addresses Hans' concerns regarding the LPSS changes.
> 
> First of all, all of the runtime-suspended PCI devices and devices in the 
> ACPI PM and LPSS
> PM domains will be resumed during hibernation (first patch).  This appears to 
> be the
> only way to avoid weird corner cases and the benefit from avoiding to resume 
> those
> devices during hibernation is questionable.
> 
> That change allows the the hibernation callbacks in all of the involved 
> subsystems to be
> simplified (patches 2 and 3).
> 
> Moreover, reusing bus-level suspend callbacks for the "poweroff" transition 
> during
> hibernation (which is the case for the ACPI PM domain and LPSS) is incorrect, 
> so patch 4
> fixes that.
> 
> Finally, there are some leftover items in linux/acpi.h that can be dropped 
> (patch 5).

For the whole series,

Reviewed-by: Mika Westerberg 


Re: [PATCH v5 net-next 6/6] net: ethernet: ti: cpsw: add XDP support

2019-07-01 Thread Jesper Dangaard Brouer
On Sun, 30 Jun 2019 20:23:48 +0300
Ivan Khoronzhuk  wrote:

> +static int cpsw_ndev_create_xdp_rxq(struct cpsw_priv *priv, int ch)
> +{
> + struct cpsw_common *cpsw = priv->cpsw;
> + int ret, new_pool = false;
> + struct xdp_rxq_info *rxq;
> +
> + rxq = >xdp_rxq[ch];
> +
> + ret = xdp_rxq_info_reg(rxq, priv->ndev, ch);
> + if (ret)
> + return ret;
> +
> + if (!cpsw->page_pool[ch]) {
> + ret =  cpsw_create_rx_pool(cpsw, ch);
> + if (ret)
> + goto err_rxq;
> +
> + new_pool = true;
> + }
> +
> + ret = xdp_rxq_info_reg_mem_model(rxq, MEM_TYPE_PAGE_POOL,
> +  cpsw->page_pool[ch]);
> + if (!ret)
> + return 0;
> +
> + if (new_pool) {
> + page_pool_free(cpsw->page_pool[ch]);
> + cpsw->page_pool[ch] = NULL;
> + }
> +
> +err_rxq:
> + xdp_rxq_info_unreg(rxq);
> + return ret;
> +}

Looking at this, and Ilias'es XDP-netsec error handling path, it might
be a mistake that I removed page_pool_destroy() and instead put the
responsibility on xdp_rxq_info_unreg().

As here, we have to detect if page_pool_create() was a success, and then
if xdp_rxq_info_reg_mem_model() was a failure, explicitly call
page_pool_free() because the xdp_rxq_info_unreg() call cannot "free"
the page_pool object given it was not registered.  

Ivan's patch in[1], might be a better approach, which forced all
drivers to explicitly call page_pool_free(), even-though it just
dec-refcnt and the real call to page_pool_free() happened via
xdp_rxq_info_unreg().

To better handle error path, I would re-introduce page_pool_destroy(),
as a driver API, that would gracefully handle NULL-pointer case, and
then call page_pool_free() with the atomic_dec_and_test().  (It should
hopefully simplify the error handling code a bit)

[1] 
https://lore.kernel.org/netdev/20190625175948.24771-2-ivan.khoronz...@linaro.org/


> +void cpsw_ndev_destroy_xdp_rxqs(struct cpsw_priv *priv)
> +{
> + struct cpsw_common *cpsw = priv->cpsw;
> + struct xdp_rxq_info *rxq;
> + int i;
> +
> + for (i = 0; i < cpsw->rx_ch_num; i++) {
> + rxq = >xdp_rxq[i];
> + if (xdp_rxq_info_is_reg(rxq))
> + xdp_rxq_info_unreg(rxq);
> + }
> +}

Are you sure you need to test xdp_rxq_info_is_reg() here?

You should just call xdp_rxq_info_unreg(rxq), if you know that this rxq
should be registered.  If your assumption failed, you will get a
WARNing, and discover your driver level bug.  This is one of the ways
the API is designed to "detect" misuse of the API.  (I found this
rather useful, when I converted the approx 12 drivers using this
xdp_rxq_info API).

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer


[GIT PULL] fixes for v5.2-rc8

2019-07-01 Thread Christian Brauner
Hi Linus,

This contains a single urgent fix for copy_process() in kernel/fork.c:

The following changes since commit 6fbc7275c7a9ba97877050335f290341a1fd8dbf:

  Linux 5.2-rc7 (2019-06-30 11:25:36 +0800)

are available in the Git repository at:

  g...@gitolite.kernel.org:pub/scm/linux/kernel/git/brauner/linux 
tags/for-linus-20190701

for you to fetch changes up to 28dd29c06d0dede4b32b2c559cff21955a830928:

  fork: return proper negative error code (2019-07-01 16:43:30 +0200)

With Al's removal of ksys_close() from cleanup paths in copy_process() a
bug was introduced. When anon_inode_getfile() failed the cleanup was
correctly performed but the error code was not propagated to callers of
copy_process() causing them to operate on a nonsensical pointer. The fix is
a simple on-liner which makes sure that a proper negative error code is
returned from copy_process().
syzkaller has also verified that the bug is not reproducible with the patch
in this branch.

Please consider pulling these changes from the signed for-linus-20190701 tag.

Thanks!
Christian


for-linus-20190701


Christian Brauner (1):
  fork: return proper negative error code

 kernel/fork.c | 1 +
 1 file changed, 1 insertion(+)


Re: [PATCH AUTOSEL 5.1 07/51] ASoC: soc-dpm: fixup DAI active unbalance

2019-07-01 Thread Mark Brown
On Wed, Jun 26, 2019 at 08:20:59PM -0400, Sasha Levin wrote:
> On Wed, Jun 26, 2019 at 11:03:15AM +0100, Mark Brown wrote:
> > On Tue, Jun 25, 2019 at 11:40:23PM -0400, Sasha Levin wrote:

> > > [ Upstream commit f7c4842abfa1a219554a3ffd8c317e8fdd979bec ]

> > > snd_soc_dai_link_event() is updating snd_soc_dai :: active,
> > > but it is unbalance.
> > > It counts up if it has startup callback.

> > Are you *sure* this doesn't have dependencies?

> The actual code seems to correspond with the issue described in the
> commit message, so I'd think not.

> I can remove this patch if you're not confident about it.

I'm not entirely, no.


signature.asc
Description: PGP signature


Re: [PATCH v2 1/5] PM: ACPI/PCI: Resume all devices during hibernation

2019-07-01 Thread Mika Westerberg
On Mon, Jul 01, 2019 at 12:44:25PM +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki 
> 
> Both the PCI bus type and the ACPI PM domain avoid resuming
> runtime-suspended devices with DPM_FLAG_SMART_SUSPEND set during
> hibernation (before creating the snapshot image of system memory),
> but that turns out to be a mistake.  It leads to functional issues
> and adds complexity that's hard to justify.
> 
> For this reason, resume all runtime-suspended PCI devices and all
> devices in the ACPI PM domains before creating a snapshot image of
> system memory during hibernation.
> 
> Fixes: 05087360fd7a (ACPI / PM: Take SMART_SUSPEND driver flag into account)
> Fixes: c4b65157aeef (PCI / PM: Take SMART_SUSPEND driver flag into account)
> Link: 
> https://lore.kernel.org/linux-acpi/917d4399-2e22-67b1-9d54-808561f90...@uwyo.edu/T/#maf065fe6e4974f2a9d79f332ab99dfaba635f64c
> Reported-by: Robert R. Howell 
> Tested-by: Robert R. Howell 
> Signed-off-by: Rafael J. Wysocki 
> ---
> 
> -> v2: No changes.
> 
> ---
>  drivers/acpi/device_pm.c |   13 +++--
>  drivers/pci/pci-driver.c |   16 
>  2 files changed, 15 insertions(+), 14 deletions(-)
> 
> Index: linux-pm/drivers/acpi/device_pm.c
> ===
> --- linux-pm.orig/drivers/acpi/device_pm.c
> +++ linux-pm/drivers/acpi/device_pm.c
> @@ -1155,13 +1155,14 @@ EXPORT_SYMBOL_GPL(acpi_subsys_resume_ear
>  int acpi_subsys_freeze(struct device *dev)
>  {
>   /*
> -  * This used to be done in acpi_subsys_prepare() for all devices and
> -  * some drivers may depend on it, so do it here.  Ideally, however,
> -  * runtime-suspended devices should not be touched during freeze/thaw
> -  * transitions.
> +  * Resume all runtime-suspended devices before creating a snapshot
> +  * image of system memory, because the restore kernel generally cannot
> +  * be expected to always handle them consistently and they need to be
> +  * put into the runtime-active metastate during system resume anyway,
> +  * so it is better to ensure that the state saved in the image will be
> +  * alwyas consistent with that.

alwyas -> always

>*/
> - if (!dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_SUSPEND))
> - pm_runtime_resume(dev);
> + pm_runtime_resume(dev);
>  
>   return pm_generic_freeze(dev);
>  }
> Index: linux-pm/drivers/pci/pci-driver.c
> ===
> --- linux-pm.orig/drivers/pci/pci-driver.c
> +++ linux-pm/drivers/pci/pci-driver.c
> @@ -1012,15 +1012,15 @@ static int pci_pm_freeze(struct device *
>   }
>  
>   /*
> -  * This used to be done in pci_pm_prepare() for all devices and some
> -  * drivers may depend on it, so do it here.  Ideally, runtime-suspended
> -  * devices should not be touched during freeze/thaw transitions,
> -  * however.
> +  * Resume all runtime-suspended devices before creating a snapshot
> +  * image of system memory, because the restore kernel generally cannot
> +  * be expected to always handle them consistently and they need to be
> +  * put into the runtime-active metastate during system resume anyway,
> +  * so it is better to ensure that the state saved in the image will be
> +  * alwyas consistent with that.

ditto

>*/
> - if (!dev_pm_smart_suspend_and_suspended(dev)) {
> - pm_runtime_resume(dev);
> - pci_dev->state_saved = false;
> - }
> + pm_runtime_resume(dev);
> + pci_dev->state_saved = false;
>  
>   if (pm->freeze) {
>   int error;
> 
> 
> 


Re: [PATCH net] ipv4: don't set IPv6 only flags to IPv4 addresses

2019-07-01 Thread Matteo Croce
On Mon, Jul 1, 2019 at 6:10 PM Joe Perches  wrote:
>
> On Mon, 2019-07-01 at 18:08 +0200, Matteo Croce wrote:
> > Avoid the situation where an IPV6 only flag is applied to an IPv4 address:
> []
> > diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> []
> > @@ -468,6 +473,9 @@ static int __inet_insert_ifa(struct in_ifaddr *ifa, 
> > struct nlmsghdr *nlh,
> >   ifa->ifa_flags &= ~IFA_F_SECONDARY;
> >   last_primary = _dev->ifa_list;
> >
> > + /* Don't set IPv6 only flags to IPv6 addresses */
>
> umm, IPv4 addresses?
>
>

Ouch, right.

/* Don't set IPv6 only flags to IPv4 addresses */

Can this be edidet on patchwork instead of spamming with a v2?

-- 
Matteo Croce
per aspera ad upstream


Re: [PATCH 3/4] net: dsa: vsc73xx: add support for parallel mode

2019-07-01 Thread Andrew Lunn
On Mon, Jul 01, 2019 at 05:27:22PM +0200, Pawel Dembicki wrote:
> +static int vsc73xx_platform_read(struct vsc73xx *vsc, u8 block, u8 subblock,
> +  u8 reg, u32 *val)
> +{
> + struct vsc73xx_platform *vsc_platform = vsc->priv;
> + u32 offset;
> +
> + if (!vsc73xx_is_addr_valid(block, subblock))
> + return -EINVAL;
> +
> + offset = vsc73xx_make_addr(block, subblock, reg);
> +
> + mutex_lock(>lock);
> + *val = ioread32be(vsc_platform->base_addr + offset);
> + mutex_unlock(>lock);

Hi Pawel

What is this mutex protecting?

Plus the indentation is wrong.

Thanks
Andrew


Re: [PATCH net] ipv4: don't set IPv6 only flags to IPv4 addresses

2019-07-01 Thread Joe Perches
On Mon, 2019-07-01 at 18:08 +0200, Matteo Croce wrote:
> Avoid the situation where an IPV6 only flag is applied to an IPv4 address:
[]
> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
[]
> @@ -468,6 +473,9 @@ static int __inet_insert_ifa(struct in_ifaddr *ifa, 
> struct nlmsghdr *nlh,
>   ifa->ifa_flags &= ~IFA_F_SECONDARY;
>   last_primary = _dev->ifa_list;
>  
> + /* Don't set IPv6 only flags to IPv6 addresses */

umm, IPv4 addresses?




Re: [PATCH v2 1/2] ASoC: tas5720.c: cleanup variant management

2019-07-01 Thread Andrew F. Davis
On 7/1/19 11:35 AM, Nikolaus Voss wrote:
> On Mon, 1 Jul 2019, Andrew F. Davis wrote:
>> On 7/1/19 9:42 AM, Nikolaus Voss wrote:
>>> Replace enum tas572x_type with struct tas5720_variant which aggregates
>>> variant specific stuff and can be directly referenced from an id table.
>>>
>>> Signed-off-by: Nikolaus Voss 
>>> ---
>>>  sound/soc/codecs/tas5720.c | 98 +-
>>>  1 file changed, 33 insertions(+), 65 deletions(-)
>>>
>>> diff --git a/sound/soc/codecs/tas5720.c b/sound/soc/codecs/tas5720.c
>>> index 37fab8f22800..b2e897f094b4 100644
>>> --- a/sound/soc/codecs/tas5720.c
>>> +++ b/sound/soc/codecs/tas5720.c
>>> @@ -28,9 +28,10 @@
>>>  /* Define how often to check (and clear) the fault status register
>>> (in ms) */
>>>  #define TAS5720_FAULT_CHECK_INTERVAL    200
>>>
>>> -enum tas572x_type {
>>> -    TAS5720,
>>> -    TAS5722,
>>> +struct tas5720_variant {
>>> +    const int device_id;
>>> +    const struct regmap_config *reg_config;
>>> +    const struct snd_soc_component_driver *comp_drv;
>>>  };
>>>
>>>  static const char * const tas5720_supply_names[] = {
>>> @@ -44,7 +45,7 @@ struct tas5720_data {
>>>  struct snd_soc_component *component;
>>>  struct regmap *regmap;
>>>  struct i2c_client *tas5720_client;
>>> -    enum tas572x_type devtype;
>>> +    const struct tas5720_variant *variant;
>>
>> Why add a new struct? Actually I don't see the need for this patch at
>> all, the commit message only explains the 'what' not the 'why'. We can
>> and do already build this info from the tas572x_type.
> 
> As the commit message says, the purpose is to aggregate the variant
> specifics and make it accessible via one pointer. This is a standard
> approach for of/acpi_device_id tables and thus makes the code simpler
> and improves readability. This is a maintenance patch to prepare using
> the device match API in a proper way.
> 


"make it accessible via one pointer" is again a "what", the "why" is:

"This is a standard approach"
"makes the code simpler and improves readability"

Those are valid reasons and should be what you put in the commit message.


>>
>> Also below are several functional changes, the cover letter says this is
>> not a functional change, yet the driver behaves differently now.
> 
> Can you be a little bit more specific? The code should behave exactly as
> before.
> 


Sure, for instance the line "unexpected private driver data" is removed,
this can now never happen, that is a functional change. The phrase "no
functional change", should be reserved for only changes to spelling,
formatting, code organizing, etc..


> Niko
> 
>>
>> Andrew
>>
>>>  struct regulator_bulk_data supplies[TAS5720_NUM_SUPPLIES];
>>>  struct delayed_work fault_check_work;
>>>  unsigned int last_fault;
>>> @@ -179,17 +180,13 @@ static int tas5720_set_dai_tdm_slot(struct
>>> snd_soc_dai *dai,
>>>  goto error_snd_soc_component_update_bits;
>>>
>>>  /* Configure TDM slot width. This is only applicable to TAS5722. */
>>> -    switch (tas5720->devtype) {
>>> -    case TAS5722:
>>> +    if (tas5720->variant->device_id == TAS5722_DEVICE_ID) {


I also don't like this, TAS5722_DEVICE_ID is the expected contents of a
register, you are using it like the enum tas572x_type that you removed.
I'd leave that enum, the device ID register itself is not guaranteed to
be correct or unique, which is why we warn about mismatches below but
then continue to use the user provided device type anyway.

Andrew


>>>  ret = snd_soc_component_update_bits(component,
>>> TAS5722_DIGITAL_CTRL2_REG,
>>>  TAS5722_TDM_SLOT_16B,
>>>  slot_width == 16 ?
>>>  TAS5722_TDM_SLOT_16B : 0);
>>>  if (ret < 0)
>>>  goto error_snd_soc_component_update_bits;
>>> -    break;
>>> -    default:
>>> -    break;
>>>  }
>>>
>>>  return 0;
>>> @@ -277,7 +274,7 @@ static void tas5720_fault_check_work(struct
>>> work_struct *work)
>>>  static int tas5720_codec_probe(struct snd_soc_component *component)
>>>  {
>>>  struct tas5720_data *tas5720 =
>>> snd_soc_component_get_drvdata(component);
>>> -    unsigned int device_id, expected_device_id;
>>> +    unsigned int device_id;
>>>  int ret;
>>>
>>>  tas5720->component = component;
>>> @@ -301,21 +298,9 @@ static int tas5720_codec_probe(struct
>>> snd_soc_component *component)
>>>  goto probe_fail;
>>>  }
>>>
>>> -    switch (tas5720->devtype) {
>>> -    case TAS5720:
>>> -    expected_device_id = TAS5720_DEVICE_ID;
>>> -    break;
>>> -    case TAS5722:
>>> -    expected_device_id = TAS5722_DEVICE_ID;
>>> -    break;
>>> -    default:
>>> -    dev_err(component->dev, "unexpected private driver data\n");
>>> -    return -EINVAL;
>>> -    }
>>> -
>>> -    if (device_id != expected_device_id)
>>> +    if (device_id != tas5720->variant->device_id)
>>>  dev_warn(component->dev, 

[PATCH net] ipv4: don't set IPv6 only flags to IPv4 addresses

2019-07-01 Thread Matteo Croce
Avoid the situation where an IPV6 only flag is applied to an IPv4 address:

# ip addr add 192.0.2.1/24 dev dummy0 nodad home mngtmpaddr noprefixroute
# ip -4 addr show dev dummy0
2: dummy0:  mtu 1500 qdisc noqueue state 
UNKNOWN group default qlen 1000
inet 192.0.2.1/24 scope global noprefixroute dummy0
   valid_lft forever preferred_lft forever

Or worse, by sending a malicious netlink command:

# ip -4 addr show dev dummy0
2: dummy0:  mtu 1500 qdisc noqueue state 
UNKNOWN group default qlen 1000
inet 192.0.2.1/24 scope global nodad optimistic dadfailed home 
tentative mngtmpaddr noprefixroute stable-privacy dummy0
   valid_lft forever preferred_lft forever

Signed-off-by: Matteo Croce 
---
 net/ipv4/devinet.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index c6bd0f7a020a..f40ccdcf4cfe 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -62,6 +62,11 @@
 #include 
 #include 
 
+#define IPV6ONLY_FLAGS \
+   (IFA_F_NODAD | IFA_F_OPTIMISTIC | IFA_F_DADFAILED | \
+IFA_F_HOMEADDRESS | IFA_F_TENTATIVE | \
+IFA_F_MANAGETEMPADDR | IFA_F_STABLE_PRIVACY)
+
 static struct ipv4_devconf ipv4_devconf = {
.data = {
[IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 1,
@@ -468,6 +473,9 @@ static int __inet_insert_ifa(struct in_ifaddr *ifa, struct 
nlmsghdr *nlh,
ifa->ifa_flags &= ~IFA_F_SECONDARY;
last_primary = _dev->ifa_list;
 
+   /* Don't set IPv6 only flags to IPv6 addresses */
+   ifa->ifa_flags &= ~IPV6ONLY_FLAGS;
+
for (ifap = _dev->ifa_list; (ifa1 = *ifap) != NULL;
 ifap = >ifa_next) {
if (!(ifa1->ifa_flags & IFA_F_SECONDARY) &&
-- 
2.21.0



Re: RISC-V nommu support v2

2019-07-01 Thread Paul Walmsley
Hi Christoph,

Probably best to feed the mm patches to Andrew.  For the RISC-V patches, 
am running a bit behind this merge window.  Combined with the end of the 
week holidays in the US, I doubt I'll make it to to the nommu series for 
v5.3.


- Paul

On Mon, 1 Jul 2019, Christoph Hellwig wrote:

> Palmer, Paul,
> 
> any comments?  Let me know if you think it is too late for 5.3
> for the full series, then I can at least feed the mm bits to
> Andrew.
> 
> On Mon, Jun 24, 2019 at 07:42:54AM +0200, Christoph Hellwig wrote:
> > Hi all,
> > 
> > below is a series to support nommu mode on RISC-V.  For now this series
> > just works under qemu with the qemu-virt platform, but Damien has also
> > been able to get kernel based on this tree with additional driver hacks
> > to work on the Kendryte KD210, but that will take a while to cleanup
> > an upstream.
> > 
> > To be useful this series also require the RISC-V binfmt_flat support,
> > which I've sent out separately.
> > 
> > A branch that includes this series and the binfmt_flat support is
> > available here:
> > 
> > git://git.infradead.org/users/hch/riscv.git riscv-nommu.2
> > 
> > Gitweb:
> > 
> > 
> > http://git.infradead.org/users/hch/riscv.git/shortlog/refs/heads/riscv-nommu.2
> > 
> > I've also pushed out a builtroot branch that can build a RISC-V nommu
> > root filesystem here:
> > 
> >git://git.infradead.org/users/hch/buildroot.git riscv-nommu.2
> > 
> > Gitweb:
> > 
> >
> > http://git.infradead.org/users/hch/buildroot.git/shortlog/refs/heads/riscv-nommu.2
> > 
> > Changes since v1:
> >  - fixes so that a kernel with this series still work on builds with an
> >IOMMU
> >  - small clint cleanups
> >  - the binfmt_flat base and buildroot now don't put arguments on the stack
> > 
> > ___
> > linux-riscv mailing list
> > linux-ri...@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-riscv
> ---end quoted text---
> 




Re: [Kernel BUG?] SMSW operation get success on UMIP KVM guest

2019-07-01 Thread Ricardo Neri
On Mon, Jul 01, 2019 at 08:57:28PM +0800, Li Wang wrote:
> On Mon, Jul 1, 2019 at 8:02 PM Paolo Bonzini  wrote:
> 
> > On 01/07/19 09:50, Li Wang wrote:
> > > Hello there,
> > >
> > > LTP/umip_basic_test get failed on KVM UMIP
> > > system(kernel-v5.2-rc4.x86_64). The test is only trying to do
> > >  asm volatile("smsw %0\n" : "=m" (val));
> > > and expect to get SIGSEGV in this SMSW operation, but it exits with 0
> > > unexpectedly.
> >
> > In addition to what Thomas said, perhaps you are using a host that does
> > *not* have UMIP, and configuring KVM to emulate it(*).  In that case, it
> > is not possible to intercept SMSW, and therefore it will incorrectly
> > succeed.
> >
> 
> Right, I checked the host system, and confirmed that CPU doesn't support
> UMIP.
> 
> >
> > Paolo
> >
> > (*) before the x86 people jump at me, this won't happen unless you
> > explicitly pass an option to QEMU, such as "-cpu host,+umip". :)  The
> > incorrect emulation of SMSW when CR4.UMIP=1 is why.
> >
> Good to know this, is there any document for that declaration? It seems
> neither LTP issue nor kernel bug here. But anyway we'd better do something
> to avoid the error in the test.

The test case already checks for umip in /proc/cpuinfo, right? And in
long mode it always expects a SIGSEGV signal. If you did not add -cpu 
host,+umip,
how come umip was present in /proc/cpuinfo?

Thanks and BR,
Ricardo


Re: [PATCH 2/4] net: dsa: vsc73xx: Split vsc73xx driver

2019-07-01 Thread Andrew Lunn
> @@ -495,12 +380,12 @@ static int vsc73xx_update_bits(struct vsc73xx *vsc, u8 
> block, u8 subblock,
>   int ret;
>  
>   /* Same read-modify-write algorithm as e.g. regmap */
> - ret = vsc73xx_read(vsc, block, subblock, reg, );
> + ret = vsc->ops->read(vsc, block, subblock, reg, );
>   if (ret)
>   return ret;
>   tmp = orig & ~mask;
>   tmp |= val & mask;
> - return vsc73xx_write(vsc, block, subblock, reg, tmp);
> + return vsc->ops->write(vsc, block, subblock, reg, tmp);

This patch would be a lot less invasive and smaller if you hid the
difference between SPI and platform inside vsc73xx_write() and
vsc73xx_read().

> -static int vsc73xx_probe(struct spi_device *spi)
> +int vsc73xx_probe(struct vsc73xx *vsc)
>  {
> - struct device *dev = >dev;

  struct device *dev = vsc->dev;

and then a lot of the changes you make here go away.

In general, think about how to make the changes small. It saves your
time from actually making changes, and reviewer time since the patch
it smaller.

Andrew


Re: [RFC] Deadlock via recursive wakeup via RCU with threadirqs

2019-07-01 Thread Paul E. McKenney
On Mon, Jul 01, 2019 at 04:00:53PM +0200, Peter Zijlstra wrote:
> On Mon, Jul 01, 2019 at 05:23:05AM -0700, Paul E. McKenney wrote:
> > On Mon, Jul 01, 2019 at 12:24:42PM +0200, Sebastian Andrzej Siewior wrote:
> > > On 2019-07-01 11:42:15 [+0200], Peter Zijlstra wrote:
> > > > I'm not sure if smp_send_reschedule() can be used as self-IPI, some
> > > > hardware doesn't particularly like that IIRC. That is, hardware might
> > > > only have interfaces to IPI _other_ CPUs, but not self.
> > > > 
> > > > The normal scheduler code takes care to not call smp_send_reschedule()
> > > > to self.
> > > 
> > > and irq_work:
> > >   471ba0e686cb1 ("irq_work: Do not raise an IPI when queueing work on the 
> > > local CPU")
> > 
> > OK, so it looks like I will need to use something else.  But thank you
> > for calling my attention to this commit.
> 
> I think that commit is worded slight confusing -- sorry I should've paid
> more attention.
> 
> irq_work _does_ work locally, and arch_irq_work_raise() must self-IPI,
> otherwise everything is horribly broken.
> 
> But what happened, was that irq_work_queue() and irq_work_queue_on(.cpu
> = smp_processor_id()) wasn't using the same code, and the latter would
> try to self-IPI through arch_send_call_function_single_ipi().
> 
> Nick fixed that so that irq_work_queue() and irq_work_queue_on(.cpu =
> smp_processor_id() now both use arch_raise_irq_work() and remote stuff
> uses arch_send_call_function_single_ipi().

OK, thank you for looking into this!

I therefore continue relying on IRQ work.  Should there be problems with
kernels not supporting IRQ work, and if there is a legitimate reason
why they should not support IRQ work, I can look into things like timers
for those kernels.

Thanx, Paul



Re: [PATCH v2 1/2] ALSA: hda: Fix widget_mutex incomplete protection

2019-07-01 Thread Evan Green
On Mon, Jul 1, 2019 at 7:09 AM Takashi Iwai  wrote:
>
> On Wed, 26 Jun 2019 23:22:19 +0200,
> Evan Green wrote:
> >
> > The widget_mutex was introduced to serialize callers to
> > hda_widget_sysfs_{re}init. However, its protection of the sysfs widget array
> > is incomplete. For example, it is acquired around the call to
> > hda_widget_sysfs_reinit(), which actually creates the new array, but isn't
> > still acquired when codec->num_nodes and codec->start_nid is updated. So
> > the lock ensures one thread sets up the new array at a time, but doesn't
> > ensure which thread's value will end up in codec->num_nodes. If a larger
> > num_nodes wins but a smaller array was set up, the next call to
> > refresh_widgets() will touch free memory as it iterates over 
> > codec->num_nodes
> > that aren't there.
> >
> > The widget_lock really protects both the tree as well as codec->num_nodes,
> > start_nid, and end_nid, so make sure it's held across that update. It should
> > also be held during snd_hdac_get_sub_nodes(), so that a very old read from 
> > that
> > function doesn't end up clobbering a later update.
>
> OK, right, this fix is needed no matter whether to take my other
> change to skip hda_widget_sysfs_init() call in
> hda_widget_sysfs_reinit().
>
> However...
>
> > While in there, move the exit mutex call inside the function. This moves the
> > mutex closer to the data structure it protects and removes a requirement of
> > acquiring the somewhat internal widget_lock before calling sysfs_exit.
>
> ... this doesn't look better from consistency POV.  The whole code in
> hdac_sysfs.c doesn't take any lock in itself.  The protection is
> supposed to be done in the caller side.  So, let's keep as is now.

Ok.

>
> Also...
>
> >   codec->num_nodes = nums;
> >   codec->start_nid = start_nid;
> >   codec->end_nid = start_nid + nums;
> > + mutex_unlock(>widget_lock);
> >   return 0;
> > +
> > +unlock:
> > + mutex_unlock(>widget_lock);
> > + return err;
>
> There is no need of two mutex_unlock() here.  They can be unified,
>
> codec->num_nodes = nums;
> codec->start_nid = start_nid;
> codec->end_nid = start_nid + nums;
>   unlock:
> mutex_unlock(>widget_lock);
> return err;
>
> Could you refresh this and resubmit?

Sure, will do. Thanks for taking a look.


Re: [PATCH 1/4] net: dsa: Change DT bindings for Vitesse VSC73xx switches

2019-07-01 Thread Andrew Lunn
On Mon, Jul 01, 2019 at 05:27:20PM +0200, Pawel Dembicki wrote:
> This commit document changes after split vsc73xx driver into core and
> spi part. The change of DT bindings is required for support the same
> vsc73xx chip, which need PI bus to communicate with CPU. It also

SPI

> introduce how to use vsc73xx platform driver.
> 
> Signed-off-by: Pawel Dembicki 
> ---
>  .../bindings/net/dsa/vitesse,vsc73xx.txt  | 74 ---
>  1 file changed, 64 insertions(+), 10 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.txt 
> b/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.txt
> index ed4710c40641..c6a4cd85891c 100644
> --- a/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.txt
> +++ b/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.txt
> @@ -2,8 +2,8 @@ Vitesse VSC73xx Switches
>  
>  
>  This defines device tree bindings for the Vitesse VSC73xx switch chips.
> -The Vitesse company has been acquired by Microsemi and Microsemi in turn
> -acquired by Microchip but retains this vendor branding.
> +The Vitesse company has been acquired by Microsemi and Microsemi has
> +been acquired Microchip but retains this vendor branding.
>  
>  The currently supported switch chips are:
>  Vitesse VSC7385 SparX-G5 5+1-port Integrated Gigabit Ethernet Switch
> @@ -11,16 +11,26 @@ Vitesse VSC7388 SparX-G8 8-port Integrated Gigabit 
> Ethernet Switch
>  Vitesse VSC7395 SparX-G5e 5+1-port Integrated Gigabit Ethernet Switch
>  Vitesse VSC7398 SparX-G8e 8-port Integrated Gigabit Ethernet Switch
>  
> -The device tree node is an SPI device so it must reside inside a SPI bus
> -device tree node, see spi/spi-bus.txt
> +This switch could have two different management interface.
> +
> +If SPI interface is used, the device tree node is an SPI device so it must
> +reside inside a SPI bus device tree node, see spi/spi-bus.txt
> +
> +If Platform driver is used, the device tree node is an platform device so it
> +must reside inside a platform bus device tree node.
>  
>  Required properties:
>  
> -- compatible: must be exactly one of:
> - "vitesse,vsc7385"
> - "vitesse,vsc7388"
> - "vitesse,vsc7395"
> - "vitesse,vsc7398"

You cannot remove these. It will break backwards compatibility.
Adding new compatible strings is fine, but you cannot remove existing
ones.

Andrew



Re: [PATCHv1] ARM64: defconfig: Add LEDS_TRIGGERS_TIMER for blinking leds

2019-07-01 Thread Dinh Nguyen



On 6/27/19 9:07 AM, Ong, Hean Loong wrote:
> Adding LED Triggers Timers for LED blinking support on ARM devices
> 
> Signed-off-by: Ong, Hean Loong 
> ---
>  arch/arm64/configs/defconfig |1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
> index 4d58351..6fbd651 100644
> --- a/arch/arm64/configs/defconfig
> +++ b/arch/arm64/configs/defconfig
> @@ -595,6 +595,7 @@ CONFIG_LEDS_TRIGGER_HEARTBEAT=y
>  CONFIG_LEDS_TRIGGER_CPU=y
>  CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
>  CONFIG_LEDS_TRIGGER_PANIC=y
> +CONFIG_LEDS_TRIGGER_TIMER=y
>  CONFIG_EDAC=y
>  CONFIG_EDAC_GHES=y
>  CONFIG_RTC_CLASS=y
> 

I've applied this patch with this change:

--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -590,6 +590,7 @@ CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_GPIO=y
 CONFIG_LEDS_PWM=y
 CONFIG_LEDS_SYSCON=y
+CONFIG_LEDS_TRIGGER_TIMER=y
 CONFIG_LEDS_TRIGGER_DISK=y defconfig
 CONFIG_LEDS_TRIGGER_HEARTBEAT=y
 CONFIG_LEDS_TRIGGER_CPU=y

Also, the commit header should be "arm64: defconfig".

Dinh


Re: [PATCH 2/2] drivers: qcom: rpmh-rsc: fix read back of trigger register

2019-07-01 Thread Lina Iyer

Switching Andy's email address.

On Mon, Jul 01 2019 at 09:32 -0600, Lina Iyer wrote:

When triggering a TCS to send its contents, reading back the trigger
value may return an incorrect value. That is because, writing the
trigger may raise an interrupt which could be handled immediately and
the trigger value could be reset in the interrupt handler. By doing a
read back we may end up spinning waiting for the value we wrote.

Fixes: 658628 ("drivers: qcom: rpmh-rsc: add RPMH controller for QCOM
SoCs")
Signed-off-by: Lina Iyer 
---
drivers/soc/qcom/rpmh-rsc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index 92461311aef3..2fc2fa879480 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -300,7 +300,7 @@ static void __tcs_trigger(struct rsc_drv *drv, int tcs_id)
enable = TCS_AMC_MODE_ENABLE;
write_tcs_reg_sync(drv, RSC_DRV_CONTROL, tcs_id, enable);
enable |= TCS_AMC_MODE_TRIGGER;
-   write_tcs_reg_sync(drv, RSC_DRV_CONTROL, tcs_id, enable);
+   write_tcs_reg(drv, RSC_DRV_CONTROL, tcs_id, enable);
}

static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs,
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



Re: [PATCH 1/2] drivers: qcom: rpmh-rsc: simplify TCS locking

2019-07-01 Thread Lina Iyer

Switching Andy's email address.

On Mon, Jul 01 2019 at 09:32 -0600, Lina Iyer wrote:

From: "Raju P.L.S.S.S.N" 

tcs->lock was introduced to serialize access with in TCS group. But
even without tcs->lock, drv->lock is serving the same purpose. So
use a single drv->lock.

Other optimizations include -
- Remove locking around clear_bit() in IRQ handler. clear_bit() is
  atomic.
- Remove redundant read of TCS registers.
- Use spin_lock instead of _irq variants as the locks are not held
  in interrupt context.

Fixes: 658628 ("drivers: qcom: rpmh-rsc: add RPMH controller for QCOM
SoCs")
Signed-off-by: Raju P.L.S.S.S.N 
Signed-off-by: Lina Iyer 
---
drivers/soc/qcom/rpmh-internal.h |  2 --
drivers/soc/qcom/rpmh-rsc.c  | 37 +++-
drivers/soc/qcom/rpmh.c  | 20 +++--
3 files changed, 21 insertions(+), 38 deletions(-)

diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
index a767991c..969d5030860e 100644
--- a/drivers/soc/qcom/rpmh-internal.h
+++ b/drivers/soc/qcom/rpmh-internal.h
@@ -28,7 +28,6 @@ struct rsc_drv;
 * @offset:start of the TCS group relative to the TCSes in the RSC
 * @num_tcs:   number of TCSes in this type
 * @ncpt:  number of commands in each TCS
- * @lock:  lock for synchronizing this TCS writes
 * @req:   requests that are sent from the TCS
 * @cmd_cache: flattened cache of cmds in sleep/wake TCS
 * @slots: indicates which of @cmd_addr are occupied
@@ -40,7 +39,6 @@ struct tcs_group {
u32 offset;
int num_tcs;
int ncpt;
-   spinlock_t lock;
const struct tcs_request *req[MAX_TCS_PER_TYPE];
u32 *cmd_cache;
DECLARE_BITMAP(slots, MAX_TCS_SLOTS);
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index e278fc11fe5c..92461311aef3 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -93,8 +93,7 @@ static void write_tcs_reg_sync(struct rsc_drv *drv, int reg, 
int tcs_id,

static bool tcs_is_free(struct rsc_drv *drv, int tcs_id)
{
-   return !test_bit(tcs_id, drv->tcs_in_use) &&
-  read_tcs_reg(drv, RSC_DRV_STATUS, tcs_id, 0);
+   return !test_bit(tcs_id, drv->tcs_in_use);
}

static struct tcs_group *get_tcs_of_type(struct rsc_drv *drv, int type)
@@ -104,29 +103,28 @@ static struct tcs_group *get_tcs_of_type(struct rsc_drv 
*drv, int type)

static int tcs_invalidate(struct rsc_drv *drv, int type)
{
-   int m;
+   int m, ret = 0;
struct tcs_group *tcs;

tcs = get_tcs_of_type(drv, type);

-   spin_lock(>lock);
-   if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS)) {
-   spin_unlock(>lock);
-   return 0;
-   }
+   spin_lock(>lock);
+   if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS))
+   goto done;

for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) {
if (!tcs_is_free(drv, m)) {
-   spin_unlock(>lock);
-   return -EAGAIN;
+   ret = -EAGAIN;
+   goto done;
}
write_tcs_reg_sync(drv, RSC_DRV_CMD_ENABLE, m, 0);
write_tcs_reg_sync(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, m, 0);
}
bitmap_zero(tcs->slots, MAX_TCS_SLOTS);
-   spin_unlock(>lock);

-   return 0;
+done:
+   spin_unlock(>lock);
+   return ret;
}

/**
@@ -242,9 +240,7 @@ static irqreturn_t tcs_tx_done(int irq, void *p)
write_tcs_reg(drv, RSC_DRV_CMD_ENABLE, i, 0);
write_tcs_reg(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, i, 0);
write_tcs_reg(drv, RSC_DRV_IRQ_CLEAR, 0, BIT(i));
-   spin_lock(>lock);
clear_bit(i, drv->tcs_in_use);
-   spin_unlock(>lock);
if (req)
rpmh_tx_done(req, err);
}
@@ -349,14 +345,12 @@ static int tcs_write(struct rsc_drv *drv, const struct 
tcs_request *msg)
{
struct tcs_group *tcs;
int tcs_id;
-   unsigned long flags;
int ret;

tcs = get_tcs_for_msg(drv, msg);
if (IS_ERR(tcs))
return PTR_ERR(tcs);

-   spin_lock_irqsave(>lock, flags);
spin_lock(>lock);
/*
 * The h/w does not like if we send a request to the same address,
@@ -364,26 +358,23 @@ static int tcs_write(struct rsc_drv *drv, const struct 
tcs_request *msg)
 */
ret = check_for_req_inflight(drv, tcs, msg);
if (ret) {
-   spin_unlock(>lock);
goto done_write;
}

tcs_id = find_free_tcs(tcs);
if (tcs_id < 0) {
ret = tcs_id;
-   spin_unlock(>lock);
goto done_write;
}

tcs->req[tcs_id - tcs->offset] = msg;
set_bit(tcs_id, drv->tcs_in_use);
-   spin_unlock(>lock);

__tcs_buffer_write(drv, tcs_id, 0, msg);
__tcs_trigger(drv, tcs_id);


[PATCH] Revert "x86/build: Move _etext to actual end of .text"

2019-07-01 Thread Ross Zwisler
This reverts commit 392bef709659abea614abfe53cf228e7a59876a4.

Per the discussion here:

https://lkml.org/lkml/2019/6/20/830

the above referenced commit breaks kernel compilation with old GCC
toolchains as well as current versions of the Gold linker.  Revert it so
we don't regress and lose the ability to compile the kernel with these
tools.

Signed-off-by: Ross Zwisler 
---
 arch/x86/kernel/vmlinux.lds.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 0850b5149345..4d1517022a14 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -141,10 +141,10 @@ SECTIONS
*(.text.__x86.indirect_thunk)
__indirect_thunk_end = .;
 #endif
-   } :text = 0x9090
 
-   /* End of text section */
-   _etext = .;
+   /* End of text section */
+   _etext = .;
+   } :text = 0x9090
 
NOTES :text :note
 
-- 
2.20.1


Re: Adding some trees to linux-next?

2019-07-01 Thread Darrick J. Wong
On Tue, Jul 02, 2019 at 01:42:10AM +1000, Stephen Rothwell wrote:
> Hi Darrick,
> 
> On Mon, 1 Jul 2019 08:35:52 -0700 "Darrick J. Wong"  
> wrote:
> >
> > Could you add my iomap-for-next and vfs-for-next branches to linux-next,
> > please?  They can be found here:
> > 
> > git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git#iomap-for-next
> > git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git#vfs-for-next
> > 
> > I've decided that trying to munge all that through the xfs for-next
> > branch is too much insanity and splitting them up will help me prevent
> > my head from falling off.
> 
> Just out of interest, do you intend to send these directly to Linus, or
> via another tree?

The iomap stuff I'd definitely send directly to Linus.

For vfs stuff, it depends.  For work in the core vfs I'll probably just
keep sending patches through Al, but for treewide things like ioctl
cleanups I suspect it'll be easier to let them soak in -next and then
send them directly.

I also dropped the f2fs parts of the setflags/fssetxattr patches because
while I think your fix from yesterday's for-next is correct, I prefer to
let Eric Biggers' cleanup land through the f2fs tree before I try to
clean up f2fs again.  There shouldn't be any harm in letting that lag a
little while longer.

--D

> -- 
> Cheers,
> Stephen Rothwell




Re: Adding some trees to linux-next?

2019-07-01 Thread Stephen Rothwell
Hi Darrick,

On Mon, 1 Jul 2019 08:35:52 -0700 "Darrick J. Wong"  
wrote:
>
> Could you add my iomap-for-next and vfs-for-next branches to linux-next,
> please?  They can be found here:
> 
> git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git#iomap-for-next
> git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git#vfs-for-next
> 
> I've decided that trying to munge all that through the xfs for-next
> branch is too much insanity and splitting them up will help me prevent
> my head from falling off.

Added from today.

Thanks for adding your subsystem tree as a participant of linux-next.  As
you may know, this is not a judgement of your code.  The purpose of
linux-next is for integration testing and to lower the impact of
conflicts between subsystems in the next merge window. 

You will need to ensure that the patches/commits in your tree/series have
been:
 * submitted under GPL v2 (or later) and include the Contributor's
Signed-off-by,
 * posted to the relevant mailing list,
 * reviewed by you (or another maintainer of your subsystem tree),
 * successfully unit tested, and 
 * destined for the current or next Linux merge window.

Basically, this should be just what you would send to Linus (or ask him
to fetch).  It is allowed to be rebased if you deem it necessary.

-- 
Cheers,
Stephen Rothwell 
s...@canb.auug.org.au


pgpIDLyYdm30f.pgp
Description: OpenPGP digital signature


[PATCH v2] sched/fair: fix imbalance due to CPU affinity

2019-07-01 Thread Vincent Guittot
The load_balance() has a dedicated mecanism to detect when an imbalance
is due to CPU affinity and must be handled at parent level. In this case,
the imbalance field of the parent's sched_group is set.

The description of sg_imbalanced() gives a typical example of two groups
of 4 CPUs each and 4 tasks each with a cpumask covering 1 CPU of the first
group and 3 CPUs of the second group. Something like:

{ 0 1 2 3 } { 4 5 6 7 }
* * * *

But the load_balance fails to fix this UC on my octo cores system
made of 2 clusters of quad cores.

Whereas the load_balance is able to detect that the imbalanced is due to
CPU affinity, it fails to fix it because the imbalance field is cleared
before letting parent level a chance to run. In fact, when the imbalance is
detected, the load_balance reruns without the CPU with pinned tasks. But
there is no other running tasks in the situation described above and
everything looks balanced this time so the imbalance field is immediately
cleared.

The imbalance field should not be cleared if there is no other task to move
when the imbalance is detected.

Signed-off-by: Vincent Guittot 
---

Sorry, I sent the patch before rebasing it on top of sched-tip and it might
conlfict when applying because it was on top of my ongoing rework of 
load_balance

This version is rebased on top of latest shced-tip/sched/core

 kernel/sched/fair.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index b798fe7..fff5632 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8992,9 +8992,10 @@ static int load_balance(int this_cpu, struct rq *this_rq,
 out_balanced:
/*
 * We reach balance although we may have faced some affinity
-* constraints. Clear the imbalance flag if it was set.
+* constraints. Clear the imbalance flag only if other tasks got
+* a chance to move and fix the imbalance.
 */
-   if (sd_parent) {
+   if (sd_parent && !(env.flags & LBF_ALL_PINNED)) {
int *group_imbalance = _parent->groups->sgc->imbalance;
 
if (*group_imbalance)
-- 
2.7.4



Re: [PATCH] csky: Improve abiv1 mem ops performance with glibc codes

2019-07-01 Thread Arnd Bergmann
On Mon, Jul 1, 2019 at 5:26 PM Guo Ren  wrote:
> On Mon, Jul 1, 2019 at 10:52 PM Arnd Bergmann  wrote:
> >
> > On Sat, Jun 29, 2019 at 7:36 AM  wrote:
> > >
> > > From: Guo Ren 
> > >
> > > These codes are copied from glibc/string directory, they are the generic
> > > implementation for string operations. We may further optimize them with
> > > assembly code in the future.
> > >
> > > In fact these code isn't tested enough for kernel, but we've tested them
> > > on glibc and it seems good. We just trust them :)
> >
> > Are these files from the architecture independent portion of glibc or
> > are they csky specific? If they are architecture independent, we might
> > want to see if they make sense for other architectures as well, and
> > add them to lib/ rather than arch/csky/lib/
> They are just copied from glibc-2.28/string/*.c and they are generic.
> OK, I'll try to add them to lib/.

Ok. Note that lib/string.c contains very basic versions of these already,
so please see which of the functions you have actually make a
difference in practice over those (if you haven't done that already).

Otherwise you can probably follow the example of the libgcc functions
in lib/ashldi3.c etc: add a Kconfig symbol like CONFIG_GENERIC_LIB_ASHLDI3
for each function you had, put the glibc version into a new file, and allow
architectures to select them individually, which in turn should
replace the version from lib/string.c.

   Arnd


Re: [PATCH] media: venus: Update to bitrate based clock scaling

2019-07-01 Thread Stanimir Varbanov
Hi Aniket,

On 6/26/19 11:23 AM, Aniket Masule wrote:
> Introduced clock scaling using bitrate, current
> calculations consider only the cycles per mb.
> Also, clock scaling is now triggered before every
> buffer being queued to the device. This helps in
> deciding precise clock cycles required.
> 
> Signed-off-by: Aniket Masule 
> ---
>  drivers/media/platform/qcom/venus/core.c| 16 +--
>  drivers/media/platform/qcom/venus/core.h|  1 +
>  drivers/media/platform/qcom/venus/helpers.c | 43 
> +
>  3 files changed, 47 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/core.c 
> b/drivers/media/platform/qcom/venus/core.c
> index f1597d6..ad6bb74 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -474,14 +474,14 @@ static __maybe_unused int venus_runtime_resume(struct 
> device *dev)
>  };
>  
>  static struct codec_freq_data sdm845_codec_freq_data[] =  {
> - { V4L2_PIX_FMT_H264, VIDC_SESSION_TYPE_ENC, 675 },
> - { V4L2_PIX_FMT_HEVC, VIDC_SESSION_TYPE_ENC, 675 },
> - { V4L2_PIX_FMT_VP8, VIDC_SESSION_TYPE_ENC, 675 },
> - { V4L2_PIX_FMT_MPEG2, VIDC_SESSION_TYPE_DEC, 200 },
> - { V4L2_PIX_FMT_H264, VIDC_SESSION_TYPE_DEC, 200 },
> - { V4L2_PIX_FMT_HEVC, VIDC_SESSION_TYPE_DEC, 200 },
> - { V4L2_PIX_FMT_VP8, VIDC_SESSION_TYPE_DEC, 200 },
> - { V4L2_PIX_FMT_VP9, VIDC_SESSION_TYPE_DEC, 200 },
> + { V4L2_PIX_FMT_H264, VIDC_SESSION_TYPE_ENC, 675, 10 },
> + { V4L2_PIX_FMT_HEVC, VIDC_SESSION_TYPE_ENC, 675, 10 },
> + { V4L2_PIX_FMT_VP8, VIDC_SESSION_TYPE_ENC, 675, 10 },
> + { V4L2_PIX_FMT_MPEG2, VIDC_SESSION_TYPE_DEC, 200, 10 },
> + { V4L2_PIX_FMT_H264, VIDC_SESSION_TYPE_DEC, 200, 10 },
> + { V4L2_PIX_FMT_HEVC, VIDC_SESSION_TYPE_DEC, 200, 10 },
> + { V4L2_PIX_FMT_VP8, VIDC_SESSION_TYPE_DEC, 200, 10 },
> + { V4L2_PIX_FMT_VP9, VIDC_SESSION_TYPE_DEC, 200, 10 },
>  };
>  
>  static const struct venus_resources sdm845_res = {
> diff --git a/drivers/media/platform/qcom/venus/core.h 
> b/drivers/media/platform/qcom/venus/core.h
> index 2ed6496..b964b7c 100644
> --- a/drivers/media/platform/qcom/venus/core.h
> +++ b/drivers/media/platform/qcom/venus/core.h
> @@ -39,6 +39,7 @@ struct codec_freq_data {
>   u32 pixfmt;
>   u32 session_type;
>   unsigned int vpp_freq;
> + unsigned int vsp_freq;

unsigned long?

>  };
>  
>  struct venus_resources {
> diff --git a/drivers/media/platform/qcom/venus/helpers.c 
> b/drivers/media/platform/qcom/venus/helpers.c
> index ef35fd8..634778a 100644
> --- a/drivers/media/platform/qcom/venus/helpers.c
> +++ b/drivers/media/platform/qcom/venus/helpers.c
> @@ -379,6 +379,9 @@ static int scale_clocks(struct venus_inst *inst)
>   unsigned int i;
>   int ret;
>  
> + if (inst->state == INST_START)
> + return 0;

This condition is related (probably) to the change in
venus_helper_vb2_buf_queue() but shouldn't it be copied in
scale_clocks_v4 too?

> +
>   mbs_per_sec = load_per_type(core, VIDC_SESSION_TYPE_ENC) +
> load_per_type(core, VIDC_SESSION_TYPE_DEC);
>  
> @@ -418,17 +421,26 @@ static int scale_clocks(struct venus_inst *inst)
>   return ret;
>  }
>  
> -static unsigned long calculate_vpp_freq(struct venus_inst *inst)
> +static unsigned long calculate_inst_freq(struct venus_inst *inst,
> +  unsigned long filled_len)
>  {
> - unsigned long vpp_freq = 0;
> + unsigned long vpp_freq = 0, vsp_freq = 0;
> + u64 fps = inst->fps;
>   u32 mbs_per_sec;
>  
>   mbs_per_sec = load_per_instance(inst);
>   vpp_freq = mbs_per_sec * inst->clk_data.codec_freq_data->vpp_freq;
>   /* 21 / 20 is overhead factor */
>   vpp_freq += vpp_freq / 20;
> + vsp_freq = mbs_per_sec * inst->clk_data.codec_freq_data->vsp_freq;

this calculation is not used below. Is that intentional?

> +
> + /* 10 / 7 is overhead factor */
> + if (inst->session_type == VIDC_SESSION_TYPE_ENC)
> + vsp_freq = (inst->controls.enc.bitrate * 10) / 7;
> + else
> + vsp_freq = ((fps * filled_len * 8) * 10) / 7;
>  
> - return vpp_freq;
> + return max(vpp_freq, vsp_freq);
>  }
>  
>  static int scale_clocks_v4(struct venus_inst *inst)
> @@ -436,14 +448,30 @@ static int scale_clocks_v4(struct venus_inst *inst)
>   struct venus_core *core = inst->core;
>   const struct freq_tbl *table = core->res->freq_tbl;
>   unsigned int num_rows = core->res->freq_tbl_size;
> -
> + struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx;
>   struct clk *clk = core->clks[0];
>   struct device *dev = core->dev;
> +

drop this addition of blank line.

>   unsigned int i;
>   unsigned long freq = 0, freq_core0 = 0, freq_core1 = 0;
> + unsigned long filled_len = 0;
> + struct venus_buffer *buf, *n;
> + struct vb2_buffer *vb;
>   int ret;
>  
> - freq = 

Re: [PATCH] vfs: move_mount: reject moving kernel internal mounts

2019-07-01 Thread Eric Biggers
On Mon, Jul 01, 2019 at 02:08:48AM +0100, Al Viro wrote:
> 
> Let's reorder that a bit:
> /* The mountpoint must be in our namespace. */
> if (!check_mnt(p))
> goto out;
> 
>   /* The thing moved must be mounted... */
>   if (!is_mounted(old_path->mnt))
>   goto out;
> 
> /* ... and either ours or the root of anon namespace */
>   if (!(attached ? check_mnt(old) : is_anon_ns(ns)))
>   goto out;
> 
> IMO that looks saner and all it costs us is a redundant check
> in attached case.  Objections?

Looks good to me.

- Eric


Re: Adding some trees to linux-next?

2019-07-01 Thread Stephen Rothwell
Hi Darrick,

On Mon, 1 Jul 2019 08:35:52 -0700 "Darrick J. Wong"  
wrote:
>
> Could you add my iomap-for-next and vfs-for-next branches to linux-next,
> please?  They can be found here:
> 
> git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git#iomap-for-next
> git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git#vfs-for-next
> 
> I've decided that trying to munge all that through the xfs for-next
> branch is too much insanity and splitting them up will help me prevent
> my head from falling off.

Just out of interest, do you intend to send these directly to Linus, or
via another tree?

-- 
Cheers,
Stephen Rothwell


pgpIfGQPKW_kY.pgp
Description: OpenPGP digital signature


Re: remove asm-generic/ptrace.h v3

2019-07-01 Thread Arnd Bergmann
On Mon, Jun 24, 2019 at 9:23 AM Thomas Gleixner  wrote:
>
> On Mon, 24 Jun 2019, Christoph Hellwig wrote:
> >
> > asm-generic/ptrace.h is a little weird in that it doesn't actually
> > implement any functionality, but it provided multiple layers of macros
> > that just implement trivial inline functions.  We implement those
> > directly in the few architectures and be off with a much simpler
> > design.
> >
> > I'm not sure which tree is the right place, but may this can go through
> > the asm-generic tree since it removes an asm-generic header?
>
> Makes sense.

Applied and pushed to asm-generic.git/master now, sorry for the delay.

 Arnd


Re: Perf framework : Cluster based counter support

2019-07-01 Thread Mukesh Ojha



On 6/28/2019 10:29 PM, Mark Rutland wrote:

On Fri, Jun 28, 2019 at 10:23:10PM +0530, Mukesh Ojha wrote:

Hi All,

Hi Mukesh,


Is it looks considerable to add cluster based event support to add in
current perf event framework and later in userspace perf to support
such events ?

Could you elaborate on what you mean by "cluster based event"?

I assume you mean something like events for a cluster-affine shared
resource like some level of cache?

If so, there's a standard pattern for supporting such system/uncore
PMUs, see drivers/perf/qcom_l2_pmu.c and friends for examples.



Thanks Mark for pointing it out.
Also What is stopping us in adding cluster based event e.g L2 cache 
hit/miss or some other type raw events  in core framework ?



Thanks.
Mukesh








Thanks,
Mark.


[PATCH] sched/fair: fix imbalance due to CPU affinity

2019-07-01 Thread Vincent Guittot
The load_balance() has a dedicated mecanism to detect when an imbalance
is due to CPU affinity and must be handled at parent level. In this case,
the imbalance field of the parent's sched_group is set.

The description of sg_imbalanced() gives a typical example of two groups
of 4 CPUs each and 4 tasks each with a cpumask covering 1 CPU of the first
group and 3 CPUs of the second group. Something like:

{ 0 1 2 3 } { 4 5 6 7 }
* * * *

But the load_balance fails to fix this UC on my octo cores system
made of 2 clusters of quad cores.

Whereas the load_balance is able to detect that the imbalanced is due to
CPU affinity, it fails to fix it because the imbalance field is cleared
before letting parent level a chance to run. In fact, when the imbalance is
detected, the load_balance reruns without the CPU with pinned tasks. But
there is no other running tasks in the situation described above and
everything looks balanced this time so the imbalance field is immediately
cleared.

The imbalance field should not be cleared if there is no other task to move
when the imbalance is detected.

Signed-off-by: Vincent Guittot 
---

 kernel/sched/fair.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9f9dcb1..bd94171 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9032,9 +9032,10 @@ static int load_balance(int this_cpu, struct rq *this_rq,
 out_balanced:
/*
 * We reach balance although we may have faced some affinity
-* constraints. Clear the imbalance flag if it was set.
+* constraints. Clear the imbalance flag only if other tasks get
+* a chance to move and fix the imbalance.
 */
-   if (sd_parent) {
+   if (sd_parent && !(env.flags & LBF_ALL_PINNED)) {
int *group_imbalance = _parent->groups->sgc->imbalance;
 
if (*group_imbalance)
-- 
2.7.4



Re: [PATCH 2/2] leds: tlc591xx: Use the OF version of the LED registration function

2019-07-01 Thread Dan Murphy

JJ

On 7/1/19 10:26 AM, Jean-Jacques Hiblot wrote:

The driver parses the device-tree to identify which LED should be handled.
Since the information about the device node is known at this time, we can
provide the LED core with it. It may be useful later.

Signed-off-by: Jean-Jacques Hiblot 
---
  drivers/leds/leds-tlc591xx.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c
index 14e47ff44df5..6a2936c94b73 100644
--- a/drivers/leds/leds-tlc591xx.c
+++ b/drivers/leds/leds-tlc591xx.c
@@ -207,7 +207,7 @@ tlc591xx_probe(struct i2c_client *client,
led->led_no = idx++;
led->ldev.brightness_set_blocking = tlc591xx_brightness_set;
led->ldev.max_brightness = LED_FULL;
-   err = devm_led_classdev_register(dev, >ldev);
+   err = devm_of_led_classdev_register(dev, child, >ldev);
if (err < 0) {
dev_err(dev, "couldn't register LED %s\n",
led->ldev.name);



Reviewed-by: Dan Murphy 



Re: [PATCH 1/2] leds: tlc591xx: simplify driver by using the managed led API

2019-07-01 Thread Dan Murphy



On 7/1/19 10:26 AM, Jean-Jacques Hiblot wrote:

Use the managed API of the LED class (devm_led_classdev_register()
instead of led_classdev_register()).
This allows us to remove the code used to track-and-destroy the LED devices

Signed-off-by: Jean-Jacques Hiblot 
---
  drivers/leds/leds-tlc591xx.c | 81 ++--
  1 file changed, 21 insertions(+), 60 deletions(-)

diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c
index 59ff088c7d75..14e47ff44df5 100644
--- a/drivers/leds/leds-tlc591xx.c
+++ b/drivers/leds/leds-tlc591xx.c
@@ -128,51 +128,6 @@ tlc591xx_brightness_set(struct led_classdev *led_cdev,
return err;
  }
  
-static void

-tlc591xx_destroy_devices(struct tlc591xx_priv *priv, unsigned int j)
-{
-   int i = j;
-
-   while (--i >= 0) {
-   if (priv->leds[i].active)
-   led_classdev_unregister(>leds[i].ldev);
-   }
-}
-
-static int
-tlc591xx_configure(struct device *dev,
-  struct tlc591xx_priv *priv,
-  const struct tlc591xx *tlc591xx)
-{
-   unsigned int i;
-   int err = 0;
-
-   tlc591xx_set_mode(priv->regmap, MODE2_DIM);
-   for (i = 0; i < TLC591XX_MAX_LEDS; i++) {
-   struct tlc591xx_led *led = >leds[i];
-
-   if (!led->active)
-   continue;
-
-   led->priv = priv;
-   led->led_no = i;
-   led->ldev.brightness_set_blocking = tlc591xx_brightness_set;
-   led->ldev.max_brightness = LED_FULL;
-   err = led_classdev_register(dev, >ldev);
-   if (err < 0) {
-   dev_err(dev, "couldn't register LED %s\n",
-   led->ldev.name);
-   goto exit;
-   }
-   }
-
-   return 0;
-
-exit:
-   tlc591xx_destroy_devices(priv, i);
-   return err;
-}
-
  static const struct regmap_config tlc591xx_regmap = {
.reg_bits = 8,
.val_bits = 8,
@@ -197,7 +152,7 @@ tlc591xx_probe(struct i2c_client *client,
const struct of_device_id *match;
const struct tlc591xx *tlc591xx;
struct tlc591xx_priv *priv;
-   int err, count, reg;
+   int err, count, reg, idx = 0;
  
  	match = of_match_device(of_tlc591xx_leds_match, dev);

if (!match)
@@ -225,7 +180,11 @@ tlc591xx_probe(struct i2c_client *client,
  
  	i2c_set_clientdata(client, priv);
  
+	tlc591xx_set_mode(priv->regmap, MODE2_DIM);

+
for_each_child_of_node(np, child) {
+   struct tlc591xx_led *led;
+
err = of_property_read_u32(child, "reg", );


You should check to make sure "reg" is not out of bounds for the device.

This was handled in the for..loop in the configure routine

Dan


if (err) {
of_node_put(child);
@@ -236,22 +195,25 @@ tlc591xx_probe(struct i2c_client *client,
of_node_put(child);
return -EINVAL;
}
-   priv->leds[reg].active = true;
-   priv->leds[reg].ldev.name =
+   led = >leds[reg];
+
+   led->active = true;
+   led->ldev.name =
of_get_property(child, "label", NULL) ? : child->name;
-   priv->leds[reg].ldev.default_trigger =
+   led->ldev.default_trigger =
of_get_property(child, "linux,default-trigger", NULL);
-   }
-   return tlc591xx_configure(dev, priv, tlc591xx);
-}
-
-static int
-tlc591xx_remove(struct i2c_client *client)
-{
-   struct tlc591xx_priv *priv = i2c_get_clientdata(client);
-
-   tlc591xx_destroy_devices(priv, TLC591XX_MAX_LEDS);
  
+		led->priv = priv;

+   led->led_no = idx++;
+   led->ldev.brightness_set_blocking = tlc591xx_brightness_set;
+   led->ldev.max_brightness = LED_FULL;
+   err = devm_led_classdev_register(dev, >ldev);
+   if (err < 0) {
+   dev_err(dev, "couldn't register LED %s\n",
+   led->ldev.name);
+   return err;
+   }
+   }
return 0;
  }
  
@@ -268,7 +230,6 @@ static struct i2c_driver tlc591xx_driver = {

.of_match_table = of_match_ptr(of_tlc591xx_leds_match),
},
.probe = tlc591xx_probe,
-   .remove = tlc591xx_remove,
.id_table = tlc591xx_id,
  };
  


Adding some trees to linux-next?

2019-07-01 Thread Darrick J. Wong
Hi Stephen,

Could you add my iomap-for-next and vfs-for-next branches to linux-next,
please?  They can be found here:

git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git#iomap-for-next
git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git#vfs-for-next

I've decided that trying to munge all that through the xfs for-next
branch is too much insanity and splitting them up will help me prevent
my head from falling off.

--Darrick


Re: [PATCH v2 1/2] ASoC: tas5720.c: cleanup variant management

2019-07-01 Thread Nikolaus Voss

On Mon, 1 Jul 2019, Andrew F. Davis wrote:

On 7/1/19 9:42 AM, Nikolaus Voss wrote:

Replace enum tas572x_type with struct tas5720_variant which aggregates
variant specific stuff and can be directly referenced from an id table.

Signed-off-by: Nikolaus Voss 
---
 sound/soc/codecs/tas5720.c | 98 +-
 1 file changed, 33 insertions(+), 65 deletions(-)

diff --git a/sound/soc/codecs/tas5720.c b/sound/soc/codecs/tas5720.c
index 37fab8f22800..b2e897f094b4 100644
--- a/sound/soc/codecs/tas5720.c
+++ b/sound/soc/codecs/tas5720.c
@@ -28,9 +28,10 @@
 /* Define how often to check (and clear) the fault status register (in ms) */
 #define TAS5720_FAULT_CHECK_INTERVAL   200

-enum tas572x_type {
-   TAS5720,
-   TAS5722,
+struct tas5720_variant {
+   const int device_id;
+   const struct regmap_config *reg_config;
+   const struct snd_soc_component_driver *comp_drv;
 };

 static const char * const tas5720_supply_names[] = {
@@ -44,7 +45,7 @@ struct tas5720_data {
struct snd_soc_component *component;
struct regmap *regmap;
struct i2c_client *tas5720_client;
-   enum tas572x_type devtype;
+   const struct tas5720_variant *variant;


Why add a new struct? Actually I don't see the need for this patch at
all, the commit message only explains the 'what' not the 'why'. We can
and do already build this info from the tas572x_type.


As the commit message says, the purpose is to aggregate the variant 
specifics and make it accessible via one pointer. This is a standard 
approach for of/acpi_device_id tables and thus makes the code simpler and 
improves readability. This is a maintenance patch to prepare using the 
device match API in a proper way.




Also below are several functional changes, the cover letter says this is
not a functional change, yet the driver behaves differently now.


Can you be a little bit more specific? The code should behave exactly as 
before.


Niko



Andrew


struct regulator_bulk_data supplies[TAS5720_NUM_SUPPLIES];
struct delayed_work fault_check_work;
unsigned int last_fault;
@@ -179,17 +180,13 @@ static int tas5720_set_dai_tdm_slot(struct snd_soc_dai 
*dai,
goto error_snd_soc_component_update_bits;

/* Configure TDM slot width. This is only applicable to TAS5722. */
-   switch (tas5720->devtype) {
-   case TAS5722:
+   if (tas5720->variant->device_id == TAS5722_DEVICE_ID) {
ret = snd_soc_component_update_bits(component, 
TAS5722_DIGITAL_CTRL2_REG,
TAS5722_TDM_SLOT_16B,
slot_width == 16 ?
TAS5722_TDM_SLOT_16B : 0);
if (ret < 0)
goto error_snd_soc_component_update_bits;
-   break;
-   default:
-   break;
}

return 0;
@@ -277,7 +274,7 @@ static void tas5720_fault_check_work(struct work_struct 
*work)
 static int tas5720_codec_probe(struct snd_soc_component *component)
 {
struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component);
-   unsigned int device_id, expected_device_id;
+   unsigned int device_id;
int ret;

tas5720->component = component;
@@ -301,21 +298,9 @@ static int tas5720_codec_probe(struct snd_soc_component 
*component)
goto probe_fail;
}

-   switch (tas5720->devtype) {
-   case TAS5720:
-   expected_device_id = TAS5720_DEVICE_ID;
-   break;
-   case TAS5722:
-   expected_device_id = TAS5722_DEVICE_ID;
-   break;
-   default:
-   dev_err(component->dev, "unexpected private driver data\n");
-   return -EINVAL;
-   }
-
-   if (device_id != expected_device_id)
+   if (device_id != tas5720->variant->device_id)
dev_warn(component->dev, "wrong device ID. expected: %u read: 
%u\n",
-expected_device_id, device_id);
+tas5720->variant->device_id, device_id);

/* Set device to mute */
ret = snd_soc_component_update_bits(component, 
TAS5720_DIGITAL_CTRL2_REG,
@@ -637,7 +622,6 @@ static int tas5720_probe(struct i2c_client *client,
 {
struct device *dev = >dev;
struct tas5720_data *data;
-   const struct regmap_config *regmap_config;
int ret;
int i;

@@ -646,20 +630,10 @@ static int tas5720_probe(struct i2c_client *client,
return -ENOMEM;

data->tas5720_client = client;
-   data->devtype = id->driver_data;

-   switch (id->driver_data) {
-   case TAS5720:
-   regmap_config = _regmap_config;
-   break;
-   case TAS5722:
-   regmap_config = _regmap_config;
-   break;
-   default:
-   dev_err(dev, "unexpected 

NO_HZ_IDLE causes consistently low cpu "iowait" time (and higher cpu "idle" time)

2019-07-01 Thread Alan Jenkins

Hi

I tried running a simple test:

    dd if=testfile iflag=direct bs=1M of=/dev/null

With my default settings, `vmstat 10` shows something like 85% idle time 
to 15% iowait time. I have 4 CPUs, so this is much less than one CPU 
worth of iowait time.


If I boot with "nohz=off", I see idle time fall to 75% or below, and 
iowait rise to about 25%, equivalent to one CPU.  That is what I had 
originally expected.


(I can also see my expected numbers, if I disable *all* C-states and 
force polling using `pm_qos_resume_latency_us` in sysfs).


The numbers above are from a kernel somewhere around v5.2-rc5.  I saw 
the "wrong" results on some previous kernels as well.  I just now 
realized the link to NO_HZ_IDLE.[1]


[1] 
https://unix.stackexchange.com/questions/517757/my-basic-assumption-about-system-iowait-does-not-hold/527836#527836


I did not find any information about this high level of inaccuracy. Can 
anyone explain, is this behaviour expected?


I found several patches that mentioned "iowait" and NO_HZ_IDLE. But if 
they described this problem, it was not clear to me.


I thought this might also be affecting the "IO pressure" values from the 
new "pressure stall information"... but I am too confused already, so I 
am only asking about iowait at the moment :-).[2]


[2] 
https://unix.stackexchange.com/questions/527342/why-does-the-new-linux-pressure-stall-information-for-io-not-show-as-100/527347#527347


I have seen the disclaimers for iowait in 
Documentation/filesystems/proc.txt, and the derived man page. 
Technically, the third disclaimer might cover anything.  But I was 
optimistic; I hoped it was talking about relatively small glitches :-).  
I didn't think it would mean a large systematic undercounting, which 
applied to the vast majority of current systems (which are not tuned for 
realtime use).


|


- iowait: In a word, iowait stands for waiting for I/O to complete. But there
 are several problems:
 1. Cpu will not wait for I/O to complete, iowait is the time that a task is
waiting for I/O to complete. When cpu goes into idle state for
outstanding task io, another task will be scheduled on this CPU.
 2. In a multi-core CPU, the task waiting for I/O to complete is not running
on any CPU, so the iowait of each CPU is difficult to calculate.
 3. The value of iowait field in /proc/stat will decrease in certain
conditions|



Thanks for all the power-saving code
Alan


[PATCH 1/2] drivers: qcom: rpmh-rsc: simplify TCS locking

2019-07-01 Thread Lina Iyer
From: "Raju P.L.S.S.S.N" 

tcs->lock was introduced to serialize access with in TCS group. But
even without tcs->lock, drv->lock is serving the same purpose. So
use a single drv->lock.

Other optimizations include -
 - Remove locking around clear_bit() in IRQ handler. clear_bit() is
   atomic.
 - Remove redundant read of TCS registers.
 - Use spin_lock instead of _irq variants as the locks are not held
   in interrupt context.

Fixes: 658628 ("drivers: qcom: rpmh-rsc: add RPMH controller for QCOM
SoCs")
Signed-off-by: Raju P.L.S.S.S.N 
Signed-off-by: Lina Iyer 
---
 drivers/soc/qcom/rpmh-internal.h |  2 --
 drivers/soc/qcom/rpmh-rsc.c  | 37 +++-
 drivers/soc/qcom/rpmh.c  | 20 +++--
 3 files changed, 21 insertions(+), 38 deletions(-)

diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
index a767991c..969d5030860e 100644
--- a/drivers/soc/qcom/rpmh-internal.h
+++ b/drivers/soc/qcom/rpmh-internal.h
@@ -28,7 +28,6 @@ struct rsc_drv;
  * @offset:start of the TCS group relative to the TCSes in the RSC
  * @num_tcs:   number of TCSes in this type
  * @ncpt:  number of commands in each TCS
- * @lock:  lock for synchronizing this TCS writes
  * @req:   requests that are sent from the TCS
  * @cmd_cache: flattened cache of cmds in sleep/wake TCS
  * @slots: indicates which of @cmd_addr are occupied
@@ -40,7 +39,6 @@ struct tcs_group {
u32 offset;
int num_tcs;
int ncpt;
-   spinlock_t lock;
const struct tcs_request *req[MAX_TCS_PER_TYPE];
u32 *cmd_cache;
DECLARE_BITMAP(slots, MAX_TCS_SLOTS);
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index e278fc11fe5c..92461311aef3 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -93,8 +93,7 @@ static void write_tcs_reg_sync(struct rsc_drv *drv, int reg, 
int tcs_id,
 
 static bool tcs_is_free(struct rsc_drv *drv, int tcs_id)
 {
-   return !test_bit(tcs_id, drv->tcs_in_use) &&
-  read_tcs_reg(drv, RSC_DRV_STATUS, tcs_id, 0);
+   return !test_bit(tcs_id, drv->tcs_in_use);
 }
 
 static struct tcs_group *get_tcs_of_type(struct rsc_drv *drv, int type)
@@ -104,29 +103,28 @@ static struct tcs_group *get_tcs_of_type(struct rsc_drv 
*drv, int type)
 
 static int tcs_invalidate(struct rsc_drv *drv, int type)
 {
-   int m;
+   int m, ret = 0;
struct tcs_group *tcs;
 
tcs = get_tcs_of_type(drv, type);
 
-   spin_lock(>lock);
-   if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS)) {
-   spin_unlock(>lock);
-   return 0;
-   }
+   spin_lock(>lock);
+   if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS))
+   goto done;
 
for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) {
if (!tcs_is_free(drv, m)) {
-   spin_unlock(>lock);
-   return -EAGAIN;
+   ret = -EAGAIN;
+   goto done;
}
write_tcs_reg_sync(drv, RSC_DRV_CMD_ENABLE, m, 0);
write_tcs_reg_sync(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, m, 0);
}
bitmap_zero(tcs->slots, MAX_TCS_SLOTS);
-   spin_unlock(>lock);
 
-   return 0;
+done:
+   spin_unlock(>lock);
+   return ret;
 }
 
 /**
@@ -242,9 +240,7 @@ static irqreturn_t tcs_tx_done(int irq, void *p)
write_tcs_reg(drv, RSC_DRV_CMD_ENABLE, i, 0);
write_tcs_reg(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, i, 0);
write_tcs_reg(drv, RSC_DRV_IRQ_CLEAR, 0, BIT(i));
-   spin_lock(>lock);
clear_bit(i, drv->tcs_in_use);
-   spin_unlock(>lock);
if (req)
rpmh_tx_done(req, err);
}
@@ -349,14 +345,12 @@ static int tcs_write(struct rsc_drv *drv, const struct 
tcs_request *msg)
 {
struct tcs_group *tcs;
int tcs_id;
-   unsigned long flags;
int ret;
 
tcs = get_tcs_for_msg(drv, msg);
if (IS_ERR(tcs))
return PTR_ERR(tcs);
 
-   spin_lock_irqsave(>lock, flags);
spin_lock(>lock);
/*
 * The h/w does not like if we send a request to the same address,
@@ -364,26 +358,23 @@ static int tcs_write(struct rsc_drv *drv, const struct 
tcs_request *msg)
 */
ret = check_for_req_inflight(drv, tcs, msg);
if (ret) {
-   spin_unlock(>lock);
goto done_write;
}
 
tcs_id = find_free_tcs(tcs);
if (tcs_id < 0) {
ret = tcs_id;
-   spin_unlock(>lock);
goto done_write;
}
 
tcs->req[tcs_id - tcs->offset] = msg;
set_bit(tcs_id, drv->tcs_in_use);
-   spin_unlock(>lock);
 
__tcs_buffer_write(drv, tcs_id, 0, msg);
__tcs_trigger(drv, tcs_id);
 
 done_write:
-   spin_unlock_irqrestore(>lock, flags);

[PATCH 2/2] drivers: qcom: rpmh-rsc: fix read back of trigger register

2019-07-01 Thread Lina Iyer
When triggering a TCS to send its contents, reading back the trigger
value may return an incorrect value. That is because, writing the
trigger may raise an interrupt which could be handled immediately and
the trigger value could be reset in the interrupt handler. By doing a
read back we may end up spinning waiting for the value we wrote.

Fixes: 658628 ("drivers: qcom: rpmh-rsc: add RPMH controller for QCOM
SoCs")
Signed-off-by: Lina Iyer 
---
 drivers/soc/qcom/rpmh-rsc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index 92461311aef3..2fc2fa879480 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -300,7 +300,7 @@ static void __tcs_trigger(struct rsc_drv *drv, int tcs_id)
enable = TCS_AMC_MODE_ENABLE;
write_tcs_reg_sync(drv, RSC_DRV_CONTROL, tcs_id, enable);
enable |= TCS_AMC_MODE_TRIGGER;
-   write_tcs_reg_sync(drv, RSC_DRV_CONTROL, tcs_id, enable);
+   write_tcs_reg(drv, RSC_DRV_CONTROL, tcs_id, enable);
 }
 
 static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



Re: [PATCH] net: usb: asix: init MAC address buffers

2019-07-01 Thread Dan Williams
On Mon, 2019-07-01 at 06:45 +0700, Phong Tran wrote:
> This is for fixing bug KMSAN: uninit-value in ax88772_bind
> 
> Tested by
> https://groups.google.com/d/msg/syzkaller-bugs/aFQurGotng4/cFe9nxMCCwAJ
> 
> Reported-by: syzbot+8a3fc6674bbc3978e...@syzkaller.appspotmail.com
> 
> syzbot found the following crash on:
> 
> HEAD commit:f75e4cfe kmsan: use kmsan_handle_urb() in urb.c
> git tree:   kmsan
> console output: 
> https://syzkaller.appspot.com/x/log.txt?x=136d720ea0
> kernel config:
> https://syzkaller.appspot.com/x/.config?x=602468164ccdc30a
> dashboard link:
> https://syzkaller.appspot.com/bug?extid=8a3fc6674bbc3978ed4e
> compiler:   clang version 9.0.0 (/home/glider/llvm/clang
> 06d00afa61eef8f7f501ebdb4e8612ea43ec2d78)
> syz repro:
> https://syzkaller.appspot.com/x/repro.syz?x=12788316a0
> C reproducer:   
> https://syzkaller.appspot.com/x/repro.c?x=120359aaa0
> 
> ==
> BUG: KMSAN: uninit-value in is_valid_ether_addr
> include/linux/etherdevice.h:200 [inline]
> BUG: KMSAN: uninit-value in asix_set_netdev_dev_addr
> drivers/net/usb/asix_devices.c:73 [inline]
> BUG: KMSAN: uninit-value in ax88772_bind+0x93d/0x11e0
> drivers/net/usb/asix_devices.c:724
> CPU: 0 PID: 3348 Comm: kworker/0:2 Not tainted 5.1.0+ #1
> Hardware name: Google Google Compute Engine/Google Compute Engine,
> BIOS
> Google 01/01/2011
> Workqueue: usb_hub_wq hub_event
> Call Trace:
>   __dump_stack lib/dump_stack.c:77 [inline]
>   dump_stack+0x191/0x1f0 lib/dump_stack.c:113
>   kmsan_report+0x130/0x2a0 mm/kmsan/kmsan.c:622
>   __msan_warning+0x75/0xe0 mm/kmsan/kmsan_instr.c:310
>   is_valid_ether_addr include/linux/etherdevice.h:200 [inline]
>   asix_set_netdev_dev_addr drivers/net/usb/asix_devices.c:73 [inline]
>   ax88772_bind+0x93d/0x11e0 drivers/net/usb/asix_devices.c:724
>   usbnet_probe+0x10f5/0x3940 drivers/net/usb/usbnet.c:1728
>   usb_probe_interface+0xd66/0x1320 drivers/usb/core/driver.c:361
>   really_probe+0xdae/0x1d80 drivers/base/dd.c:513
>   driver_probe_device+0x1b3/0x4f0 drivers/base/dd.c:671
>   __device_attach_driver+0x5b8/0x790 drivers/base/dd.c:778
>   bus_for_each_drv+0x28e/0x3b0 drivers/base/bus.c:454
>   __device_attach+0x454/0x730 drivers/base/dd.c:844
>   device_initial_probe+0x4a/0x60 drivers/base/dd.c:891
>   bus_probe_device+0x137/0x390 drivers/base/bus.c:514
>   device_add+0x288d/0x30e0 drivers/base/core.c:2106
>   usb_set_configuration+0x30dc/0x3750 drivers/usb/core/message.c:2027
>   generic_probe+0xe7/0x280 drivers/usb/core/generic.c:210
>   usb_probe_device+0x14c/0x200 drivers/usb/core/driver.c:266
>   really_probe+0xdae/0x1d80 drivers/base/dd.c:513
>   driver_probe_device+0x1b3/0x4f0 drivers/base/dd.c:671
>   __device_attach_driver+0x5b8/0x790 drivers/base/dd.c:778
>   bus_for_each_drv+0x28e/0x3b0 drivers/base/bus.c:454
>   __device_attach+0x454/0x730 drivers/base/dd.c:844
>   device_initial_probe+0x4a/0x60 drivers/base/dd.c:891
>   bus_probe_device+0x137/0x390 drivers/base/bus.c:514
>   device_add+0x288d/0x30e0 drivers/base/core.c:2106
>   usb_new_device+0x23e5/0x2ff0 drivers/usb/core/hub.c:2534
>   hub_port_connect drivers/usb/core/hub.c:5089 [inline]
>   hub_port_connect_change drivers/usb/core/hub.c:5204 [inline]
>   port_event drivers/usb/core/hub.c:5350 [inline]
>   hub_event+0x48d1/0x7290 drivers/usb/core/hub.c:5432
>   process_one_work+0x1572/0x1f00 kernel/workqueue.c:2269
>   process_scheduled_works kernel/workqueue.c:2331 [inline]
>   worker_thread+0x189c/0x2460 kernel/workqueue.c:2417
>   kthread+0x4b5/0x4f0 kernel/kthread.c:254
>   ret_from_fork+0x35/0x40 arch/x86/entry/entry_64.S:355
> 
> Signed-off-by: Phong Tran 
> ---
>  drivers/net/usb/asix_devices.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/usb/asix_devices.c
> b/drivers/net/usb/asix_devices.c
> index c9bc96310ed4..f514d19316b1 100644
> --- a/drivers/net/usb/asix_devices.c
> +++ b/drivers/net/usb/asix_devices.c
> @@ -230,6 +230,7 @@ static int ax88172_bind(struct usbnet *dev,
> struct usb_interface *intf)
>   int i;
>   unsigned long gpio_bits = dev->driver_info->data;
>  
> + memset(buf, 0, sizeof(buf));

For array variables defined in the function itself, isn't this usually
done with:

 int ret = 0;
-u8 buf[ETH_ALEN];
+u8 buf[ETH_ALEN] = {0};
 int i;
 unsigned long gpio_bits = dev->driver_info->data;

eg make the compiler do it (though maybe it's smart enough to elide the
memset, I don't know). See drivers/net/ethernet/intel/igb/e1000_mac.c
for an example.

Dan

>   usbnet_get_endpoints(dev,intf);
>  
>   /* Toggle the GPIOs in a manufacturer/model specific way */
> @@ -681,6 +682,7 @@ static int ax88772_bind(struct usbnet *dev,
> struct usb_interface *intf)
>   u32 phyid;
>   struct asix_common_private *priv;
>  
> + memset(buf, 0, sizeof(buf));
>   usbnet_get_endpoints(dev, intf);
>  
>   /* Maybe the boot loader passed the MAC 

Re: [PATCH] media: venus: Update to bitrate based clock scaling

2019-07-01 Thread Stanimir Varbanov
Hi Aniket,

On 6/26/19 11:23 AM, Aniket Masule wrote:
> This patch introduces bitrate based clock scaling. Also, clock scaling is now
> triggered before buffer being queued to the device. This checks for frequency
> requirement throughout the session and updates clock with correct frequency 
> only
> if requirement is changed.
> 
> Aniket Masule (1):
>   media: venus: Update to bitrate based clock scaling

You don't need cover letter for one patch. Also, please include this
patch in "venus: Update clock scaling and core selection" series.

> 
>  drivers/media/platform/qcom/venus/core.c| 16 +--
>  drivers/media/platform/qcom/venus/core.h|  1 +
>  drivers/media/platform/qcom/venus/helpers.c | 43 
> +
>  3 files changed, 47 insertions(+), 13 deletions(-)
> 

-- 
regards,
Stan


[PATCH 1/4] net: dsa: Change DT bindings for Vitesse VSC73xx switches

2019-07-01 Thread Pawel Dembicki
This commit document changes after split vsc73xx driver into core and
spi part. The change of DT bindings is required for support the same
vsc73xx chip, which need PI bus to communicate with CPU. It also
introduce how to use vsc73xx platform driver.

Signed-off-by: Pawel Dembicki 
---
 .../bindings/net/dsa/vitesse,vsc73xx.txt  | 74 ---
 1 file changed, 64 insertions(+), 10 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.txt 
b/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.txt
index ed4710c40641..c6a4cd85891c 100644
--- a/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.txt
+++ b/Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.txt
@@ -2,8 +2,8 @@ Vitesse VSC73xx Switches
 
 
 This defines device tree bindings for the Vitesse VSC73xx switch chips.
-The Vitesse company has been acquired by Microsemi and Microsemi in turn
-acquired by Microchip but retains this vendor branding.
+The Vitesse company has been acquired by Microsemi and Microsemi has
+been acquired Microchip but retains this vendor branding.
 
 The currently supported switch chips are:
 Vitesse VSC7385 SparX-G5 5+1-port Integrated Gigabit Ethernet Switch
@@ -11,16 +11,26 @@ Vitesse VSC7388 SparX-G8 8-port Integrated Gigabit Ethernet 
Switch
 Vitesse VSC7395 SparX-G5e 5+1-port Integrated Gigabit Ethernet Switch
 Vitesse VSC7398 SparX-G8e 8-port Integrated Gigabit Ethernet Switch
 
-The device tree node is an SPI device so it must reside inside a SPI bus
-device tree node, see spi/spi-bus.txt
+This switch could have two different management interface.
+
+If SPI interface is used, the device tree node is an SPI device so it must
+reside inside a SPI bus device tree node, see spi/spi-bus.txt
+
+If Platform driver is used, the device tree node is an platform device so it
+must reside inside a platform bus device tree node.
 
 Required properties:
 
-- compatible: must be exactly one of:
-   "vitesse,vsc7385"
-   "vitesse,vsc7388"
-   "vitesse,vsc7395"
-   "vitesse,vsc7398"
+- compatible (SPI): must be exactly one of:
+   "vitesse,vsc7385-spi"
+   "vitesse,vsc7388-spi"
+   "vitesse,vsc7395-spi"
+   "vitesse,vsc7398-spi"
+- compatible (Platform): must be exactly one of:
+   "vitesse,vsc7385-platform"
+   "vitesse,vsc7388-platform"
+   "vitesse,vsc7395-platform"
+   "vitesse,vsc7398-platform"
 - gpio-controller: indicates that this switch is also a GPIO controller,
   see gpio/gpio.txt
 - #gpio-cells: this must be set to <2> and indicates that we are a twocell
@@ -38,8 +48,9 @@ and subnodes of DSA switches.
 
 Examples:
 
+SPI:
 switch@0 {
-   compatible = "vitesse,vsc7395";
+   compatible = "vitesse,vsc7395-spi";
reg = <0>;
/* Specified for 2.5 MHz or below */
spi-max-frequency = <250>;
@@ -79,3 +90,46 @@ switch@0 {
};
};
 };
+
+Platform:
+switch@2,0 {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "vitesse,vsc7385-platform";
+   reg = <0x2 0x0 0x2>;
+   reset-gpios = < 12 GPIO_ACTIVE_LOW>;
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+   label = "lan1";
+   };
+   port@1 {
+   reg = <1>;
+   label = "lan2";
+   };
+   port@2 {
+   reg = <2>;
+   label = "lan3";
+   };
+   port@3 {
+   reg = <3>;
+   label = "lan4";
+   };
+   vsc: port@6 {
+   reg = <6>;
+   label = "cpu";
+   ethernet = <>;
+   phy-mode = "rgmii";
+   fixed-link {
+   speed = <1000>;
+   full-duplex;
+   pause;
+   };
+   };
+   };
+
+};
-- 
2.20.1



[PATCH 4/4] net: dsa: vsc73xx: Assert reset if iCPU is enabled

2019-07-01 Thread Pawel Dembicki
Driver allow to use devices with disabled iCPU only.

Some devices have pre-initialised iCPU by bootloader.
That state make switch unmanaged. This patch force reset
if device is in unmanaged state. In the result chip lost
internal firmware from RAM and it can be managed.

Signed-off-by: Pawel Dembicki 
---
 drivers/net/dsa/vitesse-vsc73xx-core.c | 36 --
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c 
b/drivers/net/dsa/vitesse-vsc73xx-core.c
index 9975446cdc66..5cdf91849b5d 100644
--- a/drivers/net/dsa/vitesse-vsc73xx-core.c
+++ b/drivers/net/dsa/vitesse-vsc73xx-core.c
@@ -405,22 +405,8 @@ static int vsc73xx_detect(struct vsc73xx *vsc)
}
 
if (val == 0x) {
-   dev_info(vsc->dev, "chip seems dead, assert reset\n");
-   gpiod_set_value_cansleep(vsc->reset, 1);
-   /* Reset pulse should be 20ns minimum, according to datasheet
-* table 245, so 10us should be fine
-*/
-   usleep_range(10, 100);
-   gpiod_set_value_cansleep(vsc->reset, 0);
-   /* Wait 20ms according to datasheet table 245 */
-   msleep(20);
-
-   ret = vsc->ops->read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
-  VSC73XX_ICPU_MBOX_VAL, );
-   if (val == 0x) {
-   dev_err(vsc->dev, "seems not to help, giving up\n");
-   return -ENODEV;
-   }
+   dev_info(vsc->dev, "chip seems dead.\n");
+   return -EAGAIN;
}
 
ret = vsc->ops->read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
@@ -471,9 +457,8 @@ static int vsc73xx_detect(struct vsc73xx *vsc)
}
if (icpu_si_boot_en && !icpu_pi_en) {
dev_err(vsc->dev,
-   "iCPU enabled boots from SI, no external memory\n");
-   dev_err(vsc->dev, "no idea how to deal with this\n");
-   return -ENODEV;
+   "iCPU enabled boots from PI/SI, no external memory\n");
+   return -EAGAIN;
}
if (!icpu_si_boot_en && icpu_pi_en) {
dev_err(vsc->dev,
@@ -1147,6 +1132,19 @@ int vsc73xx_probe(struct vsc73xx *vsc)
msleep(20);
 
ret = vsc73xx_detect(vsc);
+   if (ret == -EAGAIN) {
+   dev_err(vsc->dev,
+   "Chip seams to be out of control. Assert reset and try 
again.\n");
+   gpiod_set_value_cansleep(vsc->reset, 1);
+   /* Reset pulse should be 20ns minimum, according to datasheet
+* table 245, so 10us should be fine
+*/
+   usleep_range(10, 100);
+   gpiod_set_value_cansleep(vsc->reset, 0);
+   /* Wait 20ms according to datasheet table 245 */
+   msleep(20);
+   ret = vsc73xx_detect(vsc);
+   }
if (ret) {
dev_err(vsc->dev, "no chip found (%d)\n", ret);
return -ENODEV;
-- 
2.20.1



[PATCH 2/4] net: dsa: vsc73xx: Split vsc73xx driver

2019-07-01 Thread Pawel Dembicki
This driver (currently) only takes control of the switch chip over
SPI and configures it to route packages around when connected to a
CPU port. But Vitesse chip support also parallel interface.

This patch split driver into two parts: core and spi. It is required
for add support to another managing interface.

Tested-by: Linus Walleij 
Signed-off-by: Pawel Dembicki 
---
 arch/arm/boot/dts/gemini-sl93512r.dts |   2 +-
 arch/arm/boot/dts/gemini-sq201.dts|   2 +-
 drivers/net/dsa/Kconfig   |  11 +-
 drivers/net/dsa/Makefile  |   3 +-
 ...tesse-vsc73xx.c => vitesse-vsc73xx-core.c} | 265 --
 drivers/net/dsa/vitesse-vsc73xx-spi.c | 201 +
 drivers/net/dsa/vitesse-vsc73xx.h |  30 ++
 7 files changed, 297 insertions(+), 217 deletions(-)
 rename drivers/net/dsa/{vitesse-vsc73xx.c => vitesse-vsc73xx-core.c} (85%)
 create mode 100644 drivers/net/dsa/vitesse-vsc73xx-spi.c
 create mode 100644 drivers/net/dsa/vitesse-vsc73xx.h

diff --git a/arch/arm/boot/dts/gemini-sl93512r.dts 
b/arch/arm/boot/dts/gemini-sl93512r.dts
index 2bb953440793..87f5340387a4 100644
--- a/arch/arm/boot/dts/gemini-sl93512r.dts
+++ b/arch/arm/boot/dts/gemini-sl93512r.dts
@@ -94,7 +94,7 @@
num-chipselects = <1>;
 
switch@0 {
-   compatible = "vitesse,vsc7385";
+   compatible = "vitesse,vsc7385-spi";
reg = <0>;
/* Specified for 2.5 MHz or below */
spi-max-frequency = <250>;
diff --git a/arch/arm/boot/dts/gemini-sq201.dts 
b/arch/arm/boot/dts/gemini-sq201.dts
index 239dfacaae4d..4fcb20f87ba0 100644
--- a/arch/arm/boot/dts/gemini-sq201.dts
+++ b/arch/arm/boot/dts/gemini-sq201.dts
@@ -79,7 +79,7 @@
num-chipselects = <1>;
 
switch@0 {
-   compatible = "vitesse,vsc7395";
+   compatible = "vitesse,vsc7395-spi";
reg = <0>;
/* Specified for 2.5 MHz or below */
spi-max-frequency = <250>;
diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig
index b91e78e3598f..4ab2aa09e2e4 100644
--- a/drivers/net/dsa/Kconfig
+++ b/drivers/net/dsa/Kconfig
@@ -99,8 +99,8 @@ config NET_DSA_SMSC_LAN9303_MDIO
  for MDIO managed mode.
 
 config NET_DSA_VITESSE_VSC73XX
-   tristate "Vitesse VSC7385/7388/7395/7398 support"
-   depends on OF && SPI
+   tristate
+   depends on OF
depends on NET_DSA
select FIXED_PHY
select VITESSE_PHY
@@ -109,4 +109,11 @@ config NET_DSA_VITESSE_VSC73XX
  This enables support for the Vitesse VSC7385, VSC7388,
  VSC7395 and VSC7398 SparX integrated ethernet switches.
 
+config NET_DSA_VITESSE_VSC73XX_SPI
+   tristate "Vitesse VSC7385/7388/7395/7398 SPI mode support"
+   depends on SPI
+   select NET_DSA_VITESSE_VSC73XX
+   ---help---
+ This enables support for the Vitesse VSC7385, VSC7388, VSC7395
+ and VSC7398 SparX integrated ethernet switches in SPI managed mode.
 endmenu
diff --git a/drivers/net/dsa/Makefile b/drivers/net/dsa/Makefile
index fefb6aaa82ba..117bf78be211 100644
--- a/drivers/net/dsa/Makefile
+++ b/drivers/net/dsa/Makefile
@@ -14,7 +14,8 @@ realtek-objs  := realtek-smi.o rtl8366.o 
rtl8366rb.o
 obj-$(CONFIG_NET_DSA_SMSC_LAN9303) += lan9303-core.o
 obj-$(CONFIG_NET_DSA_SMSC_LAN9303_I2C) += lan9303_i2c.o
 obj-$(CONFIG_NET_DSA_SMSC_LAN9303_MDIO) += lan9303_mdio.o
-obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX) += vitesse-vsc73xx.o
+obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX) += vitesse-vsc73xx-core.o
+obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_SPI) += vitesse-vsc73xx-spi.o
 obj-y  += b53/
 obj-y  += microchip/
 obj-y  += mv88e6xxx/
diff --git a/drivers/net/dsa/vitesse-vsc73xx.c 
b/drivers/net/dsa/vitesse-vsc73xx-core.c
similarity index 85%
rename from drivers/net/dsa/vitesse-vsc73xx.c
rename to drivers/net/dsa/vitesse-vsc73xx-core.c
index d4780610ea8a..9975446cdc66 100644
--- a/drivers/net/dsa/vitesse-vsc73xx.c
+++ b/drivers/net/dsa/vitesse-vsc73xx-core.c
@@ -10,10 +10,6 @@
  * handling the switch in a memory-mapped manner by connecting to that external
  * CPU's memory bus.
  *
- * This driver (currently) only takes control of the switch chip over SPI and
- * configures it to route packages around when connected to a CPU port. The
- * chip has embedded PHYs and VLAN support so we model it using DSA.
- *
  * Copyright (C) 2018 Linus Wallej 
  * Includes portions of code from the firmware uploader by:
  * Copyright (C) 2009 Gabor Juhos 
@@ -24,8 +20,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -34,6 +28,8 @@
 #include 
 #include 
 
+#include "vitesse-vsc73xx.h"
+
 #define VSC73XX_BLOCK_MAC  0x1 /* Subblocks 0-4, 6 (CPU 

[PATCH 3/4] net: dsa: vsc73xx: add support for parallel mode

2019-07-01 Thread Pawel Dembicki
This patch add platform part of vsc73xx driver.
It allows to use chip connected by PI interface.

Signed-off-by: Pawel Dembicki 
---
 drivers/net/dsa/Kconfig|   8 +
 drivers/net/dsa/Makefile   |   1 +
 drivers/net/dsa/vitesse-vsc73xx-platform.c | 166 +
 3 files changed, 175 insertions(+)
 create mode 100644 drivers/net/dsa/vitesse-vsc73xx-platform.c

diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig
index 4ab2aa09e2e4..80965808949d 100644
--- a/drivers/net/dsa/Kconfig
+++ b/drivers/net/dsa/Kconfig
@@ -116,4 +116,12 @@ config NET_DSA_VITESSE_VSC73XX_SPI
---help---
  This enables support for the Vitesse VSC7385, VSC7388, VSC7395
  and VSC7398 SparX integrated ethernet switches in SPI managed mode.
+
+config NET_DSA_VITESSE_VSC73XX_PLATFORM
+   tristate "Vitesse VSC7385/7388/7395/7398 Platform mode support"
+   depends on HAS_IOMEM
+   select NET_DSA_VITESSE_VSC73XX
+   ---help---
+ This enables support for the Vitesse VSC7385, VSC7388, VSC7395
+ and VSC7398 SparX integrated ethernet switches in Platform managed 
mode.
 endmenu
diff --git a/drivers/net/dsa/Makefile b/drivers/net/dsa/Makefile
index 117bf78be211..d5e4c668ac03 100644
--- a/drivers/net/dsa/Makefile
+++ b/drivers/net/dsa/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_NET_DSA_SMSC_LAN9303) += lan9303-core.o
 obj-$(CONFIG_NET_DSA_SMSC_LAN9303_I2C) += lan9303_i2c.o
 obj-$(CONFIG_NET_DSA_SMSC_LAN9303_MDIO) += lan9303_mdio.o
 obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX) += vitesse-vsc73xx-core.o
+obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_PLATFORM) += vitesse-vsc73xx-platform.o
 obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_SPI) += vitesse-vsc73xx-spi.o
 obj-y  += b53/
 obj-y  += microchip/
diff --git a/drivers/net/dsa/vitesse-vsc73xx-platform.c 
b/drivers/net/dsa/vitesse-vsc73xx-platform.c
new file mode 100644
index ..b2e5da0ffde3
--- /dev/null
+++ b/drivers/net/dsa/vitesse-vsc73xx-platform.c
@@ -0,0 +1,166 @@
+// SPDX-License-Identifier: GPL-2.0
+/* DSA driver for:
+ * Vitesse VSC7385 SparX-G5 5+1-port Integrated Gigabit Ethernet Switch
+ * Vitesse VSC7388 SparX-G8 8-port Integrated Gigabit Ethernet Switch
+ * Vitesse VSC7395 SparX-G5e 5+1-port Integrated Gigabit Ethernet Switch
+ * Vitesse VSC7398 SparX-G8e 8-port Integrated Gigabit Ethernet Switch
+ *
+ * This driver takes control of the switch chip over Platform and
+ * configures it to route packages around when connected to a CPU port.
+ *
+ * Copyright (C) 2019 pawel Dembicki 
+ * Based on vitesse-vsc-spi.c by:
+ * Copyright (C) 2018 Linus Wallej 
+ * Includes portions of code from the firmware uploader by:
+ * Copyright (C) 2009 Gabor Juhos 
+ */
+#include 
+#include 
+#include 
+#include 
+
+#include "vitesse-vsc73xx.h"
+
+#define VSC73XX_CMD_PLATFORM_BLOCK_SHIFT   14
+#define VSC73XX_CMD_PLATFORM_BLOCK_MASK0x7
+#define VSC73XX_CMD_PLATFORM_SUBBLOCK_SHIFT10
+#define VSC73XX_CMD_PLATFORM_SUBBLOCK_MASK 0xf
+#define VSC73XX_CMD_PLATFORM_REGISTER_SHIFT2
+
+/**
+ * struct vsc73xx_platform - VSC73xx Platform state container
+ */
+struct vsc73xx_platform {
+   struct platform_device *pdev;
+   void __iomem *base_addr;
+   struct vsc73xx vsc;
+};
+
+static const struct vsc73xx_ops vsc73xx_platform_ops;
+
+static u32 vsc73xx_make_addr(u8 block, u8 subblock, u8 reg)
+{
+   u32 ret;
+
+   ret = (block & VSC73XX_CMD_PLATFORM_BLOCK_MASK)
+   << VSC73XX_CMD_PLATFORM_BLOCK_SHIFT;
+   ret |= (subblock & VSC73XX_CMD_PLATFORM_SUBBLOCK_MASK)
+   << VSC73XX_CMD_PLATFORM_SUBBLOCK_SHIFT;
+   ret |= reg << VSC73XX_CMD_PLATFORM_REGISTER_SHIFT;
+
+   return ret;
+}
+
+static int vsc73xx_platform_read(struct vsc73xx *vsc, u8 block, u8 subblock,
+u8 reg, u32 *val)
+{
+   struct vsc73xx_platform *vsc_platform = vsc->priv;
+   u32 offset;
+
+   if (!vsc73xx_is_addr_valid(block, subblock))
+   return -EINVAL;
+
+   offset = vsc73xx_make_addr(block, subblock, reg);
+
+   mutex_lock(>lock);
+   *val = ioread32be(vsc_platform->base_addr + offset);
+   mutex_unlock(>lock);
+
+   return 0;
+}
+
+static int vsc73xx_platform_write(struct vsc73xx *vsc, u8 block, u8 subblock,
+ u8 reg, u32 val)
+{
+   struct vsc73xx_platform *vsc_platform = vsc->priv;
+   u32 offset;
+
+   if (!vsc73xx_is_addr_valid(block, subblock))
+   return -EINVAL;
+
+   offset = vsc73xx_make_addr(block, subblock, reg);
+
+   mutex_lock(>lock);
+   iowrite32be(val, vsc_platform->base_addr + offset);
+   mutex_unlock(>lock);
+
+   return 0;
+}
+
+static int vsc73xx_platform_probe(struct platform_device *pdev)
+{
+   struct device *dev = >dev;
+   struct vsc73xx_platform *vsc_platform;
+   struct resource *res = NULL;
+  

[PATCH] md/raid: Replace a seq_printf() call by seq_putc() in three functions

2019-07-01 Thread Markus Elfring
From: Markus Elfring 
Date: Mon, 1 Jul 2019 17:10:13 +0200

A single character (depending on a condition check) should be put
into a sequence. Thus use the corresponding function “seq_putc”.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/md/raid1.c  | 4 ++--
 drivers/md/raid10.c | 3 ++-
 drivers/md/raid5.c  | 3 ++-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 34e26834ad28..769d79a1d2cf 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1597,7 +1597,7 @@ static void raid1_status(struct seq_file *seq, struct 
mddev *mddev)
rcu_read_lock();
for (i = 0; i < conf->raid_disks; i++) {
struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev);
-   seq_printf(seq, "%s",
-  rdev && test_bit(In_sync, >flags) ? "U" : "_");
+   seq_putc(seq,
+rdev && test_bit(In_sync, >flags) ? 'U' : '_');
}
rcu_read_unlock();
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 8a1354a08a1a..4e7da5dcbf86 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1572,6 +1572,7 @@ static void raid10_status(struct seq_file *seq, struct 
mddev *mddev)
rcu_read_lock();
for (i = 0; i < conf->geo.raid_disks; i++) {
struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev);
-   seq_printf(seq, "%s", rdev && test_bit(In_sync, >flags) ? 
"U" : "_");
+   seq_putc(seq,
+rdev && test_bit(In_sync, >flags) ? 'U' : '_');
}
rcu_read_unlock();
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 3de4e13bde98..4b0e93869801 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -7510,6 +7510,7 @@ static void raid5_status(struct seq_file *seq, struct 
mddev *mddev)
rcu_read_lock();
for (i = 0; i < conf->raid_disks; i++) {
struct md_rdev *rdev = rcu_dereference(conf->disks[i].rdev);
-   seq_printf (seq, "%s", rdev && test_bit(In_sync, >flags) 
? "U" : "_");
+   seq_putc(seq,
+rdev && test_bit(In_sync, >flags) ? 'U' : '_');
}
rcu_read_unlock();
--
2.22.0



Re: [PATCH] csky: Improve abiv1 mem ops performance with glibc codes

2019-07-01 Thread Guo Ren
Hi Arnd,

On Mon, Jul 1, 2019 at 10:52 PM Arnd Bergmann  wrote:
>
> On Sat, Jun 29, 2019 at 7:36 AM  wrote:
> >
> > From: Guo Ren 
> >
> > These codes are copied from glibc/string directory, they are the generic
> > implementation for string operations. We may further optimize them with
> > assembly code in the future.
> >
> > In fact these code isn't tested enough for kernel, but we've tested them
> > on glibc and it seems good. We just trust them :)
>
> Are these files from the architecture independent portion of glibc or
> are they csky specific? If they are architecture independent, we might
> want to see if they make sense for other architectures as well, and
> add them to lib/ rather than arch/csky/lib/
They are just copied from glibc-2.28/string/*.c and they are generic.
OK, I'll try to add them to lib/.

>
> Should the SPDX identifier list the original LGPL-2.1 license instead
> of GPL-2.0?
Yes, I removed full Licenses' description:
   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version

I'll change it to:
// SPDX-License-Identifier: LGPL-2.1

-- 
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/


Re: [PATCH v2] mmc: sdhci-msm: fix mutex while in spinlock

2019-07-01 Thread Vinod Koul
On 01-07-19, 17:01, Jorge Ramirez-Ortiz wrote:
> mutexes can sleep and therefore should not be taken while holding a
> spinlock. move clk_get_rate (can sleep) outside the spinlock protected
> region.

Reviewed-by: Vinod Koul 

-- 
~Vinod


[PATCH 1/2] leds: tlc591xx: simplify driver by using the managed led API

2019-07-01 Thread Jean-Jacques Hiblot
Use the managed API of the LED class (devm_led_classdev_register()
instead of led_classdev_register()).
This allows us to remove the code used to track-and-destroy the LED devices

Signed-off-by: Jean-Jacques Hiblot 
---
 drivers/leds/leds-tlc591xx.c | 81 ++--
 1 file changed, 21 insertions(+), 60 deletions(-)

diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c
index 59ff088c7d75..14e47ff44df5 100644
--- a/drivers/leds/leds-tlc591xx.c
+++ b/drivers/leds/leds-tlc591xx.c
@@ -128,51 +128,6 @@ tlc591xx_brightness_set(struct led_classdev *led_cdev,
return err;
 }
 
-static void
-tlc591xx_destroy_devices(struct tlc591xx_priv *priv, unsigned int j)
-{
-   int i = j;
-
-   while (--i >= 0) {
-   if (priv->leds[i].active)
-   led_classdev_unregister(>leds[i].ldev);
-   }
-}
-
-static int
-tlc591xx_configure(struct device *dev,
-  struct tlc591xx_priv *priv,
-  const struct tlc591xx *tlc591xx)
-{
-   unsigned int i;
-   int err = 0;
-
-   tlc591xx_set_mode(priv->regmap, MODE2_DIM);
-   for (i = 0; i < TLC591XX_MAX_LEDS; i++) {
-   struct tlc591xx_led *led = >leds[i];
-
-   if (!led->active)
-   continue;
-
-   led->priv = priv;
-   led->led_no = i;
-   led->ldev.brightness_set_blocking = tlc591xx_brightness_set;
-   led->ldev.max_brightness = LED_FULL;
-   err = led_classdev_register(dev, >ldev);
-   if (err < 0) {
-   dev_err(dev, "couldn't register LED %s\n",
-   led->ldev.name);
-   goto exit;
-   }
-   }
-
-   return 0;
-
-exit:
-   tlc591xx_destroy_devices(priv, i);
-   return err;
-}
-
 static const struct regmap_config tlc591xx_regmap = {
.reg_bits = 8,
.val_bits = 8,
@@ -197,7 +152,7 @@ tlc591xx_probe(struct i2c_client *client,
const struct of_device_id *match;
const struct tlc591xx *tlc591xx;
struct tlc591xx_priv *priv;
-   int err, count, reg;
+   int err, count, reg, idx = 0;
 
match = of_match_device(of_tlc591xx_leds_match, dev);
if (!match)
@@ -225,7 +180,11 @@ tlc591xx_probe(struct i2c_client *client,
 
i2c_set_clientdata(client, priv);
 
+   tlc591xx_set_mode(priv->regmap, MODE2_DIM);
+
for_each_child_of_node(np, child) {
+   struct tlc591xx_led *led;
+
err = of_property_read_u32(child, "reg", );
if (err) {
of_node_put(child);
@@ -236,22 +195,25 @@ tlc591xx_probe(struct i2c_client *client,
of_node_put(child);
return -EINVAL;
}
-   priv->leds[reg].active = true;
-   priv->leds[reg].ldev.name =
+   led = >leds[reg];
+
+   led->active = true;
+   led->ldev.name =
of_get_property(child, "label", NULL) ? : child->name;
-   priv->leds[reg].ldev.default_trigger =
+   led->ldev.default_trigger =
of_get_property(child, "linux,default-trigger", NULL);
-   }
-   return tlc591xx_configure(dev, priv, tlc591xx);
-}
-
-static int
-tlc591xx_remove(struct i2c_client *client)
-{
-   struct tlc591xx_priv *priv = i2c_get_clientdata(client);
-
-   tlc591xx_destroy_devices(priv, TLC591XX_MAX_LEDS);
 
+   led->priv = priv;
+   led->led_no = idx++;
+   led->ldev.brightness_set_blocking = tlc591xx_brightness_set;
+   led->ldev.max_brightness = LED_FULL;
+   err = devm_led_classdev_register(dev, >ldev);
+   if (err < 0) {
+   dev_err(dev, "couldn't register LED %s\n",
+   led->ldev.name);
+   return err;
+   }
+   }
return 0;
 }
 
@@ -268,7 +230,6 @@ static struct i2c_driver tlc591xx_driver = {
.of_match_table = of_match_ptr(of_tlc591xx_leds_match),
},
.probe = tlc591xx_probe,
-   .remove = tlc591xx_remove,
.id_table = tlc591xx_id,
 };
 
-- 
2.17.1



[PATCH 0/2] leds: tlc591xx: switch to OF and managed API

2019-07-01 Thread Jean-Jacques Hiblot
This mini-series updates the tlc591xx driver to use the managed API. The
driver is also modified to pass the DT node to the LED core layer.
The goal is to be able to the generic led-backlight [0] driver on top of
it.

[0] https://lore.kernel.org/patchwork/project/lkml/list/?series=400524

Jean-Jacques Hiblot (2):
  leds: tlc591xx: simplify driver by using the managed led API
  leds: tlc591xx: Use the OF version of the LED registration function

 drivers/leds/leds-tlc591xx.c | 81 ++--
 1 file changed, 21 insertions(+), 60 deletions(-)

-- 
2.17.1



[PATCH 2/2] leds: tlc591xx: Use the OF version of the LED registration function

2019-07-01 Thread Jean-Jacques Hiblot
The driver parses the device-tree to identify which LED should be handled.
Since the information about the device node is known at this time, we can
provide the LED core with it. It may be useful later.

Signed-off-by: Jean-Jacques Hiblot 
---
 drivers/leds/leds-tlc591xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c
index 14e47ff44df5..6a2936c94b73 100644
--- a/drivers/leds/leds-tlc591xx.c
+++ b/drivers/leds/leds-tlc591xx.c
@@ -207,7 +207,7 @@ tlc591xx_probe(struct i2c_client *client,
led->led_no = idx++;
led->ldev.brightness_set_blocking = tlc591xx_brightness_set;
led->ldev.max_brightness = LED_FULL;
-   err = devm_led_classdev_register(dev, >ldev);
+   err = devm_of_led_classdev_register(dev, child, >ldev);
if (err < 0) {
dev_err(dev, "couldn't register LED %s\n",
led->ldev.name);
-- 
2.17.1



Re: [PATCH v3 2/2] arch: wire-up clone3() syscall

2019-07-01 Thread Christian Brauner
On Mon, Jul 01, 2019 at 05:14:51PM +0200, Arnd Bergmann wrote:
> On Fri, Jun 21, 2019 at 5:30 PM Christian Brauner  
> wrote:
> > On Fri, Jun 21, 2019 at 04:20:15PM +0200, Arnd Bergmann wrote:
> > > On Fri, Jun 21, 2019 at 1:18 PM Christian Brauner  
> > > wrote:
> > Hm, if you believe that this is fine and want to "vouch" for it by
> > whipping up a patch that replaces the wiring up done in [1] I'm happy to
> > take it. :) Otherwise I'd feel more comfortable not adding all arches at
> > once.
> >
> > [1]: 
> > https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/log/?h=clone
> 
> Sorry for my late reply. I had actually looked at the implementations
> in a little
> more detail and I think you are right that adding these are better
> left to the arch
> maintainers in case of clone3.

Perfect, thanks!

Christian


Re: [PATCH] scsi: virtio_scsi: Use struct_size() helper

2019-07-01 Thread Stefan Hajnoczi
On Wed, Jun 19, 2019 at 02:28:33PM -0500, Gustavo A. R. Silva wrote:
> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct virtio_scsi {
>   ...
> struct virtio_scsi_vq req_vqs[];
> };
> 
> Make use of the struct_size() helper instead of an open-coded version
> in order to avoid any potential type mistakes.
> 
> So, replace the following form:
> 
> sizeof(*vscsi) + sizeof(vscsi->req_vqs[0]) * num_queues
> 
> with:
> 
> struct_size(vscsi, req_vqs, num_queues)
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 
> ---
>  drivers/scsi/virtio_scsi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Stefan Hajnoczi 


signature.asc
Description: PGP signature


Re: [UPDATE][PATCH 10/10] tools/power/x86: A tool to validate Intel Speed Select commands

2019-07-01 Thread Srinivas Pandruvada
On Mon, 2019-07-01 at 14:32 +0300, Andy Shevchenko wrote:
> On Sun, Jun 30, 2019 at 8:14 PM Srinivas Pandruvada
>  wrote:
> > 
> > The Intel(R) Speed select technologies contains four features.
> > 
> > Performance profile:An non architectural mechanism that allows
> > multiple
> > optimized performance profiles per system via static and/or dynamic
> > adjustment of core count, workload, Tjmax, and TDP, etc. aka ISS
> > in the documentation.
> > 
> > Base Frequency: Enables users to increase guaranteed base frequency
> > on
> > certain cores (high priority cores) in exchange for lower base
> > frequency
> > on remaining cores (low priority cores). aka PBF in the
> > documenation.
> > 
> > Turbo frequency: Enables the ability to set different turbo ratio
> > limits
> > to cores based on priority. aka FACT in the documentation.
> > 
> > Core power: An Interface that allows user to define per core/tile
> > priority.
> > 
> > There is a multi level help for commands and options. This can be
> > used
> > to check required arguments for each feature and commands for the
> > feature.
> > 
> > To start navigating the features start with
> > 
> > $sudo intel-speed-select --help
> > 
> > For help on a specific feature for example
> > $sudo intel-speed-select perf-profile --help
> > 
> > To get help for a command for a feature for example
> > $sudo intel-speed-select perf-profile get-lock-status --help
> > 
> > Signed-off-by: Srinivas Pandruvada <
> > srinivas.pandruv...@linux.intel.com>
> > ---
> > Updates:
> > - Copied Makefile from tools/gpio and moified the Makefile here
> > - Added entry to tools/build/Makefile
> > - Rename directory to match the executable name
> > - Fix one error message
> 
> Thanks!
> I pushed to my review and testing queue, while still waiting for some
> ACKs.
> 
> It seems I can promote the driver itself now,w/o tools, if you want
> me to do so.
I am fine with driver only push if we don't get ACK by your deadline
for the next kernel.

Thanks,
Srinivas




[PATCH 1/2] sh: stub out pud_page

2019-07-01 Thread Christoph Hellwig
There wasn't any actual need to add a real pud_page, as pud_huge
always returns false on sh.  Just stub it out to fix the sh3
compile failure.

Fixes: 937b4e1d6471 ("sh: add the missing pud_page definition")
Reported-by: Guenter Roeck 
Signed-off-by: Christoph Hellwig 
---
 arch/sh/include/asm/pgtable-3level.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/sh/include/asm/pgtable-3level.h 
b/arch/sh/include/asm/pgtable-3level.h
index 3c7ff20f3f94..779260b721ca 100644
--- a/arch/sh/include/asm/pgtable-3level.h
+++ b/arch/sh/include/asm/pgtable-3level.h
@@ -37,7 +37,9 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
 {
return pud_val(pud);
 }
-#define pud_page(pud)  pfn_to_page(pud_pfn(pud))
+
+/* only used by the stubbed out hugetlb gup code, should never be called */
+#define pud_page(pud)  NULL
 
 #define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
-- 
2.20.1



generic gup fixups

2019-07-01 Thread Christoph Hellwig
Hi Andrew,

below two fixups for the generic GUP series, as reported by Guenter.


[PATCH 2/2] MIPS: don't select ARCH_HAS_PTE_SPECIAL

2019-07-01 Thread Christoph Hellwig
MIPS doesn't really have a proper pte_special implementation, just
stubs.  It turns out they were not enough to make get_user_pages_fast
work, so drop the select.  This means get_user_pages_fast won't
actually use the fast path for non-hugepage mappings, so someone who
actually knows about mips page table management should look into
adding real pte_special support.

Fixes: eb9488e58bbc ("MIPS: use the generic get_user_pages_fast code")
Reported-by: Guenter Roeck 
Signed-off-by: Christoph Hellwig 
---
 arch/mips/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index b1e42f0e4ed0..7957d3457156 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -6,7 +6,6 @@ config MIPS
select ARCH_BINFMT_ELF_STATE if MIPS_FP_SUPPORT
select ARCH_CLOCKSOURCE_DATA
select ARCH_HAS_ELF_RANDOMIZE
-   select ARCH_HAS_PTE_SPECIAL
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_HAS_UBSAN_SANITIZE_ALL
select ARCH_SUPPORTS_UPROBES
-- 
2.20.1



Re: general protection fault in do_move_mount (2)

2019-07-01 Thread Eric Biggers
On Mon, Jul 01, 2019 at 04:59:04PM +0200, 'Dmitry Vyukov' via syzkaller-bugs 
wrote:
> >
> > Dmitry, any idea why syzbot found such a bizarre reproducer for this?
> > This is actually reproducible by a simple single threaded program:
> >
> > #include 
> >
> > #define __NR_move_mount 429
> > #define MOVE_MOUNT_F_EMPTY_PATH 0x0004
> >
> > int main()
> > {
> > int fds[2];
> >
> > pipe(fds);
> > syscall(__NR_move_mount, fds[0], "", -1, "/", 
> > MOVE_MOUNT_F_EMPTY_PATH);
> > }
> 
> 
> There is no pipe in the reproducer, so it could not theoretically come
> up with the reproducer with the pipe. During minimization syzkaller
> only tries to remove syscalls and simplify arguments and execution
> mode.
> What would be the simplest reproducer expressed as further
> minimization of this reproducer?
> https://syzkaller.appspot.com/x/repro.syz?x=154e8c2aa0
> I assume one of the syscalls is still move_mount, but what is the
> other one? If it's memfd_create, or open of the procfs file, then it
> seems that [ab]used heavy threading and syscall colliding as way to do
> an arbitrary mutation of the program. Per se results of
> memfd_create/procfs are not passed to move_mount. But by abusing races
> it probably managed to do so in small percent of cases. It would also
> explain why it's hard to reproduce.

To be clear, memfd_create() works just as well:

#define _GNU_SOURCE
#include 
#include 

#define __NR_move_mount 429
#define MOVE_MOUNT_F_EMPTY_PATH 0x0004

int main()
{
int fd = memfd_create("foo", 0);

syscall(__NR_move_mount, fd, "", -1, "/", 
MOVE_MOUNT_F_EMPTY_PATH);
}

I just changed it to pipe() in my example, because pipe() is less obscure.

> 
> 
> > FYI, it also isn't really appropriate for syzbot to bisect all bugs in new
> > syscalls to wiring them up to x86, and then blame all the x86 maintainers.
> > Normally such bugs will be in the syscall itself, regardless of 
> > architecture.
> 
> Agree. Do you think it's something worth handling automatically
> (stands out of the long tail of other inappropriate cases)? If so, how
> could we detect such cases? It seems that some of these predicates are
> quite hard to program. Similar things happen with introduction of new
> bug detection tools and checks, wiring any functionality to new access
> points and similar things.
> 

Yes, this case could easily be automatically detected (most of the time) by
listing the filenames changed in the commit, and checking whether they all match
the pattern syscall.*\.tbl.  Sure, it's not common, but it could be alongside
other similar straightforward checks like checking for merge commits and
checking for commits that only modify Documentation/.

I'm not even asking for more correct bisection results at this point, I'm just
asking for fewer bad bisection results.

- Eric


Re: [PATCH v3 2/2] arch: wire-up clone3() syscall

2019-07-01 Thread Arnd Bergmann
On Fri, Jun 21, 2019 at 5:30 PM Christian Brauner  wrote:
> On Fri, Jun 21, 2019 at 04:20:15PM +0200, Arnd Bergmann wrote:
> > On Fri, Jun 21, 2019 at 1:18 PM Christian Brauner  
> > wrote:
> Hm, if you believe that this is fine and want to "vouch" for it by
> whipping up a patch that replaces the wiring up done in [1] I'm happy to
> take it. :) Otherwise I'd feel more comfortable not adding all arches at
> once.
>
> [1]: 
> https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/log/?h=clone

Sorry for my late reply. I had actually looked at the implementations
in a little
more detail and I think you are right that adding these are better
left to the arch
maintainers in case of clone3.

  Arnd


Re: [PATCH v2 0/3] vsock/virtio: several fixes in the .probe() and .remove()

2019-07-01 Thread Stefan Hajnoczi
On Fri, Jun 28, 2019 at 02:36:56PM +0200, Stefano Garzarella wrote:
> During the review of "[PATCH] vsock/virtio: Initialize core virtio vsock
> before registering the driver", Stefan pointed out some possible issues
> in the .probe() and .remove() callbacks of the virtio-vsock driver.
> 
> This series tries to solve these issues:
> - Patch 1 adds RCU critical sections to avoid use-after-free of
>   'the_virtio_vsock' pointer.
> - Patch 2 stops workers before to call vdev->config->reset(vdev) to
>   be sure that no one is accessing the device.
> - Patch 3 moves the works flush at the end of the .remove() to avoid
>   use-after-free of 'vsock' object.
> 
> v2:
> - Patch 1: use RCU to protect 'the_virtio_vsock' pointer
> - Patch 2: no changes
> - Patch 3: flush works only at the end of .remove()
> - Removed patch 4 because virtqueue_detach_unused_buf() returns all the 
> buffers
>   allocated.
> 
> v1: https://patchwork.kernel.org/cover/10964733/

This looks good to me.

Did you run any stress tests?  For example an SMP guest constantly
connecting and sending packets together with a script that
hotplug/unplugs vhost-vsock-pci from the host side.

Stefan


signature.asc
Description: PGP signature


Re: [PATCH 1/2] ARM: davinci: da830-evm: add missing regulator constraints for OHCI

2019-07-01 Thread Sekhar Nori
On 25/06/19 10:19 PM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski 
> 
> We need to enable status changes for the fixed power supply for the USB
> controller.
> 
> Fixes: 274e4c336192 ("ARM: davinci: da830-evm: add a fixed regulator for 
> ohci-da8xx")
> Cc: sta...@vger.kernel.org
> Signed-off-by: Bartosz Golaszewski 

For both these patches as well, the offending commit was introduced in
v5.2 so I dropped the stable tag while applying.

Will send pull request tomorrow after some build and boot testing.

Thanks,
Sekhar


Re: [PATCH v2 1/3] vsock/virtio: use RCU to avoid use-after-free on the_virtio_vsock

2019-07-01 Thread Stefan Hajnoczi
On Fri, Jun 28, 2019 at 02:36:57PM +0200, Stefano Garzarella wrote:
> Some callbacks used by the upper layers can run while we are in the
> .remove(). A potential use-after-free can happen, because we free
> the_virtio_vsock without knowing if the callbacks are over or not.
> 
> To solve this issue we move the assignment of the_virtio_vsock at the
> end of .probe(), when we finished all the initialization, and at the
> beginning of .remove(), before to release resources.
> For the same reason, we do the same also for the vdev->priv.
> 
> We use RCU to be sure that all callbacks that use the_virtio_vsock
> ended before freeing it. This is not required for callbacks that
> use vdev->priv, because after the vdev->config->del_vqs() we are sure
> that they are ended and will no longer be invoked.

My question is answered in Patch 3.


signature.asc
Description: PGP signature


Re: [PATCH v2 3/3] vsock/virtio: fix flush of works during the .remove()

2019-07-01 Thread Stefan Hajnoczi
On Fri, Jun 28, 2019 at 02:36:59PM +0200, Stefano Garzarella wrote:
> This patch moves the flush of works after vdev->config->del_vqs(vdev),
> because we need to be sure that no workers run before to free the
> 'vsock' object.
> 
> Since we stopped the workers using the [tx|rx|event]_run flags,
> we are sure no one is accessing the device while we are calling
> vdev->config->reset(vdev), so we can safely move the workers' flush.
> 
> Before the vdev->config->del_vqs(vdev), workers can be scheduled
> by VQ callbacks, so we must flush them after del_vqs(), to avoid
> use-after-free of 'vsock' object.

Nevermind, I looked back at Patch 2 and saw the send_pkt and loopback
work functions were also updated.  Thanks!

Stefan


signature.asc
Description: PGP signature


Re: [PATCH] ARM: davinci: da830-evm: fix GPIO lookup for OHCI

2019-07-01 Thread Sekhar Nori
On 25/06/19 8:46 PM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski 
> 
> The fixed regulator driver doesn't specify any con_id for gpio lookup
> so it must be NULL in the table entry.
> 
> Fixes: 274e4c336192 ("ARM: davinci: da830-evm: add a fixed regulator for 
> ohci-da8xx")
> Cc: sta...@vger.kernel.org
> Signed-off-by: Bartosz Golaszewski 

The offending commit was introduced in v5.2 so I dropped the stable tag
while applying.

Will send pull request tomorrow after some build and testing.

Thanks,
Sekhar



Re: [PATCH v2 3/3] vsock/virtio: fix flush of works during the .remove()

2019-07-01 Thread Stefan Hajnoczi
On Fri, Jun 28, 2019 at 02:36:59PM +0200, Stefano Garzarella wrote:
> This patch moves the flush of works after vdev->config->del_vqs(vdev),
> because we need to be sure that no workers run before to free the
> 'vsock' object.
> 
> Since we stopped the workers using the [tx|rx|event]_run flags,
> we are sure no one is accessing the device while we are calling
> vdev->config->reset(vdev), so we can safely move the workers' flush.

What about send_pkt and loopback work?  How were they stopped safely?

For example, if send_pkt work executes then we're in trouble since it
accesses the tx virtqueue which is deleted by ->del_vqs().


signature.asc
Description: PGP signature


Re: [PATCH v2] mdev: Send uevents around parent device registration

2019-07-01 Thread Cornelia Huck
On Mon, 01 Jul 2019 08:54:44 -0600
Alex Williamson  wrote:

> This allows udev to trigger rules when a parent device is registered
> or unregistered from mdev.
> 
> Signed-off-by: Alex Williamson 
> ---
> 
> v2: Don't remove the dev_info(), Kirti requested they stay and
> removing them is only tangential to the goal of this change.
> 
>  drivers/vfio/mdev/mdev_core.c |8 
>  1 file changed, 8 insertions(+)

Not that fond of the dev_info(), but this still looks sane.

Reviewed-by: Cornelia Huck 


[PATCH] staging: kpc2000: drop useless softdep statement

2019-07-01 Thread Jean Delvare
The i2c-dev module is for access to I2C buses from user-space.
Kernel drivers do not care about its presence.

Signed-off-by: Jean Delvare 
Cc: Matt Sickler 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/kpc2000/kpc_i2c/i2c_driver.c |1 -
 1 file changed, 1 deletion(-)

--- linux-5.2-rc7.orig/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c 
2019-06-30 05:25:36.0 +0200
+++ linux-5.2-rc7/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c  2019-07-01 
11:33:17.336697545 +0200
@@ -26,7 +26,6 @@
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("matt.sick...@daktronics.com");
-MODULE_SOFTDEP("pre: i2c-dev");
 
 struct i2c_device {
 unsigned long   smba;


-- 
Jean Delvare
SUSE L3 Support


Re: [PATCH] hinic: reduce rss_init stack usage

2019-07-01 Thread Arnd Bergmann
On Fri, Jun 28, 2019 at 6:32 PM David Miller  wrote:
>
> From: Arnd Bergmann 
> Date: Fri, 28 Jun 2019 12:31:44 +0200
>
> > On 32-bit architectures, putting an array of 256 u32 values on the
> > stack uses more space than the warning limit:
> >
> > drivers/net/ethernet/huawei/hinic/hinic_main.c: In function 
> > 'hinic_rss_init':
> > drivers/net/ethernet/huawei/hinic/hinic_main.c:286:1: error: the frame size 
> > of 1068 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
> >
> > I considered changing the code to use u8 values here, since that's
> > all the hardware supports, but dynamically allocating the array is
> > a more isolated fix here.
> >
> > Signed-off-by: Arnd Bergmann 
>
> Applied to net-next.

Thanks

> Arnd, please make it clear what tree you are targetting in the
> future.

Sorry about missing this again. I usually remember but sometimes
one slips through when I send a lot of patches for different subsystems
at once.

  Arnd


Re: [PATCH] mtd: rawnand: ingenic: fix ingenic_ecc dependency

2019-07-01 Thread Arnd Bergmann
On Fri, Jun 28, 2019 at 9:53 PM Paul Cercueil  wrote:
> Le jeu. 27 juin 2019 à 18:40, Miquel Raynal
>  a écrit :

> > Miquel Raynal  wrote on Mon, 17 Jun 2019
> > 14:16:59 +0200:
> >>  I personally have a preference for this one.
> >
> > Would you mind sending the above change? I forgot about it but I would
> > like to queue it for the next release. Preferably the last version
> > Arnd
> > proposed.
>
> It does change the module name from 'ingenic_nand' to 'jz4780_nand',
> though.
> That's not really ideal...

Any other suggestion for the name? If the module keeps getting called
ingeneric_nand.ko, then the source file has to get renamed to something
else instead.

  Arnd


[PATCH v2] mmc: sdhci-msm: fix mutex while in spinlock

2019-07-01 Thread Jorge Ramirez-Ortiz
mutexes can sleep and therefore should not be taken while holding a
spinlock. move clk_get_rate (can sleep) outside the spinlock protected
region.

Fixes: 83736352e0ca ("mmc: sdhci-msm: Update DLL reset sequence")
Cc: sta...@vger.kernel.org
Signed-off-by: Jorge Ramirez-Ortiz 
Reviewed-by: Bjorn Andersson 
---
 drivers/mmc/host/sdhci-msm.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 5fc76a1993d0..9cf14b359c14 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -575,11 +575,14 @@ static int msm_init_cm_dll(struct sdhci_host *host)
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
int wait_cnt = 50;
-   unsigned long flags;
+   unsigned long flags, xo_clk = 0;
u32 config;
const struct sdhci_msm_offset *msm_offset =
msm_host->offset;
 
+   if (msm_host->use_14lpp_dll_reset && !IS_ERR_OR_NULL(msm_host->xo_clk))
+   xo_clk = clk_get_rate(msm_host->xo_clk);
+
spin_lock_irqsave(>lock, flags);
 
/*
@@ -627,10 +630,10 @@ static int msm_init_cm_dll(struct sdhci_host *host)
config &= CORE_FLL_CYCLE_CNT;
if (config)
mclk_freq = DIV_ROUND_CLOSEST_ULL((host->clock * 8),
-   clk_get_rate(msm_host->xo_clk));
+   xo_clk);
else
mclk_freq = DIV_ROUND_CLOSEST_ULL((host->clock * 4),
-   clk_get_rate(msm_host->xo_clk));
+   xo_clk);
 
config = readl_relaxed(host->ioaddr +
msm_offset->core_dll_config_2);
-- 
2.21.0



<    1   2   3   4   5   6   7   8   9   >