[PATCH v2] powerpc: implement CONFIG_DEBUG_VIRTUAL

2018-12-09 Thread Christophe Leroy
This patch implements CONFIG_DEBUG_VIRTUAL to warn about
incorrect use of virt_to_phys() and page_to_phys()

It also warns about DMA on stack when CONFIG_HAVE_ARCH_VMAP_STACK is
selected. It will help locate them before activating CONFIG_VMAP_STACK

Below is the result of test_debug_virtual:

[1.438746] WARNING: CPU: 0 PID: 1 at ./arch/powerpc/include/asm/io.h:808 
test_debug_virtual_init+0x3c/0xd4
[1.448156] CPU: 0 PID: 1 Comm: swapper Not tainted 
4.20.0-rc5-00560-g6bfb52e23a00-dirty #532
[1.457259] NIP:  c066c550 LR: c0650ccc CTR: c066c514
[1.462257] REGS: c900bdb0 TRAP: 0700   Not tainted  
(4.20.0-rc5-00560-g6bfb52e23a00-dirty)
[1.471184] MSR:  00029032   CR: 48000422  XER: 2000
[1.477811]
[1.477811] GPR00: c0650ccc c900be60 c60d  006000c0 c900 
9032 c7fa0020
[1.477811] GPR08: 2400 0001 0900  c07b5d04  
c00037d8 
[1.477811] GPR16:     c076 c074 
0092 c0685bb0
[1.477811] GPR24: c065042c c068a734 c0685b8c 0006  c076 
c075c3c0 
[1.512711] NIP [c066c550] test_debug_virtual_init+0x3c/0xd4
[1.518315] LR [c0650ccc] do_one_initcall+0x8c/0x1cc
[1.523163] Call Trace:
[1.525595] [c900be60] [c0567340] 0xc0567340 (unreliable)
[1.530954] [c900be90] [c0650ccc] do_one_initcall+0x8c/0x1cc
[1.536551] [c900bef0] [c0651000] kernel_init_freeable+0x1f4/0x2cc
[1.542658] [c900bf30] [c00037ec] kernel_init+0x14/0x110
[1.547913] [c900bf40] [c000e1d0] ret_from_kernel_thread+0x14/0x1c
[1.553971] Instruction dump:
[1.556909] 3ca50100 bfa10024 54a5000e 3fa0c076 7c0802a6 3d454000 813dc204 
554893be
[1.564566] 7d294010 7d294910 90010034 39290001 <0f09> 7c3e0b78 955e0008 
3fe0c062
[1.572425] ---[ end trace 6f6984225b280ad6 ]---
[1.577467] PA: 0x0900 for VA: 0xc900
[1.581799] PA: 0x061e8f50 for VA: 0xc61e8f50

Signed-off-by: Christophe Leroy 
---
 v2: Using asm/pgtable.h to avoid build failure on ppc64e.
 Added a verification that the object is not in stack to catch problems 
before activing VMAP_STACK.

 arch/powerpc/Kconfig  |  1 +
 arch/powerpc/include/asm/io.h | 19 ++-
 arch/powerpc/mm/pgtable_32.c  |  2 +-
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e312e92e3381..94b46624068d 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -128,6 +128,7 @@ config PPC
#
# Please keep this list sorted alphabetically.
#
+   select ARCH_HAS_DEBUG_VIRTUAL
select ARCH_HAS_DEVMEM_IS_ALLOWED
select ARCH_HAS_DMA_SET_COHERENT_MASK
select ARCH_HAS_ELF_RANDOMIZE
diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index e746becd9d6f..51e96a4413d2 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -29,12 +29,14 @@ extern struct pci_dev *isa_bridge_pcidev;
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_PPC64
 #include 
@@ -804,6 +806,11 @@ extern void __iounmap_at(void *ea, unsigned long size);
  */
 static inline unsigned long virt_to_phys(volatile void * address)
 {
+   if (IS_ENABLED(CONFIG_DEBUG_VIRTUAL) &&
+   !WARN_ON(IS_ENABLED(CONFIG_HAVE_ARCH_VMAP_STACK) && current->pid &&
+object_is_on_stack((const void*)address)))
+   WARN_ON(!virt_addr_valid(address));
+
return __pa((unsigned long)address);
 }
 
@@ -827,7 +834,17 @@ static inline void * phys_to_virt(unsigned long address)
 /*
  * Change "struct page" to physical address.
  */
-#define page_to_phys(page) ((phys_addr_t)page_to_pfn(page) << PAGE_SHIFT)
+static inline phys_addr_t page_to_phys(struct page *page)
+{
+   unsigned long pfn = page_to_pfn(page);
+
+   if (IS_ENABLED(CONFIG_DEBUG_VIRTUAL) &&
+   !WARN_ON(IS_ENABLED(CONFIG_HAVE_ARCH_VMAP_STACK) && current->pid &&
+object_is_on_stack(__va(PFN_PHYS(pfn)
+   WARN_ON(!pfn_valid(pfn));
+
+   return PFN_PHYS(pfn);
+}
 
 /*
  * 32 bits still uses virt_to_bus() for it's implementation of DMA
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 4fc77a99c9bf..68d204a45cd0 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -143,7 +143,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, 
pgprot_t prot, void *call
 * Don't allow anybody to remap normal RAM that we're using.
 * mem_init() sets high_memory so only do the check after that.
 */
-   if (slab_is_available() && (p < virt_to_phys(high_memory)) &&
+   if (slab_is_available() && virt_addr_valid(p) &&
page_is_ram(__phys_to_pfn(p))) {
printk("__ioremap(): phys addr 0x%llx is RAM lr %ps\n",
   (unsigned long long)p, 

Re: [PATCH] v4l2: i2c: ov7670: Fix PLL bypass register values

2018-12-09 Thread jacopo mondi
Hi Sakari,
   thanks for digging this out

On Mon, Dec 10, 2018 at 01:39:17AM +0200, sakari.ai...@iki.fi wrote:
> Hi Jacopo,
>
> On Fri, Dec 29, 2017 at 01:22:26PM +0100, Jacopo Mondi wrote:
> > The following commits:
> > commit f6dd927f34d6 ("[media] media: ov7670: calculate framerate properly 
> > for ov7675")
> > commit 04ee6d92047e ("[media] media: ov7670: add possibility to bypass pll 
> > for ov7675")
> > introduced the ability to bypass PLL multiplier and use input clock (xvclk)
> > as pixel clock output frequency for ov7675 sensor.
> >
> > PLL is bypassed using register DBLV[7:6], according to ov7670 and ov7675
> > sensor manuals. Macros used to set DBLV register seem wrong in the
> > driver, as their values do not match what reported in the datasheet.
> >
> > Fix by changing DBLV_* macros to use bits [7:6] and set bits [3:0] to
> > default 0x0a reserved value (according to datasheets).
> >
> > While at there, remove a write to DBLV register in
> > "ov7675_set_framerate()" that over-writes the previous one to the same
> > register that takes "info->pll_bypass" flag into account instead of setting 
> > PLL
> > multiplier to 4x unconditionally.
> >
> > And, while at there, since "info->pll_bypass" is only used in
> > set/get_framerate() functions used by ov7675 only, it is not necessary
> > to check for the device id at probe time to make sure that when using
> > ov7670 "info->pll_bypass" is set to false.
> >
> > Signed-off-by: Jacopo Mondi 
>
> I assume this is still valid and long overdue for merging. :-) No other
> work in the area seem to have been done so I'm picking it up...
>

It should still be valid, and should still apply regardless of its
age :) Is it worth a proper 'Fixes' tag?

Fixes: f6dd927f34d6 ("[media] media: ov7670: calculate framerate properly for 
ov7675")

Thanks
  j

> --
> Regards,
>
> Sakari Ailus


signature.asc
Description: PGP signature


Re: [PATCH] mm/alloc: fallback to first node if the wanted node offline

2018-12-09 Thread Pingfan Liu
On Mon, Dec 10, 2018 at 12:00 PM Pingfan Liu  wrote:
>
> On Fri, Dec 7, 2018 at 11:56 PM Michal Hocko  wrote:
> >
> > On Fri 07-12-18 22:27:13, Pingfan Liu wrote:
> > [...]
> > > diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
> > > index 1308f54..4dc497d 100644
> > > --- a/arch/x86/mm/numa.c
> > > +++ b/arch/x86/mm/numa.c
> > > @@ -754,18 +754,23 @@ void __init init_cpu_to_node(void)
> > >  {
> > > int cpu;
> > > u16 *cpu_to_apicid = early_per_cpu_ptr(x86_cpu_to_apicid);
> > > +   int node, nr;
> > >
> > > BUG_ON(cpu_to_apicid == NULL);
> > > +   nr = cpumask_weight(cpu_possible_mask);
> > > +
> > > +   /* bring up all possible node, since dev->numa_node */
> > > +   //should check acpi works for node possible,
> > > +   for_each_node(node)
> > > +   if (!node_online(node))
> > > +   init_memory_less_node(node);
> >
> > I suspect there is no change if you replace for_each_node by
> > for_each_node_mask(nid, node_possible_map)
> >
> > here. If that is the case then we are probably calling
> > free_area_init_node too early. I do not see it yet though.
>
> Maybe I do not clearly get your meaning, just try to guess. But if you
> worry about node_possible_map, then it is dynamically set by
> alloc_node_data(). The map is changed after the first time to call

A mistake, it should be node_online_map. and in free_area_init_nodes()
for_each_online_node(nid) {
   free_area_init_node(nid, NULL,..

So at this time, we do not need to worry about the memory-less node.

> free_area_init_node() for the node with memory.  This logic is the
> same as the current x86 code.
>
> Thanks,
> Pingfan


Re: [PATCH v6 4/7] tpm: modify tpm_pcr_read() definition to pass a TPM hash algorithm

2018-12-09 Thread Roberto Sassu

On 12/9/2018 9:32 PM, Mimi Zohar wrote:

On Fri, 2018-12-07 at 15:51 +0100, Roberto Sassu wrote:

On 12/6/2018 8:49 PM, Mimi Zohar wrote:



PCRs for sha1 and sha256 algorithms are being updated and the
measurement list verifies against the SHA1 PCR-10.

Roberto, have you added support in ima-evm-utils to validate the other
banks?


I modified IMA LTP.


I'm not finding it.  Was the test for the current code, where the same
value is being padded for different algorithms, or for walking the
proposed hash agile format?


I did not send the patch yet.

Roberto



Mimi



--
HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Bo PENG, Jian LI, Yanli SHI


KASAN: use-after-free Read in ___neigh_create

2018-12-09 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:83af01ba1c2d Merge branch 'tc-testing-next'
git tree:   net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=15562a4340
kernel config:  https://syzkaller.appspot.com/x/.config?x=28ecefa8a6e10719
dashboard link: https://syzkaller.appspot.com/bug?extid=e4d42eb35f6a27b0a628
compiler:   gcc (GCC) 8.0.1 20180413 (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+e4d42eb35f6a27b0a...@syzkaller.appspotmail.com

==
BUG: KASAN: use-after-free in __list_add_valid+0x8f/0xac lib/list_debug.c:26
Read of size 8 at addr 8881b83e4bb0 by task syz-executor4/14957

CPU: 0 PID: 14957 Comm: syz-executor4 Not tainted 4.20.0-rc4+ #333
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 __list_add_valid+0x8f/0xac lib/list_debug.c:26
 __list_add include/linux/list.h:60 [inline]
 list_add_tail include/linux/list.h:93 [inline]
 neigh_alloc net/core/neighbour.c:395 [inline]
 ___neigh_create+0x14b7/0x2600 net/core/neighbour.c:553
 __neigh_create+0x30/0x40 net/core/neighbour.c:640
 ip_finish_output2+0xb8b/0x1860 net/ipv4/ip_output.c:224
 ip_finish_output+0x7fd/0xfa0 net/ipv4/ip_output.c:317
 NF_HOOK_COND include/linux/netfilter.h:278 [inline]
 ip_mc_output+0x2c4/0x15b0 net/ipv4/ip_output.c:390
 dst_output include/net/dst.h:444 [inline]
 ip_local_out+0xc5/0x1b0 net/ipv4/ip_output.c:124
 ip_send_skb+0x40/0xe0 net/ipv4/ip_output.c:1463
 udp_send_skb.isra.46+0x6ad/0x1160 net/ipv4/udp.c:929
 udp_sendmsg+0x2953/0x3c40 net/ipv4/udp.c:1216
 udpv6_sendmsg+0x182c/0x36a0 net/ipv6/udp.c:1316
 inet_sendmsg+0x1a1/0x690 net/ipv4/af_inet.c:798
 sock_sendmsg_nosec net/socket.c:621 [inline]
 sock_sendmsg+0xd5/0x120 net/socket.c:631
 ___sys_sendmsg+0x51d/0x930 net/socket.c:2116
 __sys_sendmmsg+0x246/0x6d0 net/socket.c:2211
 __do_sys_sendmmsg net/socket.c:2240 [inline]
 __se_sys_sendmmsg net/socket.c:2237 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2237
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x457569
Code: fd b3 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 b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00

RSP: 002b:7fe6733c8c78 EFLAGS: 0246 ORIG_RAX: 0133
RAX: ffda RBX: 0004 RCX: 00457569
RDX: 040001da RSI: 2080 RDI: 0004
RBP: 0072bf00 R08:  R09: 
R10:  R11: 0246 R12: 7fe6733c96d4
R13: 004c3c33 R14: 004d6248 R15: 

Allocated by task 14937:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 __do_kmalloc mm/slab.c:3722 [inline]
 __kmalloc+0x15b/0x760 mm/slab.c:3731
 kmalloc include/linux/slab.h:551 [inline]
 kzalloc include/linux/slab.h:741 [inline]
 neigh_alloc net/core/neighbour.c:375 [inline]
 ___neigh_create+0x13fc/0x2600 net/core/neighbour.c:553
 neigh_add+0xbaa/0xd90 net/core/neighbour.c:1865
 rtnetlink_rcv_msg+0x46a/0xc20 net/core/rtnetlink.c:4966
 netlink_rcv_skb+0x172/0x440 net/netlink/af_netlink.c:2477
 rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:4984
 netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
 netlink_unicast+0x5a5/0x760 net/netlink/af_netlink.c:1336
 netlink_sendmsg+0xa18/0xfc0 net/netlink/af_netlink.c:1917
 sock_sendmsg_nosec net/socket.c:621 [inline]
 sock_sendmsg+0xd5/0x120 net/socket.c:631
 ___sys_sendmsg+0x7fd/0x930 net/socket.c:2116
 __sys_sendmsg+0x11d/0x280 net/socket.c:2154
 __do_sys_sendmsg net/socket.c:2163 [inline]
 __se_sys_sendmsg net/socket.c:2161 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2161
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 14947:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xcf/0x230 mm/slab.c:3817
 __rcu_reclaim kernel/rcu/rcu.h:233 [inline]
 rcu_do_batch kernel/rcu/tree.c:2437 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:2716 [inline]
 rcu_process_callbacks+0x1140/0x1ac0 kernel/rcu/tree.c:2697
 __do_softirq+0x308/0xb7e kernel/softirq.c:292

The buggy 

KASAN: slab-out-of-bounds Read in neigh_mark_dead

2018-12-09 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:83af01ba1c2d Merge branch 'tc-testing-next'
git tree:   net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=119cd8b340
kernel config:  https://syzkaller.appspot.com/x/.config?x=28ecefa8a6e10719
dashboard link: https://syzkaller.appspot.com/bug?extid=424d47d5c456ce8b2bbe
compiler:   gcc (GCC) 8.0.1 20180413 (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+424d47d5c456ce8b2...@syzkaller.appspotmail.com

==
BUG: KASAN: slab-out-of-bounds in __list_del_entry_valid+0xf1/0x100  
lib/list_debug.c:51

Read of size 8 at addr 8881cede7db0 by task kworker/0:3/6132

CPU: 0 PID: 6132 Comm: kworker/0:3 Not tainted 4.20.0-rc4+ #333
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

Workqueue: events_power_efficient neigh_periodic_work
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 __list_del_entry_valid+0xf1/0x100 lib/list_debug.c:51
 __list_del_entry include/linux/list.h:117 [inline]
 list_del_init include/linux/list.h:159 [inline]
 neigh_mark_dead+0x13b/0x410 net/core/neighbour.c:125
 neigh_periodic_work+0x89a/0xc30 net/core/neighbour.c:905
 process_one_work+0xc90/0x1c40 kernel/workqueue.c:2153
kobject: 'queues' (e56310e9): kobject_add_internal:  
parent: 'wlan340', set: ''

kobject: 'queues' (e56310e9): kobject_uevent_env
 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
kobject: 'queues' (e56310e9): kobject_uevent_env: filter function  
caused the event to drop!
kobject: 'rx-0' (ad997d75): kobject_add_internal: parent: 'queues',  
set: 'queues'

 kthread+0x35a/0x440 kernel/kthread.c:246
 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352
kobject: 'rx-0' (ad997d75): kobject_uevent_env

Allocated by task 9759:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 __do_kmalloc mm/slab.c:3722 [inline]
 __kmalloc+0x15b/0x760 mm/slab.c:3731
 kmalloc include/linux/slab.h:551 [inline]
 kzalloc include/linux/slab.h:741 [inline]
 __register_sysctl_table+0xc7/0xfb0 fs/proc/proc_sysctl.c:1307
 register_net_sysctl+0x29/0x30 net/sysctl_net.c:120
kobject: 'rx-0' (ad997d75): fill_kobj_path: path  
= '/devices/virtual/mac80211_hwsim/hwsim1910/net/wlan340/queues/rx-0'

 neigh_sysctl_register+0x399/0x730 net/core/neighbour.c:3430
 devinet_sysctl_register+0xb4/0x220 net/ipv4/devinet.c:2520
 inetdev_init+0x2df/0x590 net/ipv4/devinet.c:274
 inetdev_event+0xf19/0x1340 net/ipv4/devinet.c:1479
 notifier_call_chain+0x17e/0x380 kernel/notifier.c:93
 __raw_notifier_call_chain kernel/notifier.c:394 [inline]
 raw_notifier_call_chain+0x2d/0x40 kernel/notifier.c:401
 call_netdevice_notifiers_info+0x3f/0x90 net/core/dev.c:1737
kobject: 'tx-0' (14d217b7): kobject_add_internal: parent: 'queues',  
set: 'queues'

 call_netdevice_notifiers_extack net/core/dev.c:1749 [inline]
 call_netdevice_notifiers net/core/dev.c:1763 [inline]
 register_netdevice+0xb7d/0x11a0 net/core/dev.c:8615
 ieee80211_if_add+0x1103/0x1ab0 net/mac80211/iface.c:1885
 ieee80211_register_hw+0x351b/0x3f10 net/mac80211/main.c:1224
 mac80211_hwsim_new_radio+0x1e48/0x3460  
drivers/net/wireless/mac80211_hwsim.c:2887

 hwsim_new_radio_nl+0x7dc/0xb20 drivers/net/wireless/mac80211_hwsim.c:3369
 genl_family_rcv_msg+0x8a7/0x11a0 net/netlink/genetlink.c:601
 genl_rcv_msg+0xc6/0x168 net/netlink/genetlink.c:626
kobject: 'tx-0' (14d217b7): kobject_uevent_env
 netlink_rcv_skb+0x172/0x440 net/netlink/af_netlink.c:2477
 genl_rcv+0x28/0x40 net/netlink/genetlink.c:637
 netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
 netlink_unicast+0x5a5/0x760 net/netlink/af_netlink.c:1336
 netlink_sendmsg+0xa18/0xfc0 net/netlink/af_netlink.c:1917
 sock_sendmsg_nosec net/socket.c:621 [inline]
 sock_sendmsg+0xd5/0x120 net/socket.c:631
 ___sys_sendmsg+0x7fd/0x930 net/socket.c:2116
 __sys_sendmsg+0x11d/0x280 net/socket.c:2154
kobject: 'tx-0' (14d217b7): fill_kobj_path: path  
= '/devices/virtual/mac80211_hwsim/hwsim1910/net/wlan340/queues/tx-0'

 __do_sys_sendmsg net/socket.c:2163 [inline]
 __se_sys_sendmsg net/socket.c:2161 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2161
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 9:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 

KASAN: slab-out-of-bounds Read in ___neigh_create

2018-12-09 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:a60956ed72f7 net: dsa: Make dsa_master_set_mtu() static
git tree:   net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=17d2f3f540
kernel config:  https://syzkaller.appspot.com/x/.config?x=28ecefa8a6e10719
dashboard link: https://syzkaller.appspot.com/bug?extid=3ddead5619658537909b
compiler:   gcc (GCC) 8.0.1 20180413 (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+3ddead56196585379...@syzkaller.appspotmail.com

syz-executor0 (7463) used greatest stack depth: 14544 bytes left
audit: type=1804 audit(1544397792.605:33): pid=7506 uid=0 auid=4294967295  
ses=4294967295 subj==unconfined op=invalid_pcr cause=open_writers  
comm="syz-executor0"  
name="/root/syzkaller-testdir029218375/syzkaller.aGerof/1/memory.events"  
dev="sda1" ino=16519 res=1

==
BUG: KASAN: slab-out-of-bounds in __list_add_valid+0x8f/0xac  
lib/list_debug.c:26

Read of size 8 at addr 8881ca015db0 by task syz-executor2/7521

CPU: 1 PID: 7521 Comm: syz-executor2 Not tainted 4.20.0-rc4+ #335
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 __list_add_valid+0x8f/0xac lib/list_debug.c:26
 __list_add include/linux/list.h:60 [inline]
 list_add_tail include/linux/list.h:93 [inline]
 neigh_alloc net/core/neighbour.c:395 [inline]
 ___neigh_create+0x14b7/0x2600 net/core/neighbour.c:553
 __neigh_create+0x30/0x40 net/core/neighbour.c:640
 ip_finish_output2+0xb8b/0x1860 net/ipv4/ip_output.c:224
 ip_finish_output+0x7fd/0xfa0 net/ipv4/ip_output.c:317
 NF_HOOK_COND include/linux/netfilter.h:278 [inline]
 ip_mc_output+0x2c4/0x15b0 net/ipv4/ip_output.c:390
 dst_output include/net/dst.h:444 [inline]
 ip_local_out+0xc5/0x1b0 net/ipv4/ip_output.c:124
 ip_send_skb+0x40/0xe0 net/ipv4/ip_output.c:1464
 udp_send_skb.isra.46+0x6ad/0x1160 net/ipv4/udp.c:929
 udp_sendmsg+0x2953/0x3c40 net/ipv4/udp.c:1216
 inet_sendmsg+0x1a1/0x690 net/ipv4/af_inet.c:798
 sock_sendmsg_nosec net/socket.c:621 [inline]
 sock_sendmsg+0xd5/0x120 net/socket.c:631
 ___sys_sendmsg+0x51d/0x930 net/socket.c:2116
 __sys_sendmmsg+0x246/0x6d0 net/socket.c:2211
 __do_sys_sendmmsg net/socket.c:2240 [inline]
 __se_sys_sendmmsg net/socket.c:2237 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2237
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x457659
Code: fd b3 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 b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00

RSP: 002b:7f0c5d66fc78 EFLAGS: 0246 ORIG_RAX: 0133
RAX: ffda RBX: 0004 RCX: 00457659
RDX: 040001a8 RSI: 20007fc0 RDI: 0004
RBP: 0072bf00 R08:  R09: 
R10:  R11: 0246 R12: 7f0c5d6706d4
R13: 004c3e14 R14: 004d6c38 R15: 

Allocated by task 7079:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:490
 kmem_cache_alloc+0x12e/0x730 mm/slab.c:3554
 kmem_cache_zalloc include/linux/slab.h:731 [inline]
 copy_signal kernel/fork.c:1521 [inline]
 copy_process+0x2aba/0x87a0 kernel/fork.c:1914
 _do_fork+0x1cb/0x11d0 kernel/fork.c:2216
 __do_sys_clone kernel/fork.c:2323 [inline]
 __se_sys_clone kernel/fork.c:2317 [inline]
 __x64_sys_clone+0xbf/0x150 kernel/fork.c:2317
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 7091:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kmem_cache_free+0x83/0x290 mm/slab.c:3760
 free_signal_struct kernel/fork.c:707 [inline]
 put_signal_struct kernel/fork.c:713 [inline]
 __put_task_struct+0x3cd/0x620 kernel/fork.c:727
 put_task_struct include/linux/sched/task.h:96 [inline]
 delayed_put_task_struct+0x2ff/0x4c0 kernel/exit.c:181
 __rcu_reclaim kernel/rcu/rcu.h:240 [inline]
 rcu_do_batch kernel/rcu/tree.c:2437 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:2716 [inline]
 rcu_process_callbacks+0x100a/0x1ac0 kernel/rcu/tree.c:2697
 __do_softirq+0x308/0xb7e kernel/softirq.c:292

The buggy address 

[PATCH] exec: make prepare_bprm_creds static

2018-12-09 Thread Chanho Min
prepare_bprm_creds is not used outside exec.c, so there's no reason for it
to have external linkage.

Signed-off-by: Chanho Min 
---
 fs/exec.c   | 2 +-
 include/linux/binfmts.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index fc281b7..b6c9e5f 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1399,7 +1399,7 @@ EXPORT_SYMBOL(finalize_exec);
  * Or, if exec fails before, free_bprm() should release ->cred and
  * and unlock.
  */
-int prepare_bprm_creds(struct linux_binprm *bprm)
+static int prepare_bprm_creds(struct linux_binprm *bprm)
 {
if (mutex_lock_interruptible(>signal->cred_guard_mutex))
return -ERESTARTNOINTR;
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
index e9f5fe6..6a9e43d 100644
--- a/include/linux/binfmts.h
+++ b/include/linux/binfmts.h
@@ -138,7 +138,6 @@ extern int transfer_args_to_stack(struct linux_binprm *bprm,
 extern int bprm_change_interp(const char *interp, struct linux_binprm *bprm);
 extern int copy_strings_kernel(int argc, const char *const *argv,
   struct linux_binprm *bprm);
-extern int prepare_bprm_creds(struct linux_binprm *bprm);
 extern void install_exec_creds(struct linux_binprm *bprm);
 extern void set_binfmt(struct linux_binfmt *new);
 extern ssize_t read_code(struct file *, unsigned long, loff_t, size_t);
-- 
2.1.4



INFO: rcu detected stall in xfrm_hash_rebuild

2018-12-09 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:74c4a24df7ca Add linux-next specific files for 20181207
git tree:   linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=17dbb3d540
kernel config:  https://syzkaller.appspot.com/x/.config?x=6e9413388bf37bed
dashboard link: https://syzkaller.appspot.com/bug?extid=592df0494801b6648ec6
compiler:   gcc (GCC) 8.0.1 20180413 (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+592df0494801b6648...@syzkaller.appspotmail.com

device bridge_slave_1 entered promiscuous mode
IPv6: ADDRCONF(NETDEV_UP): veth0_to_bridge: link is not ready
IPv6: ADDRCONF(NETDEV_UP): veth1_to_bridge: link is not ready
bond0: Enslaving bond_slave_0 as an active interface with an up link
bond0: Enslaving bond_slave_1 as an active interface with an up link
rcu: INFO: rcu_preempt self-detected stall on CPU
rcu: 	1-: (1 GPs behind) idle=3e2/1/0x4002  
softirq=136882/136885 fqs=5250

rcu: (t=10501 jiffies g=189801 q=2008)
NMI backtrace for cpu 1
CPU: 1 PID: 6200 Comm: kworker/1:2 Not tainted 4.20.0-rc5-next-20181207+  
#163
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

Workqueue: events xfrm_hash_rebuild
Call Trace:
 
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
 nmi_cpu_backtrace.cold.2+0x5c/0xa1 lib/nmi_backtrace.c:101
 nmi_trigger_cpumask_backtrace+0x1e8/0x22a lib/nmi_backtrace.c:62
 arch_trigger_cpumask_backtrace+0x14/0x20 arch/x86/kernel/apic/hw_nmi.c:38
 trigger_single_cpu_backtrace include/linux/nmi.h:164 [inline]
 rcu_dump_cpu_stacks+0x16f/0x1bc kernel/rcu/tree.c:1211
 print_cpu_stall.cold.70+0x218/0x40a kernel/rcu/tree.c:1348
 check_cpu_stall kernel/rcu/tree.c:1422 [inline]
 rcu_pending kernel/rcu/tree.c:3018 [inline]
 rcu_check_callbacks+0xf3b/0x13f0 kernel/rcu/tree.c:2521
 update_process_times+0x2d/0x70 kernel/time/timer.c:1635
 tick_sched_handle+0x9f/0x180 kernel/time/tick-sched.c:161
 tick_sched_timer+0x45/0x130 kernel/time/tick-sched.c:1271
 __run_hrtimer kernel/time/hrtimer.c:1389 [inline]
 __hrtimer_run_queues+0x41c/0x10d0 kernel/time/hrtimer.c:1451
 hrtimer_interrupt+0x313/0x780 kernel/time/hrtimer.c:1509
 local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1034 [inline]
 smp_apic_timer_interrupt+0x1a1/0x760 arch/x86/kernel/apic/apic.c:1059
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:804
 
RIP: 0010:__read_once_size include/linux/compiler.h:182 [inline]
RIP: 0010:check_kcov_mode kernel/kcov.c:69 [inline]
RIP: 0010:write_comp_data+0x22/0x70 kernel/kcov.c:122
Code: 90 90 90 90 90 90 90 90 55 48 89 e5 65 4c 8b 04 25 40 ee 01 00 65 8b  
05 7c f6 81 7e a9 00 01 1f 00 75 51 41 8b 80 d8 12 00 00 <83> f8 03 75 45  
49 8b 80 e0 12 00 00 45 8b 80 dc 12 00 00 4c 8b 08

RSP: 0018:8881872f7320 EFLAGS: 0246 ORIG_RAX: ff13
RAX:  RBX: 0003 RCX: 86d1d8db
RDX: 0003 RSI: 000e RDI: 0005
RBP: 8881872f7320 R08: 8881872ea1c0 R09: 0008
R10: 0005 R11: 8881872ea1c0 R12: dc00
R13: 8881b628ca14 R14: 8881b4050114 R15: 
 __sanitizer_cov_trace_const_cmp4+0x16/0x20 kernel/kcov.c:188
 selector_cmp net/xfrm/xfrm_policy.c:1390 [inline]
 xfrm_policy_insert_list+0x62b/0x1020 net/xfrm/xfrm_policy.c:1534
 xfrm_policy_inexact_insert+0x166/0xee0 net/xfrm/xfrm_policy.c:1195
 xfrm_hash_rebuild+0xfba/0x1380 net/xfrm/xfrm_policy.c:1317
 process_one_work+0xc90/0x1c40 kernel/workqueue.c:2153
 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
 kthread+0x35a/0x440 kernel/kthread.c:246
 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352


---
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#bug-status-tracking for how to communicate with  
syzbot.


Re: Disable RT_GROUP_SCHED in PREEMPT_RT_FULL

2018-12-09 Thread gengdongjiu
Loop RT kernel Mailing lists.


On 2018/12/10 1:04, zhang jianwei wrote:
> hi Thomas and Mike??
> i say you disabled the RT_GROUP_SCHED in RT kernel because of strange cpu 
> stall was observed. currently, in my projects, I need 
> enable?0?2RT_GROUP_SCHED in RT kernel. I??d like to know how to reproduce the 
> strange cpu stall in order to fix this bug. can you guys give me some advice 
> ?0?2about how to fix this problem.
> Thanks in advance!
> 
> 
> patched mentioned?0?2
> https://lore.kernel.org/patchwork/patch/313215/
> 
> 



WARNING in xfrm_policy_inexact_gc_tree

2018-12-09 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:74c4a24df7ca Add linux-next specific files for 20181207
git tree:   linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=17bbea7d40
kernel config:  https://syzkaller.appspot.com/x/.config?x=6e9413388bf37bed
dashboard link: https://syzkaller.appspot.com/bug?extid=0b2f1bc876d301440d44
compiler:   gcc (GCC) 8.0.1 20180413 (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+0b2f1bc876d301440...@syzkaller.appspotmail.com

IPv6: ADDRCONF(NETDEV_UP): veth0: link is not ready
IPv6: ADDRCONF(NETDEV_UP): veth1: link is not ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready
8021q: adding VLAN 0 to HW filter on device team0
WARNING: CPU: 0 PID: 13116 at net/xfrm/xfrm_policy.c:1066  
xfrm_policy_inexact_gc_tree+0x233/0x280 net/xfrm/xfrm_policy.c:1066

Kernel panic - not syncing: panic_on_warn set ...
CPU: 0 PID: 13116 Comm: kworker/u4:10 Not tainted 4.20.0-rc5-next-20181207+  
#163
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

Workqueue: netns cleanup_net
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
 panic+0x2ad/0x632 kernel/panic.c:214
 __warn.cold.8+0x20/0x4f kernel/panic.c:571
 report_bug+0x254/0x2d0 lib/bug.c:186
 fixup_bug arch/x86/kernel/traps.c:178 [inline]
 do_error_trap+0x11b/0x200 arch/x86/kernel/traps.c:271
 do_invalid_op+0x36/0x40 arch/x86/kernel/traps.c:290
 invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:969
RIP: 0010:xfrm_policy_inexact_gc_tree+0x233/0x280  
net/xfrm/xfrm_policy.c:1066
Code: 00 5b 41 5c 41 5d 41 5e 41 5f 5d c3 e8 d6 00 ae fa 0f b6 9d 2b ff ff  
ff 31 ff 89 de e8 96 01 ae fa 84 db 74 8c e8 bd 00 ae fa <0f> 0b eb 83 48  
8d 7d 98 e8 e0 00 f2 fa e9 d0 fe ff ff e8 36 00 f2

RSP: 0018:88819c307108 EFLAGS: 00010293
RAX: 8881be8a82c0 RBX: 0001 RCX: 86d1f6ea
RDX:  RSI: 86d1f6f3 RDI: 0001
RBP: 88819c3071f0 R08: 8881be8a82c0 R09: 0008
R10: 0e65 R11: 8881be8a82c0 R12: dc00
R13: ed1033860e31 R14: 8881be45a330 R15: 8881bf82cdc8
 __xfrm_policy_inexact_prune_bin+0x123/0x420 net/xfrm/xfrm_policy.c:1079
 xfrm_policy_fini+0x473/0x650 net/xfrm/xfrm_policy.c:3887
 xfrm_net_exit+0x1d/0x70 net/xfrm/xfrm_policy.c:3928
 ops_exit_list.isra.5+0xb0/0x160 net/core/net_namespace.c:153
 cleanup_net+0x555/0xb10 net/core/net_namespace.c:551
 process_one_work+0xc90/0x1c40 kernel/workqueue.c:2153
kobject: 'loop5' (d2e25176): kobject_uevent_env
kobject: 'loop5' (d2e25176): fill_kobj_path: path  
= '/devices/virtual/block/loop5'

 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
 kthread+0x35a/0x440 kernel/kthread.c:246
 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352
Kernel Offset: disabled
Rebooting in 86400 seconds..


---
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#bug-status-tracking for how to communicate with  
syzbot.


KASAN: use-after-free Read in get_disk_and_module

2018-12-09 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:74c4a24df7ca Add linux-next specific files for 20181207
git tree:   linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=171e912540
kernel config:  https://syzkaller.appspot.com/x/.config?x=6e9413388bf37bed
dashboard link: https://syzkaller.appspot.com/bug?extid=b00e02299cdecb22b288
compiler:   gcc (GCC) 8.0.1 20180413 (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+b00e02299cdecb22b...@syzkaller.appspotmail.com

QAT: Invalid ioctl
QAT: Invalid ioctl
QAT: Invalid ioctl
__loop_clr_fd: partition scan of loop3 failed (rc=-22)
==
BUG: KASAN: use-after-free in get_disk_and_module+0xd5/0xf0  
block/genhd.c:1493

Read of size 8 at addr 8881b4f24f58 by task blkid/21934

CPU: 0 PID: 21934 Comm: blkid Not tainted 4.20.0-rc5-next-20181207+ #163
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
 print_address_description.cold.4+0x9/0x1ff mm/kasan/report.c:187
 kasan_report.cold.5+0x1b/0x39 mm/kasan/report.c:317
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135
 get_disk_and_module+0xd5/0xf0 block/genhd.c:1493
 get_gendisk+0x17a/0x380 block/genhd.c:855
 bdev_get_gendisk fs/block_dev.c:1092 [inline]
 __blkdev_get+0x467/0x13b0 fs/block_dev.c:1487
 blkdev_get+0xc1/0xb50 fs/block_dev.c:1643
 blkdev_open+0x1fb/0x280 fs/block_dev.c:1801
 do_dentry_open+0x499/0x1250 fs/open.c:771
 vfs_open+0xa0/0xd0 fs/open.c:880
 do_last fs/namei.c:3418 [inline]
 path_openat+0x12bc/0x5150 fs/namei.c:3534
 do_filp_open+0x255/0x380 fs/namei.c:3564
 do_sys_open+0x568/0x780 fs/open.c:1063
 __do_sys_open fs/open.c:1081 [inline]
 __se_sys_open fs/open.c:1076 [inline]
 __x64_sys_open+0x7e/0xc0 fs/open.c:1076
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7fe787296120
Code: 48 8b 15 1b 4d 2b 00 f7 d8 64 89 02 83 c8 ff c3 90 90 90 90 90 90 90  
90 90 90 83 3d d5 a4 2b 00 00 75 10 b8 02 00 00 00 0f 05 <48> 3d 01 f0 ff  
ff 73 31 c3 48 83 ec 08 e8 5e 8c 01 00 48 89 04 24

RSP: 002b:7fffed985768 EFLAGS: 0246 ORIG_RAX: 0002
RAX: ffda RBX:  RCX: 7fe787296120
RDX: 7fffed987f1f RSI:  RDI: 7fffed987f1f
RBP:  R08: 0078 R09: 
R10:  R11: 0246 R12: 00939030
R13:  R14:  R15: 0005

Allocated by task 21892:
 save_stack+0x43/0xd0 mm/kasan/common.c:73
 set_track mm/kasan/common.c:85 [inline]
 kasan_kmalloc+0xcb/0xd0 mm/kasan/common.c:482
 kmem_cache_alloc_node_trace+0x14f/0x740 mm/slab.c:3650
 kmalloc_node include/linux/slab.h:583 [inline]
 kzalloc_node include/linux/slab.h:751 [inline]
 __alloc_disk_node+0xc9/0x510 block/genhd.c:1446
 loop_add+0x453/0xa20 drivers/block/loop.c:1935
 loop_probe+0x18d/0x1d0 drivers/block/loop.c:2041
 kobj_lookup+0x264/0x460 drivers/base/map.c:124
 get_gendisk+0x4c/0x380 block/genhd.c:847
 bdev_get_gendisk fs/block_dev.c:1092 [inline]
 __blkdev_get+0x467/0x13b0 fs/block_dev.c:1487
 blkdev_get+0xc1/0xb50 fs/block_dev.c:1643
 blkdev_open+0x1fb/0x280 fs/block_dev.c:1801
 do_dentry_open+0x499/0x1250 fs/open.c:771
 vfs_open+0xa0/0xd0 fs/open.c:880
 do_last fs/namei.c:3418 [inline]
 path_openat+0x12bc/0x5150 fs/namei.c:3534
 do_filp_open+0x255/0x380 fs/namei.c:3564
 do_sys_open+0x568/0x780 fs/open.c:1063
 __do_sys_open fs/open.c:1081 [inline]
 __se_sys_open fs/open.c:1076 [inline]
 __x64_sys_open+0x7e/0xc0 fs/open.c:1076
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 21924:
 save_stack+0x43/0xd0 mm/kasan/common.c:73
 set_track mm/kasan/common.c:85 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:444
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:452
 __cache_free mm/slab.c:3485 [inline]
 kfree+0xcf/0x230 mm/slab.c:3804
 disk_release+0x1f2/0x250 block/genhd.c:1304
 device_release+0x7e/0x210 drivers/base/core.c:919
 kobject_cleanup lib/kobject.c:662 [inline]
 kobject_release lib/kobject.c:691 [inline]
 kref_put include/linux/kref.h:70 [inline]
 kobject_put.cold.9+0x287/0x2e4 lib/kobject.c:708
 put_disk+0x23/0x30 block/genhd.c:1511
 loop_remove+0x92/0xc0 drivers/block/loop.c:1990
 loop_control_ioctl+0x3f2/0x480 drivers/block/loop.c:2086
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:509 [inline]
 do_vfs_ioctl+0x1de/0x1790 fs/ioctl.c:696
 ksys_ioctl+0xa9/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+0x1b9/0x820 arch/x86/entry/common.c:290
 

Re: [PATCH v11 00/13] Intel SGX1 support

2018-12-09 Thread Josh Triplett
On Sun, Dec 09, 2018 at 09:06:00PM +0100, Pavel Machek wrote:
...
> > > > The default permissions for the device are 600.
> > > 
> > > Good. This does not belong to non-root.
> > 
> > There are entirely legitimate use cases for using this as an
> > unprivileged user. However, that'll be up to system and distribution
> > policy, which can evolve over time, and it makes sense for the *initial*
> > kernel permission to start out root-only and then adjust permissions via
> > udev.
> 
> Agreed.
> 
> > Building a software certificate store. Hardening key-agent software like
> > ssh-agent or gpg-agent. Building a challenge-response authentication
> > system. Providing more assurance that your server infrastructure is
> > uncompromised. Offloading computation to a system without having to
> > fully trust that system.
> 
> I think you can do the crypto stuff... as crypto already verifies the
> results. But I don't think you can do the computation offload.

You can, as long as you can do attestation.

> > As one of many possibilities, imagine a distcc that didn't have to trust
> > the compile nodes. The compile nodes could fail to return results at
> > all, but they couldn't alter the results.
> 
> distcc on untrusted nodes ... oh yes, that would be great.
> 
> Except that you can't do it, right? :-).
> 
> First, AFAICT it would be quite hard to get gcc to run under SGX. But
> maybe you have spare month or three and can do it.

Assuming you don't need to #include files, gcc seems quite simple to run
in an enclave: data in, computation inside, data out.


Re: [PATCH -next] IB/mlx5: remove duplicated include from mlx5_ib.h

2018-12-09 Thread Leon Romanovsky
On Mon, Dec 10, 2018 at 03:27:59PM +0800, YueHaibing wrote:
> Remove duplicated include.
>
> Signed-off-by: YueHaibing 
> ---
>  drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 -
>  1 file changed, 1 deletion(-)
>

Thanks,
Acked-by: Leon Romanovsky 


signature.asc
Description: PGP signature


Re: [Letux-kernel] [PATCH v2 4/5] gnss: sirf: add a separate supply for a lna

2018-12-09 Thread H. Nikolaus Schaller
Hi,

> Am 09.12.2018 um 20:51 schrieb Andreas Kemnade :
> 
> Devices might have a separate lna between antenna output of the gps

some nitpicking: the LNA (low noise amplifier) is between the antenna
and the GPS receiver. Therefore:

s/between antenna output of the gps/between antenna input of the gps/

Otherwise fine!

BR and thanks,
Nikolaus

> chip and the antenna which might have a separate supply.
> 
> Signed-off-by: Andreas Kemnade 
> ---
> Changes in v2:
> - handle lna also if there is no on-off gpio
> - rebase on changed 2/5
> 
> drivers/gnss/sirf.c | 26 ++
> 1 file changed, 22 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gnss/sirf.c b/drivers/gnss/sirf.c
> index c64369494afb..d339e8ef2508 100644
> --- a/drivers/gnss/sirf.c
> +++ b/drivers/gnss/sirf.c
> @@ -36,6 +36,7 @@ struct sirf_data {
>   struct serdev_device *serdev;
>   speed_t speed;
>   struct regulator *vcc;
> + struct regulator *lna;
>   struct gpio_desc *on_off;
>   struct gpio_desc *wakeup;
>   int irq;
> @@ -282,21 +283,32 @@ static int sirf_set_active(struct sirf_data *data, bool 
> active)
> static int sirf_runtime_suspend(struct device *dev)
> {
>   struct sirf_data *data = dev_get_drvdata(dev);
> + int ret = 0;
> 
>   if (!data->on_off)
> - return regulator_disable(data->vcc);
> + ret = regulator_disable(data->vcc);
> + else
> + ret = sirf_set_active(data, false);
> 
> - return sirf_set_active(data, false);
> + if (ret)
> + return ret;
> +
> + return regulator_disable(data->lna);
> }
> 
> static int sirf_runtime_resume(struct device *dev)
> {
>   struct sirf_data *data = dev_get_drvdata(dev);
> + int ret;
> +
> + ret = regulator_enable(data->lna);
> + if (ret)
> + return ret;
> 
>   if (!data->on_off)
>   return regulator_enable(data->vcc);
> -
> - return sirf_set_active(data, true);
> + else
> + return sirf_set_active(data, true);
> }
> 
> static int __maybe_unused sirf_suspend(struct device *dev)
> @@ -384,6 +396,12 @@ static int sirf_probe(struct serdev_device *serdev)
>   goto err_put_device;
>   }
> 
> + data->lna = devm_regulator_get(dev, "lna");
> + if (IS_ERR(data->lna)) {
> + ret = PTR_ERR(data->lna);
> + goto err_put_device;
> + }
> +
>   data->on_off = devm_gpiod_get_optional(dev, "sirf,onoff",
>   GPIOD_OUT_LOW);
>   if (IS_ERR(data->on_off))
> -- 
> 2.11.0
> 
> ___
> http://projects.goldelico.com/p/gta04-kernel/
> Letux-kernel mailing list
> letux-ker...@openphoenux.org
> http://lists.goldelico.com/mailman/listinfo.cgi/letux-kernel



Re: [PATCH v5 1/3] device property: Introduce fwnode_get_name()

2018-12-09 Thread Heikki Krogerus
On Fri, Dec 07, 2018 at 11:24:27AM -0600, Rob Herring wrote:
> On Wed, Nov 28, 2018 at 02:59:50PM +0300, Heikki Krogerus wrote:
> > This helper returns the name of the node. The name is
> > primarily expected to be returned from a new fwnode
> > operation meant for this purpose, but when no name is
> > returned, the helper will also attempt to read a device
> > property "name".
> > 
> > Reviewed-by: Andy Shevchenko 
> > Signed-off-by: Heikki Krogerus 
> > ---
> >  drivers/base/property.c  | 36 
> >  include/linux/fwnode.h   |  3 +++
> >  include/linux/property.h |  2 ++
> >  3 files changed, 41 insertions(+)
> > 
> > diff --git a/drivers/base/property.c b/drivers/base/property.c
> > index 240ab5230ff6..8bd35b44d9ec 100644
> > --- a/drivers/base/property.c
> > +++ b/drivers/base/property.c
> > @@ -1156,6 +1156,42 @@ void fwnode_handle_put(struct fwnode_handle *fwnode)
> >  }
> >  EXPORT_SYMBOL_GPL(fwnode_handle_put);
> >  
> > +/**
> > + * fwnode_get_name - Copy the name of an fwnode to a buffer
> > + * @fwnode: Pointer to the node
> > + * @buf: Buffer where the name is copied to
> > + * @len: Size of the buffer
> > + *
> > + * Copies the node name of @fwnode to @buf. The routine attempts to first 
> > use
> > + * the get_name fwnode op of @fwnode, and if it fails, the routine 
> > attempts to
> > + * read a property "name".
> > + *
> > + * NOTE: @buf must be large enough to accommodate the name and trailing 
> > '\0'.
> > + *
> > + * Returns 0 on success or errno in case of an error.
> > + */
> > +int fwnode_get_name(const struct fwnode_handle *fwnode, char *buf, size_t 
> > len)
> > +{
> > +   const char *name;
> > +   int ret;
> > +
> > +   ret = fwnode_call_int_op(fwnode, get_name, buf, len);
> > +   if (ret == 0 || ret == -EOVERFLOW)
> > +   return ret;
> > +
> > +   ret = fwnode_call_int_op(fwnode, property_read_string_array,
> > +"name", , 1);
> 
> Do you expect this to work on DT? It does today, but I plan to change 
> that. 'name' is a fake property on FDT.
> 
> Again, I think this is all working at too low of a level. Name is used 
> either for matching or an informational string. For matching, this 
> should remain firmware specific. For imformational strings, 
> device_node.full_name works.

OK, I'll remove call.

thanks,

-- 
heikki


[PATCH v3 01/12] clk: mediatek: fixup: Disable tuner_en before change PLL rate

2018-12-09 Thread Weiyi Lu
From: Owen Chen 

PLLs with tuner_en bit, such as APLL1, need to disable
tuner_en before apply new frequency settings, or the new frequency
settings (pcw) will not be applied.
The tuner_en bit will be disabled during changing PLL rate
and be restored after new settings applied.
Another minor change is to correct the macro name of pcw change bit
to CON1_PCW_CHG because PCW_CHG(BIT31) is on CON1.

Cc: 
Signed-off-by: Owen Chen 
---
 drivers/clk/mediatek/clk-pll.c | 33 +++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c
index f54e4015b0b1..f0ff5f535c7e 100644
--- a/drivers/clk/mediatek/clk-pll.c
+++ b/drivers/clk/mediatek/clk-pll.c
@@ -27,7 +27,7 @@
 #define CON0_BASE_EN   BIT(0)
 #define CON0_PWR_ONBIT(0)
 #define CON0_ISO_ENBIT(1)
-#define CON0_PCW_CHG   BIT(31)
+#define CON1_PCW_CHG   BIT(31)
 
 #define AUDPLL_TUNER_ENBIT(31)
 
@@ -93,9 +93,31 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, 
u32 pcw,
 {
u32 con1, val;
int pll_en;
+   u32 tuner_en = 0;
+   u32 tuner_en_mask;
+   void __iomem *tuner_en_addr = NULL;
 
pll_en = readl(pll->base_addr + REG_CON0) & CON0_BASE_EN;
 
+   /* disable tuner */
+   if (pll->tuner_en_addr) {
+   tuner_en_addr = pll->tuner_en_addr;
+   tuner_en_mask = BIT(pll->data->tuner_en_bit);
+   } else if (pll->tuner_addr) {
+   tuner_en_addr = pll->tuner_addr;
+   tuner_en_mask = AUDPLL_TUNER_EN;
+   }
+
+   if (tuner_en_addr) {
+   val = readl(tuner_en_addr);
+   tuner_en = val & tuner_en_mask;
+
+   if (tuner_en) {
+   val &= ~tuner_en_mask;
+   writel(val, tuner_en_addr);
+   }
+   }
+
/* set postdiv */
val = readl(pll->pd_addr);
val &= ~(POSTDIV_MASK << pll->data->pd_shift);
@@ -116,12 +138,19 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll 
*pll, u32 pcw,
con1 = readl(pll->base_addr + REG_CON1);
 
if (pll_en)
-   con1 |= CON0_PCW_CHG;
+   con1 |= CON1_PCW_CHG;
 
writel(con1, pll->base_addr + REG_CON1);
if (pll->tuner_addr)
writel(con1 + 1, pll->tuner_addr);
 
+   /* restore tuner_en */
+   if (tuner_en_addr && tuner_en) {
+   val = readl(tuner_en_addr);
+   val |= tuner_en_mask;
+   writel(val, tuner_en_addr);
+   }
+
if (pll_en)
udelay(20);
 }
-- 
2.18.0



[PATCH v3 03/12] clk: mediatek: add configurable pcwibits and fmin to mtk_pll_data

2018-12-09 Thread Weiyi Lu
From: Owen Chen 

1. pcwibits: The integer bits of pcw for plls is extend to 8 bits,
   add a variable to indicate this change and
   backward-compatible.
2. fmin: The pll freqency lower-bound is vary from 1GMhz to
   1.5Ghz, add a variable to indicate platform-dependent.

Signed-off-by: Owen Chen 
Signed-off-by: Weiyi Lu 
Acked-by: Sean Wang 
---
 drivers/clk/mediatek/clk-mtk.h |  2 ++
 drivers/clk/mediatek/clk-pll.c | 12 +---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index f83c2bbb677e..11b5517903d0 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -214,8 +214,10 @@ struct mtk_pll_data {
unsigned int flags;
const struct clk_ops *ops;
u32 rst_bar_mask;
+   unsigned long fmin;
unsigned long fmax;
int pcwbits;
+   int pcwibits;
uint32_t pcw_reg;
int pcw_shift;
const struct mtk_pll_div_table *div_table;
diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c
index f0ff5f535c7e..81400601f107 100644
--- a/drivers/clk/mediatek/clk-pll.c
+++ b/drivers/clk/mediatek/clk-pll.c
@@ -32,6 +32,8 @@
 #define AUDPLL_TUNER_ENBIT(31)
 
 #define POSTDIV_MASK   0x7
+
+/* default 7 bits integer, can be overridden with pcwibits. */
 #define INTEGER_BITS   7
 
 /*
@@ -69,11 +71,13 @@ static unsigned long __mtk_pll_recalc_rate(struct 
mtk_clk_pll *pll, u32 fin,
 {
int pcwbits = pll->data->pcwbits;
int pcwfbits;
+   int ibits;
u64 vco;
u8 c = 0;
 
/* The fractional part of the PLL divider. */
-   pcwfbits = pcwbits > INTEGER_BITS ? pcwbits - INTEGER_BITS : 0;
+   ibits = pll->data->pcwibits ? pll->data->pcwibits : INTEGER_BITS;
+   pcwfbits = pcwbits > ibits ? pcwbits - ibits : 0;
 
vco = (u64)fin * pcw;
 
@@ -167,9 +171,10 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, 
u32 pcw,
 static void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw, u32 
*postdiv,
u32 freq, u32 fin)
 {
-   unsigned long fmin = 1000 * MHZ;
+   unsigned long fmin = pll->data->fmin ? pll->data->fmin : (1000 * MHZ);
const struct mtk_pll_div_table *div_table = pll->data->div_table;
u64 _pcw;
+   int ibits;
u32 val;
 
if (freq > pll->data->fmax)
@@ -193,7 +198,8 @@ static void mtk_pll_calc_values(struct mtk_clk_pll *pll, 
u32 *pcw, u32 *postdiv,
}
 
/* _pcw = freq * postdiv / fin * 2^pcwfbits */
-   _pcw = ((u64)freq << val) << (pll->data->pcwbits - INTEGER_BITS);
+   ibits = pll->data->pcwibits ? pll->data->pcwibits : INTEGER_BITS;
+   _pcw = ((u64)freq << val) << (pll->data->pcwbits - ibits);
do_div(_pcw, fin);
 
*pcw = (u32)_pcw;
-- 
2.18.0



[PATCH v3 07/12] clk: mediatek: Add flags support for mtk_gate data

2018-12-09 Thread Weiyi Lu
On some Mediatek platforms, there are critical clocks of
clock gate type.
To register clock gate with flags CLK_IS_CRITICAL,
we need to add the flags field in mtk_gate data and register APIs.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-gate.c | 5 +++--
 drivers/clk/mediatek/clk-gate.h | 3 ++-
 drivers/clk/mediatek/clk-mtk.c  | 3 ++-
 drivers/clk/mediatek/clk-mtk.h  | 1 +
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/mediatek/clk-gate.c b/drivers/clk/mediatek/clk-gate.c
index 934bf0e45e26..85daf826619a 100644
--- a/drivers/clk/mediatek/clk-gate.c
+++ b/drivers/clk/mediatek/clk-gate.c
@@ -157,7 +157,8 @@ struct clk *mtk_clk_register_gate(
int clr_ofs,
int sta_ofs,
u8 bit,
-   const struct clk_ops *ops)
+   const struct clk_ops *ops,
+   unsigned long flags)
 {
struct mtk_clk_gate *cg;
struct clk *clk;
@@ -168,7 +169,7 @@ struct clk *mtk_clk_register_gate(
return ERR_PTR(-ENOMEM);
 
init.name = name;
-   init.flags = CLK_SET_RATE_PARENT;
+   init.flags = flags | CLK_SET_RATE_PARENT;
init.parent_names = parent_name ? _name : NULL;
init.num_parents = parent_name ? 1 : 0;
init.ops = ops;
diff --git a/drivers/clk/mediatek/clk-gate.h b/drivers/clk/mediatek/clk-gate.h
index 72ef89b3ad7b..9f766dfe1d57 100644
--- a/drivers/clk/mediatek/clk-gate.h
+++ b/drivers/clk/mediatek/clk-gate.h
@@ -47,6 +47,7 @@ struct clk *mtk_clk_register_gate(
int clr_ofs,
int sta_ofs,
u8 bit,
-   const struct clk_ops *ops);
+   const struct clk_ops *ops,
+   unsigned long flags);
 
 #endif /* __DRV_CLK_GATE_H */
diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index 9c0ae4278a94..35359e5397c7 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -130,7 +130,8 @@ int mtk_clk_register_gates(struct device_node *node,
gate->regs->set_ofs,
gate->regs->clr_ofs,
gate->regs->sta_ofs,
-   gate->shift, gate->ops);
+   gate->shift, gate->ops,
+   gate->flags);
 
if (IS_ERR(clk)) {
pr_err("Failed to register clk %s: %ld\n",
diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index 11b5517903d0..928905496c4b 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -158,6 +158,7 @@ struct mtk_gate {
const struct mtk_gate_regs *regs;
int shift;
const struct clk_ops *ops;
+   unsigned long flags;
 };
 
 int mtk_clk_register_gates(struct device_node *node,
-- 
2.18.0



[PATCH v3 11/12] soc: mediatek: Add MT8183 scpsys support

2018-12-09 Thread Weiyi Lu
Add scpsys driver for MT8183

Signed-off-by: Weiyi Lu 
---
 drivers/soc/mediatek/mtk-scpsys.c | 226 ++
 1 file changed, 226 insertions(+)

diff --git a/drivers/soc/mediatek/mtk-scpsys.c 
b/drivers/soc/mediatek/mtk-scpsys.c
index 98ccef566ce1..58d84fe33d2a 100644
--- a/drivers/soc/mediatek/mtk-scpsys.c
+++ b/drivers/soc/mediatek/mtk-scpsys.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define MTK_POLL_DELAY_US   10
 #define MTK_POLL_TIMEOUT(jiffies_to_usecs(HZ))
@@ -1158,6 +1159,217 @@ static const struct scp_subdomain 
scp_subdomain_mt8173[] = {
{MT8173_POWER_DOMAIN_MFG_2D, MT8173_POWER_DOMAIN_MFG},
 };
 
+/*
+ * MT8183 power domain support
+ */
+
+static const struct scp_domain_data scp_domain_data_mt8183[] = {
+   [MT8183_POWER_DOMAIN_AUDIO] = {
+   .name = "audio",
+   .sta_mask = PWR_STATUS_AUDIO,
+   .ctl_offs = 0x0314,
+   .sram_pdn_bits = GENMASK(11, 8),
+   .sram_pdn_ack_bits = GENMASK(15, 12),
+   .basic_clk_name = {"audio", "audio1", "audio2"},
+   },
+   [MT8183_POWER_DOMAIN_CONN] = {
+   .name = "conn",
+   .sta_mask = PWR_STATUS_CONN,
+   .ctl_offs = 0x032c,
+   .sram_pdn_bits = 0,
+   .sram_pdn_ack_bits = 0,
+   .bp_table = {
+   BUS_PROT(IFR_TYPE, 0x2a0, 0x2a4, 0, 0x228,
+   BIT(13) | BIT(14), BIT(13) | BIT(14)),
+   },
+   },
+   [MT8183_POWER_DOMAIN_MFG_ASYNC] = {
+   .name = "mfg_async",
+   .sta_mask = PWR_STATUS_MFG_ASYNC,
+   .ctl_offs = 0x0334,
+   .sram_pdn_bits = 0,
+   .sram_pdn_ack_bits = 0,
+   .basic_clk_name = {"mfg"},
+   },
+   [MT8183_POWER_DOMAIN_MFG] = {
+   .name = "mfg",
+   .sta_mask = PWR_STATUS_MFG,
+   .ctl_offs = 0x0338,
+   .sram_pdn_bits = GENMASK(8, 8),
+   .sram_pdn_ack_bits = GENMASK(12, 12),
+   },
+   [MT8183_POWER_DOMAIN_MFG_CORE0] = {
+   .name = "mfg_core0",
+   .sta_mask = BIT(7),
+   .ctl_offs = 0x034c,
+   .sram_pdn_bits = GENMASK(8, 8),
+   .sram_pdn_ack_bits = GENMASK(12, 12),
+   },
+   [MT8183_POWER_DOMAIN_MFG_CORE1] = {
+   .name = "mfg_core1",
+   .sta_mask = BIT(20),
+   .ctl_offs = 0x0310,
+   .sram_pdn_bits = GENMASK(8, 8),
+   .sram_pdn_ack_bits = GENMASK(12, 12),
+   },
+   [MT8183_POWER_DOMAIN_MFG_2D] = {
+   .name = "mfg_2d",
+   .sta_mask = PWR_STATUS_MFG_2D,
+   .ctl_offs = 0x0348,
+   .sram_pdn_bits = GENMASK(8, 8),
+   .sram_pdn_ack_bits = GENMASK(12, 12),
+   .bp_table = {
+   BUS_PROT(IFR_TYPE, 0x2a8, 0x2ac, 0, 0x258,
+   BIT(19) | BIT(20) | BIT(21),
+   BIT(19) | BIT(20) | BIT(21)),
+   BUS_PROT(IFR_TYPE, 0x2a0, 0x2a4, 0, 0x228,
+   BIT(21) | BIT(22), BIT(21) | BIT(22)),
+   },
+   },
+   [MT8183_POWER_DOMAIN_DISP] = {
+   .name = "disp",
+   .sta_mask = PWR_STATUS_DISP,
+   .ctl_offs = 0x030c,
+   .sram_pdn_bits = GENMASK(8, 8),
+   .sram_pdn_ack_bits = GENMASK(12, 12),
+   .basic_clk_name = {"mm"},
+   .subsys_clk_prefix = "mm",
+   .bp_table = {
+   BUS_PROT(IFR_TYPE, 0x2a8, 0x2ac, 0, 0x258,
+   BIT(16) | BIT(17), BIT(16) | BIT(17)),
+   BUS_PROT(IFR_TYPE, 0x2a0, 0x2a4, 0, 0x228,
+   BIT(10) | BIT(11), BIT(10) | BIT(11)),
+   BUS_PROT(SMI_TYPE, 0x3c4, 0x3c8, 0, 0x3c0,
+   GENMASK(7, 0), GENMASK(7, 0)),
+   },
+   },
+   [MT8183_POWER_DOMAIN_CAM] = {
+   .name = "cam",
+   .sta_mask = BIT(25),
+   .ctl_offs = 0x0344,
+   .sram_pdn_bits = GENMASK(9, 8),
+   .sram_pdn_ack_bits = GENMASK(13, 12),
+   .basic_clk_name = {"cam"},
+   .subsys_clk_prefix = "cam",
+   .bp_table = {
+   BUS_PROT(IFR_TYPE, 0x2d4, 0x2d8, 0, 0x2ec,
+   BIT(4) | BIT(5) | BIT(9) | BIT(13),
+   BIT(4) | BIT(5) | BIT(9) | BIT(13)),
+   BUS_PROT(IFR_TYPE, 0x2a0, 0x2a4, 0, 0x228,
+   BIT(28), BIT(28)),
+   BUS_PROT(IFR_TYPE, 0x2d4, 0x2d8, 0, 0x2ec,
+   BIT(11), 0),
+   BUS_PROT(SMI_TYPE, 0x3c4, 0x3c8, 0, 0x3c0,
+   BIT(3) | BIT(4), 

[PATCH v3 12/12] clk: mediatek: Allow changing PLL rate when it is off

2018-12-09 Thread Weiyi Lu
From: James Liao 

Some modules may need to change its clock rate before turn on it.
So changing PLL's rate when it is off should be allowed.
This patch removes PLL enabled check before set rate, so that
PLLs can set new frequency even if they are off.

On MT8173 for example, ARMPLL's enable bit can be controlled by
other HW. That means ARMPLL may be turned on even if we (CPU / SW)
set ARMPLL's enable bit as 0. In this case, SW may want and can
still change ARMPLL's rate by changing its pcw and postdiv settings.
But without this patch, new pcw setting will not be applied because
its enable bit is 0.

(am from https://patchwork.kernel.org/patch/9411983/)

Signed-off-by: James Liao 
Acked-by: Michael Turquette 
Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/clk-pll.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c
index 81400601f107..03b20e3bca4e 100644
--- a/drivers/clk/mediatek/clk-pll.c
+++ b/drivers/clk/mediatek/clk-pll.c
@@ -96,13 +96,10 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, 
u32 pcw,
int postdiv)
 {
u32 con1, val;
-   int pll_en;
u32 tuner_en = 0;
u32 tuner_en_mask;
void __iomem *tuner_en_addr = NULL;
 
-   pll_en = readl(pll->base_addr + REG_CON0) & CON0_BASE_EN;
-
/* disable tuner */
if (pll->tuner_en_addr) {
tuner_en_addr = pll->tuner_en_addr;
@@ -141,8 +138,7 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, 
u32 pcw,
 
con1 = readl(pll->base_addr + REG_CON1);
 
-   if (pll_en)
-   con1 |= CON1_PCW_CHG;
+   con1 |= CON1_PCW_CHG;
 
writel(con1, pll->base_addr + REG_CON1);
if (pll->tuner_addr)
@@ -155,8 +151,7 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, 
u32 pcw,
writel(val, tuner_en_addr);
}
 
-   if (pll_en)
-   udelay(20);
+   udelay(20);
 }
 
 /*
-- 
2.18.0



[PATCH v3 06/12] clk: mediatek: Add dt-bindings for MT8183 clocks

2018-12-09 Thread Weiyi Lu
Add MT8183 clock dt-bindings, include topckgen, apmixedsys,
infracfg, mcucfg and subsystem clocks.

Signed-off-by: Weiyi Lu 
Reviewed-by: Rob Herring 
---
 include/dt-bindings/clock/mt8183-clk.h | 422 +
 1 file changed, 422 insertions(+)
 create mode 100644 include/dt-bindings/clock/mt8183-clk.h

diff --git a/include/dt-bindings/clock/mt8183-clk.h 
b/include/dt-bindings/clock/mt8183-clk.h
new file mode 100644
index ..0046506eb24c
--- /dev/null
+++ b/include/dt-bindings/clock/mt8183-clk.h
@@ -0,0 +1,422 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2018 MediaTek Inc.
+ * Author: Weiyi Lu 
+ */
+
+#ifndef _DT_BINDINGS_CLK_MT8183_H
+#define _DT_BINDINGS_CLK_MT8183_H
+
+/* APMIXED */
+#define CLK_APMIXED_ARMPLL_LL  0
+#define CLK_APMIXED_ARMPLL_L   1
+#define CLK_APMIXED_CCIPLL 2
+#define CLK_APMIXED_MAINPLL3
+#define CLK_APMIXED_UNIV2PLL   4
+#define CLK_APMIXED_MSDCPLL5
+#define CLK_APMIXED_MMPLL  6
+#define CLK_APMIXED_MFGPLL 7
+#define CLK_APMIXED_TVDPLL 8
+#define CLK_APMIXED_APLL1  9
+#define CLK_APMIXED_APLL2  10
+#define CLK_APMIXED_SSUSB_26M  11
+#define CLK_APMIXED_APPLL_26M  12
+#define CLK_APMIXED_MIPIC0_26M 13
+#define CLK_APMIXED_MDPLLGP_26M14
+#define CLK_APMIXED_MMSYS_26M  15
+#define CLK_APMIXED_UFS_26M16
+#define CLK_APMIXED_MIPIC1_26M 17
+#define CLK_APMIXED_MEMPLL_26M 18
+#define CLK_APMIXED_CLKSQ_LVPLL_26M19
+#define CLK_APMIXED_MIPID0_26M 20
+#define CLK_APMIXED_MIPID1_26M 21
+#define CLK_APMIXED_NR_CLK 22
+
+/* TOPCKGEN */
+#define CLK_TOP_MUX_AXI0
+#define CLK_TOP_MUX_MM 1
+#define CLK_TOP_MUX_CAM2
+#define CLK_TOP_MUX_MFG3
+#define CLK_TOP_MUX_CAMTG  4
+#define CLK_TOP_MUX_UART   5
+#define CLK_TOP_MUX_SPI6
+#define CLK_TOP_MUX_MSDC50_0_HCLK  7
+#define CLK_TOP_MUX_MSDC50_0   8
+#define CLK_TOP_MUX_MSDC30_1   9
+#define CLK_TOP_MUX_MSDC30_2   10
+#define CLK_TOP_MUX_AUDIO  11
+#define CLK_TOP_MUX_AUD_INTBUS 12
+#define CLK_TOP_MUX_FPWRAP_ULPOSC  13
+#define CLK_TOP_MUX_SCP14
+#define CLK_TOP_MUX_ATB15
+#define CLK_TOP_MUX_SSPM   16
+#define CLK_TOP_MUX_DPI0   17
+#define CLK_TOP_MUX_SCAM   18
+#define CLK_TOP_MUX_AUD_1  19
+#define CLK_TOP_MUX_AUD_2  20
+#define CLK_TOP_MUX_DISP_PWM   21
+#define CLK_TOP_MUX_SSUSB_TOP_XHCI 22
+#define CLK_TOP_MUX_USB_TOP23
+#define CLK_TOP_MUX_SPM24
+#define CLK_TOP_MUX_I2C25
+#define CLK_TOP_MUX_F52M_MFG   26
+#define CLK_TOP_MUX_SENINF 27
+#define CLK_TOP_MUX_DXCC   28
+#define CLK_TOP_MUX_CAMTG2 29
+#define CLK_TOP_MUX_AUD_ENG1   30
+#define CLK_TOP_MUX_AUD_ENG2   31
+#define CLK_TOP_MUX_FAES_UFSFDE32
+#define CLK_TOP_MUX_FUFS   33
+#define CLK_TOP_MUX_IMG34
+#define CLK_TOP_MUX_DSP35
+#define CLK_TOP_MUX_DSP1   36
+#define CLK_TOP_MUX_DSP2   37
+#define CLK_TOP_MUX_IPU_IF 38
+#define CLK_TOP_MUX_CAMTG3 39
+#define CLK_TOP_MUX_CAMTG4 40
+#define CLK_TOP_MUX_PMICSPI41
+#define CLK_TOP_SYSPLL_CK  42
+#define CLK_TOP_SYSPLL_D2  43
+#define CLK_TOP_SYSPLL_D3  44
+#define CLK_TOP_SYSPLL_D5  45
+#define CLK_TOP_SYSPLL_D7  46
+#define CLK_TOP_SYSPLL_D2_D2   47
+#define CLK_TOP_SYSPLL_D2_D4   48
+#define CLK_TOP_SYSPLL_D2_D8   49
+#define CLK_TOP_SYSPLL_D2_D16  50
+#define CLK_TOP_SYSPLL_D3_D2   51
+#define CLK_TOP_SYSPLL_D3_D4   52
+#define CLK_TOP_SYSPLL_D3_D8   53
+#define CLK_TOP_SYSPLL_D5_D2   54
+#define CLK_TOP_SYSPLL_D5_D4   55
+#define CLK_TOP_SYSPLL_D7_D2   56
+#define CLK_TOP_SYSPLL_D7_D4   57
+#define CLK_TOP_UNIVPLL_CK 58
+#define CLK_TOP_UNIVPLL_D2 59
+#define CLK_TOP_UNIVPLL_D3 60
+#define CLK_TOP_UNIVPLL_D5 61
+#define CLK_TOP_UNIVPLL_D7 62
+#define CLK_TOP_UNIVPLL_D2_D2  63
+#define CLK_TOP_UNIVPLL_D2_D4  64
+#define CLK_TOP_UNIVPLL_D2_D8  65
+#define CLK_TOP_UNIVPLL_D3_D2  66
+#define CLK_TOP_UNIVPLL_D3_D4  67
+#define CLK_TOP_UNIVPLL_D3_D8  68
+#define CLK_TOP_UNIVPLL_D5_D2  69
+#define CLK_TOP_UNIVPLL_D5_D4  70
+#define CLK_TOP_UNIVPLL_D5_D8  71
+#define CLK_TOP_APLL1_CK   72
+#define CLK_TOP_APLL1_D2

[PATCH v3 02/12] clk: mediatek: add new clkmux register API

2018-12-09 Thread Weiyi Lu
From: Owen Chen 

On both MT8183 & MT6765, there add "set/clr" register for
each clkmux setting, and one update register to trigger value change.
It is designed to prevent read-modify-write racing issue.
The sw design need to add a new API to handle this hw change with
a new mtk_clk_mux/mtk_mux struct in new file "clk-mux.c", "clk-mux.h".

Signed-off-by: Owen Chen 
Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Makefile  |   3 +-
 drivers/clk/mediatek/clk-mux.c | 229 +
 drivers/clk/mediatek/clk-mux.h | 101 +++
 3 files changed, 332 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mux.c
 create mode 100644 drivers/clk/mediatek/clk-mux.h

diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 844b55d2770d..00e4d405231e 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_COMMON_CLK_MEDIATEK) += clk-mtk.o clk-pll.o clk-gate.o 
clk-apmixed.o clk-cpumux.o reset.o
+obj-$(CONFIG_COMMON_CLK_MEDIATEK) += clk-mtk.o clk-pll.o clk-gate.o 
clk-apmixed.o clk-cpumux.o reset.o clk-mux.o
+
 obj-$(CONFIG_COMMON_CLK_MT6797) += clk-mt6797.o
 obj-$(CONFIG_COMMON_CLK_MT6797_IMGSYS) += clk-mt6797-img.o
 obj-$(CONFIG_COMMON_CLK_MT6797_MMSYS) += clk-mt6797-mm.o
diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c
new file mode 100644
index ..efbbb35eb185
--- /dev/null
+++ b/drivers/clk/mediatek/clk-mux.c
@@ -0,0 +1,229 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018 MediaTek Inc.
+ * Author: Owen Chen 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "clk-mtk.h"
+#include "clk-mux.h"
+
+static inline struct mtk_clk_mux *to_mtk_clk_mux(struct clk_hw *hw)
+{
+   return container_of(hw, struct mtk_clk_mux, hw);
+}
+
+static int mtk_clk_mux_enable(struct clk_hw *hw)
+{
+   struct mtk_clk_mux *mux = to_mtk_clk_mux(hw);
+   u32 mask = BIT(mux->gate_shift);
+
+   return regmap_update_bits(mux->regmap, mux->mux_ofs, mask, ~mask);
+}
+
+static void mtk_clk_mux_disable(struct clk_hw *hw)
+{
+   struct mtk_clk_mux *mux = to_mtk_clk_mux(hw);
+   u32 mask = BIT(mux->gate_shift);
+
+   regmap_update_bits(mux->regmap, mux->mux_ofs, mask, mask);
+}
+
+static int mtk_clk_mux_enable_setclr(struct clk_hw *hw)
+{
+   struct mtk_clk_mux *mux = to_mtk_clk_mux(hw);
+
+   return regmap_write(mux->regmap, mux->mux_clr_ofs,
+   BIT(mux->gate_shift));
+}
+
+static void mtk_clk_mux_disable_setclr(struct clk_hw *hw)
+{
+   struct mtk_clk_mux *mux = to_mtk_clk_mux(hw);
+
+   regmap_write(mux->regmap, mux->mux_set_ofs, BIT(mux->gate_shift));
+}
+
+static int mtk_clk_mux_is_enabled(struct clk_hw *hw)
+{
+   struct mtk_clk_mux *mux = to_mtk_clk_mux(hw);
+   u32 val;
+
+   regmap_read(mux->regmap, mux->mux_ofs, );
+
+   return (val & BIT(mux->gate_shift)) == 0;
+}
+
+static u8 mtk_clk_mux_get_parent(struct clk_hw *hw)
+{
+   struct mtk_clk_mux *mux = to_mtk_clk_mux(hw);
+   u32 mask = GENMASK(mux->mux_width - 1, 0);
+   u32 val;
+
+   regmap_read(mux->regmap, mux->mux_ofs, );
+   val = (val >> mux->mux_shift) & mask;
+
+   return val;
+}
+
+static int mtk_clk_mux_set_parent_lock(struct clk_hw *hw, u8 index)
+{
+   struct mtk_clk_mux *mux = to_mtk_clk_mux(hw);
+   u32 mask = GENMASK(mux->mux_width - 1, 0);
+   unsigned long flags;
+
+   if (mux->lock)
+   spin_lock_irqsave(mux->lock, flags);
+   else
+   __acquire(mux->lock);
+
+   regmap_update_bits(mux->regmap, mux->mux_ofs, mask,
+   index << mux->mux_shift);
+
+   if (mux->lock)
+   spin_unlock_irqrestore(mux->lock, flags);
+   else
+   __release(mux->lock);
+
+   return 0;
+}
+
+static int mtk_clk_mux_set_parent_setclr_lock(struct clk_hw *hw, u8 index)
+{
+   struct mtk_clk_mux *mux = to_mtk_clk_mux(hw);
+   u32 mask = GENMASK(mux->mux_width - 1, 0);
+   u32 val, orig;
+   unsigned long flags;
+
+   if (mux->lock)
+   spin_lock_irqsave(mux->lock, flags);
+   else
+   __acquire(mux->lock);
+
+   regmap_read(mux->regmap, mux->mux_ofs, );
+   val = (orig & ~(mask << mux->mux_shift)) | (index << mux->mux_shift);
+
+   if (val != orig) {
+   regmap_write(mux->regmap, mux->mux_clr_ofs,
+   mask << mux->mux_shift);
+   regmap_write(mux->regmap, mux->mux_set_ofs,
+   index << mux->mux_shift);
+
+   if (mux->upd_shift >= 0)
+   regmap_write(mux->regmap, mux->upd_ofs,
+   BIT(mux->upd_shift));
+   }
+
+   if (mux->lock)
+   spin_unlock_irqrestore(mux->lock, flags);
+   else
+   __release(mux->lock);
+
+   return 0;
+}
+

[PATCH v3 08/12] clk: mediatek: Add MT8183 clock support

2018-12-09 Thread Weiyi Lu
Add MT8183 clock support, include topckgen, apmixedsys,
infracfg, mcucfg and subsystem clocks.

Signed-off-by: Weiyi Lu 
---
 drivers/clk/mediatek/Kconfig   |   75 ++
 drivers/clk/mediatek/Makefile  |   12 +
 drivers/clk/mediatek/clk-gate.h|   14 +
 drivers/clk/mediatek/clk-mt8183-audio.c|  102 ++
 drivers/clk/mediatek/clk-mt8183-cam.c  |   70 ++
 drivers/clk/mediatek/clk-mt8183-img.c  |   70 ++
 drivers/clk/mediatek/clk-mt8183-ipu0.c |   63 +
 drivers/clk/mediatek/clk-mt8183-ipu1.c |   63 +
 drivers/clk/mediatek/clk-mt8183-ipu_adl.c  |   61 +
 drivers/clk/mediatek/clk-mt8183-ipu_conn.c |  130 ++
 drivers/clk/mediatek/clk-mt8183-mfgcfg.c   |   61 +
 drivers/clk/mediatek/clk-mt8183-mm.c   |  118 ++
 drivers/clk/mediatek/clk-mt8183-vdec.c |   74 ++
 drivers/clk/mediatek/clk-mt8183-venc.c |   66 +
 drivers/clk/mediatek/clk-mt8183.c  | 1304 
 15 files changed, 2283 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8183-audio.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-cam.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-img.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-ipu0.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-ipu1.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-ipu_adl.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-ipu_conn.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-mfgcfg.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-mm.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-vdec.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-venc.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index 3dd1dab92223..5d4fd67fa259 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -193,4 +193,79 @@ config COMMON_CLK_MT8173
default ARCH_MEDIATEK
---help---
  This driver supports MediaTek MT8173 clocks.
+
+config COMMON_CLK_MT8183
+   bool "Clock driver for MediaTek MT8183"
+   depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST
+   select COMMON_CLK_MEDIATEK
+   default ARCH_MEDIATEK && ARM64
+   help
+ This driver supports MediaTek MT8183 basic clocks.
+
+config COMMON_CLK_MT8183_AUDIOSYS
+   bool "Clock driver for MediaTek MT8183 audiosys"
+   depends on COMMON_CLK_MT8183
+   help
+ This driver supports MediaTek MT8183 audiosys clocks.
+
+config COMMON_CLK_MT8183_CAMSYS
+   bool "Clock driver for MediaTek MT8183 camsys"
+   depends on COMMON_CLK_MT8183
+   help
+ This driver supports MediaTek MT8183 camsys clocks.
+
+config COMMON_CLK_MT8183_IMGSYS
+   bool "Clock driver for MediaTek MT8183 imgsys"
+   depends on COMMON_CLK_MT8183
+   help
+ This driver supports MediaTek MT8183 imgsys clocks.
+
+config COMMON_CLK_MT8183_IPU_CORE0
+   bool "Clock driver for MediaTek MT8183 ipu_core0"
+   depends on COMMON_CLK_MT8183
+   help
+ This driver supports MediaTek MT8183 ipu_core0 clocks.
+
+config COMMON_CLK_MT8183_IPU_CORE1
+   bool "Clock driver for MediaTek MT8183 ipu_core1"
+   depends on COMMON_CLK_MT8183
+   help
+ This driver supports MediaTek MT8183 ipu_core1 clocks.
+
+config COMMON_CLK_MT8183_IPU_ADL
+   bool "Clock driver for MediaTek MT8183 ipu_adl"
+   depends on COMMON_CLK_MT8183
+   help
+ This driver supports MediaTek MT8183 ipu_adl clocks.
+
+config COMMON_CLK_MT8183_IPU_CONN
+   bool "Clock driver for MediaTek MT8183 ipu_conn"
+   depends on COMMON_CLK_MT8183
+   help
+ This driver supports MediaTek MT8183 ipu_conn clocks.
+
+config COMMON_CLK_MT8183_MFGCFG
+   bool "Clock driver for MediaTek MT8183 mfgcfg"
+   depends on COMMON_CLK_MT8183
+   help
+ This driver supports MediaTek MT8183 mfgcfg clocks.
+
+config COMMON_CLK_MT8183_MMSYS
+   bool "Clock driver for MediaTek MT8183 mmsys"
+   depends on COMMON_CLK_MT8183
+   help
+ This driver supports MediaTek MT8183 mmsys clocks.
+
+config COMMON_CLK_MT8183_VDECSYS
+   bool "Clock driver for MediaTek MT8183 vdecsys"
+   depends on COMMON_CLK_MT8183
+   help
+ This driver supports MediaTek MT8183 vdecsys clocks.
+
+config COMMON_CLK_MT8183_VENCSYS
+   bool "Clock driver for MediaTek MT8183 vencsys"
+   depends on COMMON_CLK_MT8183
+   help
+ This driver supports MediaTek MT8183 vencsys clocks.
+
 endmenu
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 00e4d405231e..a26d02756879 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -29,3 +29,15 @@ obj-$(CONFIG_COMMON_CLK_MT7622_HIFSYS) += clk-mt7622-hif.o
 obj-$(CONFIG_COMMON_CLK_MT7622_AUDSYS) += clk-mt7622-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8135) += clk-mt8135.o
 obj-$(CONFIG_COMMON_CLK_MT8173) += 

[PATCH v3 00/11] Mediatek MT8183 clock and scpsys support

2018-12-09 Thread Weiyi Lu
This series is based on v4.20-rc1 and most of changes are extracted from series 
below
(clock/scpsys common changes for both MT8183 & MT6765)
https://patchwork.kernel.org/patch/10528495/
(clock support of MT8183)
https://patchwork.kernel.org/patch/10549891/

The whole series is composed of
clock common changes for both MT8183 & MT6765 (PATCH 1-3),
scpsys common changes for both MT8183 & MT6765 (PATCH 4),
clock support of MT8183 (PATCH 5-8),
scpsys support of MT8183 (PATCH 9-11) and
resend a clock patch long time ago(PTACH 12).

change sinve v2:
- refine for implementation consistency of mtk clk mux.
- separate the onoff API into enable/disable API for mtk scpsys.
- resend a patch about PLL rate changing.

changes since v1:
- refine for better code quality.
- some minor bug fix of clock part, like incorrect control address
  and missing clocks.




[PATCH v3 04/12] soc: mediatek: add new flow for mtcmos power.

2018-12-09 Thread Weiyi Lu
From: Owen Chen 

Both MT8183 & MT6765 add more bus protect node than previous project,
therefore we add two more register for setup bus protect, which reside
at INFRA_CFG & SMI_COMMON.

With the following change
1. bus protect need not only infracfg but smi_common registers involved
   to setup. Therefore we add a set/clr APIs with more customize arguments.

The second change is that we also add subsys CG control flow before/after
the bus protect/sram control, due to bus protect need SMI bus relative CGs
enable to feed-back its ack, and some master's sram control need CG enable
to on/off its resource sequentially.

With the following change
1. turn on subsys CG before sram pwron and release bus protect.
2. turn off subsys CG after the process of set bus protect/receive
   ack/disable sram.

The last change is for some power domains like vpu_core on MT8183 whose
sram need to do clock and internal isolation while power on/off sram.
We add a flag "sram_iso_ctrl" in scp_domain_data to judge if we need to
do the extra sram isolation control or not.

Signed-off-by: Owen Chen 
Signed-off-by: Mars Cheng 
Signed-off-by: Weiyi Lu 
---
 drivers/soc/mediatek/Makefile   |   2 +-
 drivers/soc/mediatek/mtk-scpsys-ext.c   |  99 ++
 drivers/soc/mediatek/mtk-scpsys.c   | 390 ++--
 include/linux/soc/mediatek/scpsys-ext.h |  39 +++
 4 files changed, 443 insertions(+), 87 deletions(-)
 create mode 100644 drivers/soc/mediatek/mtk-scpsys-ext.c
 create mode 100644 include/linux/soc/mediatek/scpsys-ext.h

diff --git a/drivers/soc/mediatek/Makefile b/drivers/soc/mediatek/Makefile
index 12998b08819e..9dc6670c19cb 100644
--- a/drivers/soc/mediatek/Makefile
+++ b/drivers/soc/mediatek/Makefile
@@ -1,3 +1,3 @@
-obj-$(CONFIG_MTK_INFRACFG) += mtk-infracfg.o
+obj-$(CONFIG_MTK_INFRACFG) += mtk-infracfg.o mtk-scpsys-ext.o
 obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap.o
 obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o
diff --git a/drivers/soc/mediatek/mtk-scpsys-ext.c 
b/drivers/soc/mediatek/mtk-scpsys-ext.c
new file mode 100644
index ..54df42db2a8f
--- /dev/null
+++ b/drivers/soc/mediatek/mtk-scpsys-ext.c
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018 MediaTek Inc.
+ * Author: Owen Chen 
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MTK_POLL_DELAY_US   10
+#define MTK_POLL_TIMEOUT(jiffies_to_usecs(HZ))
+
+static int set_bus_protection(struct regmap *map, u32 mask, u32 ack_mask,
+   u32 reg_set, u32 reg_sta, u32 reg_en)
+{
+   u32 val;
+
+   if (reg_set)
+   regmap_write(map, reg_set, mask);
+   else
+   regmap_update_bits(map, reg_en, mask, mask);
+
+   return regmap_read_poll_timeout(map, reg_sta,
+   val, (val & ack_mask) == ack_mask,
+   MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
+}
+
+static int clear_bus_protection(struct regmap *map, u32 mask, u32 ack_mask,
+   u32 reg_clr, u32 reg_sta, u32 reg_en)
+{
+   u32 val;
+
+   if (reg_clr)
+   regmap_write(map, reg_clr, mask);
+   else
+   regmap_update_bits(map, reg_en, mask, 0);
+
+   return regmap_read_poll_timeout(map, reg_sta,
+   val, !(val & ack_mask),
+   MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
+}
+
+int mtk_scpsys_ext_set_bus_protection(const struct bus_prot *bp_table,
+   struct regmap *infracfg, struct regmap *smi_common)
+{
+   int i;
+
+   for (i = 0; i < MAX_STEPS && bp_table[i].mask; i++) {
+   struct regmap *map;
+   int ret;
+
+   if (bp_table[i].type == IFR_TYPE)
+   map = infracfg;
+   else if (bp_table[i].type == SMI_TYPE)
+   map = smi_common;
+   else
+   return -EINVAL;
+
+   ret = set_bus_protection(map,
+   bp_table[i].mask, bp_table[i].mask,
+   bp_table[i].set_ofs, bp_table[i].sta_ofs,
+   bp_table[i].en_ofs);
+
+   if (ret)
+   return ret;
+   }
+
+   return 0;
+}
+
+int mtk_scpsys_ext_clear_bus_protection(const struct bus_prot *bp_table,
+   struct regmap *infracfg, struct regmap *smi_common)
+{
+   int i;
+
+   for (i = MAX_STEPS - 1; i >= 0; i--) {
+   struct regmap *map;
+   int ret;
+
+   if (bp_table[i].type == IFR_TYPE)
+   map = infracfg;
+   else if (bp_table[i].type == SMI_TYPE)
+   map = smi_common;
+   else
+   return -EINVAL;
+
+   ret = clear_bus_protection(map,
+   bp_table[i].mask, bp_table[i].clr_ack_mask,
+   bp_table[i].clr_ofs, bp_table[i].sta_ofs,
+   bp_table[i].en_ofs);
+
+  

[PATCH v3 05/12] dt-bindings: ARM: Mediatek: Document bindings for MT8183

2018-12-09 Thread Weiyi Lu
This patch adds the binding documentation for apmixedsys, audiosys,
camsys, imgsys, infracfg, mcucfg, mfgcfg, mmsys, topckgen, vdecsys,
vencsys and ipu for Mediatek MT8183.

Signed-off-by: Weiyi Lu 
Reviewed-by: Rob Herring 
---
 .../arm/mediatek/mediatek,apmixedsys.txt  |  1 +
 .../bindings/arm/mediatek/mediatek,audsys.txt |  1 +
 .../bindings/arm/mediatek/mediatek,camsys.txt | 22 ++
 .../bindings/arm/mediatek/mediatek,imgsys.txt |  1 +
 .../arm/mediatek/mediatek,infracfg.txt|  1 +
 .../bindings/arm/mediatek/mediatek,ipu.txt| 43 +++
 .../bindings/arm/mediatek/mediatek,mcucfg.txt |  1 +
 .../bindings/arm/mediatek/mediatek,mfgcfg.txt |  1 +
 .../bindings/arm/mediatek/mediatek,mmsys.txt  |  1 +
 .../arm/mediatek/mediatek,topckgen.txt|  1 +
 .../arm/mediatek/mediatek,vdecsys.txt |  1 +
 .../arm/mediatek/mediatek,vencsys.txt |  1 +
 12 files changed, 75 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,camsys.txt
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,ipu.txt

diff --git 
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
index 4e4a3c0ab9ab..641f19e036a2 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,apmixedsys.txt
@@ -13,6 +13,7 @@ Required Properties:
- "mediatek,mt7623-apmixedsys", "mediatek,mt2701-apmixedsys"
- "mediatek,mt8135-apmixedsys"
- "mediatek,mt8173-apmixedsys"
+   - "mediatek,mt8183-apmixedsys", "syscon"
 - #clock-cells: Must be 1
 
 The apmixedsys controller uses the common clk binding from
diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt
index d1606b2c3e63..f3cef1a6d95c 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,audsys.txt
@@ -9,6 +9,7 @@ Required Properties:
- "mediatek,mt2701-audsys", "syscon"
- "mediatek,mt7622-audsys", "syscon"
- "mediatek,mt7623-audsys", "mediatek,mt2701-audsys", "syscon"
+   - "mediatek,mt8183-audiosys", "syscon"
 - #clock-cells: Must be 1
 
 The AUDSYS controller uses the common clk binding from
diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,camsys.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,camsys.txt
new file mode 100644
index ..d8930f64aa98
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,camsys.txt
@@ -0,0 +1,22 @@
+MediaTek CAMSYS controller
+
+
+The MediaTek camsys controller provides various clocks to the system.
+
+Required Properties:
+
+- compatible: Should be one of:
+   - "mediatek,mt8183-camsys", "syscon"
+- #clock-cells: Must be 1
+
+The camsys controller uses the common clk binding from
+Documentation/devicetree/bindings/clock/clock-bindings.txt
+The available clocks are defined in dt-bindings/clock/mt*-clk.h.
+
+Example:
+
+camsys: camsys@1a00  {
+   compatible = "mediatek,mt8183-camsys", "syscon";
+   reg = <0 0x1a00  0 0x1000>;
+   #clock-cells = <1>;
+};
diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt
index 3f99672163e3..e3bc4a1e7a6e 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,imgsys.txt
@@ -11,6 +11,7 @@ Required Properties:
- "mediatek,mt6797-imgsys", "syscon"
- "mediatek,mt7623-imgsys", "mediatek,mt2701-imgsys", "syscon"
- "mediatek,mt8173-imgsys", "syscon"
+   - "mediatek,mt8183-imgsys", "syscon"
 - #clock-cells: Must be 1
 
 The imgsys controller uses the common clk binding from
diff --git 
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt
index 89f4272a1441..44b2f3281c34 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.txt
@@ -14,6 +14,7 @@ Required Properties:
- "mediatek,mt7623-infracfg", "mediatek,mt2701-infracfg", "syscon"
- "mediatek,mt8135-infracfg", "syscon"
- "mediatek,mt8173-infracfg", "syscon"
+   - "mediatek,mt8183-infracfg", "syscon"
 - #clock-cells: Must be 1
 - #reset-cells: Must be 1
 
diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,ipu.txt 
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,ipu.txt
new file mode 100644
index ..aabc8c5c8ed2
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,ipu.txt
@@ -0,0 

[PATCH v3 09/12] dt-bindings: soc: fix typo of MT8173 power dt-bindings

2018-12-09 Thread Weiyi Lu
fix incorrect IC name that will affect the MT8183 power dt-bindings

Signed-off-by: Weiyi Lu 
---
 include/dt-bindings/power/mt8173-power.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/dt-bindings/power/mt8173-power.h 
b/include/dt-bindings/power/mt8173-power.h
index 15d531aa6e78..ef4a7f944848 100644
--- a/include/dt-bindings/power/mt8173-power.h
+++ b/include/dt-bindings/power/mt8173-power.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _DT_BINDINGS_POWER_MT8183_POWER_H
-#define _DT_BINDINGS_POWER_MT8183_POWER_H
+#ifndef _DT_BINDINGS_POWER_MT8173_POWER_H
+#define _DT_BINDINGS_POWER_MT8173_POWER_H
 
 #define MT8173_POWER_DOMAIN_VDEC   0
 #define MT8173_POWER_DOMAIN_VENC   1
@@ -13,4 +13,4 @@
 #define MT8173_POWER_DOMAIN_MFG_2D 8
 #define MT8173_POWER_DOMAIN_MFG9
 
-#endif /* _DT_BINDINGS_POWER_MT8183_POWER_H */
+#endif /* _DT_BINDINGS_POWER_MT8173_POWER_H */
-- 
2.18.0



[PATCH v3 10/12] dt-bindings: soc: Add MT8183 power dt-bindings

2018-12-09 Thread Weiyi Lu
Add power dt-bindings for MT8183.

Signed-off-by: Weiyi Lu 
---
 .../bindings/soc/mediatek/scpsys.txt  | 14 ++
 include/dt-bindings/power/mt8183-power.h  | 26 +++
 2 files changed, 40 insertions(+)
 create mode 100644 include/dt-bindings/power/mt8183-power.h

diff --git a/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt 
b/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt
index d6fe16f094af..b4728ce81c43 100644
--- a/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt
+++ b/Documentation/devicetree/bindings/soc/mediatek/scpsys.txt
@@ -14,6 +14,7 @@ power/power_domain.txt. It provides the power domains defined 
in
 - include/dt-bindings/power/mt2701-power.h
 - include/dt-bindings/power/mt2712-power.h
 - include/dt-bindings/power/mt7622-power.h
+- include/dt-bindings/power/mt8183-power.h
 
 Required properties:
 - compatible: Should be one of:
@@ -24,18 +25,31 @@ Required properties:
- "mediatek,mt7623-scpsys", "mediatek,mt2701-scpsys": For MT7623 SoC
- "mediatek,mt7623a-scpsys": For MT7623A SoC
- "mediatek,mt8173-scpsys"
+   - "mediatek,mt8183-scpsys"
 - #power-domain-cells: Must be 1
 - reg: Address range of the SCPSYS unit
 - infracfg: must contain a phandle to the infracfg controller
 - clock, clock-names: clocks according to the common clock binding.
   These are clocks which hardware needs to be
   enabled before enabling certain power domains.
+  The new clock type "BASIC" belongs to the type above.
+  As to the new clock type "SUBSYS" needs to be
+  enabled before releasing bus protection.
Required clocks for MT2701 or MT7623: "mm", "mfg", "ethif"
Required clocks for MT2712: "mm", "mfg", "venc", "jpgdec", "audio", 
"vdec"
Required clocks for MT6797: "mm", "mfg", "vdec"
Required clocks for MT7622: "hif_sel"
Required clocks for MT7622A: "ethif"
Required clocks for MT8173: "mm", "mfg", "venc", "venc_lt"
+   Required clocks for MT8183: BASIC: "audio", "mfg", "mm", "cam", "isp",
+  "vpu", "vpu1", "vpu2", "vpu3"
+   SUBSYS: "mm-0", "mm-1", "mm-2", "mm-3",
+   "mm-4", "mm-5", "mm-6", "mm-7",
+   "mm-8", "mm-9", "isp-0", "isp-1",
+   "cam-0", "cam-1", "cam-2", "cam-3",
+   "cam-4", "cam-5", "cam-6", "vpu-0",
+   "vpu-1", "vpu-2", "vpu-3", "vpu-4",
+   "vpu-5"
 
 Optional properties:
 - vdec-supply: Power supply for the vdec power domain
diff --git a/include/dt-bindings/power/mt8183-power.h 
b/include/dt-bindings/power/mt8183-power.h
new file mode 100644
index ..5c0c8c7e3cd0
--- /dev/null
+++ b/include/dt-bindings/power/mt8183-power.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (c) 2018 MediaTek Inc.
+ * Author: Weiyi Lu 
+ */
+
+#ifndef _DT_BINDINGS_POWER_MT8183_POWER_H
+#define _DT_BINDINGS_POWER_MT8183_POWER_H
+
+#define MT8183_POWER_DOMAIN_AUDIO  0
+#define MT8183_POWER_DOMAIN_CONN   1
+#define MT8183_POWER_DOMAIN_MFG_ASYNC  2
+#define MT8183_POWER_DOMAIN_MFG3
+#define MT8183_POWER_DOMAIN_MFG_CORE0  4
+#define MT8183_POWER_DOMAIN_MFG_CORE1  5
+#define MT8183_POWER_DOMAIN_MFG_2D 6
+#define MT8183_POWER_DOMAIN_DISP   7
+#define MT8183_POWER_DOMAIN_CAM8
+#define MT8183_POWER_DOMAIN_ISP9
+#define MT8183_POWER_DOMAIN_VDEC   10
+#define MT8183_POWER_DOMAIN_VENC   11
+#define MT8183_POWER_DOMAIN_VPU_TOP12
+#define MT8183_POWER_DOMAIN_VPU_CORE0  13
+#define MT8183_POWER_DOMAIN_VPU_CORE1  14
+
+#endif /* _DT_BINDINGS_POWER_MT8183_POWER_H */
-- 
2.18.0



[PATCH v3 00/12] Mediatek MT8183 clock and scpsys support

2018-12-09 Thread Weiyi Lu
This series is based on v4.20-rc1 and most of changes are extracted from series 
below
(clock/scpsys common changes for both MT8183 & MT6765)
https://patchwork.kernel.org/patch/10528495/
(clock support of MT8183)
https://patchwork.kernel.org/patch/10549891/

The whole series is composed of
clock common changes for both MT8183 & MT6765 (PATCH 1-3),
scpsys common changes for both MT8183 & MT6765 (PATCH 4),
clock support of MT8183 (PATCH 5-8),
scpsys support of MT8183 (PATCH 9-11) and
resend a clock patch long time ago(PTACH 12).

change sinve v2:
- refine for implementation consistency of mtk clk mux.
- separate the onoff API into enable/disable API for mtk scpsys.
- resend a patch about PLL rate changing.

changes since v1:
- refine for better code quality.
- some minor bug fix of clock part, like incorrect control address
  and missing clocks.

James Liao (1):
  clk: mediatek: Allow changing PLL rate when it is off

Owen Chen (4):
  clk: mediatek: fixup: Disable tuner_en before change PLL rate
  clk: mediatek: add new clkmux register API
  clk: mediatek: add configurable pcwibits and fmin to mtk_pll_data
  soc: mediatek: add new flow for mtcmos power.

Weiyi Lu (7):
  dt-bindings: ARM: Mediatek: Document bindings for MT8183
  clk: mediatek: Add dt-bindings for MT8183 clocks
  clk: mediatek: Add flags support for mtk_gate data
  clk: mediatek: Add MT8183 clock support
  dt-bindings: soc: fix typo of MT8173 power dt-bindings
  dt-bindings: soc: Add MT8183 power dt-bindings
  soc: mediatek: Add MT8183 scpsys support

 .../arm/mediatek/mediatek,apmixedsys.txt  |1 +
 .../bindings/arm/mediatek/mediatek,audsys.txt |1 +
 .../bindings/arm/mediatek/mediatek,camsys.txt |   22 +
 .../bindings/arm/mediatek/mediatek,imgsys.txt |1 +
 .../arm/mediatek/mediatek,infracfg.txt|1 +
 .../bindings/arm/mediatek/mediatek,ipu.txt|   43 +
 .../bindings/arm/mediatek/mediatek,mcucfg.txt |1 +
 .../bindings/arm/mediatek/mediatek,mfgcfg.txt |1 +
 .../bindings/arm/mediatek/mediatek,mmsys.txt  |1 +
 .../arm/mediatek/mediatek,topckgen.txt|1 +
 .../arm/mediatek/mediatek,vdecsys.txt |1 +
 .../arm/mediatek/mediatek,vencsys.txt |1 +
 .../bindings/soc/mediatek/scpsys.txt  |   14 +
 drivers/clk/mediatek/Kconfig  |   75 +
 drivers/clk/mediatek/Makefile |   15 +-
 drivers/clk/mediatek/clk-gate.c   |5 +-
 drivers/clk/mediatek/clk-gate.h   |   17 +-
 drivers/clk/mediatek/clk-mt8183-audio.c   |  102 ++
 drivers/clk/mediatek/clk-mt8183-cam.c |   70 +
 drivers/clk/mediatek/clk-mt8183-img.c |   70 +
 drivers/clk/mediatek/clk-mt8183-ipu0.c|   63 +
 drivers/clk/mediatek/clk-mt8183-ipu1.c|   63 +
 drivers/clk/mediatek/clk-mt8183-ipu_adl.c |   61 +
 drivers/clk/mediatek/clk-mt8183-ipu_conn.c|  130 ++
 drivers/clk/mediatek/clk-mt8183-mfgcfg.c  |   61 +
 drivers/clk/mediatek/clk-mt8183-mm.c  |  118 ++
 drivers/clk/mediatek/clk-mt8183-vdec.c|   74 +
 drivers/clk/mediatek/clk-mt8183-venc.c|   66 +
 drivers/clk/mediatek/clk-mt8183.c | 1304 +
 drivers/clk/mediatek/clk-mtk.c|3 +-
 drivers/clk/mediatek/clk-mtk.h|3 +
 drivers/clk/mediatek/clk-mux.c|  229 +++
 drivers/clk/mediatek/clk-mux.h|  101 ++
 drivers/clk/mediatek/clk-pll.c|   50 +-
 drivers/soc/mediatek/Makefile |2 +-
 drivers/soc/mediatek/mtk-scpsys-ext.c |   99 ++
 drivers/soc/mediatek/mtk-scpsys.c |  616 ++--
 include/dt-bindings/clock/mt8183-clk.h|  422 ++
 include/dt-bindings/power/mt8173-power.h  |6 +-
 include/dt-bindings/power/mt8183-power.h  |   26 +
 include/linux/soc/mediatek/scpsys-ext.h   |   39 +
 41 files changed, 3874 insertions(+), 105 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,camsys.txt
 create mode 100644 
Documentation/devicetree/bindings/arm/mediatek/mediatek,ipu.txt
 create mode 100644 drivers/clk/mediatek/clk-mt8183-audio.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-cam.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-img.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-ipu0.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-ipu1.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-ipu_adl.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-ipu_conn.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-mfgcfg.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-mm.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-vdec.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183-venc.c
 create mode 100644 drivers/clk/mediatek/clk-mt8183.c
 create mode 100644 drivers/clk/mediatek/clk-mux.c
 create mode 100644 drivers/clk/mediatek/clk-mux.h
 create mode 100644 drivers/soc/mediatek/mtk-scpsys-ext.c
 create mode 100644 

[PATCH -next] IB/mlx5: remove duplicated include from mlx5_ib.h

2018-12-09 Thread YueHaibing
Remove duplicated include.

Signed-off-by: YueHaibing 
---
 drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h 
b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index 484a080..64fbf45 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -41,7 +41,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.7.0




Re: dma_declare_coherent_memory on main memory

2018-12-09 Thread Sascha Hauer
On Fri, Dec 07, 2018 at 04:34:32PM +0100, Christoph Hellwig wrote:
> Hi all,
> 
> the ARM imx27/31 ports and various sh boards use
> dma_declare_coherent_memory on main memory taken from the memblock
> allocator.
> 
> Is there any good reason these couldn't be switched to CMA areas?
> Getting rid of these magic dma_declare_coherent_memory area would
> help making the dma allocator a lot simpler.

At least for i.MX27/31 I'd say this predates CMA support, so historical
reasons.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


[PATCH V2 1/2] dt-bindings: iio: accel: mma8452: add optional power supply property

2018-12-09 Thread Anson Huang
The accelerometer's power supply could be controlled by regulator
on some platforms, add optional property "vdd/vddio" power supply
to let device tree to pass phandles to the regulators to driver.

Signed-off-by: Anson Huang 
---
 Documentation/devicetree/bindings/iio/accel/mma8452.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/accel/mma8452.txt 
b/Documentation/devicetree/bindings/iio/accel/mma8452.txt
index 2100e9a..e132394 100644
--- a/Documentation/devicetree/bindings/iio/accel/mma8452.txt
+++ b/Documentation/devicetree/bindings/iio/accel/mma8452.txt
@@ -20,6 +20,10 @@ Optional properties:
   - interrupt-names: should contain "INT1" and/or "INT2", the accelerometer's
 interrupt line in use.
 
+  - vdd-supply: phandle to the regulator that provides vdd power to the 
accelerometer.
+
+  - vddio-supply: phandle to the regulator that provides vddio power to the 
accelerometer.
+
 Example:
 
mma8453fc@1d {
-- 
2.7.4



[PATCH -next] bus: qcom: remove duplicated include from qcom-ebi2.c

2018-12-09 Thread YueHaibing
Remove duplicated include.

Signed-off-by: YueHaibing 
---
 drivers/bus/qcom-ebi2.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/bus/qcom-ebi2.c b/drivers/bus/qcom-ebi2.c
index a644424..56b01e4 100644
--- a/drivers/bus/qcom-ebi2.c
+++ b/drivers/bus/qcom-ebi2.c
@@ -21,7 +21,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.7.0




[PATCH V2 2/2] iio: accell: mma8452: add optional vdd/vddio regulator operation support

2018-12-09 Thread Anson Huang
The accelerometer's power supply could be controlled by regulator
on some platforms, such as i.MX6Q-SABRESD board, the mma8451's
power supply is controlled by a GPIO fixed regulator, need to make
sure the regulator is enabled before any communication with mma8451,
this patch adds optional vdd/vddio regulator operation support.

Signed-off-by: Anson Huang 
---
ChangeLog since V1:
- Add defer_probe check if the return value from 
devm_regulator_get_optional is ERR_PTR(-EPROBE_DEFER);
- Replace the "vcc" with "vdd" according to datasheet, and add optional 
"vddio" supply as well since
  mma8452 also has a vddio supply.
---
 drivers/iio/accel/mma8452.c | 151 +++-
 1 file changed, 149 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 421a0a8..18dcf33 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define MMA8452_STATUS 0x00
 #define  MMA8452_STATUS_DRDY   (BIT(2) | BIT(1) | BIT(0))
@@ -107,6 +108,8 @@ struct mma8452_data {
u8 data_cfg;
const struct mma_chip_info *chip_info;
int sleep_val;
+   struct regulator *vdd_reg;
+   struct regulator *vddio_reg;
 };
 
  /**
@@ -1533,6 +1536,27 @@ static int mma8452_probe(struct i2c_client *client,
data->client = client;
mutex_init(>lock);
data->chip_info = match->data;
+   data->vdd_reg = devm_regulator_get_optional(>dev, "vdd");
+   if (!IS_ERR(data->vdd_reg)) {
+   ret = regulator_enable(data->vdd_reg);
+   if (ret) {
+   dev_err(>dev, "failed to enable VDD 
regulator\n");
+   return ret;
+   }
+   } else if (data->vdd_reg == ERR_PTR(-EPROBE_DEFER)) {
+   return -EPROBE_DEFER;
+   }
+
+   data->vddio_reg = devm_regulator_get_optional(>dev, "vddio");
+   if (!IS_ERR(data->vddio_reg)) {
+   ret = regulator_enable(data->vddio_reg);
+   if (ret) {
+   dev_err(>dev, "failed to enable VDDIO 
regulator\n");
+   return ret;
+   }
+   } else if (data->vddio_reg == ERR_PTR(-EPROBE_DEFER)) {
+   return -EPROBE_DEFER;
+   }
 
ret = i2c_smbus_read_byte_data(client, MMA8452_WHO_AM_I);
if (ret < 0)
@@ -1667,6 +1691,8 @@ static int mma8452_probe(struct i2c_client *client,
 static int mma8452_remove(struct i2c_client *client)
 {
struct iio_dev *indio_dev = i2c_get_clientdata(client);
+   struct mma8452_data *data = iio_priv(indio_dev);
+   int ret;
 
iio_device_unregister(indio_dev);
 
@@ -1678,6 +1704,21 @@ static int mma8452_remove(struct i2c_client *client)
mma8452_trigger_cleanup(indio_dev);
mma8452_standby(iio_priv(indio_dev));
 
+   if (!IS_ERR(data->vdd_reg)) {
+   ret = regulator_disable(data->vdd_reg);
+   if (ret) {
+   dev_err(>dev, "failed to disable VDD 
regulator\n");
+   return ret;
+   }
+   }
+   if (!IS_ERR(data->vddio_reg)) {
+   ret = regulator_disable(data->vddio_reg);
+   if (ret) {
+   dev_err(>dev, "failed to disable VDDIO 
regulator\n");
+   return ret;
+   }
+   }
+
return 0;
 }
 
@@ -1696,6 +1737,21 @@ static int mma8452_runtime_suspend(struct device *dev)
return -EAGAIN;
}
 
+   if (!IS_ERR(data->vdd_reg)) {
+   ret = regulator_disable(data->vdd_reg);
+   if (ret) {
+   dev_err(dev, "failed to disable VDD regulator\n");
+   return ret;
+   }
+   }
+   if (!IS_ERR(data->vddio_reg)) {
+   ret = regulator_disable(data->vddio_reg);
+   if (ret) {
+   dev_err(dev, "failed to disable VDDIO regulator\n");
+   return ret;
+   }
+   }
+
return 0;
 }
 
@@ -1705,6 +1761,21 @@ static int mma8452_runtime_resume(struct device *dev)
struct mma8452_data *data = iio_priv(indio_dev);
int ret, sleep_val;
 
+   if (!IS_ERR(data->vdd_reg)) {
+   ret = regulator_enable(data->vdd_reg);
+   if (ret) {
+   dev_err(dev, "failed to enable VDD regulator\n");
+   return ret;
+   }
+   }
+   if (!IS_ERR(data->vddio_reg)) {
+   ret = regulator_enable(data->vddio_reg);
+   if (ret) {
+   dev_err(dev, "failed to enable VDDIO regulator\n");
+   return ret;
+   }
+   }
+
ret = mma8452_active(data);
if (ret < 0)
return ret;
@@ -1723,14 +1794,90 @@ static int 

[PATCH v11 9/9] powerpc: clean stack pointers naming

2018-12-09 Thread Christophe Leroy
Some stack pointers used to also be thread_info pointers
and were called tp. Now that they are only stack pointers,
rename them sp.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/irq.c  | 17 +++--
 arch/powerpc/kernel/setup_64.c | 20 ++--
 2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 62cfccf4af89..754f0efc507b 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -659,21 +659,21 @@ void __do_irq(struct pt_regs *regs)
 void do_IRQ(struct pt_regs *regs)
 {
struct pt_regs *old_regs = set_irq_regs(regs);
-   void *curtp, *irqtp, *sirqtp;
+   void *cursp, *irqsp, *sirqsp;
 
/* Switch to the irq stack to handle this */
-   curtp = (void *)(current_stack_pointer() & ~(THREAD_SIZE - 1));
-   irqtp = hardirq_ctx[raw_smp_processor_id()];
-   sirqtp = softirq_ctx[raw_smp_processor_id()];
+   cursp = (void *)(current_stack_pointer() & ~(THREAD_SIZE - 1));
+   irqsp = hardirq_ctx[raw_smp_processor_id()];
+   sirqsp = softirq_ctx[raw_smp_processor_id()];
 
/* Already there ? */
-   if (unlikely(curtp == irqtp || curtp == sirqtp)) {
+   if (unlikely(cursp == irqsp || cursp == sirqsp)) {
__do_irq(regs);
set_irq_regs(old_regs);
return;
}
/* Switch stack and call */
-   call_do_irq(regs, irqtp);
+   call_do_irq(regs, irqsp);
 
set_irq_regs(old_regs);
 }
@@ -732,10 +732,7 @@ void irq_ctx_init(void)
 
 void do_softirq_own_stack(void)
 {
-   void *irqtp;
-
-   irqtp = softirq_ctx[smp_processor_id()];
-   call_do_softirq(irqtp);
+   call_do_softirq(softirq_ctx[smp_processor_id()]);
 }
 
 irq_hw_number_t virq_to_hw(unsigned int virq)
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 0b227d0891ec..49765ccbc8c0 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -718,22 +718,22 @@ void __init emergency_stack_init(void)
limit = min(ppc64_bolted_size(), ppc64_rma_size);
 
for_each_possible_cpu(i) {
-   void *ti;
+   void *sp;
 
-   ti = alloc_stack(limit, i);
-   memset(ti, 0, THREAD_SIZE);
-   paca_ptrs[i]->emergency_sp = ti + THREAD_SIZE;
+   sp = alloc_stack(limit, i);
+   memset(sp, 0, THREAD_SIZE);
+   paca_ptrs[i]->emergency_sp = sp + THREAD_SIZE;
 
 #ifdef CONFIG_PPC_BOOK3S_64
/* emergency stack for NMI exception handling. */
-   ti = alloc_stack(limit, i);
-   memset(ti, 0, THREAD_SIZE);
-   paca_ptrs[i]->nmi_emergency_sp = ti + THREAD_SIZE;
+   sp = alloc_stack(limit, i);
+   memset(sp, 0, THREAD_SIZE);
+   paca_ptrs[i]->nmi_emergency_sp = sp + THREAD_SIZE;
 
/* emergency stack for machine check exception handling. */
-   ti = alloc_stack(limit, i);
-   memset(ti, 0, THREAD_SIZE);
-   paca_ptrs[i]->mc_emergency_sp = ti + THREAD_SIZE;
+   sp = alloc_stack(limit, i);
+   memset(sp, 0, THREAD_SIZE);
+   paca_ptrs[i]->mc_emergency_sp = sp + THREAD_SIZE;
 #endif
}
 }
-- 
2.13.3



[PATCH v11 5/9] powerpc: regain entire stack space

2018-12-09 Thread Christophe Leroy
thread_info is not anymore in the stack, so the entire stack
can now be used.

There is also no risk anymore of corrupting task_cpu(p) with a
stack overflow so the patch removes the test.

When doing this, an explicit test for NULL stack pointer is
needed in validate_sp() as it is not anymore implicitely covered
by the sizeof(thread_info) gap.

In the meantime, with the previous patch all pointers to the stacks
are not anymore pointers to thread_info so this patch changes them
to void*

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/include/asm/irq.h   | 10 +-
 arch/powerpc/include/asm/processor.h |  3 +--
 arch/powerpc/kernel/asm-offsets.c|  1 -
 arch/powerpc/kernel/entry_32.S   | 14 --
 arch/powerpc/kernel/irq.c| 19 +--
 arch/powerpc/kernel/misc_32.S|  6 ++
 arch/powerpc/kernel/process.c| 32 +---
 arch/powerpc/kernel/setup_64.c   |  8 
 8 files changed, 38 insertions(+), 55 deletions(-)

diff --git a/arch/powerpc/include/asm/irq.h b/arch/powerpc/include/asm/irq.h
index 2efbae8d93be..966ddd4d2414 100644
--- a/arch/powerpc/include/asm/irq.h
+++ b/arch/powerpc/include/asm/irq.h
@@ -48,9 +48,9 @@ struct pt_regs;
  * Per-cpu stacks for handling critical, debug and machine check
  * level interrupts.
  */
-extern struct thread_info *critirq_ctx[NR_CPUS];
-extern struct thread_info *dbgirq_ctx[NR_CPUS];
-extern struct thread_info *mcheckirq_ctx[NR_CPUS];
+extern void *critirq_ctx[NR_CPUS];
+extern void *dbgirq_ctx[NR_CPUS];
+extern void *mcheckirq_ctx[NR_CPUS];
 extern void exc_lvl_ctx_init(void);
 #else
 #define exc_lvl_ctx_init()
@@ -59,8 +59,8 @@ extern void exc_lvl_ctx_init(void);
 /*
  * Per-cpu stacks for handling hard and soft interrupts.
  */
-extern struct thread_info *hardirq_ctx[NR_CPUS];
-extern struct thread_info *softirq_ctx[NR_CPUS];
+extern void *hardirq_ctx[NR_CPUS];
+extern void *softirq_ctx[NR_CPUS];
 
 extern void irq_ctx_init(void);
 void call_do_softirq(void *sp);
diff --git a/arch/powerpc/include/asm/processor.h 
b/arch/powerpc/include/asm/processor.h
index 15acb282a876..8179b64871ed 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -325,8 +325,7 @@ struct thread_struct {
 #define ARCH_MIN_TASKALIGN 16
 
 #define INIT_SP(sizeof(init_stack) + (unsigned long) 
_stack)
-#define INIT_SP_LIMIT \
-   (_ALIGN_UP(sizeof(struct thread_info), 16) + (unsigned long)_stack)
+#define INIT_SP_LIMIT  ((unsigned long)_stack)
 
 #ifdef CONFIG_SPE
 #define SPEFSCR_INIT \
diff --git a/arch/powerpc/kernel/asm-offsets.c 
b/arch/powerpc/kernel/asm-offsets.c
index 1fb52206c106..94ac190a0b16 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -92,7 +92,6 @@ int main(void)
DEFINE(SIGSEGV, SIGSEGV);
DEFINE(NMI_MASK, NMI_MASK);
 #else
-   DEFINE(THREAD_INFO_GAP, _ALIGN_UP(sizeof(struct thread_info), 16));
OFFSET(KSP_LIMIT, thread_struct, ksp_limit);
 #endif /* CONFIG_PPC64 */
OFFSET(TASK_STACK, task_struct, stack);
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 1f5a76283bd4..b547bd4168d8 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -97,14 +97,11 @@ crit_transfer_to_handler:
mfspr   r0,SPRN_SRR1
stw r0,_SRR1(r11)
 
-   /* set the stack limit to the current stack
-* and set the limit to protect the thread_info
-* struct
-*/
+   /* set the stack limit to the current stack */
mfspr   r8,SPRN_SPRG_THREAD
lwz r0,KSP_LIMIT(r8)
stw r0,SAVED_KSP_LIMIT(r11)
-   rlwimi  r0,r1,0,0,(31-THREAD_SHIFT)
+   rlwinm  r0,r1,0,0,(31 - THREAD_SHIFT)
stw r0,KSP_LIMIT(r8)
/* fall through */
 #endif
@@ -121,14 +118,11 @@ crit_transfer_to_handler:
mfspr   r0,SPRN_SRR1
stw r0,crit_srr1@l(0)
 
-   /* set the stack limit to the current stack
-* and set the limit to protect the thread_info
-* struct
-*/
+   /* set the stack limit to the current stack */
mfspr   r8,SPRN_SPRG_THREAD
lwz r0,KSP_LIMIT(r8)
stw r0,saved_ksp_limit@l(0)
-   rlwimi  r0,r1,0,0,(31-THREAD_SHIFT)
+   rlwinm  r0,r1,0,0,(31 - THREAD_SHIFT)
stw r0,KSP_LIMIT(r8)
/* fall through */
 #endif
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 3fdb6b6973cf..62cfccf4af89 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -618,9 +618,8 @@ static inline void check_stack_overflow(void)
sp = current_stack_pointer() & (THREAD_SIZE-1);
 
/* check for stack overflow: is there less than 2KB free? */
-   if (unlikely(sp < (sizeof(struct thread_info) + 2048))) {
-   pr_err("do_IRQ: stack overflow: %ld\n",
-   sp - sizeof(struct thread_info));
+  

[PATCH v11 2/9] powerpc: Only use task_struct 'cpu' field on SMP

2018-12-09 Thread Christophe Leroy
When moving to CONFIG_THREAD_INFO_IN_TASK, the thread_info 'cpu' field
gets moved into task_struct and only defined when CONFIG_SMP is set.

This patch ensures that TI_CPU is only used when CONFIG_SMP is set and
that task_struct 'cpu' field is not used directly out of SMP code.

Signed-off-by: Christophe Leroy 
Reviewed-by: Nicholas Piggin 
---
 arch/powerpc/kernel/head_fsl_booke.S | 2 ++
 arch/powerpc/kernel/misc_32.S| 4 
 arch/powerpc/xmon/xmon.c | 2 +-
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/head_fsl_booke.S 
b/arch/powerpc/kernel/head_fsl_booke.S
index e2750b856c8f..05b574f416b3 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -243,8 +243,10 @@ set_ivor:
li  r0,0
stwur0,THREAD_SIZE-STACK_FRAME_OVERHEAD(r1)
 
+#ifdef CONFIG_SMP
CURRENT_THREAD_INFO(r22, r1)
stw r24, TI_CPU(r22)
+#endif
 
bl  early_init
 
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 57d2ffb2d45c..02b8cdd73792 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -183,10 +183,14 @@ _GLOBAL(low_choose_750fx_pll)
or  r4,r4,r5
mtspr   SPRN_HID1,r4
 
+#ifdef CONFIG_SMP
/* Store new HID1 image */
CURRENT_THREAD_INFO(r6, r1)
lwz r6,TI_CPU(r6)
slwir6,r6,2
+#else
+   li  r6, 0
+#endif
addis   r6,r6,nap_save_hid1@ha
stw r4,nap_save_hid1@l(r6)
 
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 372f4d80bcd6..5e5e44dcbf89 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2997,7 +2997,7 @@ static void show_task(struct task_struct *tsk)
printf("%px %016lx %6d %6d %c %2d %s\n", tsk,
tsk->thread.ksp,
tsk->pid, rcu_dereference(tsk->parent)->pid,
-   state, task_thread_info(tsk)->cpu,
+   state, task_cpu(tsk),
tsk->comm);
 }
 
-- 
2.13.3



[PATCH v11 8/9] powerpc/64: Remove CURRENT_THREAD_INFO

2018-12-09 Thread Christophe Leroy
Now that current_thread_info is located at the beginning of 'current'
task struct, CURRENT_THREAD_INFO macro is not really needed any more.

This patch replaces it by loads of the value at PACACURRENT(r13).

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/include/asm/exception-64s.h   |  4 ++--
 arch/powerpc/include/asm/thread_info.h |  4 
 arch/powerpc/kernel/entry_64.S | 10 +-
 arch/powerpc/kernel/exceptions-64e.S   |  2 +-
 arch/powerpc/kernel/exceptions-64s.S   |  2 +-
 arch/powerpc/kernel/idle_book3e.S  |  2 +-
 arch/powerpc/kernel/idle_power4.S  |  2 +-
 arch/powerpc/kernel/trace/ftrace_64_mprofile.S |  6 +++---
 8 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/include/asm/exception-64s.h 
b/arch/powerpc/include/asm/exception-64s.h
index 3b4767ed3ec5..dd6a5ae7a769 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -671,7 +671,7 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
 
 #define RUNLATCH_ON\
 BEGIN_FTR_SECTION  \
-   CURRENT_THREAD_INFO(r3, r1);\
+   ld  r3, PACACURRENT(r13);   \
ld  r4,TI_LOCAL_FLAGS(r3);  \
andi.   r0,r4,_TLF_RUNLATCH;\
beqlppc64_runlatch_on_trampoline;   \
@@ -721,7 +721,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_CTRL)
 #ifdef CONFIG_PPC_970_NAP
 #define FINISH_NAP \
 BEGIN_FTR_SECTION  \
-   CURRENT_THREAD_INFO(r11, r1);   \
+   ld  r11, PACACURRENT(r13);  \
ld  r9,TI_LOCAL_FLAGS(r11); \
andi.   r10,r9,_TLF_NAPPING;\
bnelpower4_fixup_nap;   \
diff --git a/arch/powerpc/include/asm/thread_info.h 
b/arch/powerpc/include/asm/thread_info.h
index c959b8d66cac..8e1d0195ac36 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -17,10 +17,6 @@
 
 #define THREAD_SIZE(1 << THREAD_SHIFT)
 
-#ifdef CONFIG_PPC64
-#define CURRENT_THREAD_INFO(dest, sp)  stringify_in_c(ld dest, 
PACACURRENT(r13))
-#endif
-
 #ifndef __ASSEMBLY__
 #include 
 #include 
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 03cbf409c3f8..b017bd3da1ed 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -158,7 +158,7 @@ system_call:/* label this so stack 
traces look sane */
li  r10,IRQS_ENABLED
std r10,SOFTE(r1)
 
-   CURRENT_THREAD_INFO(r11, r1)
+   ld  r11, PACACURRENT(r13)
ld  r10,TI_FLAGS(r11)
andi.   r11,r10,_TIF_SYSCALL_DOTRACE
bne .Lsyscall_dotrace   /* does not return */
@@ -205,7 +205,7 @@ system_call:/* label this so stack 
traces look sane */
ld  r3,RESULT(r1)
 #endif
 
-   CURRENT_THREAD_INFO(r12, r1)
+   ld  r12, PACACURRENT(r13)
 
ld  r8,_MSR(r1)
 #ifdef CONFIG_PPC_BOOK3S
@@ -336,7 +336,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
 
/* Repopulate r9 and r10 for the syscall path */
addir9,r1,STACK_FRAME_OVERHEAD
-   CURRENT_THREAD_INFO(r10, r1)
+   ld  r10, PACACURRENT(r13)
ld  r10,TI_FLAGS(r10)
 
cmpldi  r0,NR_syscalls
@@ -734,7 +734,7 @@ _GLOBAL(ret_from_except_lite)
mtmsrd  r10,1 /* Update machine state */
 #endif /* CONFIG_PPC_BOOK3E */
 
-   CURRENT_THREAD_INFO(r9, r1)
+   ld  r9, PACACURRENT(r13)
ld  r3,_MSR(r1)
 #ifdef CONFIG_PPC_BOOK3E
ld  r10,PACACURRENT(r13)
@@ -848,7 +848,7 @@ resume_kernel:
 1: bl  preempt_schedule_irq
 
/* Re-test flags and eventually loop */
-   CURRENT_THREAD_INFO(r9, r1)
+   ld  r9, PACACURRENT(r13)
ld  r4,TI_FLAGS(r9)
andi.   r0,r4,_TIF_NEED_RESCHED
bne 1b
diff --git a/arch/powerpc/kernel/exceptions-64e.S 
b/arch/powerpc/kernel/exceptions-64e.S
index 231d066b4a3d..dfafcd0af009 100644
--- a/arch/powerpc/kernel/exceptions-64e.S
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -469,7 +469,7 @@ exc_##n##_bad_stack:
\
  * interrupts happen before the wait instruction.
  */
 #define CHECK_NAPPING()
\
-   CURRENT_THREAD_INFO(r11, r1);   \
+   ld  r11, PACACURRENT(r13);  \
ld  r10,TI_LOCAL_FLAGS(r11);\
andi.   r9,r10,_TLF_NAPPING;\
beq+1f; \
diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 89d32bb79d5e..1cbe1a78df57 100644

[PATCH v11 4/9] powerpc: Activate CONFIG_THREAD_INFO_IN_TASK

2018-12-09 Thread Christophe Leroy
This patch activates CONFIG_THREAD_INFO_IN_TASK which
moves the thread_info into task_struct.

Moving thread_info into task_struct has the following advantages:
- It protects thread_info from corruption in the case of stack
overflows.
- Its address is harder to determine if stack addresses are
leaked, making a number of attacks more difficult.

This has the following consequences:
- thread_info is now located at the beginning of task_struct.
- The 'cpu' field is now in task_struct, and only exists when
CONFIG_SMP is active.
- thread_info doesn't have anymore the 'task' field.

This patch:
- Removes all recopy of thread_info struct when the stack changes.
- Changes the CURRENT_THREAD_INFO() macro to point to current.
- Selects CONFIG_THREAD_INFO_IN_TASK.
- Modifies raw_smp_processor_id() to get ->cpu from current without
including linux/sched.h to avoid circular inclusion and without
including asm/asm-offsets.h to avoid symbol names duplication
between ASM constants and C constants.

Signed-off-by: Christophe Leroy 
Reviewed-by: Nicholas Piggin 
---
 arch/powerpc/Kconfig   |  1 +
 arch/powerpc/Makefile  |  7 +
 arch/powerpc/include/asm/ptrace.h  |  2 +-
 arch/powerpc/include/asm/smp.h | 17 +++-
 arch/powerpc/include/asm/thread_info.h | 17 ++--
 arch/powerpc/kernel/asm-offsets.c  |  7 +++--
 arch/powerpc/kernel/entry_32.S |  9 +++
 arch/powerpc/kernel/exceptions-64e.S   | 11 
 arch/powerpc/kernel/head_32.S  |  6 ++---
 arch/powerpc/kernel/head_44x.S |  4 +--
 arch/powerpc/kernel/head_64.S  |  1 +
 arch/powerpc/kernel/head_booke.h   |  8 +-
 arch/powerpc/kernel/head_fsl_booke.S   |  7 +++--
 arch/powerpc/kernel/irq.c  | 47 +-
 arch/powerpc/kernel/kgdb.c | 28 
 arch/powerpc/kernel/machine_kexec_64.c |  6 ++---
 arch/powerpc/kernel/setup_64.c | 21 ---
 arch/powerpc/kernel/smp.c  |  2 +-
 arch/powerpc/net/bpf_jit32.h   |  5 ++--
 19 files changed, 52 insertions(+), 154 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 8ea7c2c02cbf..e312e92e3381 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -238,6 +238,7 @@ config PPC
select RTC_LIB
select SPARSE_IRQ
select SYSCTL_EXCEPTION_TRACE
+   select THREAD_INFO_IN_TASK
select VIRT_TO_BUS  if !PPC64
#
# Please keep this list sorted alphabetically.
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 40bbeeeb5b4a..1135cb0b7e48 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -421,6 +421,13 @@ else
 endif
 endif
 
+ifdef CONFIG_SMP
+prepare: task_cpu_prepare
+
+task_cpu_prepare: prepare0
+   $(eval KBUILD_CFLAGS += -D_TASK_CPU=$(shell awk '{if ($$2 == "TI_CPU") 
print $$3;}' include/generated/asm-offsets.h))
+endif
+
 # Check toolchain versions:
 # - gcc-4.6 is the minimum kernel-wide version so nothing required.
 checkbin:
diff --git a/arch/powerpc/include/asm/ptrace.h 
b/arch/powerpc/include/asm/ptrace.h
index 0b8a735b6d85..64271e562fed 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -157,7 +157,7 @@ extern int ptrace_put_reg(struct task_struct *task, int 
regno,
  unsigned long data);
 
 #define current_pt_regs() \
-   ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) 
- 1)
+   ((struct pt_regs *)((unsigned long)task_stack_page(current) + 
THREAD_SIZE) - 1)
 /*
  * We use the least-significant bit of the trap field to indicate
  * whether we have saved the full set of registers, or only a
diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
index 41695745032c..0de717e16dd6 100644
--- a/arch/powerpc/include/asm/smp.h
+++ b/arch/powerpc/include/asm/smp.h
@@ -83,7 +83,22 @@ int is_cpu_dead(unsigned int cpu);
 /* 32-bit */
 extern int smp_hw_index[];
 
-#define raw_smp_processor_id() (current_thread_info()->cpu)
+/*
+ * This is particularly ugly: it appears we can't actually get the definition
+ * of task_struct here, but we need access to the CPU this task is running on.
+ * Instead of using task_struct we're using _TASK_CPU which is extracted from
+ * asm-offsets.h by kbuild to get the current processor ID.
+ *
+ * This also needs to be safeguarded when building asm-offsets.s because at
+ * that time _TASK_CPU is not defined yet. It could have been guarded by
+ * _TASK_CPU itself, but we want the build to fail if _TASK_CPU is missing
+ * when building something else than asm-offsets.s
+ */
+#ifdef GENERATING_ASM_OFFSETS
+#define raw_smp_processor_id() (0)
+#else
+#define raw_smp_processor_id() (*(unsigned int *)((void *)current + 
_TASK_CPU))
+#endif
 #define hard_smp_processor_id()(smp_hw_index[smp_processor_id()])
 
 static inline int 

[PATCH v11 3/9] powerpc: Prepare for moving thread_info into task_struct

2018-12-09 Thread Christophe Leroy
This patch cleans the powerpc kernel before activating
CONFIG_THREAD_INFO_IN_TASK:
- The purpose of the pointer given to call_do_softirq() and
call_do_irq() is to point the new stack ==> change it to void* and
rename it 'sp'
- Don't use CURRENT_THREAD_INFO() to locate the stack.
- Fix a few comments.
- Replace current_thread_info()->task by current
- Remove unnecessary casts to thread_info, as they'll become invalid
once thread_info is not in stack anymore.
- Rename THREAD_INFO to TASK_STASK: as it is in fact the offset of the
pointer to the stack in task_struct, this pointer will not be impacted
by the move of THREAD_INFO.
- Makes TASK_STACK available to PPC64. PPC64 will need it to get the
stack pointer from current once the thread_info have been moved.
- Modifies klp_init_thread_info() to take task_struct pointer argument.

Signed-off-by: Christophe Leroy 
Reviewed-by: Nicholas Piggin 
---
 arch/powerpc/include/asm/irq.h   |  4 ++--
 arch/powerpc/include/asm/livepatch.h |  7 ---
 arch/powerpc/include/asm/processor.h |  4 ++--
 arch/powerpc/include/asm/reg.h   |  2 +-
 arch/powerpc/kernel/asm-offsets.c|  2 +-
 arch/powerpc/kernel/entry_32.S   |  2 +-
 arch/powerpc/kernel/entry_64.S   |  2 +-
 arch/powerpc/kernel/head_32.S|  4 ++--
 arch/powerpc/kernel/head_40x.S   |  4 ++--
 arch/powerpc/kernel/head_44x.S   |  2 +-
 arch/powerpc/kernel/head_8xx.S   |  2 +-
 arch/powerpc/kernel/head_booke.h |  4 ++--
 arch/powerpc/kernel/head_fsl_booke.S |  4 ++--
 arch/powerpc/kernel/irq.c|  2 +-
 arch/powerpc/kernel/misc_32.S|  4 ++--
 arch/powerpc/kernel/process.c|  8 
 arch/powerpc/kernel/setup-common.c   |  2 +-
 arch/powerpc/kernel/setup_32.c   | 15 +--
 arch/powerpc/kernel/smp.c|  4 +++-
 19 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/arch/powerpc/include/asm/irq.h b/arch/powerpc/include/asm/irq.h
index ee39ce56b2a2..2efbae8d93be 100644
--- a/arch/powerpc/include/asm/irq.h
+++ b/arch/powerpc/include/asm/irq.h
@@ -63,8 +63,8 @@ extern struct thread_info *hardirq_ctx[NR_CPUS];
 extern struct thread_info *softirq_ctx[NR_CPUS];
 
 extern void irq_ctx_init(void);
-extern void call_do_softirq(struct thread_info *tp);
-extern void call_do_irq(struct pt_regs *regs, struct thread_info *tp);
+void call_do_softirq(void *sp);
+void call_do_irq(struct pt_regs *regs, void *sp);
 extern void do_IRQ(struct pt_regs *regs);
 extern void __init init_IRQ(void);
 extern void __do_irq(struct pt_regs *regs);
diff --git a/arch/powerpc/include/asm/livepatch.h 
b/arch/powerpc/include/asm/livepatch.h
index 47a03b9b528b..8a81d10ccc82 100644
--- a/arch/powerpc/include/asm/livepatch.h
+++ b/arch/powerpc/include/asm/livepatch.h
@@ -43,13 +43,14 @@ static inline unsigned long 
klp_get_ftrace_location(unsigned long faddr)
return ftrace_location_range(faddr, faddr + 16);
 }
 
-static inline void klp_init_thread_info(struct thread_info *ti)
+static inline void klp_init_thread_info(struct task_struct *p)
 {
+   struct thread_info *ti = task_thread_info(p);
/* + 1 to account for STACK_END_MAGIC */
-   ti->livepatch_sp = (unsigned long *)(ti + 1) + 1;
+   ti->livepatch_sp = end_of_stack(p) + 1;
 }
 #else
-static void klp_init_thread_info(struct thread_info *ti) { }
+static inline void klp_init_thread_info(struct task_struct *p) { }
 #endif /* CONFIG_LIVEPATCH */
 
 #endif /* _ASM_POWERPC_LIVEPATCH_H */
diff --git a/arch/powerpc/include/asm/processor.h 
b/arch/powerpc/include/asm/processor.h
index 692f7383d461..15acb282a876 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -40,7 +40,7 @@
 
 #ifndef __ASSEMBLY__
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -326,7 +326,7 @@ struct thread_struct {
 
 #define INIT_SP(sizeof(init_stack) + (unsigned long) 
_stack)
 #define INIT_SP_LIMIT \
-   (_ALIGN_UP(sizeof(init_thread_info), 16) + (unsigned long) _stack)
+   (_ALIGN_UP(sizeof(struct thread_info), 16) + (unsigned long)_stack)
 
 #ifdef CONFIG_SPE
 #define SPEFSCR_INIT \
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 0d2139a0d5b9..f75eee7b0789 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -1060,7 +1060,7 @@
  * - SPRG9 debug exception scratch
  *
  * All 32-bit:
- * - SPRG3 current thread_info pointer
+ * - SPRG3 current thread_struct physical addr pointer
  *(virtual on BookE, physical on others)
  *
  * 32-bit classic:
diff --git a/arch/powerpc/kernel/asm-offsets.c 
b/arch/powerpc/kernel/asm-offsets.c
index 9ffc72ded73a..b2b52e002a76 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -90,10 +90,10 @@ int main(void)
DEFINE(SIGSEGV, SIGSEGV);
DEFINE(NMI_MASK, NMI_MASK);
 #else
-   OFFSET(THREAD_INFO, task_struct, stack);
DEFINE(THREAD_INFO_GAP, 

[PATCH v11 6/9] powerpc: 'current_set' is now a table of task_struct pointers

2018-12-09 Thread Christophe Leroy
The table of pointers 'current_set' has been used for retrieving
the stack and current. They used to be thread_info pointers as
they were pointing to the stack and current was taken from the
'task' field of the thread_info.

Now, the pointers of 'current_set' table are now both pointers
to task_struct and pointers to thread_info.

As they are used to get current, and the stack pointer is
retrieved from current's stack field, this patch changes
their type to task_struct, and renames secondary_ti to
secondary_current.

Reviewed-by: Nicholas Piggin 
Signed-off-by: Christophe Leroy 
---
 arch/powerpc/include/asm/asm-prototypes.h |  4 ++--
 arch/powerpc/kernel/head_32.S |  6 +++---
 arch/powerpc/kernel/head_44x.S|  4 ++--
 arch/powerpc/kernel/head_fsl_booke.S  |  4 ++--
 arch/powerpc/kernel/smp.c | 10 --
 5 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/include/asm/asm-prototypes.h 
b/arch/powerpc/include/asm/asm-prototypes.h
index 6f201b199c02..f5347fbaf03c 100644
--- a/arch/powerpc/include/asm/asm-prototypes.h
+++ b/arch/powerpc/include/asm/asm-prototypes.h
@@ -23,8 +23,8 @@
 #include 
 
 /* SMP */
-extern struct thread_info *current_set[NR_CPUS];
-extern struct thread_info *secondary_ti;
+extern struct task_struct *current_set[NR_CPUS];
+extern struct task_struct *secondary_current;
 void start_secondary(void *unused);
 
 /* kexec */
diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
index 9dd85af46669..43bff4deca3e 100644
--- a/arch/powerpc/kernel/head_32.S
+++ b/arch/powerpc/kernel/head_32.S
@@ -842,9 +842,9 @@ __secondary_start:
 #endif /* CONFIG_PPC_BOOK3S_32 */
 
/* get current's stack and current */
-   lis r1,secondary_ti@ha
-   tophys(r1,r1)
-   lwz r2,secondary_ti@l(r1)
+   lis r2,secondary_current@ha
+   tophys(r2,r2)
+   lwz r2,secondary_current@l(r2)
tophys(r1,r2)
lwz r1,TASK_STACK(r1)
 
diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index 2c7e90f36358..48e4de4dfd0c 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -1021,8 +1021,8 @@ _GLOBAL(start_secondary_47x)
/* Now we can get our task struct and real stack pointer */
 
/* Get current's stack and current */
-   lis r1,secondary_ti@ha
-   lwz r2,secondary_ti@l(r1)
+   lis r2,secondary_current@ha
+   lwz r2,secondary_current@l(r2)
lwz r1,TASK_STACK(r2)
 
/* Current stack pointer */
diff --git a/arch/powerpc/kernel/head_fsl_booke.S 
b/arch/powerpc/kernel/head_fsl_booke.S
index b8a2b789677e..0d27bfff52dd 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -1076,8 +1076,8 @@ __secondary_start:
bl  call_setup_cpu
 
/* get current's stack and current */
-   lis r1,secondary_ti@ha
-   lwz r2,secondary_ti@l(r1)
+   lis r2,secondary_current@ha
+   lwz r2,secondary_current@l(r2)
lwz r1,TASK_STACK(r2)
 
/* stack */
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index aa4517686f90..a41fa8924004 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -76,7 +76,7 @@
 static DEFINE_PER_CPU(int, cpu_state) = { 0 };
 #endif
 
-struct thread_info *secondary_ti;
+struct task_struct *secondary_current;
 bool has_big_cores;
 
 DEFINE_PER_CPU(cpumask_var_t, cpu_sibling_map);
@@ -664,7 +664,7 @@ void smp_send_stop(void)
 }
 #endif /* CONFIG_NMI_IPI */
 
-struct thread_info *current_set[NR_CPUS];
+struct task_struct *current_set[NR_CPUS];
 
 static void smp_store_cpu_info(int id)
 {
@@ -929,7 +929,7 @@ void smp_prepare_boot_cpu(void)
paca_ptrs[boot_cpuid]->__current = current;
 #endif
set_numa_node(numa_cpu_lookup_table[boot_cpuid]);
-   current_set[boot_cpuid] = task_thread_info(current);
+   current_set[boot_cpuid] = current;
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
@@ -1014,15 +1014,13 @@ static bool secondaries_inhibited(void)
 
 static void cpu_idle_thread_init(unsigned int cpu, struct task_struct *idle)
 {
-   struct thread_info *ti = task_thread_info(idle);
-
 #ifdef CONFIG_PPC64
paca_ptrs[cpu]->__current = idle;
paca_ptrs[cpu]->kstack = (unsigned long)task_stack_page(idle) +
 THREAD_SIZE - STACK_FRAME_OVERHEAD;
 #endif
idle->cpu = cpu;
-   secondary_ti = current_set[cpu] = ti;
+   secondary_current = current_set[cpu] = idle;
 }
 
 int __cpu_up(unsigned int cpu, struct task_struct *tidle)
-- 
2.13.3



[PATCH v10 0/9] powerpc: Switch to CONFIG_THREAD_INFO_IN_TASK

2018-12-09 Thread Christophe Leroy
The purpose of this serie is to activate CONFIG_THREAD_INFO_IN_TASK which
moves the thread_info into task_struct.

Moving thread_info into task_struct has the following advantages:
- It protects thread_info from corruption in the case of stack
overflows.
- Its address is harder to determine if stack addresses are
leaked, making a number of attacks more difficult.

Changes since v10:
 - Rebased on 21622a0d2023 ("Automatic merge of branches 'master', 'next' and 
'fixes' into merge")
  ==> Fixed conflict in setup_32.S

Changes since v9:
 - Rebased on 183cbf93be88 ("Automatic merge of branches 'master', 'next' and 
'fixes' into merge")
  ==> Fixed conflict on xmon

Changes since v8:
 - Rebased on e589b79e40d9 ("Automatic merge of branches 'master', 'next' and 
'fixes' into merge")
  ==> Main impact was conflicts due to commit 9a8dd708d547 ("memblock: rename 
memblock_alloc{_nid,_try_nid} to memblock_phys_alloc*")

Changes since v7:
 - Rebased on fb6c6ce7907d ("Automatic merge of branches 'master', 'next' and 
'fixes' into merge")

Changes since v6:
 - Fixed validate_sp() to exclude NULL sp in 'regain entire stack space' patch 
(early crash with CONFIG_KMEMLEAK)

Changes since v5:
 - Fixed livepatch_sp setup by using end_of_stack() instead of hardcoding
 - Fixed PPC_BPF_LOAD_CPU() macro

Changes since v4:
 - Fixed a build failure on 32bits SMP when include/generated/asm-offsets.h is 
not
 already existing, was due to spaces instead of a tab in the Makefile

Changes since RFC v3: (based on Nick's review)
 - Renamed task_size.h to task_size_user64.h to better relate to what it 
contains.
 - Handling of the isolation of thread_info cpu field inside CONFIG_SMP #ifdefs 
moved to a separate patch.
 - Removed CURRENT_THREAD_INFO macro completely.
 - Added a guard in asm/smp.h to avoid build failure before _TASK_CPU is 
defined.
 - Added a patch at the end to rename 'tp' pointers to 'sp' pointers
 - Renamed 'tp' into 'sp' pointers in preparation patch when relevant
 - Fixed a few commit logs
 - Fixed checkpatch report.

Changes since RFC v2:
 - Removed the modification of names in asm-offsets
 - Created a rule in arch/powerpc/Makefile to append the offset of current->cpu 
in CFLAGS
 - Modified asm/smp.h to use the offset set in CFLAGS
 - Squashed the renaming of THREAD_INFO to TASK_STACK in the preparation patch
 - Moved the modification of current_pt_regs in the patch activating 
CONFIG_THREAD_INFO_IN_TASK

Changes since RFC v1:
 - Removed the first patch which was modifying header inclusion order in timer
 - Modified some names in asm-offsets to avoid conflicts when including 
asm-offsets in C files
 - Modified asm/smp.h to avoid having to include linux/sched.h (using 
asm-offsets instead)
 - Moved some changes from the activation patch to the preparation patch.

Christophe Leroy (9):
  book3s/64: avoid circular header inclusion in mmu-hash.h
  powerpc: Only use task_struct 'cpu' field on SMP
  powerpc: Prepare for moving thread_info into task_struct
  powerpc: Activate CONFIG_THREAD_INFO_IN_TASK
  powerpc: regain entire stack space
  powerpc: 'current_set' is now a table of task_struct pointers
  powerpc/32: Remove CURRENT_THREAD_INFO and rename TI_CPU
  powerpc/64: Remove CURRENT_THREAD_INFO
  powerpc: clean stack pointers naming

 arch/powerpc/Kconfig   |  1 +
 arch/powerpc/Makefile  |  7 +++
 arch/powerpc/include/asm/asm-prototypes.h  |  4 +-
 arch/powerpc/include/asm/book3s/64/mmu-hash.h  |  2 +-
 arch/powerpc/include/asm/exception-64s.h   |  4 +-
 arch/powerpc/include/asm/irq.h | 14 ++---
 arch/powerpc/include/asm/livepatch.h   |  7 ++-
 arch/powerpc/include/asm/processor.h   | 39 +
 arch/powerpc/include/asm/ptrace.h  |  2 +-
 arch/powerpc/include/asm/reg.h |  2 +-
 arch/powerpc/include/asm/smp.h | 17 +-
 arch/powerpc/include/asm/task_size_user64.h| 42 ++
 arch/powerpc/include/asm/thread_info.h | 19 ---
 arch/powerpc/kernel/asm-offsets.c  | 10 ++--
 arch/powerpc/kernel/entry_32.S | 66 --
 arch/powerpc/kernel/entry_64.S | 12 ++--
 arch/powerpc/kernel/epapr_hcalls.S |  5 +-
 arch/powerpc/kernel/exceptions-64e.S   | 13 +
 arch/powerpc/kernel/exceptions-64s.S   |  2 +-
 arch/powerpc/kernel/head_32.S  | 14 ++---
 arch/powerpc/kernel/head_40x.S |  4 +-
 arch/powerpc/kernel/head_44x.S |  8 +--
 arch/powerpc/kernel/head_64.S  |  1 +
 arch/powerpc/kernel/head_8xx.S |  2 +-
 arch/powerpc/kernel/head_booke.h   | 12 +---
 arch/powerpc/kernel/head_fsl_booke.S   | 16 +++---
 arch/powerpc/kernel/idle_6xx.S |  8 +--
 arch/powerpc/kernel/idle_book3e.S  |  2 +-
 arch/powerpc/kernel/idle_e500.S|  8 +--
 

[PATCH v11 1/9] book3s/64: avoid circular header inclusion in mmu-hash.h

2018-12-09 Thread Christophe Leroy
When activating CONFIG_THREAD_INFO_IN_TASK, linux/sched.h
includes asm/current.h. This generates a circular dependency.
To avoid that, asm/processor.h shall not be included in mmu-hash.h

In order to do that, this patch moves into a new header called
asm/task_size_user64.h the information from asm/processor.h required
by mmu-hash.h

Signed-off-by: Christophe Leroy 
Reviewed-by: Nicholas Piggin 
---
 arch/powerpc/include/asm/book3s/64/mmu-hash.h |  2 +-
 arch/powerpc/include/asm/processor.h  | 34 +-
 arch/powerpc/include/asm/task_size_user64.h   | 42 +++
 arch/powerpc/kvm/book3s_hv_hmi.c  |  1 +
 4 files changed, 45 insertions(+), 34 deletions(-)
 create mode 100644 arch/powerpc/include/asm/task_size_user64.h

diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h 
b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
index 12e522807f9f..b2aba048301e 100644
--- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h
+++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
@@ -23,7 +23,7 @@
  */
 #include 
 #include 
-#include 
+#include 
 #include 
 
 /*
diff --git a/arch/powerpc/include/asm/processor.h 
b/arch/powerpc/include/asm/processor.h
index ee58526cb6c2..692f7383d461 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -95,40 +95,8 @@ void release_thread(struct task_struct *);
 #endif
 
 #ifdef CONFIG_PPC64
-/*
- * 64-bit user address space can have multiple limits
- * For now supported values are:
- */
-#define TASK_SIZE_64TB  (0x4000UL)
-#define TASK_SIZE_128TB (0x8000UL)
-#define TASK_SIZE_512TB (0x0002UL)
-#define TASK_SIZE_1PB   (0x0004UL)
-#define TASK_SIZE_2PB   (0x0008UL)
-/*
- * With 52 bits in the address we can support
- * upto 4PB of range.
- */
-#define TASK_SIZE_4PB   (0x0010UL)
 
-/*
- * For now 512TB is only supported with book3s and 64K linux page size.
- */
-#if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_PPC_64K_PAGES)
-/*
- * Max value currently used:
- */
-#define TASK_SIZE_USER64   TASK_SIZE_4PB
-#define DEFAULT_MAP_WINDOW_USER64  TASK_SIZE_128TB
-#define TASK_CONTEXT_SIZE  TASK_SIZE_512TB
-#else
-#define TASK_SIZE_USER64   TASK_SIZE_64TB
-#define DEFAULT_MAP_WINDOW_USER64  TASK_SIZE_64TB
-/*
- * We don't need to allocate extended context ids for 4K page size, because
- * we limit the max effective address on this config to 64TB.
- */
-#define TASK_CONTEXT_SIZE  TASK_SIZE_64TB
-#endif
+#include 
 
 /*
  * 32-bit user address space is 4GB - 1 page
diff --git a/arch/powerpc/include/asm/task_size_user64.h 
b/arch/powerpc/include/asm/task_size_user64.h
new file mode 100644
index ..a4043075864b
--- /dev/null
+++ b/arch/powerpc/include/asm/task_size_user64.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_POWERPC_TASK_SIZE_USER64_H
+#define _ASM_POWERPC_TASK_SIZE_USER64_H
+
+#ifdef CONFIG_PPC64
+/*
+ * 64-bit user address space can have multiple limits
+ * For now supported values are:
+ */
+#define TASK_SIZE_64TB  (0x4000UL)
+#define TASK_SIZE_128TB (0x8000UL)
+#define TASK_SIZE_512TB (0x0002UL)
+#define TASK_SIZE_1PB   (0x0004UL)
+#define TASK_SIZE_2PB   (0x0008UL)
+/*
+ * With 52 bits in the address we can support
+ * upto 4PB of range.
+ */
+#define TASK_SIZE_4PB   (0x0010UL)
+
+/*
+ * For now 512TB is only supported with book3s and 64K linux page size.
+ */
+#if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_PPC_64K_PAGES)
+/*
+ * Max value currently used:
+ */
+#define TASK_SIZE_USER64   TASK_SIZE_4PB
+#define DEFAULT_MAP_WINDOW_USER64  TASK_SIZE_128TB
+#define TASK_CONTEXT_SIZE  TASK_SIZE_512TB
+#else
+#define TASK_SIZE_USER64   TASK_SIZE_64TB
+#define DEFAULT_MAP_WINDOW_USER64  TASK_SIZE_64TB
+/*
+ * We don't need to allocate extended context ids for 4K page size, because
+ * we limit the max effective address on this config to 64TB.
+ */
+#define TASK_CONTEXT_SIZE  TASK_SIZE_64TB
+#endif
+
+#endif /* CONFIG_PPC64 */
+#endif /* _ASM_POWERPC_TASK_SIZE_USER64_H */
diff --git a/arch/powerpc/kvm/book3s_hv_hmi.c b/arch/powerpc/kvm/book3s_hv_hmi.c
index e3f738eb1cac..64b5011475c7 100644
--- a/arch/powerpc/kvm/book3s_hv_hmi.c
+++ b/arch/powerpc/kvm/book3s_hv_hmi.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 void wait_for_subcore_guest_exit(void)
 {
-- 
2.13.3



[PATCH v11 7/9] powerpc/32: Remove CURRENT_THREAD_INFO and rename TI_CPU

2018-12-09 Thread Christophe Leroy
Now that thread_info is similar to task_struct, it's address is in r2
so CURRENT_THREAD_INFO() macro is useless. This patch removes it.

At the same time, as the 'cpu' field is not anymore in thread_info,
this patch renames it to TASK_CPU.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/Makefile  |  2 +-
 arch/powerpc/include/asm/thread_info.h |  2 --
 arch/powerpc/kernel/asm-offsets.c  |  2 +-
 arch/powerpc/kernel/entry_32.S | 43 --
 arch/powerpc/kernel/epapr_hcalls.S |  5 ++--
 arch/powerpc/kernel/head_fsl_booke.S   |  5 ++--
 arch/powerpc/kernel/idle_6xx.S |  8 +++
 arch/powerpc/kernel/idle_e500.S|  8 +++
 arch/powerpc/kernel/misc_32.S  |  3 +--
 arch/powerpc/mm/hash_low_32.S  | 14 ---
 arch/powerpc/sysdev/6xx-suspend.S  |  5 ++--
 11 files changed, 35 insertions(+), 62 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 1135cb0b7e48..ad2fd4ba916f 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -425,7 +425,7 @@ ifdef CONFIG_SMP
 prepare: task_cpu_prepare
 
 task_cpu_prepare: prepare0
-   $(eval KBUILD_CFLAGS += -D_TASK_CPU=$(shell awk '{if ($$2 == "TI_CPU") 
print $$3;}' include/generated/asm-offsets.h))
+   $(eval KBUILD_CFLAGS += -D_TASK_CPU=$(shell awk '{if ($$2 == 
"TASK_CPU") print $$3;}' include/generated/asm-offsets.h))
 endif
 
 # Check toolchain versions:
diff --git a/arch/powerpc/include/asm/thread_info.h 
b/arch/powerpc/include/asm/thread_info.h
index d91523c2c7d8..c959b8d66cac 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -19,8 +19,6 @@
 
 #ifdef CONFIG_PPC64
 #define CURRENT_THREAD_INFO(dest, sp)  stringify_in_c(ld dest, 
PACACURRENT(r13))
-#else
-#define CURRENT_THREAD_INFO(dest, sp)  stringify_in_c(mr dest, r2)
 #endif
 
 #ifndef __ASSEMBLY__
diff --git a/arch/powerpc/kernel/asm-offsets.c 
b/arch/powerpc/kernel/asm-offsets.c
index 94ac190a0b16..03439785c2ea 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -96,7 +96,7 @@ int main(void)
 #endif /* CONFIG_PPC64 */
OFFSET(TASK_STACK, task_struct, stack);
 #ifdef CONFIG_SMP
-   OFFSET(TI_CPU, task_struct, cpu);
+   OFFSET(TASK_CPU, task_struct, cpu);
 #endif
 
 #ifdef CONFIG_LIVEPATCH
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index b547bd4168d8..52a061f14c7d 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -168,8 +168,7 @@ transfer_to_handler:
tophys(r11,r11)
addir11,r11,global_dbcr0@l
 #ifdef CONFIG_SMP
-   CURRENT_THREAD_INFO(r9, r1)
-   lwz r9,TI_CPU(r9)
+   lwz r9,TASK_CPU(r2)
slwir9,r9,3
add r11,r11,r9
 #endif
@@ -180,8 +179,7 @@ transfer_to_handler:
stw r12,4(r11)
 #endif
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
-   CURRENT_THREAD_INFO(r9, r1)
-   tophys(r9, r9)
+   tophys(r9, r2)
ACCOUNT_CPU_USER_ENTRY(r9, r11, r12)
 #endif
 
@@ -195,8 +193,7 @@ transfer_to_handler:
ble-stack_ovf   /* then the kernel stack overflowed */
 5:
 #if defined(CONFIG_PPC_BOOK3S_32) || defined(CONFIG_E500)
-   CURRENT_THREAD_INFO(r9, r1)
-   tophys(r9,r9)   /* check local flags */
+   tophys(r9,r2)   /* check local flags */
lwz r12,TI_LOCAL_FLAGS(r9)
mtcrf   0x01,r12
bt- 31-TLF_NAPPING,4f
@@ -345,8 +342,7 @@ _GLOBAL(DoSyscall)
mtmsr   r11
 1:
 #endif /* CONFIG_TRACE_IRQFLAGS */
-   CURRENT_THREAD_INFO(r10, r1)
-   lwz r11,TI_FLAGS(r10)
+   lwz r11,TI_FLAGS(r2)
andi.   r11,r11,_TIF_SYSCALL_DOTRACE
bne-syscall_dotrace
 syscall_dotrace_cont:
@@ -379,13 +375,12 @@ ret_from_syscall:
lwz r3,GPR3(r1)
 #endif
mr  r6,r3
-   CURRENT_THREAD_INFO(r12, r1)
/* disable interrupts so current_thread_info()->flags can't change */
LOAD_MSR_KERNEL(r10,MSR_KERNEL) /* doesn't include MSR_EE */
/* Note: We don't bother telling lockdep about it */
SYNC
MTMSRD(r10)
-   lwz r9,TI_FLAGS(r12)
+   lwz r9,TI_FLAGS(r2)
li  r8,-MAX_ERRNO
andi.   
r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK)
bne-syscall_exit_work
@@ -432,8 +427,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRED_STWCX)
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
andi.   r4,r8,MSR_PR
beq 3f
-   CURRENT_THREAD_INFO(r4, r1)
-   ACCOUNT_CPU_USER_EXIT(r4, r5, r7)
+   ACCOUNT_CPU_USER_EXIT(r2, r5, r7)
 3:
 #endif
lwz r4,_LINK(r1)
@@ -526,7 +520,7 @@ syscall_exit_work:
/* Clear per-syscall TIF flags if any are set.  */
 
li  r11,_TIF_PERSYSCALL_MASK
-   addir12,r12,TI_FLAGS
+   addir12,r2,TI_FLAGS
 3: lwarx   

[PATCH V2] iio: magnetometer: mag3110: add optional vdd/vddio regulator operation support

2018-12-09 Thread Anson Huang
The magnetometer's power supply could be controlled by regulator
on some platforms, such as i.MX6Q-SABRESD board, the mag3110's
power supply is controlled by a GPIO fixed regulator, need to make
sure the regulator is enabled before any communication with mag3110,
this patch adds optional vdd/vddio regulator operation support.

Signed-off-by: Anson Huang 
---
ChangeLog since V1:
- Add defer_probe check if the return value from 
devm_regulator_get_optional is ERR_PTR(-EPROBE_DEFER);
- Replace the "vcc" with "vdd" according to datasheet, and add optional 
"vddio" supply as well since
  mag3110 also has a vddio power supply.
---
 drivers/iio/magnetometer/mag3110.c | 77 +++---
 1 file changed, 71 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/magnetometer/mag3110.c 
b/drivers/iio/magnetometer/mag3110.c
index f063355..6308b7f 100644
--- a/drivers/iio/magnetometer/mag3110.c
+++ b/drivers/iio/magnetometer/mag3110.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define MAG3110_STATUS 0x00
 #define MAG3110_OUT_X 0x01 /* MSB first */
@@ -56,6 +57,8 @@ struct mag3110_data {
struct mutex lock;
u8 ctrl_reg1;
int sleep_val;
+   struct regulator *vdd_reg;
+   struct regulator *vddio_reg;
 };
 
 static int mag3110_request(struct mag3110_data *data)
@@ -469,17 +472,40 @@ static int mag3110_probe(struct i2c_client *client,
struct iio_dev *indio_dev;
int ret;
 
+   indio_dev = devm_iio_device_alloc(>dev, sizeof(*data));
+   if (!indio_dev)
+   return -ENOMEM;
+
+   data = iio_priv(indio_dev);
+
+   data->vdd_reg = devm_regulator_get_optional(>dev, "vdd");
+   if (!IS_ERR(data->vdd_reg)) {
+   ret = regulator_enable(data->vdd_reg);
+   if (ret) {
+   dev_err(>dev, "failed to enable VDD 
regulator\n");
+   return ret;
+   }
+   } else if (data->vdd_reg == ERR_PTR(-EPROBE_DEFER)) {
+   return -EPROBE_DEFER;
+   }
+
+   data->vddio_reg = devm_regulator_get_optional(>dev, "vddio");
+   if (!IS_ERR(data->vddio_reg)) {
+   ret = regulator_enable(data->vddio_reg);
+   if (ret) {
+   dev_err(>dev, "failed to enable VDDIO 
regulator\n");
+   return ret;
+   }
+   } else if (data->vddio_reg == ERR_PTR(-EPROBE_DEFER)) {
+   return -EPROBE_DEFER;
+   }
+
ret = i2c_smbus_read_byte_data(client, MAG3110_WHO_AM_I);
if (ret < 0)
return ret;
if (ret != MAG3110_DEVICE_ID)
return -ENODEV;
 
-   indio_dev = devm_iio_device_alloc(>dev, sizeof(*data));
-   if (!indio_dev)
-   return -ENOMEM;
-
-   data = iio_priv(indio_dev);
data->client = client;
mutex_init(>lock);
 
@@ -537,14 +563,53 @@ static int mag3110_remove(struct i2c_client *client)
 #ifdef CONFIG_PM_SLEEP
 static int mag3110_suspend(struct device *dev)
 {
-   return mag3110_standby(iio_priv(i2c_get_clientdata(
+   struct mag3110_data *data = iio_priv(i2c_get_clientdata(
+   to_i2c_client(dev)));
+   int ret;
+
+   ret = mag3110_standby(iio_priv(i2c_get_clientdata(
to_i2c_client(dev;
+   if (ret)
+   return ret;
+
+   if (!IS_ERR(data->vdd_reg)) {
+   ret = regulator_disable(data->vdd_reg);
+   if (ret) {
+   dev_err(dev, "failed to disable VDD regulator\n");
+   return ret;
+   }
+   }
+   if (!IS_ERR(data->vddio_reg)) {
+   ret = regulator_disable(data->vddio_reg);
+   if (ret) {
+   dev_err(dev, "failed to disable VDDIO regulator\n");
+   return ret;
+   }
+   }
+
+   return 0;
 }
 
 static int mag3110_resume(struct device *dev)
 {
struct mag3110_data *data = iio_priv(i2c_get_clientdata(
to_i2c_client(dev)));
+   int ret;
+
+   if (!IS_ERR(data->vdd_reg)) {
+   ret = regulator_enable(data->vdd_reg);
+   if (ret) {
+   dev_err(dev, "failed to enable VDD regulator\n");
+   return ret;
+   }
+   }
+   if (!IS_ERR(data->vddio_reg)) {
+   ret = regulator_enable(data->vddio_reg);
+   if (ret) {
+   dev_err(dev, "failed to enable VDDIO regulator\n");
+   return ret;
+   }
+   }
 
return i2c_smbus_write_byte_data(data->client, MAG3110_CTRL_REG1,
data->ctrl_reg1);
-- 
2.7.4



Re: [PATCH -next] input: keyboard: remove duplicated include from mtk-pmic-keys.c

2018-12-09 Thread YueHaibing
On 2018/12/10 14:15, Lee Jones wrote:
> On Sun, 09 Dec 2018, YueHaibing wrote:
> 
>> Remove duplicated include.
>>
>> Signed-off-by: YueHaibing 
>> ---
>>  drivers/input/keyboard/mtk-pmic-keys.c | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> diff --git a/drivers/input/keyboard/mtk-pmic-keys.c 
>> b/drivers/input/keyboard/mtk-pmic-keys.c
>> index 02c67a1..5027ebb 100644
>> --- a/drivers/input/keyboard/mtk-pmic-keys.c
>> +++ b/drivers/input/keyboard/mtk-pmic-keys.c
>> @@ -19,7 +19,6 @@
>>  #include 
>>  #include 
>>  #include 
>> -#include 
>>  #include 
>>  #include 
>>  #include 
> 
> You are removing the wrong one.

No, linux/kernel.h is a duplicated include indeed.

> 
> Please convert this patch's main intent to alphabetise the header
> files.  Then you can remove any obvious duplicates.

I can alphabetize it in v2 if need be.

> 



[PATCH V3 2/2] iio: light: isl29018: add optional vdd/vdda regulator operation support

2018-12-09 Thread Anson Huang
The light sensor's power supply could be controlled by regulator
on some platforms, such as i.MX6Q-SABRESD board, the light sensor
isl29023's power supply is controlled by a GPIO fixed regulator,
need to make sure the regulator is enabled before any operation of
sensor, this patch adds optional vdd/vdda regulator operation support.

Signed-off-by: Anson Huang 
---
ChangeLog since V2:
- Add defer_probe check if the return value from 
devm_regulator_get_optional is ERR_PTR(-EPROBE_DEFER);
- Replace the "vcc" with "vdd" according to datasheet, and add optional 
"vdda" supply as well since
  isl29018 also has a vdda supply.
---
 drivers/iio/light/isl29018.c | 59 
 1 file changed, 59 insertions(+)

diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c
index b45400f..477eb95 100644
--- a/drivers/iio/light/isl29018.c
+++ b/drivers/iio/light/isl29018.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -95,6 +96,8 @@ struct isl29018_chip {
struct isl29018_scale   scale;
int prox_scheme;
boolsuspended;
+   struct regulator*vdd_reg;
+   struct regulator*vdda_reg;
 };
 
 static int isl29018_set_integration_time(struct isl29018_chip *chip,
@@ -735,6 +738,28 @@ static int isl29018_probe(struct i2c_client *client,
 
mutex_init(>lock);
 
+   chip->vdd_reg = devm_regulator_get_optional(>dev, "vdd");
+   if (!IS_ERR(chip->vdd_reg)) {
+   err = regulator_enable(chip->vdd_reg);
+   if (err) {
+   dev_err(>dev, "failed to enable VDD 
regulator\n");
+   return err;
+   }
+   } else if (chip->vdd_reg == ERR_PTR(-EPROBE_DEFER)) {
+   return -EPROBE_DEFER;
+   }
+
+   chip->vdda_reg = devm_regulator_get_optional(>dev, "vdda");
+   if (!IS_ERR(chip->vdda_reg)) {
+   err = regulator_enable(chip->vdda_reg);
+   if (err) {
+   dev_err(>dev, "failed to enable VDDA 
regulator\n");
+   return err;
+   }
+   } else if (chip->vdda_reg == ERR_PTR(-EPROBE_DEFER)) {
+   return -EPROBE_DEFER;
+   }
+
chip->type = dev_id;
chip->calibscale = 1;
chip->ucalibscale = 0;
@@ -768,6 +793,7 @@ static int isl29018_probe(struct i2c_client *client,
 static int isl29018_suspend(struct device *dev)
 {
struct isl29018_chip *chip = iio_priv(dev_get_drvdata(dev));
+   int ret;
 
mutex_lock(>lock);
 
@@ -777,6 +803,22 @@ static int isl29018_suspend(struct device *dev)
 * So we do not have much to do here.
 */
chip->suspended = true;
+   if (!IS_ERR(chip->vdd_reg)) {
+   ret = regulator_disable(chip->vdd_reg);
+   if (ret) {
+   dev_err(dev, "failed to disable VDD regulator\n");
+   mutex_unlock(>lock);
+   return ret;
+   }
+   }
+   if (!IS_ERR(chip->vdda_reg)) {
+   ret = regulator_disable(chip->vdda_reg);
+   if (ret) {
+   dev_err(dev, "failed to disable VDDA regulator\n");
+   mutex_unlock(>lock);
+   return ret;
+   }
+   }
 
mutex_unlock(>lock);
 
@@ -790,6 +832,23 @@ static int isl29018_resume(struct device *dev)
 
mutex_lock(>lock);
 
+   if (!IS_ERR(chip->vdd_reg)) {
+   err = regulator_enable(chip->vdd_reg);
+   if (err) {
+   dev_err(dev, "failed to enable VDD regulator\n");
+   mutex_unlock(>lock);
+   return err;
+   }
+   }
+   if (!IS_ERR(chip->vdda_reg)) {
+   err = regulator_enable(chip->vdda_reg);
+   if (err) {
+   dev_err(dev, "failed to enable VDDA regulator\n");
+   mutex_unlock(>lock);
+   return err;
+   }
+   }
+
err = isl29018_chip_init(chip);
if (!err)
chip->suspended = false;
-- 
2.7.4



[PATCH V3 1/2] dt-bindings: iio: light: isl29018: update power supply name

2018-12-09 Thread Anson Huang
According to datasheet, the isl29018 has "vddd/vdda" power
supply, and isl29023/isl29035 ONLY has "vdd" power supply,
update the power supply name with "vdd" and "vdda" according
to datasheet to cover all devices and avoid confusion.

Signed-off-by: Anson Huang 
---
 Documentation/devicetree/bindings/iio/light/isl29018.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/iio/light/isl29018.txt 
b/Documentation/devicetree/bindings/iio/light/isl29018.txt
index b9bbde3..36f737d 100644
--- a/Documentation/devicetree/bindings/iio/light/isl29018.txt
+++ b/Documentation/devicetree/bindings/iio/light/isl29018.txt
@@ -15,7 +15,9 @@ Optional properties:
   Refer to interrupt-controller/interrupts.txt for generic interrupt client
   node bindings.
 
-  - vcc-supply: phandle to the regulator that provides power to the sensor.
+  - vdd-supply: phandle to the regulator that provides vdd power to the sensor.
+
+  - vdda-supply: phandle to the regulator that provides vdda power to the 
sensor.
 
 Example:
 
-- 
2.7.4



Re: linux-next: manual merge of the scsi-mkp tree with Linus' tree

2018-12-09 Thread Stephen Rothwell
Hi all,

On Mon, 10 Dec 2018 17:17:16 +1100 Stephen Rothwell  
wrote:
>
> I fixed it up (see below) and can carry the fix as necessary. This

See below :-)

Also I accidentally left the declaration of "status" in 
__qla2x00_abort_all_cmds().
-- 
Cheers,
Stephen Rothwell

diff --cc drivers/scsi/qla2xxx/qla_os.c
index f92196ec5489,643cd7c0efc1..
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@@ -1742,6 -1746,41 +1742,49 @@@ qla2x00_loop_reset(scsi_qla_host_t *vha
return QLA_SUCCESS;
  }
  
+ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res,
+ unsigned long *flags)
+   __releases(qp->qp_lock_ptr)
+   __acquires(qp->qp_lock_ptr)
+ {
+   scsi_qla_host_t *vha = qp->vha;
+   struct qla_hw_data *ha = vha->hw;
+ 
+   if (sp->type == SRB_NVME_CMD || sp->type == SRB_NVME_LS) {
+   if (!sp_get(sp)) {
+   /* got sp */
+   spin_unlock_irqrestore(qp->qp_lock_ptr, *flags);
+   qla_nvme_abort(ha, sp, res);
+   spin_lock_irqsave(qp->qp_lock_ptr, *flags);
+   }
+   } else if (GET_CMD_SP(sp) && !ha->flags.eeh_busy &&
+  !test_bit(ABORT_ISP_ACTIVE, >dpc_flags) &&
+  !qla2x00_isp_reg_stat(ha) && sp->type == SRB_SCSI_CMD) {
+   /*
+* Don't abort commands in adapter during EEH recovery as it's
+* not accessible/responding.
+*
+* Get a reference to the sp and drop the lock. The reference
+* ensures this sp->done() call and not the call in
+* qla2xxx_eh_abort() ends the SCSI cmd (with result 'res').
+*/
+   if (!sp_get(sp)) {
++  int status;
++
+   spin_unlock_irqrestore(qp->qp_lock_ptr, *flags);
 -  qla2xxx_eh_abort(GET_CMD_SP(sp));
++  status = qla2xxx_eh_abort(GET_CMD_SP(sp));
+   spin_lock_irqsave(qp->qp_lock_ptr, *flags);
++  /*
++   * Get rid of extra reference causedby early
++   * exit from qla2xxx_eh_abort
++   */
++  if (status == FAST_IO_FAIL)
++  atomic_dec(>ref_count);
+   }
+   }
+   sp->done(sp, res);
+ }
+ 
  static void
  __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res)
  {


pgpuKvgfth6uJ.pgp
Description: OpenPGP digital signature


Re: [PATCH v8 1/2] mfd: axp20x: Re-align mfd cell entries

2018-12-09 Thread Lee Jones
On Mon, 10 Dec 2018, Oskari Lemmelä wrote:
> On 10.12.2018 8.36, Lee Jones wrote:
> > On Sat, 08 Dec 2018, Oskari Lemmela wrote:
> >
> >> From: Chen-Yu Tsai 
> >>
> >> In the axp20x driver, the various mfd_cell lists had varying amounts
> >> of indentation, sometimes even within the same list. For the axp288,
> >> there's no alignment at all.
> >>
> >> Re-align the right hand side of the assignments with the least amount
> >> of tabs possible. Also collapse the closing bracket and the opening
> >> bracket of the next entry onto the same line for the axp288, to be
> >> consistent with all the other mfd_cell lists.
> >>
> >> This patch is whitespace change only. No functionality is modified.
> >>
> >> Signed-off-by: Chen-Yu Tsai 
> >> Signed-off-by: Oskari Lemmela 
> > Why is Oskari Lemmela's SoB here?
> >
> > You both authored this alignment patch?
> I picked up Chen-Yu's patch from
> https://github.com/wens/linux/commit/b99cec26bae2835a0374463570ea9ea26b034afa.
> I should have mentioned it cover letter.
> 
> Chen-Yu is correct author. I'm just sending his patch.

That's fine.  Thanks for the explanation.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH v8 2/2] mfd: axp20x: Add supported cells for AXP803

2018-12-09 Thread Lee Jones
On Mon, 10 Dec 2018, Chen-Yu Tsai wrote:

> On Mon, Dec 10, 2018 at 2:35 PM Lee Jones  wrote:
> >
> > On Sat, 08 Dec 2018, Oskari Lemmela wrote:
> >
> > > Parts of the AXP803 are compatible with their counterparts on the AXP813.
> > > These include the GPIO, ADC, AC and battery power supplies.
> > >
> > > Signed-off-by: Oskari Lemmela 
> > > Reviewed-by: Chen-Yu Tsai 
> > > Tested-by: Vasily Khoruzhick 
> > > Signed-off-by: Chen-Yu Tsai 
> >
> > I'm happy to fix this, but ...
> >
> > Can you explain these tags for me please?
> >
> > Specifically the last one.
> >
> > Why does Chen-Yu Tsai have an SoB there?
> 
> I picked his patch to rebase off the previous one, and reworked the ordering.
> I then pushed it onto GitHub [1], but didn't get around to sending it to the
> mailing lists. Oskari said on IRC that he would handle it.
> 
> I'm not sure what would be appropriate here though? Oskari's first SoB should
> be kept, since he's the original author. Maybe he should've added his SoB
> again as the final entry? Either way I suppose it would be confusing without
> any explanation.

Yes, I agree, but thanks for taking the time to do so.

Let's leave it as it is.

> [1] 
> https://github.com/wens/linux/commit/951afe2dc32086174ab07a1a997d748f69bf5bf2
> [2] https://freenode.irclog.whitequark.org/linux-sunxi/2018-12-08#23644905;

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


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

2018-12-09 Thread Stephen Rothwell
Hi Linus,

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

ERROR: "irq_chip_retrigger_hierarchy" [drivers/gpio/gpio-lpc18xx.ko] undefined!

Caused by commit

  5ddabfe8d3de ("gpio: lpc18xx: add GPIO pin interrupt controller support")

I have used the gpio tree from next-20181207 for today.

-- 
Cheers,
Stephen Rothwell


pgpSYKqUD6wsp.pgp
Description: OpenPGP digital signature


RE: rcu_preempt caused oom

2018-12-09 Thread He, Bo
Hi, 
   We have start the test with the CONFIG_PROVE_RCU=y, and also add one 2s to 
detect the preempt rcu hang, hope we can get more useful logs tomorrow.
   I also enclosed the config and the debug patches for you review.

-Original Message-
From: Paul E. McKenney  
Sent: Monday, December 10, 2018 3:56 AM
To: He, Bo 
Cc: Steven Rostedt ; linux-kernel@vger.kernel.org; 
j...@joshtriplett.org; mathieu.desnoy...@efficios.com; jiangshan...@gmail.com; 
Zhang, Jun ; Xiao, Jin ; Zhang, Yanmin 
; Bai, Jie A 
Subject: Re: rcu_preempt caused oom

On Fri, Dec 07, 2018 at 06:11:31AM -0800, Paul E. McKenney wrote:
> On Fri, Dec 07, 2018 at 08:25:09AM +, He, Bo wrote:
> > Bad news,  the issue is still reproduced after 61 Hours monkey test on 1/6 
> > boards with the CONFIG_RCU_BOOST=y, and the issue is not seen on kernel 
> > 4.14, the CONFIG_RCU_BOOST is also not enabled in our kernel 4.14 config.
> > Here enclosed is the logs.
> > 
> > > So the question becomes "Why is the grace-period kthread being awakened 
> > > so many times, but not actually waking up?"  
> > maybe it's not schedule issue, I have two suspects:
> > we can see tons of grace_period with 117392312: 
> >  [219346.919405, 0] showmap-31232 [000] d..1 219346.136035: 
> > rcu_future_grace_period: rcu_preempt 117392312 117392316 0 0 3 
> > Startleaf  [219346.919417, 0] showmap-31232 [000] d..1 
> > 219346.136036: rcu_future_grace_period: rcu_preempt 117392312 
> > 117392316 0 0 3 Prestarted  [219346.919429, 0] showmap-31232 [000] 
> > d..1 219346.136036: rcu_grace_period: rcu_preempt 117392312 
> > AccWaitCB
> > 
> > "Startleaf" means start the grace period, "Prestarted" means the grace 
> > period is already started or other conditions blocked, RCU_GP_FLAG_INIT 
> > should follow the "Startedroot", then the kthread can be wakeup.
> 
> Yes, when "Startleaf" is followed by "Prestarted", that means that we 
> reached an rcu_node structure that is already aware that the requested 
> grace period is needed.  Breaking down the relevant "if" statement in
> rcu_start_this_gp():
> 
>   if (ULONG_CMP_GE(rnp->gp_seq_needed, gp_seq_req) ||
>   // A.  GP already requested at this rcu_node
>   rcu_seq_started(>gp_seq, gp_seq_req) ||
>   // B.  The requested grace period already started
>   (rnp != rnp_start &&
>rcu_seq_state(rcu_seq_current(>gp_seq {
>   // C.  Leaf rcu_node recorded request, and
>   // some grace period is in progress
> 
> A:In this case, the "Startedroot" should be taken care of by some
>   other thread, or one of B or C held earlier.
> 
> B:This cannot be the case, because your earlier trace showed that
>   the requested grace period had not started.
> 
> C:This cannot be the case because both traces above are on the
>   leaf rcu_node structure.  If it were the case, the currently
>   running grace period would notice the need for the requested
>   grace period when it ended, and would start the grace period
>   at that time.
> 
> So you are saying that your trace goes back far enough to capture the 
> very first "Startleaf" for this new grace period, and you don't ever 
> see a "Startedroot"?  This would be OK if the later "Startedleaf" 
> showed up at that point.  If you do have such a trace, could you 
> please send it to me (or post it somewhere and send me the URL)?
> 
> In any case, this code has bee reworked recently, so I will take a 
> closer look, which will take some time.  Please feel free to continue 
> to do so as well, of course!

Hmmm...  Could you please build with CONFIG_PROVE_RCU=y and run the original 
(for example, CONFIG_RCU_BOOST=n)?  I would expect this to trigger the warning 
in rcu_check_gp_start_stall().  Of course, if it does not trigger, that would 
be valuable information as well.

Thanx, Paul

> > I do experiment to dump the backtrace, the rcu_quiescent_state_report is 
> > called in softirq context:
> > -0 [000] dNs2 24471.669280: rcu_quiescent_state_report: 
> > rcu_preempt 3562401 1>0 0 0 3 0
> >   -0 [000] dNs2 24471.669293: 
> >  => rcu_report_qs_rnp+0x1e2/0x2a0
> >  => rcu_process_callbacks+0x2f1/0x3c0  => __do_softirq+0x12a/0x386  
> > => irq_exit+0xb1/0xc0  => smp_apic_timer_interrupt+0xd4/0x1e0
> >  => apic_timer_interrupt+0xf/0x20
> >  => cpuidle_enter_state+0xb1/0x340
> >  => cpuidle_enter+0x17/0x20
> >  => call_cpuidle+0x23/0x40
> >  => do_idle+0x1ed/0x250
> >  => cpu_startup_entry+0x73/0x80
> >  => rest_init+0xf3/0x100
> >  => start_kernel+0x46f/0x490
> >  => x86_64_start_reservations+0x2a/0x2c
> >  => x86_64_start_kernel+0x72/0x75
> >  => secondary_startup_64+0xa4/0xb0
> > rcu_report_qs_rnp=>rcu_report_qs_rdp
> > 
> > and in the rcu_report_qs_rdp(), rcu_report_qs_rnp is follow the 
> > rcu_accelerate_cbs, we can see AccWaitCB 

Re: [PATCH v8 1/2] mfd: axp20x: Re-align mfd cell entries

2018-12-09 Thread Oskari Lemmelä
Hi Lee,

On 10.12.2018 8.36, Lee Jones wrote:
> On Sat, 08 Dec 2018, Oskari Lemmela wrote:
>
>> From: Chen-Yu Tsai 
>>
>> In the axp20x driver, the various mfd_cell lists had varying amounts
>> of indentation, sometimes even within the same list. For the axp288,
>> there's no alignment at all.
>>
>> Re-align the right hand side of the assignments with the least amount
>> of tabs possible. Also collapse the closing bracket and the opening
>> bracket of the next entry onto the same line for the axp288, to be
>> consistent with all the other mfd_cell lists.
>>
>> This patch is whitespace change only. No functionality is modified.
>>
>> Signed-off-by: Chen-Yu Tsai 
>> Signed-off-by: Oskari Lemmela 
> Why is Oskari Lemmela's SoB here?
>
> You both authored this alignment patch?
I picked up Chen-Yu's patch from
https://github.com/wens/linux/commit/b99cec26bae2835a0374463570ea9ea26b034afa.
I should have mentioned it cover letter.

Chen-Yu is correct author. I'm just sending his patch.

>
>> ---
>>  drivers/mfd/axp20x.c | 107 +--
>>  1 file changed, 51 insertions(+), 56 deletions(-)
>>
>> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
>> index dfc3cff1d08b..8037b4e01ed6 100644
>> --- a/drivers/mfd/axp20x.c
>> +++ b/drivers/mfd/axp20x.c
>> @@ -640,9 +640,9 @@ static const struct mfd_cell axp221_cells[] = {
>>  
>>  static const struct mfd_cell axp223_cells[] = {
>>  {
>> -.name   = "axp221-pek",
>> -.num_resources  = ARRAY_SIZE(axp22x_pek_resources),
>> -.resources  = axp22x_pek_resources,
>> +.name   = "axp221-pek",
>> +.num_resources  = ARRAY_SIZE(axp22x_pek_resources),
>> +.resources  = axp22x_pek_resources,
>>  }, {
>>  .name   = "axp22x-adc",
>>  .of_compatible  = "x-powers,axp221-adc",
>> @@ -650,7 +650,7 @@ static const struct mfd_cell axp223_cells[] = {
>>  .name   = "axp20x-battery-power-supply",
>>  .of_compatible  = "x-powers,axp221-battery-power-supply",
>>  }, {
>> -.name   = "axp20x-regulator",
>> +.name   = "axp20x-regulator",
>>  }, {
>>  .name   = "axp20x-ac-power-supply",
>>  .of_compatible  = "x-powers,axp221-ac-power-supply",
>> @@ -666,9 +666,9 @@ static const struct mfd_cell axp223_cells[] = {
>>  
>>  static const struct mfd_cell axp152_cells[] = {
>>  {
>> -.name   = "axp20x-pek",
>> -.num_resources  = ARRAY_SIZE(axp152_pek_resources),
>> -.resources  = axp152_pek_resources,
>> +.name   = "axp20x-pek",
>> +.num_resources  = ARRAY_SIZE(axp152_pek_resources),
>> +.resources  = axp152_pek_resources,
>>  },
>>  };
>>  
>> @@ -697,84 +697,79 @@ static const struct resource 
>> axp288_charger_resources[] = {
>>  
>>  static const struct mfd_cell axp288_cells[] = {
>>  {
>> -.name = "axp288_adc",
>> -.num_resources = ARRAY_SIZE(axp288_adc_resources),
>> -.resources = axp288_adc_resources,
>> -},
>> -{
>> -.name = "axp288_extcon",
>> -.num_resources = ARRAY_SIZE(axp288_extcon_resources),
>> -.resources = axp288_extcon_resources,
>> -},
>> -{
>> -.name = "axp288_charger",
>> -.num_resources = ARRAY_SIZE(axp288_charger_resources),
>> -.resources = axp288_charger_resources,
>> -},
>> -{
>> -.name = "axp288_fuel_gauge",
>> -.num_resources = ARRAY_SIZE(axp288_fuel_gauge_resources),
>> -.resources = axp288_fuel_gauge_resources,
>> -},
>> -{
>> -.name = "axp221-pek",
>> -.num_resources = ARRAY_SIZE(axp288_power_button_resources),
>> -.resources = axp288_power_button_resources,
>> -},
>> -{
>> -.name = "axp288_pmic_acpi",
>> +.name   = "axp288_adc",
>> +.num_resources  = ARRAY_SIZE(axp288_adc_resources),
>> +.resources  = axp288_adc_resources,
>> +}, {
>> +.name   = "axp288_extcon",
>> +.num_resources  = ARRAY_SIZE(axp288_extcon_resources),
>> +.resources  = axp288_extcon_resources,
>> +}, {
>> +.name   = "axp288_charger",
>> +.num_resources  = ARRAY_SIZE(axp288_charger_resources),
>> +.resources  = axp288_charger_resources,
>> +}, {
>> +.name   = "axp288_fuel_gauge",
>> +.num_resources  = ARRAY_SIZE(axp288_fuel_gauge_resources),
>> +.resources  = axp288_fuel_gauge_resources,
>> +}, {
>> +.name   = "axp221-pek",
>> +.num_resources  = ARRAY_SIZE(axp288_power_button_resources),
>> +   

RE: [PATCH v7 09/10] usb: dwc3: Check for IOC/LST bit in both event->status and TRB->ctrl fields

2018-12-09 Thread Felipe Balbi

Hi,

Anurag Kumar Vulisha  writes:
> HI Felipe,
>
>>-Original Message-
>>From: Felipe Balbi [mailto:ba...@kernel.org]
>>Sent: Friday, December 07, 2018 11:42 AM
>>To: Anurag Kumar Vulisha ; Greg Kroah-Hartman
>>; Shuah Khan ; Alan Stern
>>; Johan Hovold ; Jaejoong Kim
>>; Benjamin Herrenschmidt ;
>>Roger Quadros ; Manu Gautam ;
>>martin.peter...@oracle.com; Bart Van Assche ; Mike
>>Christie ; Matthew Wilcox ; Colin 
>>Ian
>>King 
>>Cc: linux-...@vger.kernel.org; linux-kernel@vger.kernel.org;
>>v.anuragku...@gmail.com; Thinh Nguyen ; Tejas Joglekar
>>; Ajay Yugalkishore Pandey 
>>Subject: RE: [PATCH v7 09/10] usb: dwc3: Check for IOC/LST bit in both 
>>event->status
>>and TRB->ctrl fields
>>
>>
>>Hi,
>>
>>Anurag Kumar Vulisha  writes:
> @@ -2286,7 +2286,12 @@ static int
dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
>   if (event->status & DEPEVT_STATUS_SHORT && !chain)
>   return 1;
>
> - if (event->status & (DEPEVT_STATUS_IOC | DEPEVT_STATUS_LST))
> + if ((event->status & DEPEVT_STATUS_IOC) &&
> + (trb->ctrl & DWC3_TRB_CTRL_IOC))
> + return 1;

this shouldn't be necessary. According to databook, event->status
contains the bits from the completed TRB.  Which means that
event->status & IOC will always be equal to trb->ctrl & IOC.

>>> Thanks for reviewing this patch. Lets consider an example where a
>>> request has num_sgs > 0 and each sg is mapped to a TRB and the last
>>> TRB has the IOC bit set. Once the controller is done with the
>>> transfer, it  generates XferInProgress for the last TRB (since IOC bit
>>> is set). As a part of trb reclaim process
>>> dwc3_gadget_ep_reclaim_trb_sg() calls
>>> dwc3_gadget_ep_reclaim_completed_trb() for req->num_sgs times. Since
>>> the event already has the IOC bit set, the loop is exited from the
>>> loop at the very first TRB and the remaining TRBs (mapped to the sglist) 
>>> are left
>>unhandled.
>>> To avoid this we modified the code to exit only if both TRB & event
>>> has the IOC bit set.
>>
>>Seems like IOC case should just test for chain flag as well:
>>
>
> Okay. Along with this logic the code for updating chain bit should also be 
> modified I guess.

not really

> Since the IOC bit is also set when there are not enough TRBs available, the 
> code should be
> modified to not set DWC3_TRB_CTRL_CHN bit when the IOC bit is set. I will 
> update below
> changes along with your suggestions and resend the patches.

no. Actually I don't think we're allowed to split a scatter/gather like
that. I did that quite a while ago, but I don't think we're allowed to
do so. What we should do, in that case, is not even queue that request
until we have enough for all members of the scatter/gather. But that's a
separate patch, anyway.

-- 
balbi


signature.asc
Description: PGP signature


[PATCH] userfaultfd: clear flag if remap event not enabled

2018-12-09 Thread Peter Xu
When the process being tracked do mremap() without
UFFD_FEATURE_EVENT_REMAP on the corresponding tracking uffd file
handle, we should not generate the remap event, and at the same
time we should clear all the uffd flags on the new VMA.  Without
this patch, we can still have the VM_UFFD_MISSING|VM_UFFD_WP
flags on the new VMA even the fault handling process does not
even know the existance of the VMA.

CC: Andrea Arcangeli 
CC: Andrew Morton 
CC: Mike Rapoport 
CC: Kirill A. Shutemov 
CC: Hugh Dickins 
CC: Pavel Emelyanov 
CC: Pravin Shedge 
CC: linux...@kvack.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Peter Xu 
---
 fs/userfaultfd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index cd58939dc977..798ae8a438ff 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -740,6 +740,9 @@ void mremap_userfaultfd_prep(struct vm_area_struct *vma,
vm_ctx->ctx = ctx;
userfaultfd_ctx_get(ctx);
WRITE_ONCE(ctx->mmap_changing, true);
+   } else if (ctx) {
+   vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
+   vma->vm_flags &= ~(VM_UFFD_WP | VM_UFFD_MISSING);
}
 }
 
-- 
2.17.1



[PATCH v3] powerpc/uaccess: fix warning/error with access_ok()

2018-12-09 Thread Christophe Leroy
With the following piece of code, the following compilation warning
is encountered:

if (_IOC_DIR(ioc) != _IOC_NONE) {
int verify = _IOC_DIR(ioc) & _IOC_READ ? VERIFY_WRITE : 
VERIFY_READ;

if (!access_ok(verify, ioarg, _IOC_SIZE(ioc))) {

drivers/platform/test/dev.c: In function 'my_ioctl':
drivers/platform/test/dev.c:219:7: warning: unused variable 'verify' 
[-Wunused-variable]
   int verify = _IOC_DIR(ioc) & _IOC_READ ? VERIFY_WRITE : VERIFY_READ;

This patch fixes it by referencing 'type' in the macro allthough
doing nothing with it.

Signed-off-by: Christophe Leroy 
---
 v3: not changing __access_ok() anymyre, only referencing type in access_ok()

 v2: fixed the three direct users of __access_ok()

 arch/powerpc/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/uaccess.h 
b/arch/powerpc/include/asm/uaccess.h
index 15bea9a0f260..ebc0b916dcf9 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -63,7 +63,7 @@ static inline int __access_ok(unsigned long addr, unsigned 
long size,
 #endif
 
 #define access_ok(type, addr, size)\
-   (__chk_user_ptr(addr),  \
+   (__chk_user_ptr(addr), (void)(type),\
 __access_ok((__force unsigned long)(addr), (size), get_fs()))
 
 /*
-- 
2.13.3



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

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

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

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



Re: [PATCH v8 2/2] mfd: axp20x: Add supported cells for AXP803

2018-12-09 Thread Chen-Yu Tsai
On Mon, Dec 10, 2018 at 2:35 PM Lee Jones  wrote:
>
> On Sat, 08 Dec 2018, Oskari Lemmela wrote:
>
> > Parts of the AXP803 are compatible with their counterparts on the AXP813.
> > These include the GPIO, ADC, AC and battery power supplies.
> >
> > Signed-off-by: Oskari Lemmela 
> > Reviewed-by: Chen-Yu Tsai 
> > Tested-by: Vasily Khoruzhick 
> > Signed-off-by: Chen-Yu Tsai 
>
> I'm happy to fix this, but ...
>
> Can you explain these tags for me please?
>
> Specifically the last one.
>
> Why does Chen-Yu Tsai have an SoB there?

I picked his patch to rebase off the previous one, and reworked the ordering.
I then pushed it onto GitHub [1], but didn't get around to sending it to the
mailing lists. Oskari said on IRC that he would handle it.

I'm not sure what would be appropriate here though? Oskari's first SoB should
be kept, since he's the original author. Maybe he should've added his SoB
again as the final entry? Either way I suppose it would be confusing without
any explanation.

ChenYu

[1] 
https://github.com/wens/linux/commit/951afe2dc32086174ab07a1a997d748f69bf5bf2
[2] https://freenode.irclog.whitequark.org/linux-sunxi/2018-12-08#23644905;


[resend PATCH v4 0/2] add uart DMA function

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

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

Changes compared to v3:
-fix CONFIG_PM, will cause build fail
Changes compared to v2:
-remove unimportant parameters
-instead of cookie, use APIs of virtual channel.
-use of_dma_xlate_by_chan_id.
Changes compared to v1:
-mian revised file, 8250_mtk_dma.c
--parameters renamed for standard
--remove atomic operation

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

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

-- 
1.7.9.5



Re: [PATCH 17/18] mfd: wm8350-core: drop unused MODULE_ tags from non-modular code

2018-12-09 Thread Lee Jones
On Fri, 07 Dec 2018, Paul Gortmaker wrote:

> The Kconfig currently controlling compilation of this code is:
> 
> drivers/mfd/Kconfig:config MFD_WM8350
> drivers/mfd/Kconfig:bool
> 
> ...meaning that it currently is not being built as a module by anyone.
> 
> Lets remove the couple traces of modular infrastructure use, so that
> when reading the driver there is no doubt it is builtin-only.
> 
> We delete the MODULE_LICENSE tag etc. since all that information
> is already contained at the top of the file in the comments.
> 
> We replace module.h with init.h and export.h ; the latter since the
> file does export some symbols.
> 
> Cc: Linus Walleij 
> Cc: Lee Jones 
> Cc: patc...@opensource.cirrus.com
> Acked-by: Linus Walleij 
> Signed-off-by: Paul Gortmaker 

When you submit this patch again (collecting more Acks or
what-have-you), please re-order your tags chronologically.

Your SoB here should represent the first time you submitted the patch,
therefore it would be impossible for Linus to review the patch on the
ML *before* you sent it.

> ---
>  drivers/mfd/wm8350-core.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
> index 8a07c5634aee..e6434a4d7439 100644
> --- a/drivers/mfd/wm8350-core.c
> +++ b/drivers/mfd/wm8350-core.c
> @@ -13,7 +13,8 @@
>   */
>  
>  #include 
> -#include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -466,6 +467,3 @@ void wm8350_device_exit(struct wm8350 *wm8350)
>   wm8350_irq_exit(wm8350);
>  }
>  EXPORT_SYMBOL_GPL(wm8350_device_exit);
> -
> -MODULE_DESCRIPTION("WM8350 AudioPlus PMIC core driver");
> -MODULE_LICENSE("GPL");

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH v8 1/2] mfd: axp20x: Re-align mfd cell entries

2018-12-09 Thread Lee Jones
On Sat, 08 Dec 2018, Oskari Lemmela wrote:

> From: Chen-Yu Tsai 
> 
> In the axp20x driver, the various mfd_cell lists had varying amounts
> of indentation, sometimes even within the same list. For the axp288,
> there's no alignment at all.
> 
> Re-align the right hand side of the assignments with the least amount
> of tabs possible. Also collapse the closing bracket and the opening
> bracket of the next entry onto the same line for the axp288, to be
> consistent with all the other mfd_cell lists.
> 
> This patch is whitespace change only. No functionality is modified.
> 
> Signed-off-by: Chen-Yu Tsai 
> Signed-off-by: Oskari Lemmela 

Why is Oskari Lemmela's SoB here?

You both authored this alignment patch?

> ---
>  drivers/mfd/axp20x.c | 107 +--
>  1 file changed, 51 insertions(+), 56 deletions(-)
> 
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index dfc3cff1d08b..8037b4e01ed6 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -640,9 +640,9 @@ static const struct mfd_cell axp221_cells[] = {
>  
>  static const struct mfd_cell axp223_cells[] = {
>   {
> - .name   = "axp221-pek",
> - .num_resources  = ARRAY_SIZE(axp22x_pek_resources),
> - .resources  = axp22x_pek_resources,
> + .name   = "axp221-pek",
> + .num_resources  = ARRAY_SIZE(axp22x_pek_resources),
> + .resources  = axp22x_pek_resources,
>   }, {
>   .name   = "axp22x-adc",
>   .of_compatible  = "x-powers,axp221-adc",
> @@ -650,7 +650,7 @@ static const struct mfd_cell axp223_cells[] = {
>   .name   = "axp20x-battery-power-supply",
>   .of_compatible  = "x-powers,axp221-battery-power-supply",
>   }, {
> - .name   = "axp20x-regulator",
> + .name   = "axp20x-regulator",
>   }, {
>   .name   = "axp20x-ac-power-supply",
>   .of_compatible  = "x-powers,axp221-ac-power-supply",
> @@ -666,9 +666,9 @@ static const struct mfd_cell axp223_cells[] = {
>  
>  static const struct mfd_cell axp152_cells[] = {
>   {
> - .name   = "axp20x-pek",
> - .num_resources  = ARRAY_SIZE(axp152_pek_resources),
> - .resources  = axp152_pek_resources,
> + .name   = "axp20x-pek",
> + .num_resources  = ARRAY_SIZE(axp152_pek_resources),
> + .resources  = axp152_pek_resources,
>   },
>  };
>  
> @@ -697,84 +697,79 @@ static const struct resource axp288_charger_resources[] 
> = {
>  
>  static const struct mfd_cell axp288_cells[] = {
>   {
> - .name = "axp288_adc",
> - .num_resources = ARRAY_SIZE(axp288_adc_resources),
> - .resources = axp288_adc_resources,
> - },
> - {
> - .name = "axp288_extcon",
> - .num_resources = ARRAY_SIZE(axp288_extcon_resources),
> - .resources = axp288_extcon_resources,
> - },
> - {
> - .name = "axp288_charger",
> - .num_resources = ARRAY_SIZE(axp288_charger_resources),
> - .resources = axp288_charger_resources,
> - },
> - {
> - .name = "axp288_fuel_gauge",
> - .num_resources = ARRAY_SIZE(axp288_fuel_gauge_resources),
> - .resources = axp288_fuel_gauge_resources,
> - },
> - {
> - .name = "axp221-pek",
> - .num_resources = ARRAY_SIZE(axp288_power_button_resources),
> - .resources = axp288_power_button_resources,
> - },
> - {
> - .name = "axp288_pmic_acpi",
> + .name   = "axp288_adc",
> + .num_resources  = ARRAY_SIZE(axp288_adc_resources),
> + .resources  = axp288_adc_resources,
> + }, {
> + .name   = "axp288_extcon",
> + .num_resources  = ARRAY_SIZE(axp288_extcon_resources),
> + .resources  = axp288_extcon_resources,
> + }, {
> + .name   = "axp288_charger",
> + .num_resources  = ARRAY_SIZE(axp288_charger_resources),
> + .resources  = axp288_charger_resources,
> + }, {
> + .name   = "axp288_fuel_gauge",
> + .num_resources  = ARRAY_SIZE(axp288_fuel_gauge_resources),
> + .resources  = axp288_fuel_gauge_resources,
> + }, {
> + .name   = "axp221-pek",
> + .num_resources  = ARRAY_SIZE(axp288_power_button_resources),
> + .resources  = axp288_power_button_resources,
> + }, {
> + .name   = "axp288_pmic_acpi",
>   },
>  };
>  
>  static const struct mfd_cell axp803_cells[] = {
>   {
> - .name   = "axp221-pek",
> - .num_resources  

Re: [PATCH v8 2/2] mfd: axp20x: Add supported cells for AXP803

2018-12-09 Thread Lee Jones
On Sat, 08 Dec 2018, Oskari Lemmela wrote:

> Parts of the AXP803 are compatible with their counterparts on the AXP813.
> These include the GPIO, ADC, AC and battery power supplies.
> 
> Signed-off-by: Oskari Lemmela 
> Reviewed-by: Chen-Yu Tsai 
> Tested-by: Vasily Khoruzhick 
> Signed-off-by: Chen-Yu Tsai 

I'm happy to fix this, but ...

Can you explain these tags for me please?

Specifically the last one.

Why does Chen-Yu Tsai have an SoB there?

> ---
>  drivers/mfd/axp20x.c | 14 ++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index 8037b4e01ed6..f8e0fa97bb31 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -726,6 +726,20 @@ static const struct mfd_cell axp803_cells[] = {
>   .name   = "axp221-pek",
>   .num_resources  = ARRAY_SIZE(axp803_pek_resources),
>   .resources  = axp803_pek_resources,
> + }, {
> + .name   = "axp20x-gpio",
> + .of_compatible  = "x-powers,axp813-gpio",
> + }, {
> + .name   = "axp813-adc",
> + .of_compatible  = "x-powers,axp813-adc",
> + }, {
> + .name   = "axp20x-battery-power-supply",
> + .of_compatible  = "x-powers,axp813-battery-power-supply",
> + }, {
> + .name   = "axp20x-ac-power-supply",
> + .of_compatible  = "x-powers,axp813-ac-power-supply",
> + .num_resources  = ARRAY_SIZE(axp20x_ac_power_supply_resources),
> + .resources  = axp20x_ac_power_supply_resources,
>   },
>   {   .name   = "axp20x-regulator" },
>  };

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


[resend PATCH v4 1/2] dmaengine: 8250_mtk_dma: add Mediatek uart DMA support

2018-12-09 Thread Long Cheng
In DMA engine framework, add 8250 mtk dma to support it.

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

diff --git a/drivers/dma/mediatek/8250_mtk_dma.c 
b/drivers/dma/mediatek/8250_mtk_dma.c
new file mode 100644
index 000..f79d180
--- /dev/null
+++ b/drivers/dma/mediatek/8250_mtk_dma.c
@@ -0,0 +1,830 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Mediatek 8250 DMA driver.
+ *
+ * Copyright (c) 2018 MediaTek Inc.
+ * Author: Long Cheng 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../virt-dma.h"
+
+#define MTK_APDMA_DEFAULT_REQUESTS 127
+#define MTK_APDMA_CHANNELS (CONFIG_SERIAL_8250_NR_UARTS * 2)
+
+#define VFF_EN_B   BIT(0)
+#define VFF_STOP_B BIT(0)
+#define VFF_FLUSH_BBIT(0)
+#define VFF_4G_SUPPORT_B   BIT(0)
+#define VFF_RX_INT_EN0_B   BIT(0)  /*rx valid size >=  vff thre*/
+#define VFF_RX_INT_EN1_B   BIT(1)
+#define VFF_TX_INT_EN_BBIT(0)  /*tx left size >= vff thre*/
+#define VFF_WARM_RST_B BIT(0)
+#define VFF_RX_INT_FLAG_CLR_B  (BIT(0) | BIT(1))
+#define VFF_TX_INT_FLAG_CLR_B  0
+#define VFF_STOP_CLR_B 0
+#define VFF_FLUSH_CLR_B0
+#define VFF_INT_EN_CLR_B   0
+#define VFF_4G_SUPPORT_CLR_B   0
+
+/* interrupt trigger level for tx */
+#define VFF_TX_THRE(n) ((n) * 7 / 8)
+/* interrupt trigger level for rx */
+#define VFF_RX_THRE(n) ((n) * 3 / 4)
+
+#define MTK_DMA_RING_SIZE  0xU
+/* invert this bit when wrap ring head again*/
+#define MTK_DMA_RING_WRAP  0x1U
+
+#define VFF_INT_FLAG   0x00
+#define VFF_INT_EN 0x04
+#define VFF_EN 0x08
+#define VFF_RST0x0c
+#define VFF_STOP   0x10
+#define VFF_FLUSH  0x14
+#define VFF_ADDR   0x1c
+#define VFF_LEN0x24
+#define VFF_THRE   0x28
+#define VFF_WPT0x2c
+#define VFF_RPT0x30
+/*TX: the buffer size HW can read. RX: the buffer size SW can read.*/
+#define VFF_VALID_SIZE 0x3c
+/*TX: the buffer size SW can write. RX: the buffer size HW can write.*/
+#define VFF_LEFT_SIZE  0x40
+#define VFF_DEBUG_STATUS   0x50
+#define VFF_4G_SUPPORT 0x54
+
+struct mtk_dmadev {
+   struct dma_device ddev;
+   void __iomem *mem_base[MTK_APDMA_CHANNELS];
+   spinlock_t lock; /* dma dev lock */
+   struct tasklet_struct task;
+   struct list_head pending;
+   struct clk *clk;
+   unsigned int dma_requests;
+   bool support_33bits;
+   unsigned int dma_irq[MTK_APDMA_CHANNELS];
+   struct mtk_chan *ch[MTK_APDMA_CHANNELS];
+};
+
+struct mtk_chan {
+   struct virt_dma_chan vc;
+   struct list_head node;
+   struct dma_slave_config cfg;
+   void __iomem *base;
+   struct mtk_dma_desc *desc;
+
+   bool stop;
+   bool requested;
+
+   unsigned int rx_status;
+};
+
+struct mtk_dma_sg {
+   dma_addr_t addr;
+   unsigned int en;/* number of elements (24-bit) */
+   unsigned int fn;/* number of frames (16-bit) */
+};
+
+struct mtk_dma_desc {
+   struct virt_dma_desc vd;
+   enum dma_transfer_direction dir;
+
+   unsigned int sglen;
+   struct mtk_dma_sg sg[0];
+
+   unsigned int len;
+};
+
+static inline struct mtk_dmadev *to_mtk_dma_dev(struct dma_device *d)
+{
+   return container_of(d, struct mtk_dmadev, ddev);
+}
+
+static inline struct mtk_chan *to_mtk_dma_chan(struct dma_chan *c)
+{
+   return container_of(c, struct mtk_chan, vc.chan);
+}
+
+static inline struct mtk_dma_desc *to_mtk_dma_desc
+   (struct dma_async_tx_descriptor *t)
+{
+   return container_of(t, struct mtk_dma_desc, vd.tx);
+}
+
+static void mtk_dma_chan_write(struct mtk_chan *c,
+  unsigned int reg, unsigned int val)
+{
+   writel(val, c->base + reg);
+}
+
+static unsigned int mtk_dma_chan_read(struct mtk_chan *c, unsigned int reg)
+{
+   return readl(c->base + reg);
+}
+
+static void mtk_dma_desc_free(struct virt_dma_desc *vd)
+{
+   struct dma_chan *chan = vd->tx.chan;
+   struct mtk_chan *c = to_mtk_dma_chan(chan);
+
+   kfree(c->desc);
+   c->desc = NULL;
+}
+
+static void mtk_dma_tx_flush(struct dma_chan *chan)
+{
+   struct mtk_chan *c = to_mtk_dma_chan(chan);
+
+   if (mtk_dma_chan_read(c, VFF_FLUSH) == 0U)
+   mtk_dma_chan_write(c, VFF_FLUSH, VFF_FLUSH_B);
+}
+
+static void mtk_dma_tx_write(struct dma_chan *chan)
+{
+   struct mtk_chan *c = 

Re: [PATCH v8 1/2] mfd: axp20x: Re-align mfd cell entries

2018-12-09 Thread Lee Jones
On Sat, 08 Dec 2018, Oskari Lemmela wrote:

> From: Chen-Yu Tsai 
> 
> In the axp20x driver, the various mfd_cell lists had varying amounts
> of indentation, sometimes even within the same list. For the axp288,
> there's no alignment at all.
> 
> Re-align the right hand side of the assignments with the least amount
> of tabs possible. Also collapse the closing bracket and the opening
> bracket of the next entry onto the same line for the axp288, to be
> consistent with all the other mfd_cell lists.
> 
> This patch is whitespace change only. No functionality is modified.
> 
> Signed-off-by: Chen-Yu Tsai 
> Signed-off-by: Oskari Lemmela 
> ---
>  drivers/mfd/axp20x.c | 107 +--
>  1 file changed, 51 insertions(+), 56 deletions(-)

Applied, thanks.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH v8 2/2] mfd: axp20x: Add supported cells for AXP803

2018-12-09 Thread Lee Jones
On Sat, 08 Dec 2018, Oskari Lemmela wrote:

> Parts of the AXP803 are compatible with their counterparts on the AXP813.
> These include the GPIO, ADC, AC and battery power supplies.
> 
> Signed-off-by: Oskari Lemmela 
> Reviewed-by: Chen-Yu Tsai 
> Tested-by: Vasily Khoruzhick 
> Signed-off-by: Chen-Yu Tsai 
> ---
>  drivers/mfd/axp20x.c | 14 ++
>  1 file changed, 14 insertions(+)

Applied, thanks.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH][RFC v2] ACPI: acpi_pad: Do not launch acpi_pad threads on idle cpus

2018-12-09 Thread joeyli
Hi Chen Yu and ACPI experts,

On Sat, May 05, 2018 at 07:53:22PM +0800, Chen Yu wrote:
> According to current implementation of acpi_pad driver,
> it does not make sense to spawn any power saving threads
> on the cpus which are already idle - it might bring
> unnecessary overhead on these idle cpus and causes power
> waste. So verify the condition that if the number of 'busy'
> cpus exceeds the amount of the 'forced idle' cpus is met.
> This is applicable due to round-robin attribute of the
> power saving threads, otherwise ignore the setting/ACPI
> notification.
> 
> Suggested-by: Lenny Szubowicz 
> Suggested-by: Len Brown 
> Cc: "Rafael J. Wysocki" 
> Cc: Lenny Szubowicz 
> Cc: Len Brown 
> Cc: Jacob Pan 
> Cc: Rui Zhang 
> Cc: linux-a...@vger.kernel.org
> Signed-off-by: Chen Yu 

Do you have any news for this patch? Why it did not merged by kernel
maineline?

Thanks a lot!
Joey Lee

> ---
>  drivers/acpi/acpi_pad.c | 52 
> -
>  1 file changed, 51 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
> index 552c1f7..515e60e 100644
> --- a/drivers/acpi/acpi_pad.c
> +++ b/drivers/acpi/acpi_pad.c
> @@ -254,12 +254,62 @@ static void set_power_saving_task_num(unsigned int num)
>   }
>  }
>  
> +/*
> + * Extra acpi_pad threads should not be created until
> + * the requested idle count is less than/equals to the
> + * number of the busy cpus - it does not make sense to
> + * throttle the idle cpus.
> + */
> +#define SAMPLE_INTERVAL_JIF  20
> +
> +static u64 get_idle_time(int cpu)
> +{
> + u64 idle, idle_usecs = -1ULL;
> +
> + idle_usecs = get_cpu_idle_time_us(cpu, NULL);
> +
> + if (idle_usecs == -1ULL)
> + idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE];
> + else
> + idle = idle_usecs * NSEC_PER_USEC;
> +
> + return idle;
> +}
> +
> +static bool idle_nr_valid(unsigned int num_cpus)
> +{
> + int busy_nr = 0, i = 0, load_thresh = 100 - idle_pct;
> +
> + if (!num_cpus)
> + return true;
> +
> + for_each_online_cpu(i) {
> + u64 wall_time, idle_time;
> + unsigned int elapsed_delta, idle_delta, load;
> +
> + wall_time = jiffies64_to_nsecs(get_jiffies_64());
> + idle_time = get_idle_time(i);
> + /* Wait and see... */
> + schedule_timeout_uninterruptible(SAMPLE_INTERVAL_JIF);
> +
> + idle_delta = get_idle_time(i) - idle_time;
> + elapsed_delta = jiffies64_to_nsecs(get_jiffies_64()) - 
> wall_time;
> + idle_delta = (idle_delta > elapsed_delta) ? elapsed_delta : 
> idle_delta;
> + load = 100 * (elapsed_delta - idle_delta) / elapsed_delta;
> + if (load >= load_thresh)
> + busy_nr++;
> + }
> +
> + return (busy_nr >= num_cpus) ? true : false;
> +}
> +
>  static void acpi_pad_idle_cpus(unsigned int num_cpus)
>  {
>   get_online_cpus();
>  
>   num_cpus = min_t(unsigned int, num_cpus, num_online_cpus());
> - set_power_saving_task_num(num_cpus);
> + if (idle_nr_valid(num_cpus))
> + set_power_saving_task_num(num_cpus);
>  
>   put_online_cpus();
>  }
> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 8/8] mfd: axp20x: Add supported cells for AXP803

2018-12-09 Thread Lee Jones
On Tue, 20 Nov 2018, Oskari Lemmela wrote:

> Parts of the AXP803 are compatible with their counterparts on the AXP813.
> These include the GPIO, ADC, AC and battery power supplies.
> 
> Signed-off-by: Oskari Lemmela 
> Reviewed-by: Chen-Yu Tsai 
> Tested-by: Vasily Khoruzhick 
> ---
>  drivers/mfd/axp20x.c | 15 +++
>  1 file changed, 15 insertions(+)

Applied, thanks.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH v6 8/8] mfd: axp20x: Add supported cells for AXP803

2018-12-09 Thread Lee Jones
On Sat, 08 Dec 2018, Quentin Schulz wrote:

> Hi Lee,
> 
> On Fri, Dec 07, 2018 at 07:22:37PM +, Lee Jones wrote:
> > On Fri, 07 Dec 2018, Vasily Khoruzhick wrote:
> > 
> > > On Fri, Dec 7, 2018 at 8:40 AM Lee Jones  wrote:
> > > 
> > > > My OCD-dar is going crazy.
> > > >
> > > > Why haven't you used the same alignment as is already there?
> > > >
> > > > If it starts to run over 80-chars then bring the others back.
> > > >
> > > > Also why is there a single liner shoved in the middle of the
> > > > multi-line entries?  Please move the singles to the top or the
> > > > bottom.
> > > 
> > > Hi Lee,
> > > 
> > > Could you please reformat it in the way that makes your OCD-dar happy?
> > > It would be really nice to get
> > 
> > I'm afraid not, for a multitude of reasons.
> > 
> > The most important of which surround testing.
> > 
> > > AC and battery support for APX8x3 merged -- it'll make Pinebook and
> > > Teres-I pretty well supported by mainline kernel.
> > 
> > That's great.  A worthy cause indeed.  So I'm sure you guys will want
> > to turn the patch around in short order so that it's applied in time
> > for the next merge window.
> > 
> 
> Aren't the MFD cells probed in order?
> 
> In that case, it makes little sense to short order them for this
> particular device (X-Powers PMICs in general). It will just make the
> system boot slower because of probe deferring.
> 
> Why? As explained by Chen-Yu in v3[1], axp-gpios can be muxed as
> regulators, thus should be probed before axp-regulators. axp-adc is
> often used by axp-battery, axp-usb-power, axp-ac-power, thus should be
> probed beforehand as well.

If there are inter-dependencies between the devices, it makes sense to
keep them in the most efficient order.

> For the alignment that also triggered your OCD, I can send you a patch
> the day you merge this one if it can help. I sent a few patches for this
> driver that didn't respect the alignment so I'm fine fixing the mfd
> cells (and eventually re-order them as I saw a few axp-gpio cells being
> declared after axp-regulators).

That's fine.  Please send the patch (based on this set) right away.

> Does that make this patch OK for you, Lee?

Yes, thank you.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


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

2018-12-09 Thread Stephen Rothwell
Hi Martin,

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

  drivers/scsi/qla2xxx/qla_os.c

between commit:

  f2ffd4e5bc7b ("scsi: qla2xxx: Timeouts occur on surprise removal of QLogic 
adapter")

from Linus' tree and commit:

  c4e521b654e1 ("scsi: qla2xxx: Split the __qla2x00_abort_all_cmds() function")

from the scsi-mkp tree.

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



-- 
Cheers,
Stephen Rothwell


pgpOyheqsGdxF.pgp
Description: OpenPGP digital signature


Re: [PATCH v3 1/4] mfd: stmpe: Move ADC related defines to header of mfd

2018-12-09 Thread Lee Jones
On Sat, 08 Dec 2018, Dmitry Torokhov wrote:

> On Wed, Nov 28, 2018 at 09:15:32AM +, Lee Jones wrote:
> > On Fri, 23 Nov 2018, Philippe Schenker wrote:
> > 
> > > Move defines that are ADC related to the header of the overlying mfd,
> > > so they can be used from multiple sub-devices.
> > > 
> > > Signed-off-by: Philippe Schenker 
> > > ---
> > > 
> > > Changes in v3:
> > >  - None
> > > 
> > > Changes in v2:
> > >  - This is a new added commit. Separate commit for moving the defines out 
> > > of
> > >drivers/input/touchscreen/stmpe-ts.c to overlying mfd-device 
> > > drivers/mfd/stmpe.c
> > >  - Pre-fix defines with STMPE_
> > > 
> > >  drivers/input/touchscreen/stmpe-ts.c | 34 +++-
> > >  include/linux/mfd/stmpe.h| 11 +
> > 
> > Acked-by: Lee Jones 
> 
> The series seem to be heading towards MFD or IIO, so I assume this patch
> will be merged through one of these trees.
> 
> Acked-by: Dmitry Torokhov 

I'd be happy to take it.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH -next] input: keyboard: remove duplicated include from mtk-pmic-keys.c

2018-12-09 Thread Lee Jones
On Sun, 09 Dec 2018, YueHaibing wrote:

> Remove duplicated include.
> 
> Signed-off-by: YueHaibing 
> ---
>  drivers/input/keyboard/mtk-pmic-keys.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/input/keyboard/mtk-pmic-keys.c 
> b/drivers/input/keyboard/mtk-pmic-keys.c
> index 02c67a1..5027ebb 100644
> --- a/drivers/input/keyboard/mtk-pmic-keys.c
> +++ b/drivers/input/keyboard/mtk-pmic-keys.c
> @@ -19,7 +19,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 

You are removing the wrong one.

Please convert this patch's main intent to alphabetise the header
files.  Then you can remove any obvious duplicates.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH] kernel/hung_task.c: force ignore_loglevel before panic

2018-12-09 Thread Sergey Senozhatsky
On (12/10/18 05:58), Liu, Chuansheng wrote:
> > On (12/10/18 05:40), Liu, Chuansheng wrote:
> > > @@ -130,6 +130,13 @@ static void check_hung_task(struct task_struct *t,
> > unsigned long timeout)
> > > init_utsname()->version);
> > > pr_err("\"echo 0 > 
> > > /proc/sys/kernel/hung_task_timeout_secs\""
> > > " disables this message.\n");
> > > +   /* When sysctl_hung_task_panic is set, we have to force
> > > +* ignore_loglevel to get really useful hung task
> > > +* information.
> > > +*/
> > > +   if (sysctl_hung_task_panic && !ignore_loglevel)
> > > +   ignore_loglevel = true;
> > 
> > console_verbose()?
> 
> Thanks Sergey, it is really my need. I will prepare for a new version of 
> patch:)

Let's wait for people to take a look at this patch first.

-ss


Re: [PATCH 1/1] usb: dwc2: disable power_down on Amlogic devices

2018-12-09 Thread Minas Harutyunyan
On 12/9/2018 11:01 PM, Martin Blumenstingl wrote:
> Disable power_down by setting the parameter to
> DWC2_POWER_DOWN_PARAM_NONE. This fixes a problem on various Amlogic
> Meson SoCs where USB devices are only recognized when plugged in before
> booting Linux. A hot-plugged USB device was not detected even though the
> device got power (my USB thumb drive for example has an LED which lit
> up).
> 
> A similar fix was implemented for Rockchip SoCs in commit c216765d3a1def
> ("usb: dwc2: disable power_down on rockchip devices"). That commit
> suggests that a change in the dwc2 driver is the cause because the
> default value for the "hibernate" parameter (which then got renamed to
> "power_down" to support other modes) was changed in the v4.17 merge
> window with:
> commit 6d23ee9caa6790 ("Merge tag 'usb-for-v4.17' of 
> git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-testing").
> 
> Cc:  # 4.19
> Suggested-by: Christian Hewitt 
> Signed-off-by: Martin Blumenstingl 

Acked-by: Minas Harutyunyan 
> ---
>   drivers/usb/dwc2/params.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
> index 7c1b6938f212..38c813b1d203 100644
> --- a/drivers/usb/dwc2/params.c
> +++ b/drivers/usb/dwc2/params.c
> @@ -111,6 +111,7 @@ static void dwc2_set_amlogic_params(struct dwc2_hsotg 
> *hsotg)
>   p->phy_type = DWC2_PHY_TYPE_PARAM_UTMI;
>   p->ahbcfg = GAHBCFG_HBSTLEN_INCR8 <<
>   GAHBCFG_HBSTLEN_SHIFT;
> + p->power_down = DWC2_POWER_DOWN_PARAM_NONE;
>   }
>   
>   static void dwc2_set_amcc_params(struct dwc2_hsotg *hsotg)
> 



RE: [PATCH] kernel/hung_task.c: force ignore_loglevel before panic

2018-12-09 Thread Liu, Chuansheng



> -Original Message-
> From: Sergey Senozhatsky [mailto:sergey.senozhatsky.w...@gmail.com]
> Sent: Monday, December 10, 2018 1:46 PM
> To: Liu, Chuansheng 
> Cc: a...@linux-foundation.org; pmla...@suse.com;
> sergey.senozhat...@gmail.com; rost...@goodmis.org; dvyu...@google.com;
> penguin-ker...@i-love.sakura.ne.jp; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] kernel/hung_task.c: force ignore_loglevel before panic
> 
> On (12/10/18 05:40), Liu, Chuansheng wrote:
> > @@ -130,6 +130,13 @@ static void check_hung_task(struct task_struct *t,
> unsigned long timeout)
> > init_utsname()->version);
> > pr_err("\"echo 0 > 
> > /proc/sys/kernel/hung_task_timeout_secs\""
> > " disables this message.\n");
> > +   /* When sysctl_hung_task_panic is set, we have to force
> > +* ignore_loglevel to get really useful hung task
> > +* information.
> > +*/
> > +   if (sysctl_hung_task_panic && !ignore_loglevel)
> > +   ignore_loglevel = true;
> 
>   console_verbose()?

Thanks Sergey, it is really my need. I will prepare for a new version of patch:)


linux-next: manual merge of the staging tree with the v4l-dvb tree

2018-12-09 Thread Stephen Rothwell
Hi all,

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

  drivers/staging/media/tegra-vde/tegra-vde.c

between commit:

  91dc5e91edf7 ("media: staging: tegra-vde: Replace debug messages with trace 
points")

from the v4l-dvb tree and commit:

  9483804a725a ("media: staging: tegra-vde: print long unsigned using %lu 
format specifier")

from the staging tree.

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

-- 
Cheers,
Stephen Rothwell


pgpc2wym0hAJS.pgp
Description: OpenPGP digital signature


Re: [PATCH] kernel/hung_task.c: force ignore_loglevel before panic

2018-12-09 Thread Sergey Senozhatsky
On (12/10/18 05:40), Liu, Chuansheng wrote:
> @@ -130,6 +130,13 @@ static void check_hung_task(struct task_struct *t, 
> unsigned long timeout)
> init_utsname()->version);
> pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\""
> " disables this message.\n");
> +   /* When sysctl_hung_task_panic is set, we have to force
> +* ignore_loglevel to get really useful hung task
> +* information.
> +*/
> +   if (sysctl_hung_task_panic && !ignore_loglevel)
> +   ignore_loglevel = true;

console_verbose()?

-ss


BUG: corrupted list in neigh_mark_dead

2018-12-09 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:83af01ba1c2d Merge branch 'tc-testing-next'
git tree:   net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=14cea3f540
kernel config:  https://syzkaller.appspot.com/x/.config?x=28ecefa8a6e10719
dashboard link: https://syzkaller.appspot.com/bug?extid=6cc2fd1d3bdd2e007363
compiler:   gcc (GCC) 8.0.1 20180413 (experimental)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=141032db40
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=150bb3d540

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

list_del corruption. prev->next should be 8881b4412b70, but was  
8881d5d58ff0

[ cut here ]
kernel BUG at lib/list_debug.c:53!
invalid opcode:  [#1] PREEMPT SMP KASAN
CPU: 0 PID: 2770 Comm: kworker/0:2 Not tainted 4.20.0-rc4+ #333
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

Workqueue: events_power_efficient neigh_periodic_work
RIP: 0010:__list_del_entry_valid.cold.1+0x48/0x4a lib/list_debug.c:51
Code: d6 60 88 e8 b2 fd d1 fd 0f 0b 48 89 de 48 c7 c7 40 d8 60 88 e8 a1 fd  
d1 fd 0f 0b 48 89 de 48 c7 c7 e0 d7 60 88 e8 90 fd d1 fd <0f> 0b 48 89 d9  
48 c7 c7 a0 d8 60 88 e8 7f fd d1 fd 0f 0b 48 89 f1

RSP: 0018:8881cda97440 EFLAGS: 00010282
RAX: 0054 RBX: 8881b4412b70 RCX: 
RDX:  RSI: 8165eae5 RDI: 0005
RBP: 8881cda97458 R08: 8881cdb4e400 R09: ed103b5c5020
R10: ed103b5c5020 R11: 8881dae28107 R12: 8881bb333930
R13: 8881d13d62b0 R14: 8881cda97560 R15: 111039b52e94
FS:  () GS:8881dae0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 004155d0 CR3: 0001c1769000 CR4: 001406f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 __list_del_entry include/linux/list.h:117 [inline]
 list_del_init include/linux/list.h:159 [inline]
 neigh_mark_dead+0x13b/0x410 net/core/neighbour.c:125
 neigh_periodic_work+0x89a/0xc30 net/core/neighbour.c:905
 process_one_work+0xc90/0x1c40 kernel/workqueue.c:2153
 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
 kthread+0x35a/0x440 kernel/kthread.c:246
 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352
Modules linked in:
---[ end trace 4c84591405102c9f ]---
RIP: 0010:__list_del_entry_valid.cold.1+0x48/0x4a lib/list_debug.c:51
Code: d6 60 88 e8 b2 fd d1 fd 0f 0b 48 89 de 48 c7 c7 40 d8 60 88 e8 a1 fd  
d1 fd 0f 0b 48 89 de 48 c7 c7 e0 d7 60 88 e8 90 fd d1 fd <0f> 0b 48 89 d9  
48 c7 c7 a0 d8 60 88 e8 7f fd d1 fd 0f 0b 48 89 f1

RSP: 0018:8881cda97440 EFLAGS: 00010282
RAX: 0054 RBX: 8881b4412b70 RCX: 
RDX:  RSI: 8165eae5 RDI: 0005
RBP: 8881cda97458 R08: 8881cdb4e400 R09: ed103b5c5020
R10: ed103b5c5020 R11: 8881dae28107 R12: 8881bb333930
R13: 8881d13d62b0 R14: 8881cda97560 R15: 111039b52e94
FS:  () GS:8881dae0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 004155d0 CR3: 0001c1769000 CR4: 001406f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400


---
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#bug-status-tracking for how to communicate with  
syzbot.

syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches


Re: [PATCH v4 0/7] mips: system call table generation support

2018-12-09 Thread Paul Burton
Hi Firoz,

On Mon, Dec 10, 2018 at 11:05:38AM +0530, Firoz Khan wrote:
> Please review this patch series and queue it for linux-next.

It's been ~4 days, 2 of which were a weekend. I'll get to it, but
pinging so often won't help.

Thanks,
Paul


BUG: corrupted list in ___neigh_create

2018-12-09 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:97ef7b4c5501 ip: silence udp zerocopy smatch false positive
git tree:   net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=13f4592b40
kernel config:  https://syzkaller.appspot.com/x/.config?x=28ecefa8a6e10719
dashboard link: https://syzkaller.appspot.com/bug?extid=b354d1fb59091ea73c37
compiler:   gcc (GCC) 8.0.1 20180413 (experimental)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=1442c92540
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17778d6d40

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

list_add corruption. prev->next should be next (89fd0da0), but was  
8881d7bf42b0. (prev=8881d4465db0).

[ cut here ]
kernel BUG at lib/list_debug.c:28!
invalid opcode:  [#1] PREEMPT SMP KASAN
CPU: 0 PID: 6257 Comm: syz-executor648 Not tainted 4.20.0-rc4+ #334
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

RIP: 0010:__list_add_valid.cold.2+0x23/0x2a lib/list_debug.c:26
Code: e8 90 fd d1 fd 0f 0b 48 89 d9 48 c7 c7 a0 d8 60 88 e8 7f fd d1 fd 0f  
0b 48 89 f1 48 c7 c7 20 d9 60 88 48 89 de e8 6b fd d1 fd <0f> 0b 90 90 90  
90 90 55 48 89 e5 41 57 41 56 49 be 00 00 00 00 00

RSP: 0018:8881dae06cf0 EFLAGS: 00010282
RAX: 0075 RBX: 89fd0da0 RCX: 
RDX:  RSI: 8165eae5 RDI: 0005
RBP: 8881dae06d08 R08: 8881bcdbe000 R09: ed103b5c5020
R10: ed103b5c5020 R11: 8881dae28107 R12: 8881ce059030
R13: 8881ce058dc0 R14: 89fd0b60 R15: 89fd0df0
FS:  () GS:8881dae0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 0042de80 CR3: 0001bd45f000 CR4: 001406f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 
 __list_add include/linux/list.h:60 [inline]
 list_add_tail include/linux/list.h:93 [inline]
 neigh_alloc net/core/neighbour.c:395 [inline]
 ___neigh_create+0x14b7/0x2600 net/core/neighbour.c:553
cgroup: fork rejected by pids controller in /syz2
cgroup: fork rejected by pids controller in /syz5
 __neigh_create+0x30/0x40 net/core/neighbour.c:640
 ip6_finish_output2+0xa59/0x27a0 net/ipv6/ip6_output.c:117
 ip6_finish_output+0x58c/0xc60 net/ipv6/ip6_output.c:154
 NF_HOOK_COND include/linux/netfilter.h:278 [inline]
 ip6_output+0x232/0x9d0 net/ipv6/ip6_output.c:171
 dst_output include/net/dst.h:444 [inline]
 NF_HOOK include/linux/netfilter.h:289 [inline]
 ndisc_send_skb+0x1005/0x1560 net/ipv6/ndisc.c:491
 ndisc_send_rs+0x134/0x6e0 net/ipv6/ndisc.c:685
 addrconf_rs_timer+0x314/0x690 net/ipv6/addrconf.c:3840
 call_timer_fn+0x272/0x920 kernel/time/timer.c:1326
 expire_timers kernel/time/timer.c:1363 [inline]
 __run_timers+0x7e5/0xc70 kernel/time/timer.c:1682
cgroup: fork rejected by pids controller in /syz0
 run_timer_softirq+0x52/0xb0 kernel/time/timer.c:1695
cgroup: fork rejected by pids controller in /syz4
 __do_softirq+0x308/0xb7e kernel/softirq.c:292
cgroup: fork rejected by pids controller in /syz3
 invoke_softirq kernel/softirq.c:373 [inline]
 irq_exit+0x17f/0x1c0 kernel/softirq.c:413
 exiting_irq arch/x86/include/asm/apic.h:536 [inline]
 smp_apic_timer_interrupt+0x1cb/0x760 arch/x86/kernel/apic/apic.c:1061
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:804
 
RIP: 0010:arch_atomic_add_negative arch/x86/include/asm/atomic.h:154  
[inline]
RIP: 0010:atomic_add_negative include/asm-generic/atomic-instrumented.h:398  
[inline]

RIP: 0010:page_remove_file_rmap mm/rmap.c:1235 [inline]
RIP: 0010:page_remove_rmap+0x934/0x1a30 mm/rmap.c:1300
Code: 32 6a c7 ff 45 85 ff 0f 85 45 fb ff ff e9 0d f9 ff ff e8 0f 69 c7 ff  
48 8d 7b 30 be 04 00 00 00 e8 11 d6 0a 00 f0 83 43 30 ff <41> 0f 98 c4 31  
ff 44 89 e6 e8 be 69 c7 ff 45 84 e4 0f 84 3e ff ff

RSP: 0018:8881c1786918 EFLAGS: 0213 ORIG_RAX: ff13
RAX: f94000d8c6b7 RBX: ea0006c63580 RCX: 81b821ef
RDX: 0001 RSI: 0004 RDI: ea0006c635b0
RBP: 8881c1786c88 R08: f94000d8c6b7 R09: f94000d8c6b6
R10: f94000d8c6b6 R11: ea0006c635b3 R12: 
R13: 8881c1786c60 R14: ea0006c63588 R15: 
 zap_pte_range mm/memory.c:1091 [inline]
 zap_pmd_range mm/memory.c:1193 [inline]
 zap_pud_range mm/memory.c:1222 [inline]
 zap_p4d_range mm/memory.c:1243 [inline]
 unmap_page_range+0x11c7/0x2930 mm/memory.c:1264
 unmap_single_vma+0x19b/0x310 mm/memory.c:1309
 unmap_vmas+0x125/0x200 mm/memory.c:1339
 exit_mmap+0x2be/0x590 mm/mmap.c:3145
 __mmput kernel/fork.c:1045 [inline]
 mmput+0x247/0x610 kernel/fork.c:1066
 exit_mm kernel/exit.c:545 [inline]
 do_exit+0xe74/0x26d0 kernel/exit.c:854
 do_group_exit+0x177/0x440 

KASAN: use-after-free Read in neigh_mark_dead

2018-12-09 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:a60956ed72f7 net: dsa: Make dsa_master_set_mtu() static
git tree:   net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=14df67eb40
kernel config:  https://syzkaller.appspot.com/x/.config?x=28ecefa8a6e10719
dashboard link: https://syzkaller.appspot.com/bug?extid=35e87b87c00f386b041f
compiler:   gcc (GCC) 8.0.1 20180413 (experimental)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=1444565d40
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=123832db40

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

IPv6: ADDRCONF(NETDEV_UP): veth1: link is not ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready
8021q: adding VLAN 0 to HW filter on device team0
==
BUG: KASAN: use-after-free in __list_del_entry_valid+0xf1/0x100  
lib/list_debug.c:51

Read of size 8 at addr 8881bb7394b0 by task ip/7510

CPU: 0 PID: 7510 Comm: ip Not tainted 4.20.0-rc4+ #335
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 __list_del_entry_valid+0xf1/0x100 lib/list_debug.c:51
 __list_del_entry include/linux/list.h:117 [inline]
 list_del_init include/linux/list.h:159 [inline]
 neigh_mark_dead+0x13b/0x410 net/core/neighbour.c:125
 neigh_flush_dev+0x3a1/0x960 net/core/neighbour.c:290
 neigh_changeaddr+0x31/0x40 net/core/neighbour.c:319
 ndisc_netdev_event+0xe6/0x5b0 net/ipv6/ndisc.c:1770
 notifier_call_chain+0x17e/0x380 kernel/notifier.c:93
 __raw_notifier_call_chain kernel/notifier.c:394 [inline]
 raw_notifier_call_chain+0x2d/0x40 kernel/notifier.c:401
 call_netdevice_notifiers_info+0x3f/0x90 net/core/dev.c:1737
 call_netdevice_notifiers_extack net/core/dev.c:1749 [inline]
 call_netdevice_notifiers net/core/dev.c:1763 [inline]
 dev_set_mac_address+0x293/0x3b0 net/core/dev.c:7775
 do_setlink+0x7c7/0x3f30 net/core/rtnetlink.c:2447
 __rtnl_newlink+0xcde/0x19e0 net/core/rtnetlink.c:3115
 rtnl_newlink+0x6b/0xa0 net/core/rtnetlink.c:3240
 rtnetlink_rcv_msg+0x46a/0xc20 net/core/rtnetlink.c:4966
 netlink_rcv_skb+0x172/0x440 net/netlink/af_netlink.c:2477
 rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:4984
 netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
 netlink_unicast+0x5a5/0x760 net/netlink/af_netlink.c:1336
 netlink_sendmsg+0xa18/0xfc0 net/netlink/af_netlink.c:1917
 sock_sendmsg_nosec net/socket.c:621 [inline]
 sock_sendmsg+0xd5/0x120 net/socket.c:631
 ___sys_sendmsg+0x7fd/0x930 net/socket.c:2116
 __sys_sendmsg+0x11d/0x280 net/socket.c:2154
 __do_sys_sendmsg net/socket.c:2163 [inline]
 __se_sys_sendmsg net/socket.c:2161 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2161
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f1baeb6e320
Code: 02 48 83 c8 ff eb 8d 48 8b 05 14 7b 2a 00 f7 da 64 89 10 48 83 c8 ff  
eb c9 90 83 3d d5 d2 2a 00 00 75 10 b8 2e 00 00 00 0f 05 <48> 3d 01 f0 ff  
ff 73 31 c3 48 83 ec 08 e8 5e ba 00 00 48 89 04 24

RSP: 002b:7fff37bc5c58 EFLAGS: 0246 ORIG_RAX: 002e
RAX: ffda RBX: 7fff37bc9d50 RCX: 7f1baeb6e320
RDX:  RSI: 7fff37bc5c90 RDI: 0003
RBP: 7fff37bc5c90 R08:  R09: 000e
R10:  R11: 0246 R12: 5c0d8897
R13:  R14: 006395c0 R15: 7fff37bca530

Allocated by task 22:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 __do_kmalloc mm/slab.c:3722 [inline]
 __kmalloc+0x15b/0x760 mm/slab.c:3731
 kmalloc include/linux/slab.h:551 [inline]
 kzalloc include/linux/slab.h:741 [inline]
 neigh_alloc net/core/neighbour.c:375 [inline]
 ___neigh_create+0x13fc/0x2600 net/core/neighbour.c:553
 __neigh_create+0x30/0x40 net/core/neighbour.c:640
 ip6_finish_output2+0xa59/0x27a0 net/ipv6/ip6_output.c:117
 ip6_finish_output+0x58c/0xc60 net/ipv6/ip6_output.c:154
 NF_HOOK_COND include/linux/netfilter.h:278 [inline]
 ip6_output+0x232/0x9d0 net/ipv6/ip6_output.c:171
 dst_output include/net/dst.h:444 [inline]
 NF_HOOK include/linux/netfilter.h:289 [inline]
 ndisc_send_skb+0x1005/0x1560 net/ipv6/ndisc.c:491
 ndisc_send_ns+0x3c6/0x8e0 net/ipv6/ndisc.c:633
 addrconf_dad_work+0xbf2/0x1310 net/ipv6/addrconf.c:4081
 process_one_work+0xc90/0x1c40 kernel/workqueue.c:2153
 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
 

[PATCH] kernel/hung_task.c: force ignore_loglevel before panic

2018-12-09 Thread Liu, Chuansheng


Based on patch commit 401c636a0eeb ("kernel/hung_task.c:
show all hung tasks before panic"), we could get the
call stack of hung task.

However, if the console loglevel is not high, we still
can not get the useful information in practice, and
in most cases users don't set console loglevel to
high level.

This patch is to force ignore_loglevel before system
panic, so that the real useful information can be seen
in the console, instead of being like the following,
which doesn't have hung task information.

[  246.916600] INFO: task init:1 blocked for more than 120 seconds.
[  246.922320]   Tainted: G U  W 
4.19.0-quilt-2e5dc0ac-g51b6c21d76cc #1
[  246.926790] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this 
message.
[  246.932553] Kernel panic - not syncing: hung_task: blocked tasks
[  246.938503] CPU: 2 PID: 479 Comm: khungtaskd Tainted: G U  W 
4.19.0-quilt-2e5dc0ac-g51b6c21d76cc #1
[  246.990266] Call Trace:
[  246.991707]  dump_stack+0x4f/0x65
[  246.993710]  panic+0xde/0x231
[  246.995445]  watchdog+0x290/0x410
[  246.997390]  kthread+0x12c/0x150
[  246.999301]  ? reset_hung_task_detector+0x20/0x20
[  247.004825]  ? kthread_create_worker_on_cpu+0x70/0x70
[  247.007735]  ret_from_fork+0x35/0x40
[  247.010280] reboot: panic mode set: p,w
[  247.012619] Kernel Offset: 0x3400 from 0x8100 (relocation 
range: 0x8000-0xbfff)

Signed-off-by: Chuansheng Liu 
---
 include/linux/printk.h | 2 +-
 kernel/hung_task.c | 7 +++
 kernel/printk/printk.c | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index cf3eccf..24748c1 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -59,8 +59,8 @@ static inline const char *printk_skip_headers(const char 
*buffer)
  */
 #define CONSOLE_LOGLEVEL_DEFAULT CONFIG_CONSOLE_LOGLEVEL_DEFAULT
 #define CONSOLE_LOGLEVEL_QUIET  CONFIG_CONSOLE_LOGLEVEL_QUIET
-
 extern int console_printk[];
+extern bool ignore_loglevel;

 #define console_loglevel (console_printk[0])
 #define default_message_loglevel (console_printk[1])
diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index cb8e3e8..7d942d1 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -130,6 +130,13 @@ static void check_hung_task(struct task_struct *t, 
unsigned long timeout)
init_utsname()->version);
pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\""
" disables this message.\n");
+   /* When sysctl_hung_task_panic is set, we have to force
+* ignore_loglevel to get really useful hung task
+* information.
+*/
+   if (sysctl_hung_task_panic && !ignore_loglevel)
+   ignore_loglevel = true;
+
sched_show_task(t);
hung_task_show_lock = true;
}
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 1b2a029..31a7a56 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1135,7 +1135,7 @@ void __init setup_log_buf(int early)
free, (free * 100) / __LOG_BUF_LEN);
 }

-static bool __read_mostly ignore_loglevel;
+bool __read_mostly ignore_loglevel;

 static int __init ignore_loglevel_setup(char *str)
 {
--
2.7.4



Re: [PATCH v2] misc: cxl: Use device_type helpers to access the node type

2018-12-09 Thread Michael Ellerman
Rob Herring  writes:

> Remove directly accessing device_type property and use the
> of_node_is_type accessor instead. While not using it here, this is
> part of eventually removing the struct device_node.type pointer.
>
> Cc: Frederic Barrat 
> Cc: Arnd Bergmann 
> Cc: Greg Kroah-Hartman 
> Cc: linuxppc-...@lists.ozlabs.org
> Acked-by: Andrew Donnellan 
> Signed-off-by: Rob Herring 
> ---
> v2:
> - Reword commit message as this change was using the .type ptr.

I already have v1 in my next.

cheers

> diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
> index b66d832d3233..c79ba1c699ad 100644
> --- a/drivers/misc/cxl/pci.c
> +++ b/drivers/misc/cxl/pci.c
> @@ -1718,7 +1718,6 @@ int cxl_slot_is_switched(struct pci_dev *dev)
>  {
>   struct device_node *np;
>   int depth = 0;
> - const __be32 *prop;
>  
>   if (!(np = pci_device_to_OF_node(dev))) {
>   pr_err("cxl: np = NULL\n");
> @@ -1727,8 +1726,7 @@ int cxl_slot_is_switched(struct pci_dev *dev)
>   of_node_get(np);
>   while (np) {
>   np = of_get_next_parent(np);
> - prop = of_get_property(np, "device_type", NULL);
> - if (!prop || strcmp((char *)prop, "pciex"))
> + if (!of_node_is_type(np, "pciex"))
>   break;
>   depth++;
>   }
> -- 
> 2.19.1


Re: [PATCH v4 0/7] mips: system call table generation support

2018-12-09 Thread Firoz Khan
Hi Paul,

On Thu, 6 Dec 2018 at 10:49, Firoz Khan  wrote:
>
> The purpose of this patch series is, we can easily
> add/modify/delete system call table support by cha-
> nging entry in syscall.tbl file instead of manually
> changing many files. The other goal is to unify the
> system call table generation support implementation
> across all the architectures.
>
> The system call tables are in different format in
> all architecture. It will be difficult to manually
> add, modify or delete the system calls in the resp-
> ective files manually. To make it easy by keeping a
> script and which'll generate uapi header file and
> syscall table file.
>
> syscall.tbl contains the list of available system
> calls along with system call number and correspond-
> ing entry point. Add a new system call in this arch-
> itecture will be possible by adding new entry in
> the syscall.tbl file.
>
> Adding a new table entry consisting of:
> - System call number.
> - ABI.
> - System call name.
> - Entry point name.
> - Compat entry name, if required.
>
> ARM, s390 and x86 architecuture does exist the sim-
> ilar support. I leverage their implementation to
> come up with a generic solution.
>
> I have done the same support for work for alpha,
> ia64, m68k, microblaze, parisc, powerpc, sh, sparc,
> and xtensa. Below mentioned git repository contains
> more details about the workflow.
>
> https://github.com/frzkhn/system_call_table_generator/
>
> Finally, this is the ground work to solve the Y2038
> issue. We need to add two dozen of system calls to
> solve Y2038 issue. So this patch series will help to
> add new system calls easily by adding new entry in
> the syscall.tbl.
>
> Changes since v3:
>  - rearranged the patches for '64' to 'n64' conver-
>sion.
>  - moved the unistd_nr_*.h files to asm/unistd.h
>  - modified the *.sh files.

Please review this patch series and queue it for linux-next.

Thanks
Firoz

>
> Changes since v2:
>  - fixed __NR_syscalls assign issue.
>
> Changes since v1:
>  - optimized/updated the syscall table generation
>scripts.
>  - fixed all mixed indentation issues in syscall.tbl.
>  - added "comments" in syscall_*.tbl.
>  - changed from generic-y to generated-y in Kbuild.
>
> Firoz Khan (7):
>   mips: add __NR_syscalls along with __NR_Linux_syscalls
>   mips: remove unused macros
>   mips: rename macros and files from '64' to 'n64'
>   mips: add +1 to __NR_syscalls in uapi header
>   mips: remove syscall table entries
>   mips: add system call table generation support
>   mips: generate uapi header and system call table files
>
>  arch/mips/Makefile|3 +
>  arch/mips/include/asm/Kbuild  |4 +
>  arch/mips/include/asm/asm.h   |6 +-
>  arch/mips/include/asm/fpregdef.h  |4 +-
>  arch/mips/include/asm/fw/arc/hinv.h   |2 +-
>  arch/mips/include/asm/regdef.h|4 +-
>  arch/mips/include/asm/sigcontext.h|4 +-
>  arch/mips/include/asm/unistd.h|   11 +-
>  arch/mips/include/uapi/asm/Kbuild |6 +
>  arch/mips/include/uapi/asm/fcntl.h|2 +-
>  arch/mips/include/uapi/asm/reg.h  |4 +-
>  arch/mips/include/uapi/asm/sgidefs.h  |2 +-
>  arch/mips/include/uapi/asm/sigcontext.h   |4 +-
>  arch/mips/include/uapi/asm/stat.h |4 +-
>  arch/mips/include/uapi/asm/statfs.h   |4 +-
>  arch/mips/include/uapi/asm/unistd.h   | 1069 
> +
>  arch/mips/kernel/Makefile |2 +-
>  arch/mips/kernel/ftrace.c |8 +-
>  arch/mips/kernel/scall32-o32.S|  391 +--
>  arch/mips/kernel/scall64-64.S |  444 
>  arch/mips/kernel/scall64-n32.S|  341 +
>  arch/mips/kernel/scall64-n64.S|  117 
>  arch/mips/kernel/scall64-o32.S|  379 +-
>  arch/mips/kernel/syscalls/Makefile|   96 +++
>  arch/mips/kernel/syscalls/syscall_n32.tbl |  343 +
>  arch/mips/kernel/syscalls/syscall_n64.tbl |  339 +
>  arch/mips/kernel/syscalls/syscall_o32.tbl |  382 +++
>  arch/mips/kernel/syscalls/syscallhdr.sh   |   37 +
>  arch/mips/kernel/syscalls/syscallnr.sh|   28 +
>  arch/mips/kernel/syscalls/syscalltbl.sh   |   36 +
>  arch/mips/kvm/entry.c |4 +-
>  arch/mips/vdso/vdso.h |2 +-
>  arch/mips/vdso/vdso.lds.S |2 +-
>  33 files changed, 1450 insertions(+), 2634 deletions(-)
>  delete mode 100644 arch/mips/kernel/scall64-64.S
>  create mode 100644 arch/mips/kernel/scall64-n64.S
>  create mode 100644 arch/mips/kernel/syscalls/Makefile
>  create mode 100644 arch/mips/kernel/syscalls/syscall_n32.tbl
>  create mode 100644 arch/mips/kernel/syscalls/syscall_n64.tbl
>  create mode 100644 arch/mips/kernel/syscalls/syscall_o32.tbl
>  create mode 100644 arch/mips/kernel/syscalls/syscallhdr.sh

linux-next: manual merge of the driver-core tree with the pm tree

2018-12-09 Thread Stephen Rothwell
Hi all,

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

  drivers/base/platform.c
u
between commit:

  2d51ac9086fd ("driver core: platform: Remove duplicated 
device_remove_properties() call")

from the pm tree and commit:

  99fef587ff98 ("driver core: platform: Respect return code of 
platform_device_register_full()")

from the driver-core tree.

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

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/base/platform.c
index 0fb5f140f1b0,e1ba610482c0..
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@@ -447,7 -447,8 +447,7 @@@ void platform_device_del(struct platfor
  {
int i;
  
-   if (pdev) {
+   if (!IS_ERR_OR_NULL(pdev)) {
 -  device_remove_properties(>dev);
device_del(>dev);
  
if (pdev->id_auto) {


pgpKtCa6q0O48.pgp
Description: OpenPGP digital signature


Re: linux-next: manual merge of the device-mapper tree with the block tree

2018-12-09 Thread Mike Snitzer
On Sun, Dec 09 2018 at 10:55pm -0500,
Jens Axboe  wrote:

> On 12/9/18 8:43 PM, Stephen Rothwell wrote:
> > Hi all,
> > 
> > It appears that there are a series of shared patches between the block
> > and device-mapper trees that are not the same commits.  I assume that the
> > block tree has been rebased, while the device mapper tree that was based
> > (or includes) part of the block tree has not bee rebased (yet).
> 
> Yep that's my fault, due to a stupid mistake I had to rebase the
> block tree. Didn't realize that Mike's tree was based on it. Mike,
> would it be a big issue for you to rebase the dm tree?

No problem, just did it and pushed to linux-dm.git's for-next.
(I was already anticipating rebasing dm's for-next again once the
bio-based percpu in_flight was merged into linux-block, hopefully we can
get that to land)


Re: linux-next: manual merge of the rcu tree with the crypto tree

2018-12-09 Thread Stephen Rothwell
Hi all,

On Mon, 10 Dec 2018 15:47:44 +1100 Stephen Rothwell  
wrote:
>
> I fixed it up (I used the crypto tree version of the changes) and can

This turned out to be the correct thing to do since my email to Paulo
Flabiano Smorigo  (when forwarded to 
) bounced.   ;-)
 

-- 
Cheers,
Stephen Rothwell


pgpNOTr4M8FAx.pgp
Description: OpenPGP digital signature


Re: [PATCH v5 19/25] xtensa: define syscall_get_* functions

2018-12-09 Thread Max Filippov
Hello,

On Sun, Dec 9, 2018 at 8:30 PM Dmitry V. Levin  wrote:
> syscall_get_* functions are required to be implemented on all
> architectures in order to extend the generic ptrace API with
> PTRACE_GET_SYSCALL_INFO request.
>
> This adds all 5 syscall_get_* functions on xtensa as documented
> in asm-generic/syscall.h: syscall_get_nr, syscall_get_arguments,
> syscall_get_error, syscall_get_return_value, and syscall_get_arch.

I have this set of functions plus syscall_set_arguments implemented
for syscall tracing here:
  
https://github.com/jcmvbkbc/linux-xtensa/commit/0023f56298cc92ce47e61b1b5dd1038f7be4f826

How should we synchronize our changes?

> diff --git a/arch/xtensa/include/asm/syscall.h 
> b/arch/xtensa/include/asm/syscall.h
> index 3673ff1f1bc5..d529c855a144 100644
> --- a/arch/xtensa/include/asm/syscall.h
> +++ b/arch/xtensa/include/asm/syscall.h

[...]

> +static inline void
> +syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
> + unsigned int i, unsigned int n, unsigned long *args)
> +{
> +   switch (i) {
> +   case 0:
> +   if (!n--)
> +   break;
> +   *args++ = regs->areg[6];
> +   /* fall through */
> +   case 1:
> +   if (!n--)
> +   break;
> +   *args++ = regs->areg[3];
> +   /* fall through */
> +   case 2:
> +   if (!n--)
> +   break;
> +   *args++ = regs->areg[4];
> +   /* fall through */
> +   case 3:
> +   if (!n--)
> +   break;
> +   *args++ = regs->areg[5];
> +   /* fall through */
> +   case 4:
> +   if (!n--)
> +   break;
> +   *args++ = regs->areg[8];
> +   /* fall through */
> +   case 5:
> +   if (!n--)
> +   break;
> +   *args++ = regs->areg[9];
> +   /* fall through */
> +   case 6:
> +   if (!n--)
> +   break;
> +   /* fall through */
> +   default:
> +   BUG();

A WARN should be enough.

-- 
Thanks.
-- Max


KASAN: use-after-free Read in tipc_group_bc_cong

2018-12-09 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:0844895a2e51 Merge tag 'char-misc-4.20-rc6' of git://git.k..
git tree:   upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=153c192540
kernel config:  https://syzkaller.appspot.com/x/.config?x=8110fb1cd164e8f
dashboard link: https://syzkaller.appspot.com/bug?extid=10a9db47c3a0e13eb31c
compiler:   gcc (GCC) 8.0.1 20180413 (experimental)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=177a927d40
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=11b59da340

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

audit: type=1400 audit(1544417020.270:36): avc:  denied  { map } for   
pid=6121 comm="syz-executor870" path="/root/syz-executor870904155"  
dev="sda1" ino=16484 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023  
tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1

==
BUG: KASAN: use-after-free in tipc_group_bc_cong+0x327/0x3f0  
net/tipc/group.c:448

Read of size 2 at addr 8881d7bc1674 by task syz-executor870/6139

CPU: 0 PID: 6139 Comm: syz-executor870 Not tainted 4.20.0-rc5+ #149
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:431
 tipc_group_bc_cong+0x327/0x3f0 net/tipc/group.c:448
 tipc_send_group_bcast+0x50a/0xd90 net/tipc/socket.c:1023
 __tipc_sendmsg+0xeec/0x1d40 net/tipc/socket.c:1307
 tipc_sendmsg+0x50/0x70 net/tipc/socket.c:1272
 sock_sendmsg_nosec net/socket.c:621 [inline]
 sock_sendmsg+0xd5/0x120 net/socket.c:631
 ___sys_sendmsg+0x51d/0x930 net/socket.c:2116
 __sys_sendmmsg+0x246/0x6d0 net/socket.c:2211
 __do_sys_sendmmsg net/socket.c:2240 [inline]
 __se_sys_sendmmsg net/socket.c:2237 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2237
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x446339
Code: e8 2c b3 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7  
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff  
ff 0f 83 2b 09 fc ff c3 66 2e 0f 1f 84 00 00 00 00

RSP: 002b:7ff1bd83bdb8 EFLAGS: 0297 ORIG_RAX: 0133
RAX: ffda RBX: 006dac38 RCX: 00446339
RDX: 0142 RSI: 2000 RDI: 0006
RBP: 006dac30 R08:  R09: 
R10:  R11: 0297 R12: 006dac3c
R13: 7ffea6d1565f R14: 7ff1bd83c9c0 R15: 006dad2c

Allocated by task 6139:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 kmem_cache_alloc_trace+0x152/0x750 mm/slab.c:3620
 kmalloc include/linux/slab.h:546 [inline]
 kzalloc include/linux/slab.h:741 [inline]
 tipc_group_create+0x152/0xa70 net/tipc/group.c:171
 tipc_sk_join net/tipc/socket.c:2829 [inline]
 tipc_setsockopt+0x2d1/0xd70 net/tipc/socket.c:2944
 __sys_setsockopt+0x1ba/0x3c0 net/socket.c:1902
 __do_sys_setsockopt net/socket.c:1913 [inline]
 __se_sys_setsockopt net/socket.c:1910 [inline]
 __x64_sys_setsockopt+0xbe/0x150 net/socket.c:1910
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 6140:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xcf/0x230 mm/slab.c:3817
 tipc_group_delete+0x2e4/0x3f0 net/tipc/group.c:227
 tipc_sk_leave+0x113/0x220 net/tipc/socket.c:2863
 tipc_setsockopt+0x97d/0xd70 net/tipc/socket.c:2947
 __sys_setsockopt+0x1ba/0x3c0 net/socket.c:1902
 __do_sys_setsockopt net/socket.c:1913 [inline]
 __se_sys_setsockopt net/socket.c:1910 [inline]
 __x64_sys_setsockopt+0xbe/0x150 net/socket.c:1910
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at 8881d7bc1600
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 116 bytes inside of
 192-byte region [8881d7bc1600, 8881d7bc16c0)
The buggy address belongs to the page:
page:ea00075ef040 count:1 mapcount:0 mapping:8881da800040 index:0x0
flags: 0x2fffc000200(slab)
raw: 02fffc000200 ea00075e7e88 ea00075d5c08 8881da800040
raw:  8881d7bc1000 00010010 
page dumped because: kasan: bad access detected


KASAN: slab-out-of-bounds Write in default_read_copy_kernel

2018-12-09 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:abb8d6ecbd8f Merge tag 'trace-v4.20-rc5' of git://git.kern..
git tree:   upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17932f4d40
kernel config:  https://syzkaller.appspot.com/x/.config?x=b9cc5a440391cbfd
dashboard link: https://syzkaller.appspot.com/bug?extid=12f17c177de05efea72d
compiler:   gcc (GCC) 8.0.1 20180413 (experimental)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=16c2712540
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=152a2a4340

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

RDX: 0001 RSI: 20001640 RDI: 0003
RBP: 006cf018 R08: 0001 R09: 0037
R10:  R11: 0246 R12: 0004
R13:  R14:  R15: 
==
BUG: KASAN: slab-out-of-bounds in memcpy include/linux/string.h:352 [inline]
BUG: KASAN: slab-out-of-bounds in default_read_copy_kernel+0xe1/0x140  
sound/core/pcm_lib.c:1988

Write of size 64 at addr 8881cec699c0 by task syz-executor520/6056

CPU: 1 PID: 6056 Comm: syz-executor520 Not tainted 4.20.0-rc5+ #365
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
 check_memory_region_inline mm/kasan/kasan.c:260 [inline]
 check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
 memcpy+0x37/0x50 mm/kasan/kasan.c:303
 memcpy include/linux/string.h:352 [inline]
 default_read_copy_kernel+0xe1/0x140 sound/core/pcm_lib.c:1988
 interleaved_copy+0xd1/0x110 sound/core/pcm_lib.c:2007
 __snd_pcm_lib_xfer+0x115f/0x1f23 sound/core/pcm_lib.c:2227
 snd_pcm_oss_read3+0x1c8/0x410 sound/core/oss/pcm_oss.c:1274
 io_capture_transfer+0x27d/0x310 sound/core/oss/io.c:73
 snd_pcm_plug_read_transfer+0x1d7/0x3b0 sound/core/oss/pcm_plugin.c:651
 snd_pcm_oss_read2+0x221/0x450 sound/core/oss/pcm_oss.c:1474
 snd_pcm_oss_read1 sound/core/oss/pcm_oss.c:1531 [inline]
 snd_pcm_oss_read+0x638/0x830 sound/core/oss/pcm_oss.c:2752
 do_loop_readv_writev fs/read_write.c:700 [inline]
 do_iter_read+0x4a3/0x650 fs/read_write.c:924
 vfs_readv+0x175/0x1c0 fs/read_write.c:986
 do_readv+0x11a/0x310 fs/read_write.c:1019
 __do_sys_readv fs/read_write.c:1106 [inline]
 __se_sys_readv fs/read_write.c:1103 [inline]
 __x64_sys_readv+0x75/0xb0 fs/read_write.c:1103
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x444079
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7  
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff  
ff 0f 83 7b d8 fb ff c3 66 2e 0f 1f 84 00 00 00 00

RSP: 002b:7ffc8067a328 EFLAGS: 0246 ORIG_RAX: 0013
RAX: ffda RBX:  RCX: 00444079
RDX: 0001 RSI: 20001640 RDI: 0003
RBP: 006cf018 R08: 0001 R09: 0037
R10:  R11: 0246 R12: 0004
R13:  R14:  R15: 

Allocated by task 6056:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 __do_kmalloc_node mm/slab.c:3684 [inline]
 __kmalloc_node+0x50/0x70 mm/slab.c:3691
 kmalloc_node include/linux/slab.h:589 [inline]
 kvmalloc_node+0x65/0xf0 mm/util.c:416
 kvmalloc include/linux/mm.h:577 [inline]
 kvzalloc include/linux/mm.h:585 [inline]
 snd_pcm_plugin_alloc+0x577/0x770 sound/core/oss/pcm_plugin.c:70
 snd_pcm_plug_alloc+0x149/0x340 sound/core/oss/pcm_plugin.c:129
 snd_pcm_oss_change_params_locked+0x2209/0x3c60  
sound/core/oss/pcm_oss.c:1038

 snd_pcm_oss_make_ready_locked+0xbc/0x130 sound/core/oss/pcm_oss.c:1183
 snd_pcm_oss_read1 sound/core/oss/pcm_oss.c:1507 [inline]
 snd_pcm_oss_read+0x417/0x830 sound/core/oss/pcm_oss.c:2752
 do_loop_readv_writev fs/read_write.c:700 [inline]
 do_iter_read+0x4a3/0x650 fs/read_write.c:924
 vfs_readv+0x175/0x1c0 fs/read_write.c:986
 do_readv+0x11a/0x310 fs/read_write.c:1019
 __do_sys_readv fs/read_write.c:1106 [inline]
 __se_sys_readv fs/read_write.c:1103 [inline]
 __x64_sys_readv+0x75/0xb0 fs/read_write.c:1103
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 9:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 

Re: [LKP] [mm] ac5b2c1891: vm-scalability.throughput -61.3% regression

2018-12-09 Thread Andrea Arcangeli
Hello,

On Sun, Dec 09, 2018 at 04:29:13PM -0800, David Rientjes wrote:
> [..] on this platform, at least, hugepages are 
> preferred on the same socket but there isn't a significant benefit from 
> getting a cross socket hugepage over small page. [..]

You didn't release the proprietary software that depends on
__GFP_THISNODE behavior and that you're afraid is getting a
regression.

Could you at least release with an open source license the benchmark
software that you must have used to do the above measurement to
understand why it gives such a weird result on remote THP?

On skylake and on the threadripper I can't confirm that there isn't a
significant benefit from cross socket hugepage over cross socket small
page.

Skylake Xeon(R) Gold 5115:

# numactl --hardware
available: 2 nodes (0-1)
node 0 cpus: 0 1 2 3 4 5 6 7 8 9 20 21 22 23 24 25 26 27 28 29
node 0 size: 15602 MB
node 0 free: 14077 MB
node 1 cpus: 10 11 12 13 14 15 16 17 18 19 30 31 32 33 34 35 36 37 38 39
node 1 size: 16099 MB
node 1 free: 15949 MB
node distances:
node   0   1
  0:  10  21
  1:  21  10
# numactl -m 0 -C 0 ./numa-thp-bench
random writes MADV_HUGEPAGE 10109753 usec
random writes MADV_NOHUGEPAGE 13682041 usec
random writes MADV_NOHUGEPAGE 13704208 usec
random writes MADV_HUGEPAGE 10120405 usec
# numactl -m 0 -C 10 ./numa-thp-bench
random writes MADV_HUGEPAGE 15393923 usec
random writes MADV_NOHUGEPAGE 19644793 usec
random writes MADV_NOHUGEPAGE 19671287 usec
random writes MADV_HUGEPAGE 15495281 usec
# grep Xeon /proc/cpuinfo |head -1
model name  : Intel(R) Xeon(R) Gold 5115 CPU @ 2.40GHz

local 4k -> local 2m: +35%
local 4k -> remote 2m: -11% 
remote 4k -> remote 2m: +26%

threadripper 1950x:

# numactl --hardware
available: 2 nodes (0-1)
node 0 cpus: 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23
node 0 size: 15982 MB
node 0 free: 14422 MB
node 1 cpus: 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31
node 1 size: 16124 MB
node 1 free: 5357 MB
node distances:
node   0   1
  0:  10  16
  1:  16  10
# numactl -m 0 -C 0 /tmp/numa-thp-bench
random writes MADV_HUGEPAGE 12902667 usec
random writes MADV_NOHUGEPAGE 17543070 usec
random writes MADV_NOHUGEPAGE 17568858 usec
random writes MADV_HUGEPAGE 12896588 usec
# numactl -m 0 -C 8 /tmp/numa-thp-bench
random writes MADV_HUGEPAGE 19663515 usec
random writes MADV_NOHUGEPAGE 27819864 usec
random writes MADV_NOHUGEPAGE 27844066 usec
random writes MADV_HUGEPAGE 19662706 usec
# grep Threadripper /proc/cpuinfo |head -1
model name  : AMD Ryzen Threadripper 1950X 16-Core Processor

local 4k -> local 2m: +35%
local 4k -> remote 2m: -10% 
remote 4k -> remote 2m: +41%

Or if you prefer reversed in terms of compute time (negative
percentage is better in this case):

local 4k -> local 2m: -26%
local 4k -> remote 2m: +12%
remote 4k -> remote 2m: -29%

It's true that local 4k is generally a win vs remote THP when the
workload is memory bound also for the threadripper, the threadripper
seems even more favorable to remote THP than skylake Xeon is.

The above is the host bare metal result. Now let's try guest mode on
the threadripper. The last two lines seems more reliable (the first
two lines also needs to fault in the guest RAM because the guest
was fresh booted).

guest backed by local 2M pages:

random writes MADV_HUGEPAGE 16025855 usec
random writes MADV_NOHUGEPAGE 21903002 usec
random writes MADV_NOHUGEPAGE 19762767 usec
random writes MADV_HUGEPAGE 15189231 usec

guest backed by remote 2M pages:

random writes MADV_HUGEPAGE 25434251 usec
random writes MADV_NOHUGEPAGE 32404119 usec
random writes MADV_NOHUGEPAGE 31455592 usec
random writes MADV_HUGEPAGE 22248304 usec

guest backed by local 4k pages:

random writes MADV_HUGEPAGE 28945251 usec
random writes MADV_NOHUGEPAGE 32217690 usec
random writes MADV_NOHUGEPAGE 30664731 usec
random writes MADV_HUGEPAGE 22981082 usec

guest backed by remote 4k pages:

random writes MADV_HUGEPAGE 43772939 usec
random writes MADV_NOHUGEPAGE 52745664 usec
random writes MADV_NOHUGEPAGE 51632065 usec
random writes MADV_HUGEPAGE 40263194 usec

I haven't yet tried the guest mode on the skylake nor
haswell/broadwell. I can do that too but I don't expect a significant
difference.

On a threadripper guest, the remote 2m is practically identical to
local 4k. So shutting down compaction to try to generate local 4k
memory looks a sure loss.

Even if we ignore the guest mode results completely, if we don't make
assumption on the workload to be able to fit in the node, if I use
MADV_HUGEPAGE I think I'd prefer the risk of a -10% slowdown if the
THP page ends up in a remote node, than not getting the +41% THP
speedup on remote memory if the pagetable ends up being remote or the
4k page itself ends up being remote over time.

The cons left from your latest patch, is that you eventually also lose
the +35% speedup when compaction is clogged by COMPACT_SKIPPED, which
for a guest mode computation translates in losing the +59% speedup of
having host local THP (when guest uses 4k pages). 

linux-next: manual merge of the rcu tree with the crypto tree

2018-12-09 Thread Stephen Rothwell
Hi all,

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

  MAINTAINERS

between commit:

  c97e4df573f2 ("MAINTAINERS: change NX/VMX maintainers")

from the crypto tree and commit:

  1dfddcdb95c4 ("MAINTAINERS: Update from @linux.vnet.ibm.com to 
@linux.ibm.com")

from the rcu tree.

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

-- 
Cheers,
Stephen Rothwell


pgpSHFWSYDMj4.pgp
Description: OpenPGP digital signature


Re: [PATCH 00/23] PCI: refactor the Mobiveil driver and add PCIe support for NXP LX SoCs

2018-12-09 Thread Subrahmanya Lingappa
Lorenzo,
You are right, I reviewed few DT files, will need some time to review
this train.
I will start doing it in a while.

Thanks for pitching in.

Thanks.

On Mon, Dec 3, 2018 at 8:58 AM Lorenzo Pieralisi
 wrote:
>
> On Tue, Nov 06, 2018 at 01:19:03PM +, Z.q. Hou wrote:
> > From: Hou Zhiqiang 
> >
> > This patch set is aim to refactor the Mobiveil driver and add
> > PCIe support for NXP LX series SoCs.
> >
> > Hou Zhiqiang (23):
> >   PCI: mobiveil: uniform the register accessors
> >   PCI: mobiveil: format the code without function change
> >   PCI: mobiveil: correct the returned error number
> >   PCI: mobiveil: remove flag MSI_FLAG_MULTI_PCI_MSI
> >   PCI: mobiveil: correct PCI base address in MEM/IO outbound windows
> >   PCI: mobiveil: replace the resource list iteration function
> >   PCI: mobiveil: use WIN_NUM_0 explicitly for CFG outbound window
> >   PCI: mobiveil: use the 1st inbound window for MEM inbound transactions
> >   PCI: mobiveil: correct the inbound/outbound window setup routine
> >   PCI: mobiveil: fix the INTx process error
> >   PCI: mobiveil: only fixup the Class Code field
> >   PCI: mobiveil: move out the link up waiting from mobiveil_host_init
> >   PCI: mobiveil: move irq chained handler setup out of DT parse
> >   PCI: mobiveil: initialize Primary/Secondary/Subordinate bus number
> >   dt-bindings: pci: mobiveil: change gpio_slave and apb_csr to optional
> >   PCI: mobiveil: refactor the Mobiveil driver
> >   PCI: mobiveil: continue to initialize the host upon no PCIe link
> >   PCI: mobiveil: disabled IB and OB windows set by bootloader
> >   PCI: mobiveil: add Byte and Half-Word width register accessors
> >   PCI: mobiveil: change prototype of function mobiveil_host_init
> >   dt-bindings: pci: Add NXP LX SoCs PCIe controller
> >   PCI: mobiveil: add PCIe RC driver for NXP LX series SoCs
> >   arm64: dts: freescale: lx2160a: add pcie DT nodes
> >
> >  .../devicetree/bindings/pci/lx-pci.txt|  52 ++
> >  .../devicetree/bindings/pci/mobiveil-pcie.txt |   2 +
> >  MAINTAINERS   |  10 +-
> >  .../arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 157 
> >  drivers/pci/controller/Kconfig|  11 +-
> >  drivers/pci/controller/Makefile   |   2 +-
> >  drivers/pci/controller/mobiveil/Kconfig   |  34 +
> >  drivers/pci/controller/mobiveil/Makefile  |   5 +
> >  drivers/pci/controller/mobiveil/pci-lx.c  | 222 +
> >  .../controller/mobiveil/pcie-mobiveil-host.c  | 622 +
> >  .../controller/mobiveil/pcie-mobiveil-plat.c  |  54 ++
> >  .../pci/controller/mobiveil/pcie-mobiveil.c   | 245 +
> >  .../pci/controller/mobiveil/pcie-mobiveil.h   | 221 +
> >  drivers/pci/controller/pcie-mobiveil.c| 861 --
> >  14 files changed, 1625 insertions(+), 873 deletions(-)
> >  create mode 100644 Documentation/devicetree/bindings/pci/lx-pci.txt
> >  create mode 100644 drivers/pci/controller/mobiveil/Kconfig
> >  create mode 100644 drivers/pci/controller/mobiveil/Makefile
> >  create mode 100644 drivers/pci/controller/mobiveil/pci-lx.c
> >  create mode 100644 drivers/pci/controller/mobiveil/pcie-mobiveil-host.c
> >  create mode 100644 drivers/pci/controller/mobiveil/pcie-mobiveil-plat.c
> >  create mode 100644 drivers/pci/controller/mobiveil/pcie-mobiveil.c
> >  create mode 100644 drivers/pci/controller/mobiveil/pcie-mobiveil.h
> >  delete mode 100644 drivers/pci/controller/pcie-mobiveil.c
>
> Subrahmanya,
>
> for the records, this is the driver *you* are maintaining, aren't you ?
>
> We ask developers to be added to the MAINTAINERS list in order to hold
> them accountable, merging a driver upstream means that you need to
> actively maintain it, which in turn means reviewing series affecting
> its code, like this one.
>
> I will have a look too but it is your responsibility to review these
> patches and ACK them accordingly.
>
> So I strongly suggest you start doing it please.
>
> Thanks,
> Lorenzo


[PATCH] ASoC: Intel: kbl_da7219_max98927: fix the audio jack button remapping

2018-12-09 Thread Zhuohao Lee
>From the da7219 spec, the button A, B, C and D are remapped to
0, 1, 2 and 3 respectively where button A is KEY_PLAYPAUSE,
B is KEY_VOLUMEUP, C is KEY_VOLUMEDOWN and D is KEY_VOICECOMMAND.

Signed-off-by: Zhuohao Lee 
Signed-off-by: Max Chang  
---
 sound/soc/intel/boards/kbl_da7219_max98927.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/intel/boards/kbl_da7219_max98927.c 
b/sound/soc/intel/boards/kbl_da7219_max98927.c
index 3fa1c3ca6d37..d3531f0eb357 100644
--- a/sound/soc/intel/boards/kbl_da7219_max98927.c
+++ b/sound/soc/intel/boards/kbl_da7219_max98927.c
@@ -262,9 +262,9 @@ static int kabylake_da7219_codec_init(struct 
snd_soc_pcm_runtime *rtd)
 
jack = >kabylake_headset;
snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
-   snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
-   snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
-   snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
+   snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
+   snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
+   snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
 
da7219_aad_jack_det(component, >kabylake_headset);
 
-- 
2.20.0.rc2.403.gdbc3b29805-goog



[PATCH v5 22/25] syscall_get_arch: add "struct task_struct *" argument

2018-12-09 Thread Dmitry V. Levin
This argument is required to extend the generic ptrace API with
PTRACE_GET_SYSCALL_INFO request: syscall_get_arch() is going
to be called from ptrace_request() along with syscall_get_nr(),
syscall_get_arguments(), syscall_get_error(), and
syscall_get_return_value() functions with a tracee as their argument.

Reverts: 5e937a9ae913 ("syscall_get_arch: remove useless function arguments")
Reverts: 1002d94d3076 ("syscall.h: fix doc text for syscall_get_arch()")
Reviewed-by: Andy Lutomirski  # for x86
Reviewed-by: Palmer Dabbelt 
Acked-by: Paul Burton  # MIPS parts
Acked-by: Michael Ellerman  (powerpc)
Cc: Eric Paris 
Cc: Paul Moore 
Cc: Richard Henderson 
Cc: Ivan Kokshaysky 
Cc: Matt Turner 
Cc: Vineet Gupta 
Cc: Russell King 
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: Mark Salter 
Cc: Aurelien Jacquiot 
Cc: Yoshinori Sato 
Cc: Richard Kuo 
Cc: Tony Luck 
Cc: Fenghua Yu 
Cc: Geert Uytterhoeven 
Cc: Michal Simek 
Cc: Greentime Hu 
Cc: Vincent Chen 
Cc: Ley Foon Tan 
Cc: Jonas Bonn 
Cc: Stefan Kristiansson 
Cc: Stafford Horne 
Cc: James E.J. Bottomley 
Cc: Helge Deller 
Cc: Albert Ou 
Cc: Martin Schwidefsky 
Cc: Heiko Carstens 
Cc: Rich Felker 
Cc: David S. Miller 
Cc: Guan Xuetao 
Cc: Jeff Dike 
Cc: Richard Weinberger 
Cc: Chris Zankel 
Cc: Max Filippov 
Cc: Arnd Bergmann 
Cc: Kees Cook 
Cc: Will Drewry 
Cc: Oleg Nesterov 
Cc: Elvira Khabirova 
Cc: Eugene Syromyatnikov 
Cc: Ralf Baechle 
Cc: James Hogan 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: H. Peter Anvin 
Cc: x...@kernel.org
Cc: linux-al...@vger.kernel.org
Cc: linux-snps-...@lists.infradead.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-c6x-...@linux-c6x.org
Cc: uclinux-h8-de...@lists.sourceforge.jp
Cc: linux-hexa...@vger.kernel.org
Cc: linux-i...@vger.kernel.org
Cc: linux-m...@lists.linux-m68k.org
Cc: linux-m...@vger.kernel.org
Cc: nios2-...@lists.rocketboards.org
Cc: openr...@lists.librecores.org
Cc: linux-par...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-ri...@lists.infradead.org
Cc: linux-s...@vger.kernel.org
Cc: linux...@vger.kernel.org
Cc: sparcli...@vger.kernel.org
Cc: linux...@lists.infradead.org
Cc: linux-xte...@linux-xtensa.org
Cc: linux-a...@vger.kernel.org
Cc: linux-au...@redhat.com
Signed-off-by: Dmitry V. Levin 
---

Notes:
v5: fixed asm-generic docs by reverting 1002d94d3076, added Cc
v2: cleaned up mips part, added Reviewed-by

 arch/alpha/include/asm/syscall.h  |  2 +-
 arch/arc/include/asm/syscall.h|  2 +-
 arch/arm/include/asm/syscall.h|  2 +-
 arch/arm64/include/asm/syscall.h  |  4 ++--
 arch/c6x/include/asm/syscall.h|  2 +-
 arch/csky/include/asm/syscall.h   |  2 +-
 arch/h8300/include/asm/syscall.h  |  2 +-
 arch/hexagon/include/asm/syscall.h|  2 +-
 arch/ia64/include/asm/syscall.h   |  2 +-
 arch/m68k/include/asm/syscall.h   |  2 +-
 arch/microblaze/include/asm/syscall.h |  2 +-
 arch/mips/include/asm/syscall.h   |  6 +++---
 arch/mips/kernel/ptrace.c |  2 +-
 arch/nds32/include/asm/syscall.h  |  2 +-
 arch/nios2/include/asm/syscall.h  |  2 +-
 arch/openrisc/include/asm/syscall.h   |  2 +-
 arch/parisc/include/asm/syscall.h |  4 ++--
 arch/powerpc/include/asm/syscall.h| 10 --
 arch/riscv/include/asm/syscall.h  |  2 +-
 arch/s390/include/asm/syscall.h   |  4 ++--
 arch/sh/include/asm/syscall_32.h  |  2 +-
 arch/sh/include/asm/syscall_64.h  |  2 +-
 arch/sparc/include/asm/syscall.h  |  5 +++--
 arch/unicore32/include/asm/syscall.h  |  2 +-
 arch/x86/include/asm/syscall.h|  8 +---
 arch/x86/um/asm/syscall.h |  2 +-
 arch/xtensa/include/asm/syscall.h |  2 +-
 include/asm-generic/syscall.h |  5 +++--
 kernel/auditsc.c  |  4 ++--
 kernel/seccomp.c  |  4 ++--
 30 files changed, 52 insertions(+), 42 deletions(-)

diff --git a/arch/alpha/include/asm/syscall.h b/arch/alpha/include/asm/syscall.h
index 437758bdc49f..288779aa9847 100644
--- a/arch/alpha/include/asm/syscall.h
+++ b/arch/alpha/include/asm/syscall.h
@@ -31,7 +31,7 @@ syscall_get_return_value(struct task_struct *task, struct 
pt_regs *regs)
 }
 
 static inline int
-syscall_get_arch(void)
+syscall_get_arch(struct task_struct *task)
 {
return AUDIT_ARCH_ALPHA;
 }
diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h
index c7fc4c0c3bcb..caf2697ef5b7 100644
--- a/arch/arc/include/asm/syscall.h
+++ b/arch/arc/include/asm/syscall.h
@@ -70,7 +70,7 @@ syscall_get_arguments(struct task_struct *task, struct 
pt_regs *regs,
 }
 
 static inline int
-syscall_get_arch(void)
+syscall_get_arch(struct task_struct *task)
 {
return IS_ENABLED(CONFIG_ISA_ARCOMPACT)
? (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h
index 06dea6bce293..3940ceac0bdc 100644
--- a/arch/arm/include/asm/syscall.h
+++ 

[PATCH v5 24/25] ptrace: add PTRACE_GET_SYSCALL_INFO request

2018-12-09 Thread Dmitry V. Levin
From: Elvira Khabirova 

PTRACE_GET_SYSCALL_INFO is a generic ptrace API that lets ptracer obtain
details of the syscall the tracee is blocked in.

There are two reasons for a special syscall-related ptrace request.

Firstly, with the current ptrace API there are cases when ptracer cannot
retrieve necessary information about syscalls.  Some examples include:
* The notorious int-0x80-from-64-bit-task issue.  See [1] for details.
In short, if a 64-bit task performs a syscall through int 0x80, its tracer
has no reliable means to find out that the syscall was, in fact,
a compat syscall, and misidentifies it.
* Syscall-enter-stop and syscall-exit-stop look the same for the tracer.
Common practice is to keep track of the sequence of ptrace-stops in order
not to mix the two syscall-stops up.  But it is not as simple as it looks;
for example, strace had a (just recently fixed) long-standing bug where
attaching strace to a tracee that is performing the execve system call
led to the tracer identifying the following syscall-exit-stop as
syscall-enter-stop, which messed up all the state tracking.
* Since the introduction of commit 84d77d3f06e7e8dea057d10e8ec77ad71f721be3
("ptrace: Don't allow accessing an undumpable mm"), both PTRACE_PEEKDATA
and process_vm_readv become unavailable when the process dumpable flag
is cleared.  On such architectures as ia64 this results in all syscall
arguments being unavailable for the tracer.

Secondly, ptracers also have to support a lot of arch-specific code for
obtaining information about the tracee.  For some architectures, this
requires a ptrace(PTRACE_PEEKUSER, ...) invocation for every syscall
argument and return value.

ptrace(2) man page:

long ptrace(enum __ptrace_request request, pid_t pid,
void *addr, void *data);
...
PTRACE_GET_SYSCALL_INFO
   Retrieve information about the syscall that caused the stop.
   The information is placed into the buffer pointed by "data"
   argument, which should be a pointer to a buffer of type
   "struct ptrace_syscall_info".
   The "addr" argument contains the size of the buffer pointed to
   by "data" argument (i.e., sizeof(struct ptrace_syscall_info)).
   The return value contains the number of bytes available
   to be written by the kernel.
   If the size of data to be written by the kernel exceeds the size
   specified by "addr" argument, the output is truncated.

Co-authored-by: Dmitry V. Levin 
Cc: Oleg Nesterov 
Cc: Andy Lutomirski 
Cc: Eugene Syromyatnikov 
Cc: Kees Cook 
Cc: Jann Horn 
Cc: linux-...@vger.kernel.org
Cc: strace-de...@lists.strace.io
Signed-off-by: Elvira Khabirova 
Signed-off-by: Dmitry V. Levin 
---

Notes:
v5:
* Change PTRACE_EVENTMSG_SYSCALL_{ENTRY,EXIT} values as requested by Oleg.
* Change struct ptrace_syscall_info: generalize instruction_pointer,
  stack_pointer, and frame_pointer fields by moving them from
  ptrace_syscall_info.{entry,seccomp} substructures to ptrace_syscall_info
  and initializing them for all stops.
* Add PTRACE_SYSCALL_INFO_NONE, set it when not in a syscall stop,
  so e.g. "strace -i" could use PTRACE_SYSCALL_INFO_SECCOMP to obtain
  instruction_pointer when the tracee is in a signal stop.
* Make available for all architectures: do not conditionalize on
  CONFIG_HAVE_ARCH_TRACEHOOK since all syscall_get_* functions
  are implemented on all architectures.

v4:
* Do not introduce task_struct.ptrace_event,
  use child->last_siginfo->si_code instead.
* Implement PTRACE_SYSCALL_INFO_SECCOMP and ptrace_syscall_info.seccomp
  support along with PTRACE_SYSCALL_INFO_{ENTRY,EXIT} and
  ptrace_syscall_info.{entry,exit}.

v3:
* Change struct ptrace_syscall_info.
* Support PTRACE_EVENT_SECCOMP by adding ptrace_event to task_struct.
* Add proper defines for ptrace_syscall_info.op values.
* Rename PT_SYSCALL_IS_ENTERING and PT_SYSCALL_IS_EXITING to
  PTRACE_EVENTMSG_SYSCALL_ENTRY and PTRACE_EVENTMSG_SYSCALL_EXIT
* and move them to uapi.

v2:
* Do not use task->ptrace.
* Replace entry_info.is_compat with entry_info.arch, use syscall_get_arch().
* Use addr argument of sys_ptrace to get expected size of the struct;
  return full size of the struct.

 include/linux/tracehook.h   |  9 ++--
 include/uapi/linux/ptrace.h | 39 +++
 kernel/ptrace.c | 99 -
 3 files changed, 143 insertions(+), 4 deletions(-)

diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
index df20f8bdbfa3..6bc7a3d58e2f 100644
--- a/include/linux/tracehook.h
+++ b/include/linux/tracehook.h
@@ -57,13 +57,15 @@ struct linux_binprm;
 /*
  * ptrace report for syscall entry and exit looks identical.
  */
-static inline int ptrace_report_syscall(struct pt_regs *regs)
+static inline int ptrace_report_syscall(struct pt_regs *regs,
+   unsigned long message)
 {
  

[PATCH v5 19/25] xtensa: define syscall_get_* functions

2018-12-09 Thread Dmitry V. Levin
syscall_get_* functions are required to be implemented on all
architectures in order to extend the generic ptrace API with
PTRACE_GET_SYSCALL_INFO request.

This adds all 5 syscall_get_* functions on xtensa as documented
in asm-generic/syscall.h: syscall_get_nr, syscall_get_arguments,
syscall_get_error, syscall_get_return_value, and syscall_get_arch.

Cc: Max Filippov 
Cc: Oleg Nesterov 
Cc: Andy Lutomirski 
Cc: Elvira Khabirova 
Cc: Eugene Syromyatnikov 
Cc: Chris Zankel 
Cc: Paul Moore 
Cc: Eric Paris 
Cc: linux-xte...@linux-xtensa.org
Cc: linux-au...@redhat.com
Signed-off-by: Dmitry V. Levin 
---

Notes:
v5: added syscall_get_nr, syscall_get_arguments, syscall_get_error,
and syscall_get_return_value
v2: added Acked-by
v1: added syscall_get_arch

 arch/xtensa/include/asm/syscall.h | 69 +++
 include/uapi/linux/audit.h|  1 +
 2 files changed, 70 insertions(+)

diff --git a/arch/xtensa/include/asm/syscall.h 
b/arch/xtensa/include/asm/syscall.h
index 3673ff1f1bc5..d529c855a144 100644
--- a/arch/xtensa/include/asm/syscall.h
+++ b/arch/xtensa/include/asm/syscall.h
@@ -8,6 +8,75 @@
  * Copyright (C) 2001 - 2007 Tensilica Inc.
  */
 
+#include 
+
+static inline int
+syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
+{
+   return regs->syscall;
+}
+
+static inline void
+syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
+ unsigned int i, unsigned int n, unsigned long *args)
+{
+   switch (i) {
+   case 0:
+   if (!n--)
+   break;
+   *args++ = regs->areg[6];
+   /* fall through */
+   case 1:
+   if (!n--)
+   break;
+   *args++ = regs->areg[3];
+   /* fall through */
+   case 2:
+   if (!n--)
+   break;
+   *args++ = regs->areg[4];
+   /* fall through */
+   case 3:
+   if (!n--)
+   break;
+   *args++ = regs->areg[5];
+   /* fall through */
+   case 4:
+   if (!n--)
+   break;
+   *args++ = regs->areg[8];
+   /* fall through */
+   case 5:
+   if (!n--)
+   break;
+   *args++ = regs->areg[9];
+   /* fall through */
+   case 6:
+   if (!n--)
+   break;
+   /* fall through */
+   default:
+   BUG();
+   }
+}
+
+static inline long
+syscall_get_error(struct task_struct *task, struct pt_regs *regs)
+{
+   return IS_ERR_VALUE(regs->areg[2]) ? regs->areg[2] : 0;
+
+static inline long
+syscall_get_return_value(struct task_struct *task, struct pt_regs *regs)
+{
+   return regs->areg[2];
+}
+
+static inline int
+syscall_get_arch(void)
+{
+   return AUDIT_ARCH_XTENSA;
+}
+
 struct pt_regs;
 asmlinkage long xtensa_ptrace(long, long, long, long);
 asmlinkage long xtensa_sigreturn(struct pt_regs*);
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 1e9808f3a240..bcc0619b046f 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -425,6 +425,7 @@ enum {
 #define AUDIT_ARCH_TILEGX32(EM_TILEGX|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_TILEPRO (EM_TILEPRO|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_X86_64  (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_XTENSA  (EM_XTENSA)
 
 #define AUDIT_PERM_EXEC1
 #define AUDIT_PERM_WRITE   2
-- 
ldv


[PATCH v5 23/25] powerpc/ptrace: replace ptrace_report_syscall() with a tracehook call

2018-12-09 Thread Dmitry V. Levin
From: Elvira Khabirova 

Arch code should use tracehook_*() helpers, as documented
in include/linux/tracehook.h,
ptrace_report_syscall() is not expected to be used outside that file.

The patch does not look very nice, but at least it is correct
and opens the way for PTRACE_GET_SYSCALL_INFO API.

Co-authored-by: Dmitry V. Levin 
Fixes: 5521eb4bca2d ("powerpc/ptrace: Add support for PTRACE_SYSEMU")
Cc: Michael Ellerman 
Cc: Oleg Nesterov 
Cc: Eugene Syromyatnikov 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Breno Leitao 
Cc: Andy Lutomirski 
Cc: linuxppc-...@lists.ozlabs.org
Signed-off-by: Elvira Khabirova 
Signed-off-by: Dmitry V. Levin 
---

Notes:
v5: reverted to a simple approach, compile- and run-tested
v4: rewritten to call tracehook_report_syscall_entry() once, compile-tested
v3: add a descriptive comment
v2: explicitly ignore tracehook_report_syscall_entry() return code

 arch/powerpc/kernel/ptrace.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index afb819f4ca68..714c3480c52d 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -3266,12 +3266,17 @@ long do_syscall_trace_enter(struct pt_regs *regs)
user_exit();
 
if (test_thread_flag(TIF_SYSCALL_EMU)) {
-   ptrace_report_syscall(regs);
/*
+* A nonzero return code from tracehook_report_syscall_entry()
+* tells us to prevent the syscall execution, but we are not
+* going to execute it anyway.
+*
 * Returning -1 will skip the syscall execution. We want to
 * avoid clobbering any register also, thus, not 'gotoing'
 * skip label.
 */
+   if (tracehook_report_syscall_entry(regs))
+   ;
return -1;
}
 
-- 
ldv


[PATCH v5 20/25] Move EM_UNICORE to uapi/linux/elf-em.h

2018-12-09 Thread Dmitry V. Levin
This should never have been defined in the arch tree to begin with,
and now uapi/linux/audit.h header is going to use EM_UNICORE
in order to define AUDIT_ARCH_UNICORE which is needed to implement
syscall_get_arch() which in turn is required to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Cc: Guan Xuetao 
Cc: Oleg Nesterov 
Cc: Andy Lutomirski 
Cc: Elvira Khabirova 
Cc: Eugene Syromyatnikov 
Signed-off-by: Dmitry V. Levin 
---

Notes:
v5: added Cc

 arch/unicore32/include/asm/elf.h | 3 +--
 include/uapi/linux/elf-em.h  | 1 +
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/unicore32/include/asm/elf.h b/arch/unicore32/include/asm/elf.h
index 829042d07722..ae66dc1be49e 100644
--- a/arch/unicore32/include/asm/elf.h
+++ b/arch/unicore32/include/asm/elf.h
@@ -19,6 +19,7 @@
  * ELF register definitions..
  */
 #include 
+#include 
 
 typedef unsigned long elf_greg_t;
 typedef unsigned long elf_freg_t[3];
@@ -28,8 +29,6 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 typedef struct fp_state elf_fpregset_t;
 
-#define EM_UNICORE 110
-
 #define R_UNICORE_NONE 0
 #define R_UNICORE_PC24 1
 #define R_UNICORE_ABS322
diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index f392dd9d07f7..2533bb1db3ef 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -37,6 +37,7 @@
 #define EM_ARCOMPACT   93  /* ARCompact processor */
 #define EM_XTENSA  94  /* Tensilica Xtensa Architecture */
 #define EM_BLACKFIN 106 /* ADI Blackfin Processor */
+#define EM_UNICORE 110 /* UniCore-32 */
 #define EM_ALTERA_NIOS2113 /* Altera Nios II soft-core processor */
 #define EM_TI_C6000140 /* TI C6X DSPs */
 #define EM_HEXAGON 164 /* QUALCOMM Hexagon */
-- 
ldv


  1   2   3   4   5   6   7   8   >