KASAN: global-out-of-bounds Read in mqueue_get_tree

2018-09-12 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:7c1b097f27bf Add linux-next specific files for 20180912
git tree:   linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=152fcd4940
kernel config:  https://syzkaller.appspot.com/x/.config?x=5980033172920ec0
dashboard link: https://syzkaller.appspot.com/bug?extid=8a81fb3d40f8c58aa8e2
compiler:   gcc (GCC) 8.0.1 20180413 (experimental)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=140a53da40
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=10b0c6ae40

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

random: sshd: uninitialized urandom read (32 bytes read)
random: sshd: uninitialized urandom read (32 bytes read)
random: sshd: uninitialized urandom read (32 bytes read)
random: sshd: uninitialized urandom read (32 bytes read)
==
BUG: KASAN: global-out-of-bounds in mqueue_get_tree+0x2a2/0x2e0  
ipc/mqueue.c:362

Read of size 8 at addr 885cef68 by task syz-executor013/5545

CPU: 0 PID: 5545 Comm: syz-executor013 Not tainted  
4.19.0-rc3-next-20180912+ #72
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+0x1d3/0x2c4 lib/dump_stack.c:113
 print_address_description.cold.8+0x58/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 mqueue_get_tree+0x2a2/0x2e0 ipc/mqueue.c:362
 vfs_get_tree+0x1cb/0x5c0 fs/super.c:1787
 mq_create_mount+0xe3/0x190 ipc/mqueue.c:415
 mq_init_ns+0x15a/0x210 ipc/mqueue.c:1621
 create_ipc_ns ipc/namespace.c:58 [inline]
 copy_ipcs+0x3d2/0x580 ipc/namespace.c:84
 create_new_namespaces+0x376/0x900 kernel/nsproxy.c:87
 unshare_nsproxy_namespaces+0xc3/0x1f0 kernel/nsproxy.c:206
 ksys_unshare+0x79c/0x10b0 kernel/fork.c:2535
 __do_sys_unshare kernel/fork.c:2603 [inline]
 __se_sys_unshare kernel/fork.c:2601 [inline]
 __x64_sys_unshare+0x31/0x40 kernel/fork.c:2601
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x446257
Code: 00 00 00 b8 63 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 dd d7 fb ff c3  
66 2e 0f 1f 84 00 00 00 00 00 66 90 b8 10 01 00 00 0f 05 <48> 3d 01 f0 ff  
ff 0f 83 bd d7 fb ff c3 66 2e 0f 1f 84 00 00 00 00

RSP: 002b:7ffe2677e8e8 EFLAGS: 0217 ORIG_RAX: 0110
RAX: ffda RBX: 7ffe2677f450 RCX: 00446257
RDX:  RSI: 7ffe2677e8f0 RDI: 0800
RBP:  R08:  R09: 0018
R10:  R11: 0217 R12: 00403ea0
R13: 00403f30 R14:  R15: 

The buggy address belongs to the variable:
 ipcns_operations+0x68/0xa00

Memory state around the buggy address:
 885cee00: fa fa fa fa 00 00 00 00 00 02 fa fa fa fa fa fa
 885cee80: 00 00 00 01 fa fa fa fa 04 fa fa fa fa fa fa fa

885cef00: 00 00 00 00 00 00 00 00 fa fa fa fa 03 fa fa fa

  ^
 885cef80: fa fa fa fa 07 fa fa fa fa fa fa fa 00 03 fa fa
 885cf000: fa fa fa fa 00 fa fa fa fa fa fa fa 00 04 fa fa
==


---
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: [PATCHv3 2/2] btrfs: change remove_extent_mapping to be void function

2018-09-12 Thread Nikolay Borisov



On 13.09.2018 06:01, zhong jiang wrote:
> remove_extent_mapping use the variable "ret" for return value,
> but it is not modified after initialzation. Further, I find that
> any of the callers do not handle the return value, so it is safe
> to drop the unneeded "ret" and make it to be void function.
> 
> Signed-off-by: zhong jiang 

Reviewed-by: Nikolay Borisov  ---
>  fs/btrfs/extent_map.c | 5 +
>  fs/btrfs/extent_map.h | 2 +-
>  2 files changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
> index c4e2347..81b6a08 100644
> --- a/fs/btrfs/extent_map.c
> +++ b/fs/btrfs/extent_map.c
> @@ -428,16 +428,13 @@ struct extent_map *search_extent_mapping(struct 
> extent_map_tree *tree,
>   * Removes @em from @tree.  No reference counts are dropped, and no checks
>   * are done to see if the range is in use
>   */
> -int remove_extent_mapping(struct extent_map_tree *tree, struct extent_map 
> *em)
> +void remove_extent_mapping(struct extent_map_tree *tree, struct extent_map 
> *em)
>  {
> - int ret = 0;
> -
>   WARN_ON(test_bit(EXTENT_FLAG_PINNED, >flags));
>   rb_erase_cached(>rb_node, >map);
>   if (!test_bit(EXTENT_FLAG_LOGGING, >flags))
>   list_del_init(>list);
>   RB_CLEAR_NODE(>rb_node);
> - return ret;
>  }
>  
>  void replace_extent_mapping(struct extent_map_tree *tree,
> diff --git a/fs/btrfs/extent_map.h b/fs/btrfs/extent_map.h
> index df4e1a5..8798745 100644
> --- a/fs/btrfs/extent_map.h
> +++ b/fs/btrfs/extent_map.h
> @@ -78,7 +78,7 @@ struct extent_map *lookup_extent_mapping(struct 
> extent_map_tree *tree,
>u64 start, u64 len);
>  int add_extent_mapping(struct extent_map_tree *tree,
>  struct extent_map *em, int modified);
> -int remove_extent_mapping(struct extent_map_tree *tree, struct extent_map 
> *em);
> +void remove_extent_mapping(struct extent_map_tree *tree, struct extent_map 
> *em);
>  void replace_extent_mapping(struct extent_map_tree *tree,
>   struct extent_map *cur,
>   struct extent_map *new,
> 


KASAN: global-out-of-bounds Read in mqueue_get_tree

2018-09-12 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:7c1b097f27bf Add linux-next specific files for 20180912
git tree:   linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=152fcd4940
kernel config:  https://syzkaller.appspot.com/x/.config?x=5980033172920ec0
dashboard link: https://syzkaller.appspot.com/bug?extid=8a81fb3d40f8c58aa8e2
compiler:   gcc (GCC) 8.0.1 20180413 (experimental)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=140a53da40
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=10b0c6ae40

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

random: sshd: uninitialized urandom read (32 bytes read)
random: sshd: uninitialized urandom read (32 bytes read)
random: sshd: uninitialized urandom read (32 bytes read)
random: sshd: uninitialized urandom read (32 bytes read)
==
BUG: KASAN: global-out-of-bounds in mqueue_get_tree+0x2a2/0x2e0  
ipc/mqueue.c:362

Read of size 8 at addr 885cef68 by task syz-executor013/5545

CPU: 0 PID: 5545 Comm: syz-executor013 Not tainted  
4.19.0-rc3-next-20180912+ #72
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+0x1d3/0x2c4 lib/dump_stack.c:113
 print_address_description.cold.8+0x58/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 mqueue_get_tree+0x2a2/0x2e0 ipc/mqueue.c:362
 vfs_get_tree+0x1cb/0x5c0 fs/super.c:1787
 mq_create_mount+0xe3/0x190 ipc/mqueue.c:415
 mq_init_ns+0x15a/0x210 ipc/mqueue.c:1621
 create_ipc_ns ipc/namespace.c:58 [inline]
 copy_ipcs+0x3d2/0x580 ipc/namespace.c:84
 create_new_namespaces+0x376/0x900 kernel/nsproxy.c:87
 unshare_nsproxy_namespaces+0xc3/0x1f0 kernel/nsproxy.c:206
 ksys_unshare+0x79c/0x10b0 kernel/fork.c:2535
 __do_sys_unshare kernel/fork.c:2603 [inline]
 __se_sys_unshare kernel/fork.c:2601 [inline]
 __x64_sys_unshare+0x31/0x40 kernel/fork.c:2601
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x446257
Code: 00 00 00 b8 63 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 dd d7 fb ff c3  
66 2e 0f 1f 84 00 00 00 00 00 66 90 b8 10 01 00 00 0f 05 <48> 3d 01 f0 ff  
ff 0f 83 bd d7 fb ff c3 66 2e 0f 1f 84 00 00 00 00

RSP: 002b:7ffe2677e8e8 EFLAGS: 0217 ORIG_RAX: 0110
RAX: ffda RBX: 7ffe2677f450 RCX: 00446257
RDX:  RSI: 7ffe2677e8f0 RDI: 0800
RBP:  R08:  R09: 0018
R10:  R11: 0217 R12: 00403ea0
R13: 00403f30 R14:  R15: 

The buggy address belongs to the variable:
 ipcns_operations+0x68/0xa00

Memory state around the buggy address:
 885cee00: fa fa fa fa 00 00 00 00 00 02 fa fa fa fa fa fa
 885cee80: 00 00 00 01 fa fa fa fa 04 fa fa fa fa fa fa fa

885cef00: 00 00 00 00 00 00 00 00 fa fa fa fa 03 fa fa fa

  ^
 885cef80: fa fa fa fa 07 fa fa fa fa fa fa fa 00 03 fa fa
 885cf000: fa fa fa fa 00 fa fa fa fa fa fa fa 00 04 fa fa
==


---
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: [PATCHv3 2/2] btrfs: change remove_extent_mapping to be void function

2018-09-12 Thread Nikolay Borisov



On 13.09.2018 06:01, zhong jiang wrote:
> remove_extent_mapping use the variable "ret" for return value,
> but it is not modified after initialzation. Further, I find that
> any of the callers do not handle the return value, so it is safe
> to drop the unneeded "ret" and make it to be void function.
> 
> Signed-off-by: zhong jiang 

Reviewed-by: Nikolay Borisov  ---
>  fs/btrfs/extent_map.c | 5 +
>  fs/btrfs/extent_map.h | 2 +-
>  2 files changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
> index c4e2347..81b6a08 100644
> --- a/fs/btrfs/extent_map.c
> +++ b/fs/btrfs/extent_map.c
> @@ -428,16 +428,13 @@ struct extent_map *search_extent_mapping(struct 
> extent_map_tree *tree,
>   * Removes @em from @tree.  No reference counts are dropped, and no checks
>   * are done to see if the range is in use
>   */
> -int remove_extent_mapping(struct extent_map_tree *tree, struct extent_map 
> *em)
> +void remove_extent_mapping(struct extent_map_tree *tree, struct extent_map 
> *em)
>  {
> - int ret = 0;
> -
>   WARN_ON(test_bit(EXTENT_FLAG_PINNED, >flags));
>   rb_erase_cached(>rb_node, >map);
>   if (!test_bit(EXTENT_FLAG_LOGGING, >flags))
>   list_del_init(>list);
>   RB_CLEAR_NODE(>rb_node);
> - return ret;
>  }
>  
>  void replace_extent_mapping(struct extent_map_tree *tree,
> diff --git a/fs/btrfs/extent_map.h b/fs/btrfs/extent_map.h
> index df4e1a5..8798745 100644
> --- a/fs/btrfs/extent_map.h
> +++ b/fs/btrfs/extent_map.h
> @@ -78,7 +78,7 @@ struct extent_map *lookup_extent_mapping(struct 
> extent_map_tree *tree,
>u64 start, u64 len);
>  int add_extent_mapping(struct extent_map_tree *tree,
>  struct extent_map *em, int modified);
> -int remove_extent_mapping(struct extent_map_tree *tree, struct extent_map 
> *em);
> +void remove_extent_mapping(struct extent_map_tree *tree, struct extent_map 
> *em);
>  void replace_extent_mapping(struct extent_map_tree *tree,
>   struct extent_map *cur,
>   struct extent_map *new,
> 


Re: [PATCH] ACPI/PPTT: Handle architecturally unknown cache types

2018-09-12 Thread Brice Goglin
Le 12/09/2018 à 11:49, Sudeep Holla a écrit :
>
>> Yes.  Without this change, we hit the lscpu error in the commit message,
>> and get zero output about the system.  We don't even get information
>> about the caches which are architecturally specified or how many cpus
>> are present.  With this change, we get what we expect out of lscpu (and
>> also lstopo) including the cache(s) which are not architecturally
>> specified.
>>
> lscpu and lstopo are so broken. They just assume everything on CPU0.
> If you hotplug them out, you start seeing issues. So reading and file
> that doesn't exist and then bail out on other essential info though they
> are present, hmmm ...

Can you elaborate?

I am not sure cpu0 is supposed to be offlineable on Linux. There's no
"online" file in /sys/devices/system/cpu/cpu0. That's why former lstopo
doesn't like CPU0 being hotplugged out. We are actually making that case
work for another non-standard corner case. But offlining "cpu0" this is
considered "normal", somebody must add that missing "online" sysfs
attribute for "cpu0" (change
https://elixir.bootlin.com/linux/latest/source/drivers/base/cpu.c#L375).

By the way, did anybody actually see an error with lstopo when there's
no "type" attribute for L3? I can't reproduce any issue, we just skip
that specific cache entirely, but everything else appears. If you guys
want to make that "no_cache" cache appear, I'll make it a Unified cache
unless you tell me what to show :)

Brice


Re: [PATCH] ACPI/PPTT: Handle architecturally unknown cache types

2018-09-12 Thread Brice Goglin
Le 12/09/2018 à 11:49, Sudeep Holla a écrit :
>
>> Yes.  Without this change, we hit the lscpu error in the commit message,
>> and get zero output about the system.  We don't even get information
>> about the caches which are architecturally specified or how many cpus
>> are present.  With this change, we get what we expect out of lscpu (and
>> also lstopo) including the cache(s) which are not architecturally
>> specified.
>>
> lscpu and lstopo are so broken. They just assume everything on CPU0.
> If you hotplug them out, you start seeing issues. So reading and file
> that doesn't exist and then bail out on other essential info though they
> are present, hmmm ...

Can you elaborate?

I am not sure cpu0 is supposed to be offlineable on Linux. There's no
"online" file in /sys/devices/system/cpu/cpu0. That's why former lstopo
doesn't like CPU0 being hotplugged out. We are actually making that case
work for another non-standard corner case. But offlining "cpu0" this is
considered "normal", somebody must add that missing "online" sysfs
attribute for "cpu0" (change
https://elixir.bootlin.com/linux/latest/source/drivers/base/cpu.c#L375).

By the way, did anybody actually see an error with lstopo when there's
no "type" attribute for L3? I can't reproduce any issue, we just skip
that specific cache entirely, but everything else appears. If you guys
want to make that "no_cache" cache appear, I'll make it a Unified cache
unless you tell me what to show :)

Brice


[GIT PULL 3/3] bcm2835-defconfig-next-2018-09-09

2018-09-12 Thread Stefan Wahren
Hi Florian,

The following changes since commit 5b394b2ddf0347bef56e50c69a58773c94343ff3:

  Linux 4.19-rc1 (2018-08-26 14:11:59 -0700)

are available in the git repository at:

  git://github.com/anholt/linux tags/bcm2835-defconfig-next-2018-09-09

for you to fetch changes up to 99fa3b0c6082bff346f7d09f29e5edcc93d40bd3:

  ARM: bcm2835_defconfig: Enable bcm2835-audio (2018-09-02 18:49:33 +0200)


This pull request brings enables the RPi audio driver in the
bcm2835_defconfig.


Stefan Wahren (1):
  ARM: bcm2835_defconfig: Enable bcm2835-audio

 arch/arm/configs/bcm2835_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


[GIT PULL 2/3] bcm2835-dt-64-next-2018-09-09

2018-09-12 Thread Stefan Wahren
Hi Florian,

The following changes since commit 5b394b2ddf0347bef56e50c69a58773c94343ff3:

  Linux 4.19-rc1 (2018-08-26 14:11:59 -0700)

are available in the git repository at:

  git://github.com/anholt/linux tags/bcm2835-dt-64-next-2018-09-09

for you to fetch changes up to a7eb26392b893bff92b1eb6483f4af3d2eb19510:

  arm64: dts: broadcom: Add reference to Compute Module IO Board V3 (2018-08-31 
07:01:34 +0200)


This pull request brings in the arm64 reference for Raspberry Pi Compute
Module 3.


Stefan Wahren (1):
  arm64: dts: broadcom: Add reference to Compute Module IO Board V3

 arch/arm64/boot/dts/broadcom/Makefile| 3 ++-
 arch/arm64/boot/dts/broadcom/bcm2837-rpi-cm3-io3.dts | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/boot/dts/broadcom/bcm2837-rpi-cm3-io3.dts


[GIT PULL 3/3] bcm2835-defconfig-next-2018-09-09

2018-09-12 Thread Stefan Wahren
Hi Florian,

The following changes since commit 5b394b2ddf0347bef56e50c69a58773c94343ff3:

  Linux 4.19-rc1 (2018-08-26 14:11:59 -0700)

are available in the git repository at:

  git://github.com/anholt/linux tags/bcm2835-defconfig-next-2018-09-09

for you to fetch changes up to 99fa3b0c6082bff346f7d09f29e5edcc93d40bd3:

  ARM: bcm2835_defconfig: Enable bcm2835-audio (2018-09-02 18:49:33 +0200)


This pull request brings enables the RPi audio driver in the
bcm2835_defconfig.


Stefan Wahren (1):
  ARM: bcm2835_defconfig: Enable bcm2835-audio

 arch/arm/configs/bcm2835_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


[GIT PULL 2/3] bcm2835-dt-64-next-2018-09-09

2018-09-12 Thread Stefan Wahren
Hi Florian,

The following changes since commit 5b394b2ddf0347bef56e50c69a58773c94343ff3:

  Linux 4.19-rc1 (2018-08-26 14:11:59 -0700)

are available in the git repository at:

  git://github.com/anholt/linux tags/bcm2835-dt-64-next-2018-09-09

for you to fetch changes up to a7eb26392b893bff92b1eb6483f4af3d2eb19510:

  arm64: dts: broadcom: Add reference to Compute Module IO Board V3 (2018-08-31 
07:01:34 +0200)


This pull request brings in the arm64 reference for Raspberry Pi Compute
Module 3.


Stefan Wahren (1):
  arm64: dts: broadcom: Add reference to Compute Module IO Board V3

 arch/arm64/boot/dts/broadcom/Makefile| 3 ++-
 arch/arm64/boot/dts/broadcom/bcm2837-rpi-cm3-io3.dts | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/boot/dts/broadcom/bcm2837-rpi-cm3-io3.dts


[GIT PULL 1/3] bcm2835-dt-next-2018-09-09

2018-09-12 Thread Stefan Wahren
Hi Florian,

The following changes since commit 5b394b2ddf0347bef56e50c69a58773c94343ff3:

  Linux 4.19-rc1 (2018-08-26 14:11:59 -0700)

are available in the git repository at:

  git://github.com/anholt/linux tags/bcm2835-dt-next-2018-09-09

for you to fetch changes up to 6ef5bd6cfd5da9fe67aea031fd0a66ff77d64ad6:

  ARM: dts: bcm283x-rpi-lan7515: Enable Ethernet LEDs (2018-09-05 21:31:25 
+0200)


This pull request brings in a board DT for the Raspberry Pi Compute
Module 3, its I/O board and enables the Ethernet LEDs for the RPi 3B+.


Stefan Wahren (3):
  dt-bindings: bcm: Add Raspberry Pi CM3 and CM3L
  ARM: dts: add Raspberry Pi Compute Module 3 and IO board
  ARM: dts: bcm283x-rpi-lan7515: Enable Ethernet LEDs

 .../devicetree/bindings/arm/bcm/brcm,bcm2835.txt   |  8 ++
 arch/arm/boot/dts/Makefile |  1 +
 arch/arm/boot/dts/bcm2837-rpi-cm3-io3.dts  | 87 ++
 arch/arm/boot/dts/bcm2837-rpi-cm3.dtsi | 52 +
 arch/arm/boot/dts/bcm283x-rpi-lan7515.dtsi | 14 
 5 files changed, 162 insertions(+)
 create mode 100644 arch/arm/boot/dts/bcm2837-rpi-cm3-io3.dts
 create mode 100644 arch/arm/boot/dts/bcm2837-rpi-cm3.dtsi


[GIT PULL 1/3] bcm2835-dt-next-2018-09-09

2018-09-12 Thread Stefan Wahren
Hi Florian,

The following changes since commit 5b394b2ddf0347bef56e50c69a58773c94343ff3:

  Linux 4.19-rc1 (2018-08-26 14:11:59 -0700)

are available in the git repository at:

  git://github.com/anholt/linux tags/bcm2835-dt-next-2018-09-09

for you to fetch changes up to 6ef5bd6cfd5da9fe67aea031fd0a66ff77d64ad6:

  ARM: dts: bcm283x-rpi-lan7515: Enable Ethernet LEDs (2018-09-05 21:31:25 
+0200)


This pull request brings in a board DT for the Raspberry Pi Compute
Module 3, its I/O board and enables the Ethernet LEDs for the RPi 3B+.


Stefan Wahren (3):
  dt-bindings: bcm: Add Raspberry Pi CM3 and CM3L
  ARM: dts: add Raspberry Pi Compute Module 3 and IO board
  ARM: dts: bcm283x-rpi-lan7515: Enable Ethernet LEDs

 .../devicetree/bindings/arm/bcm/brcm,bcm2835.txt   |  8 ++
 arch/arm/boot/dts/Makefile |  1 +
 arch/arm/boot/dts/bcm2837-rpi-cm3-io3.dts  | 87 ++
 arch/arm/boot/dts/bcm2837-rpi-cm3.dtsi | 52 +
 arch/arm/boot/dts/bcm283x-rpi-lan7515.dtsi | 14 
 5 files changed, 162 insertions(+)
 create mode 100644 arch/arm/boot/dts/bcm2837-rpi-cm3-io3.dts
 create mode 100644 arch/arm/boot/dts/bcm2837-rpi-cm3.dtsi


Re: [PATCH] MAINTAINERS: Clarify UIO vs UACCESS maintainer

2018-09-12 Thread Greg Kroah-Hartman
On Wed, Sep 12, 2018 at 10:09:28PM -0700, Dan Williams wrote:
> The UIO file mask in MAINTAINERS was incorrectly directing UACCESS
> (include/linux/uio.h) patches to Greg.
> 
> Tag Al as the UACCESS maintainer as Ingo and others have explicitly
> required his ack before taking architecture patches that touch
> lib/iov_iter.c.
> 
> Cc: Al Viro 
> Reported-by: Greg Kroah-Hartman 
> Signed-off-by: Dan Williams 
> ---
> Al, let me know if this is ok. Alternatively we could just fix the file
> mask for UIO and not add a new UACCESS section.

Thanks for doing this!

Acked-by: Greg Kroah-Hartman 



Re: [PATCH] MAINTAINERS: Clarify UIO vs UACCESS maintainer

2018-09-12 Thread Greg Kroah-Hartman
On Wed, Sep 12, 2018 at 10:09:28PM -0700, Dan Williams wrote:
> The UIO file mask in MAINTAINERS was incorrectly directing UACCESS
> (include/linux/uio.h) patches to Greg.
> 
> Tag Al as the UACCESS maintainer as Ingo and others have explicitly
> required his ack before taking architecture patches that touch
> lib/iov_iter.c.
> 
> Cc: Al Viro 
> Reported-by: Greg Kroah-Hartman 
> Signed-off-by: Dan Williams 
> ---
> Al, let me know if this is ok. Alternatively we could just fix the file
> mask for UIO and not add a new UACCESS section.

Thanks for doing this!

Acked-by: Greg Kroah-Hartman 



Re: [PATCH] ucma: fix a use-after-free in ucma_resolve_ip()

2018-09-12 Thread Leon Romanovsky
On Wed, Sep 12, 2018 at 04:27:44PM -0700, Cong Wang wrote:
> There is a race condition between ucma_close() and ucma_resolve_ip():
>
> CPU0  CPU1
> ucma_resolve_ip():ucma_close():
>
> ctx = ucma_get_ctx(file, cmd.id);
>
> list_for_each_entry_safe(ctx, tmp, >ctx_list, list) {
> mutex_lock();
> idr_remove(_idr, ctx->id);
> mutex_unlock();
>   ...
> mutex_lock();
> if (!ctx->closing) {
> mutex_unlock();
> rdma_destroy_id(ctx->cm_id);
>   ...
> ucma_free_ctx(ctx);
>
> ret = rdma_resolve_addr();
> ucma_put_ctx(ctx);
>
> Before idr_remove(), ucma_get_ctx() could still find the ctx
> and after rdma_destroy_id(), rdma_resolve_addr() may still
> access id_priv pointer. Also, ucma_put_ctx() may use ctx after
> ucma_free_ctx() too.
>
> ucma_close() should call ucma_put_ctx() too which tests the
> refcnt and waits for the last one releasing it. The similar
> pattern is already used by ucma_destroy_id().
>
> Reported-and-tested-by: syzbot+da2591e115d57a9cb...@syzkaller.appspotmail.com
> Reported-by: syzbot+cfe3c1e8ef634ba89...@syzkaller.appspotmail.com
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Leon Romanovsky 
> Signed-off-by: Cong Wang 
> ---
>  drivers/infiniband/core/ucma.c | 2 ++
>  1 file changed, 2 insertions(+)
>

Thanks,
Reviewed-by: Leon Romanovsky 


signature.asc
Description: PGP signature


Re: [PATCH] ucma: fix a use-after-free in ucma_resolve_ip()

2018-09-12 Thread Leon Romanovsky
On Wed, Sep 12, 2018 at 04:27:44PM -0700, Cong Wang wrote:
> There is a race condition between ucma_close() and ucma_resolve_ip():
>
> CPU0  CPU1
> ucma_resolve_ip():ucma_close():
>
> ctx = ucma_get_ctx(file, cmd.id);
>
> list_for_each_entry_safe(ctx, tmp, >ctx_list, list) {
> mutex_lock();
> idr_remove(_idr, ctx->id);
> mutex_unlock();
>   ...
> mutex_lock();
> if (!ctx->closing) {
> mutex_unlock();
> rdma_destroy_id(ctx->cm_id);
>   ...
> ucma_free_ctx(ctx);
>
> ret = rdma_resolve_addr();
> ucma_put_ctx(ctx);
>
> Before idr_remove(), ucma_get_ctx() could still find the ctx
> and after rdma_destroy_id(), rdma_resolve_addr() may still
> access id_priv pointer. Also, ucma_put_ctx() may use ctx after
> ucma_free_ctx() too.
>
> ucma_close() should call ucma_put_ctx() too which tests the
> refcnt and waits for the last one releasing it. The similar
> pattern is already used by ucma_destroy_id().
>
> Reported-and-tested-by: syzbot+da2591e115d57a9cb...@syzkaller.appspotmail.com
> Reported-by: syzbot+cfe3c1e8ef634ba89...@syzkaller.appspotmail.com
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Leon Romanovsky 
> Signed-off-by: Cong Wang 
> ---
>  drivers/infiniband/core/ucma.c | 2 ++
>  1 file changed, 2 insertions(+)
>

Thanks,
Reviewed-by: Leon Romanovsky 


signature.asc
Description: PGP signature


[PATCH 2/2] vfio: add edid support to mbochs sample driver

2018-09-12 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 samples/vfio-mdev/mbochs.c | 54 --
 1 file changed, 52 insertions(+), 2 deletions(-)

diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c
index 2535c3677c..6331871ff5 100644
--- a/samples/vfio-mdev/mbochs.c
+++ b/samples/vfio-mdev/mbochs.c
@@ -95,16 +95,24 @@ MODULE_PARM_DESC(mem, "megabytes available to " MBOCHS_NAME 
" devices");
 static const struct mbochs_type {
const char *name;
u32 mbytes;
+   u32 max_x;
+   u32 max_y;
 } mbochs_types[] = {
{
.name   = MBOCHS_CLASS_NAME "-" MBOCHS_TYPE_1,
.mbytes = 4,
+   .max_x  = 800,
+   .max_y  = 600,
}, {
.name   = MBOCHS_CLASS_NAME "-" MBOCHS_TYPE_2,
.mbytes = 16,
+   .max_x  = 1920,
+   .max_y  = 1440,
}, {
.name   = MBOCHS_CLASS_NAME "-" MBOCHS_TYPE_3,
.mbytes = 64,
+   .max_x  = 0,
+   .max_y  = 0,
},
 };
 
@@ -151,6 +159,7 @@ struct mdev_state {
u64 memsize;
struct page **pages;
pgoff_t pagecount;
+   u8 edid[512];
 
struct list_head dmabufs;
u32 active_id;
@@ -346,6 +355,11 @@ static void handle_mmio_read(struct mdev_state 
*mdev_state, u16 offset,
int index;
 
switch (offset) {
+   case 0x000 ... 0x3ff: /* edid block */
+   if (offset + count > sizeof(mdev_state->edid))
+   goto unhandled;
+   memcpy(buf, mdev_state->edid + offset, count);
+   break;
case 0x500 ... 0x515: /* bochs dispi interface */
if (count != 2)
goto unhandled;
@@ -983,9 +997,13 @@ static int mbochs_get_irq_info(struct mdev_device *mdev,
 static int mbochs_get_device_info(struct mdev_device *mdev,
  struct vfio_device_info *dev_info)
 {
+   struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+
dev_info->flags = VFIO_DEVICE_FLAGS_PCI;
dev_info->num_regions = VFIO_PCI_NUM_REGIONS;
dev_info->num_irqs = VFIO_PCI_NUM_IRQS;
+   dev_info->edid_max_x = mdev_state->type->max_x;
+   dev_info->edid_max_y = mdev_state->type->max_y;
return 0;
 }
 
@@ -1084,7 +1102,7 @@ static long mbochs_ioctl(struct mdev_device *mdev, 
unsigned int cmd,
unsigned long arg)
 {
int ret = 0;
-   unsigned long minsz;
+   unsigned long minsz, outsz;
struct mdev_state *mdev_state;
 
mdev_state = mdev_get_drvdata(mdev);
@@ -1095,6 +1113,7 @@ static long mbochs_ioctl(struct mdev_device *mdev, 
unsigned int cmd,
struct vfio_device_info info;
 
minsz = offsetofend(struct vfio_device_info, num_irqs);
+   outsz = offsetofend(struct vfio_device_info, edid_max_y);
 
if (copy_from_user(, (void __user *)arg, minsz))
return -EFAULT;
@@ -1108,7 +1127,9 @@ static long mbochs_ioctl(struct mdev_device *mdev, 
unsigned int cmd,
 
memcpy(_state->dev_info, , sizeof(info));
 
-   if (copy_to_user((void __user *)arg, , minsz))
+   if (outsz > info.argsz)
+   outsz = info.argsz;
+   if (copy_to_user((void __user *)arg, , outsz))
return -EFAULT;
 
return 0;
@@ -1194,6 +1215,35 @@ static long mbochs_ioctl(struct mdev_device *mdev, 
unsigned int cmd,
return mbochs_get_gfx_dmabuf(mdev, dmabuf_id);
}
 
+   case VFIO_DEVICE_SET_GFX_EDID:
+   {
+   struct vfio_device_set_gfx_edid *edid;
+
+   edid = kmalloc(sizeof(*edid), GFP_KERNEL);
+
+   minsz = offsetofend(struct vfio_device_set_gfx_edid,
+   edid_blob);
+
+   if (copy_from_user(edid, (void __user *)arg, minsz)) {
+   kfree(edid);
+   return -EFAULT;
+   }
+
+   if (edid->argsz < minsz ||
+   edid->edid_size > sizeof(mdev_state->edid)) {
+   kfree(edid);
+   return -EINVAL;
+   }
+
+   memset(mdev_state->edid, 0, sizeof(mdev_state->edid));
+   if (edid->link_state == VFIO_DEVICE_GFX_LINK_STATE_UP) {
+   memcpy(mdev_state->edid, edid->edid_blob, 
edid->edid_size);
+   }
+   kfree(edid);
+
+   return 0;
+   }
+
case VFIO_DEVICE_SET_IRQS:
return -EINVAL;
 
-- 
2.9.3



[PATCH 2/2] vfio: add edid support to mbochs sample driver

2018-09-12 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 samples/vfio-mdev/mbochs.c | 54 --
 1 file changed, 52 insertions(+), 2 deletions(-)

diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c
index 2535c3677c..6331871ff5 100644
--- a/samples/vfio-mdev/mbochs.c
+++ b/samples/vfio-mdev/mbochs.c
@@ -95,16 +95,24 @@ MODULE_PARM_DESC(mem, "megabytes available to " MBOCHS_NAME 
" devices");
 static const struct mbochs_type {
const char *name;
u32 mbytes;
+   u32 max_x;
+   u32 max_y;
 } mbochs_types[] = {
{
.name   = MBOCHS_CLASS_NAME "-" MBOCHS_TYPE_1,
.mbytes = 4,
+   .max_x  = 800,
+   .max_y  = 600,
}, {
.name   = MBOCHS_CLASS_NAME "-" MBOCHS_TYPE_2,
.mbytes = 16,
+   .max_x  = 1920,
+   .max_y  = 1440,
}, {
.name   = MBOCHS_CLASS_NAME "-" MBOCHS_TYPE_3,
.mbytes = 64,
+   .max_x  = 0,
+   .max_y  = 0,
},
 };
 
@@ -151,6 +159,7 @@ struct mdev_state {
u64 memsize;
struct page **pages;
pgoff_t pagecount;
+   u8 edid[512];
 
struct list_head dmabufs;
u32 active_id;
@@ -346,6 +355,11 @@ static void handle_mmio_read(struct mdev_state 
*mdev_state, u16 offset,
int index;
 
switch (offset) {
+   case 0x000 ... 0x3ff: /* edid block */
+   if (offset + count > sizeof(mdev_state->edid))
+   goto unhandled;
+   memcpy(buf, mdev_state->edid + offset, count);
+   break;
case 0x500 ... 0x515: /* bochs dispi interface */
if (count != 2)
goto unhandled;
@@ -983,9 +997,13 @@ static int mbochs_get_irq_info(struct mdev_device *mdev,
 static int mbochs_get_device_info(struct mdev_device *mdev,
  struct vfio_device_info *dev_info)
 {
+   struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+
dev_info->flags = VFIO_DEVICE_FLAGS_PCI;
dev_info->num_regions = VFIO_PCI_NUM_REGIONS;
dev_info->num_irqs = VFIO_PCI_NUM_IRQS;
+   dev_info->edid_max_x = mdev_state->type->max_x;
+   dev_info->edid_max_y = mdev_state->type->max_y;
return 0;
 }
 
@@ -1084,7 +1102,7 @@ static long mbochs_ioctl(struct mdev_device *mdev, 
unsigned int cmd,
unsigned long arg)
 {
int ret = 0;
-   unsigned long minsz;
+   unsigned long minsz, outsz;
struct mdev_state *mdev_state;
 
mdev_state = mdev_get_drvdata(mdev);
@@ -1095,6 +1113,7 @@ static long mbochs_ioctl(struct mdev_device *mdev, 
unsigned int cmd,
struct vfio_device_info info;
 
minsz = offsetofend(struct vfio_device_info, num_irqs);
+   outsz = offsetofend(struct vfio_device_info, edid_max_y);
 
if (copy_from_user(, (void __user *)arg, minsz))
return -EFAULT;
@@ -1108,7 +1127,9 @@ static long mbochs_ioctl(struct mdev_device *mdev, 
unsigned int cmd,
 
memcpy(_state->dev_info, , sizeof(info));
 
-   if (copy_to_user((void __user *)arg, , minsz))
+   if (outsz > info.argsz)
+   outsz = info.argsz;
+   if (copy_to_user((void __user *)arg, , outsz))
return -EFAULT;
 
return 0;
@@ -1194,6 +1215,35 @@ static long mbochs_ioctl(struct mdev_device *mdev, 
unsigned int cmd,
return mbochs_get_gfx_dmabuf(mdev, dmabuf_id);
}
 
+   case VFIO_DEVICE_SET_GFX_EDID:
+   {
+   struct vfio_device_set_gfx_edid *edid;
+
+   edid = kmalloc(sizeof(*edid), GFP_KERNEL);
+
+   minsz = offsetofend(struct vfio_device_set_gfx_edid,
+   edid_blob);
+
+   if (copy_from_user(edid, (void __user *)arg, minsz)) {
+   kfree(edid);
+   return -EFAULT;
+   }
+
+   if (edid->argsz < minsz ||
+   edid->edid_size > sizeof(mdev_state->edid)) {
+   kfree(edid);
+   return -EINVAL;
+   }
+
+   memset(mdev_state->edid, 0, sizeof(mdev_state->edid));
+   if (edid->link_state == VFIO_DEVICE_GFX_LINK_STATE_UP) {
+   memcpy(mdev_state->edid, edid->edid_blob, 
edid->edid_size);
+   }
+   kfree(edid);
+
+   return 0;
+   }
+
case VFIO_DEVICE_SET_IRQS:
return -EINVAL;
 
-- 
2.9.3



[PATCH 1/2] vfio: add edid api for display (vgpu) devices.

2018-09-12 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 include/uapi/linux/vfio.h | 38 ++
 1 file changed, 38 insertions(+)

diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 1aa7b82e81..38b591e909 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -200,8 +200,11 @@ struct vfio_device_info {
 #define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2)/* vfio-platform device */
 #define VFIO_DEVICE_FLAGS_AMBA  (1 << 3)   /* vfio-amba device */
 #define VFIO_DEVICE_FLAGS_CCW  (1 << 4)/* vfio-ccw device */
+#define VFIO_DEVICE_FLAGS_EDID (1 << 5)/* Device supports edid */
__u32   num_regions;/* Max region index + 1 */
__u32   num_irqs;   /* Max IRQ index + 1 */
+   __u32   edid_max_x; /* Max display width (zero == no limit) */
+   __u32   edid_max_y; /* Max display height (zero == no limit) */
 };
 #define VFIO_DEVICE_GET_INFO   _IO(VFIO_TYPE, VFIO_BASE + 7)
 
@@ -602,6 +605,41 @@ struct vfio_device_ioeventfd {
 
 #define VFIO_DEVICE_IOEVENTFD  _IO(VFIO_TYPE, VFIO_BASE + 16)
 
+/**
+ * VFIO_DEVICE_SET_GFX_EDID - _IOW(VFIO_TYPE, VFIO_BASE + 17,
+ * struct vfio_device_set_gfx_edid)
+ *
+ * Set display link state and edid blob (for UP state).
+ *
+ * For the edid blob spec look here:
+ * https://en.wikipedia.org/wiki/Extended_Display_Identification_Data
+ *
+ * The guest should be notified about edid changes, for example by
+ * setting the link status to down temporarely (emulate monitor
+ * hotplug).
+ *
+ * @link_state:
+ * VFIO_DEVICE_GFX_LINK_STATE_UP: Monitor is turned on.
+ * VFIO_DEVICE_GFX_LINK_STATE_DOWN: Monitor is turned off.
+ *
+ * @edid_size: Size of the edid data blob.
+ * @edid_blob: The actual edid data.
+ *
+ * Returns 0 on success, error code (such as -EINVAL) on failure.
+ */
+struct vfio_device_set_gfx_edid {
+   __u32 argsz;
+   __u32 flags;
+   /* in */
+   __u32 link_state;
+#define VFIO_DEVICE_GFX_LINK_STATE_UP1
+#define VFIO_DEVICE_GFX_LINK_STATE_DOWN  2
+   __u32 edid_size;
+   __u8  edid_blob[512];
+};
+
+#define VFIO_DEVICE_SET_GFX_EDID _IO(VFIO_TYPE, VFIO_BASE + 17)
+
 /*  API for Type1 VFIO IOMMU  */
 
 /**
-- 
2.9.3



[PATCH 1/2] vfio: add edid api for display (vgpu) devices.

2018-09-12 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 include/uapi/linux/vfio.h | 38 ++
 1 file changed, 38 insertions(+)

diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 1aa7b82e81..38b591e909 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -200,8 +200,11 @@ struct vfio_device_info {
 #define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2)/* vfio-platform device */
 #define VFIO_DEVICE_FLAGS_AMBA  (1 << 3)   /* vfio-amba device */
 #define VFIO_DEVICE_FLAGS_CCW  (1 << 4)/* vfio-ccw device */
+#define VFIO_DEVICE_FLAGS_EDID (1 << 5)/* Device supports edid */
__u32   num_regions;/* Max region index + 1 */
__u32   num_irqs;   /* Max IRQ index + 1 */
+   __u32   edid_max_x; /* Max display width (zero == no limit) */
+   __u32   edid_max_y; /* Max display height (zero == no limit) */
 };
 #define VFIO_DEVICE_GET_INFO   _IO(VFIO_TYPE, VFIO_BASE + 7)
 
@@ -602,6 +605,41 @@ struct vfio_device_ioeventfd {
 
 #define VFIO_DEVICE_IOEVENTFD  _IO(VFIO_TYPE, VFIO_BASE + 16)
 
+/**
+ * VFIO_DEVICE_SET_GFX_EDID - _IOW(VFIO_TYPE, VFIO_BASE + 17,
+ * struct vfio_device_set_gfx_edid)
+ *
+ * Set display link state and edid blob (for UP state).
+ *
+ * For the edid blob spec look here:
+ * https://en.wikipedia.org/wiki/Extended_Display_Identification_Data
+ *
+ * The guest should be notified about edid changes, for example by
+ * setting the link status to down temporarely (emulate monitor
+ * hotplug).
+ *
+ * @link_state:
+ * VFIO_DEVICE_GFX_LINK_STATE_UP: Monitor is turned on.
+ * VFIO_DEVICE_GFX_LINK_STATE_DOWN: Monitor is turned off.
+ *
+ * @edid_size: Size of the edid data blob.
+ * @edid_blob: The actual edid data.
+ *
+ * Returns 0 on success, error code (such as -EINVAL) on failure.
+ */
+struct vfio_device_set_gfx_edid {
+   __u32 argsz;
+   __u32 flags;
+   /* in */
+   __u32 link_state;
+#define VFIO_DEVICE_GFX_LINK_STATE_UP1
+#define VFIO_DEVICE_GFX_LINK_STATE_DOWN  2
+   __u32 edid_size;
+   __u8  edid_blob[512];
+};
+
+#define VFIO_DEVICE_SET_GFX_EDID _IO(VFIO_TYPE, VFIO_BASE + 17)
+
 /*  API for Type1 VFIO IOMMU  */
 
 /**
-- 
2.9.3



Re: [PATCH] tty: max3100: Fix oops while 'cat /proc/tty/driver/ttyMAX'

2018-09-12 Thread Jiri Slaby
On 09/13/2018, 04:38 AM, chen.l...@zte.com.cn wrote:
> Before wq 's->workqueue' be initialized in function 'max3100_startup',
> 
> 'cat /proc/tty/driver/ttyMAX' will cause oops.
> 
> 
> Oops: Kernel access of bad area, sig: 11 [#1]
> 
> ...
> 
> NIP [c0049070] __queue_work+0x24/0x268
> 
> LR [c0049308] queue_work_on+0x54/0x70
> 
> Call Trace:
> 
> [db44dba0] [c0049308] queue_work_on+0x54/0x70
> 
> [db44dbb0] [c036befc] max3100_get_mctrl+0x18/0x40
> 
> [db44dbc0] [c03614a4] uart_proc_show+0xfc/0x448
> 
> [db44dc40] [c0111aa8] seq_read+0x198/0x514
> 
> [db44dc90] [c01436e4] proc_reg_read+0x58/0x94
> 
> [db44dca0] [c00ee804] do_iter_read+0x190/0x1e0
> 
> [db44dcc0] [c00f0040] vfs_readv+0x58/0x7c
> 
> [db44dd40] [c011a2f4] default_file_splice_read+0x160/0x27c
> 
> [db44de30] [c0119f74] splice_direct_to_actor+0xec/0x23c
> 
> [db44de80] [c011a158] do_splice_direct+0x94/0xd0
> 
> [db44dec0] [c008] do_sendfile+0x1e0/0x380
> 
> [db44df10] [c00f0424] sys_sendfile64+0xc0/0xd4
> 
> [db44df40] [c000e260] ret_from_syscall+0x0/0x3c
> 
> 
> Signed-off-by: Chen Lin 
> 
> ---
> 
>  drivers/tty/serial/max3100.c | 3 ++-
> 
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c
> 
> index 371569a..0429c2d 100644
> 
> --- a/drivers/tty/serial/max3100.c
> 
> +++ b/drivers/tty/serial/max3100.c
> 
> @@ -391,7 +391,8 @@ static unsigned int max3100_get_mctrl(struct
> uart_port *port)
> 
>         dev_dbg(>spi->dev, "%s\n", __func__);
> 
> 
>         /* may not be truly up-to-date */
> 
> -       max3100_dowork(s);
> 
> +       if (s->workqueue)
> 
> +               max3100_dowork(s);

This does not look right in the sense of races (shutdown can kill the
workqueue right after the if. Or even before the if, as s->workqueue =
NULL is only after destroy_workqueue in max3100_shutdown).

If get_mctrl needs the queue, it shall not be created and destroyed ad hoc.

>         /* always assert DCD and DSR since these lines are not wired */
> 
>         return (s->cts ? TIOCM_CTS : 0) | TIOCM_DSR | TIOCM_CAR;
> 
>  }

thanks,
-- 
js
suse labs


Re: [PATCH] tty: max3100: Fix oops while 'cat /proc/tty/driver/ttyMAX'

2018-09-12 Thread Jiri Slaby
On 09/13/2018, 04:38 AM, chen.l...@zte.com.cn wrote:
> Before wq 's->workqueue' be initialized in function 'max3100_startup',
> 
> 'cat /proc/tty/driver/ttyMAX' will cause oops.
> 
> 
> Oops: Kernel access of bad area, sig: 11 [#1]
> 
> ...
> 
> NIP [c0049070] __queue_work+0x24/0x268
> 
> LR [c0049308] queue_work_on+0x54/0x70
> 
> Call Trace:
> 
> [db44dba0] [c0049308] queue_work_on+0x54/0x70
> 
> [db44dbb0] [c036befc] max3100_get_mctrl+0x18/0x40
> 
> [db44dbc0] [c03614a4] uart_proc_show+0xfc/0x448
> 
> [db44dc40] [c0111aa8] seq_read+0x198/0x514
> 
> [db44dc90] [c01436e4] proc_reg_read+0x58/0x94
> 
> [db44dca0] [c00ee804] do_iter_read+0x190/0x1e0
> 
> [db44dcc0] [c00f0040] vfs_readv+0x58/0x7c
> 
> [db44dd40] [c011a2f4] default_file_splice_read+0x160/0x27c
> 
> [db44de30] [c0119f74] splice_direct_to_actor+0xec/0x23c
> 
> [db44de80] [c011a158] do_splice_direct+0x94/0xd0
> 
> [db44dec0] [c008] do_sendfile+0x1e0/0x380
> 
> [db44df10] [c00f0424] sys_sendfile64+0xc0/0xd4
> 
> [db44df40] [c000e260] ret_from_syscall+0x0/0x3c
> 
> 
> Signed-off-by: Chen Lin 
> 
> ---
> 
>  drivers/tty/serial/max3100.c | 3 ++-
> 
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c
> 
> index 371569a..0429c2d 100644
> 
> --- a/drivers/tty/serial/max3100.c
> 
> +++ b/drivers/tty/serial/max3100.c
> 
> @@ -391,7 +391,8 @@ static unsigned int max3100_get_mctrl(struct
> uart_port *port)
> 
>         dev_dbg(>spi->dev, "%s\n", __func__);
> 
> 
>         /* may not be truly up-to-date */
> 
> -       max3100_dowork(s);
> 
> +       if (s->workqueue)
> 
> +               max3100_dowork(s);

This does not look right in the sense of races (shutdown can kill the
workqueue right after the if. Or even before the if, as s->workqueue =
NULL is only after destroy_workqueue in max3100_shutdown).

If get_mctrl needs the queue, it shall not be created and destroyed ad hoc.

>         /* always assert DCD and DSR since these lines are not wired */
> 
>         return (s->cts ? TIOCM_CTS : 0) | TIOCM_DSR | TIOCM_CAR;
> 
>  }

thanks,
-- 
js
suse labs


linux-next: Tree for Sep 13

2018-09-12 Thread Stephen Rothwell
Hi all,

News: there will be no linux-next releases on Friday or Monday.

Changes since 20180912:

Dropped trees: xarray, ida (temporarily)

I still disabled building some samples in the vfs tree.

I added a supplied patch to the akpm-current tree.

The akpm tree lost a patch for a bug that was fixed elsewhere.

Non-merge commits (relative to Linus' tree): 3643
 4039 files changed, 119566 insertions(+), 73090 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" and checkout or reset to the new
master.

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log
files in the Next directory.  Between each merge, the tree was built
with a ppc64_defconfig for powerpc, an allmodconfig for x86_64, a
multi_v7_defconfig for arm and a native build of tools/perf. After
the final fixups (if any), I do an x86_64 modules_install followed by
builds for x86_64 allnoconfig, powerpc allnoconfig (32 and 64 bit),
ppc44x_defconfig, allyesconfig and pseries_le_defconfig and i386, sparc
and sparc64 defconfig. And finally, a simple boot test of the powerpc
pseries_le_defconfig kernel in qemu (with and without kvm enabled).

Below is a summary of the state of the merge.

I am currently merging 287 trees (counting Linus' and 66 trees of bug
fix patches pending for the current merge release).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (96eddb810b14 Merge tag 'riscv-for-linus-4.19-rc3' of 
git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux)
Merging fixes/master (72358c0b59b7 linux-next: build warnings from the build of 
Linus' tree)
Merging kbuild-current/fixes (11da3a7f84f1 Linux 4.19-rc3)
Merging arc-current/for-curr (00a99339f0a3 ARCv2: build: use mcpu=hs38 iso 
generic mcpu=archs)
Merging arm-current/fixes (afc9f65e01cd ARM: 8781/1: Fix Thumb-2 syscall return 
for binutils 2.29+)
Merging arm64-fixes/for-next/fixes (84c57dbd3c48 arm64: kernel: 
arch_crash_save_vmcoreinfo() should depend on CONFIG_CRASH_CORE)
Merging m68k-current/for-linus (0986b16ab49b m68k/mac: Use correct PMU response 
format)
Merging powerpc-fixes/fixes (cca19f0b684f powerpc/64s/radix: Fix missing global 
invalidations when removing copro)
Merging sparc/master (df2def49c57b Merge tag 'acpi-4.19-rc1-2' of 
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm)
Merging fscrypt-current/for-stable (ae64f9bd1d36 Linux 4.15-rc2)
Merging net/master (4851bfd64d42 Merge branch 'nfp-flower-fixes')
Merging bpf/master (dd066823db2a bpf/verifier: disallow pointer subtraction)
Merging ipsec/master (9e1437937807 xfrm: Fix NULL pointer dereference when 
skb_dst_force clears the dst_entry.)
Merging netfilter/master (1286df269f49 netfilter: xt_hashlimit: use s->file 
instead of s->private)
Merging ipvs/master (feb9f55c33e5 netfilter: nft_dynset: allow dynamic updates 
of non-anonymous set)
Merging wireless-drivers/master (5b394b2ddf03 Linux 4.19-rc1)
Merging mac80211/master (c42055105785 mac80211: fix TX status reporting for 
ieee80211s)
Merging rdma-fixes/for-rc (9f34519a8235 cxgb4: fix abort_req_rss6 struct)
Merging sound-current/for-linus (49434c6c575d ALSA: emu10k1: fix possible info 
leak to userspace on SNDRV_EMU10K1_IOCTL_INFO)
Merging sound-asoc-fixes/for-linus (de7609683fef Merge branch 'asoc-4.19' into 
asoc-linus)
Merging regmap-fixes/for-linus (57361846b52b Linux 4.19-rc2)
Merging regulator-fixes/for-linus (b832dd4f2c04 Merge branch 'regulator-4.19' 
into regulator-linus)
Merging spi-fixes/for-linus (9029858be9ef Merge branch 'spi-4.19' into 
spi-linus)
Merging pci-current/for-linus (9d27e39d309c PCI: Fix enabling of PASID on RC 
integrated endpoints)
Merging driver-core.current/driver-core-linus (11da3a7f84f1 Linux 4.19-rc3)
Merging tty.current/tty-linus (7f2bf7840b74 tty: hvc: hvc_write() fix break 
condition)
Merging usb.current/usb-linus (df3aa13c7bbb Revert "cdc-acm: implement 
put_char() and flush_chars()")
Merging usb-gadget-fixes/fixes (d9707490077b usb: dwc2: Fix call location of 
dwc2_check_core_endianness)
Merging usb-serial-fixes/usb-linus (5dfdd24eb3d3 USB: serial: ti

linux-next: Tree for Sep 13

2018-09-12 Thread Stephen Rothwell
Hi all,

News: there will be no linux-next releases on Friday or Monday.

Changes since 20180912:

Dropped trees: xarray, ida (temporarily)

I still disabled building some samples in the vfs tree.

I added a supplied patch to the akpm-current tree.

The akpm tree lost a patch for a bug that was fixed elsewhere.

Non-merge commits (relative to Linus' tree): 3643
 4039 files changed, 119566 insertions(+), 73090 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" and checkout or reset to the new
master.

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log
files in the Next directory.  Between each merge, the tree was built
with a ppc64_defconfig for powerpc, an allmodconfig for x86_64, a
multi_v7_defconfig for arm and a native build of tools/perf. After
the final fixups (if any), I do an x86_64 modules_install followed by
builds for x86_64 allnoconfig, powerpc allnoconfig (32 and 64 bit),
ppc44x_defconfig, allyesconfig and pseries_le_defconfig and i386, sparc
and sparc64 defconfig. And finally, a simple boot test of the powerpc
pseries_le_defconfig kernel in qemu (with and without kvm enabled).

Below is a summary of the state of the merge.

I am currently merging 287 trees (counting Linus' and 66 trees of bug
fix patches pending for the current merge release).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (96eddb810b14 Merge tag 'riscv-for-linus-4.19-rc3' of 
git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux)
Merging fixes/master (72358c0b59b7 linux-next: build warnings from the build of 
Linus' tree)
Merging kbuild-current/fixes (11da3a7f84f1 Linux 4.19-rc3)
Merging arc-current/for-curr (00a99339f0a3 ARCv2: build: use mcpu=hs38 iso 
generic mcpu=archs)
Merging arm-current/fixes (afc9f65e01cd ARM: 8781/1: Fix Thumb-2 syscall return 
for binutils 2.29+)
Merging arm64-fixes/for-next/fixes (84c57dbd3c48 arm64: kernel: 
arch_crash_save_vmcoreinfo() should depend on CONFIG_CRASH_CORE)
Merging m68k-current/for-linus (0986b16ab49b m68k/mac: Use correct PMU response 
format)
Merging powerpc-fixes/fixes (cca19f0b684f powerpc/64s/radix: Fix missing global 
invalidations when removing copro)
Merging sparc/master (df2def49c57b Merge tag 'acpi-4.19-rc1-2' of 
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm)
Merging fscrypt-current/for-stable (ae64f9bd1d36 Linux 4.15-rc2)
Merging net/master (4851bfd64d42 Merge branch 'nfp-flower-fixes')
Merging bpf/master (dd066823db2a bpf/verifier: disallow pointer subtraction)
Merging ipsec/master (9e1437937807 xfrm: Fix NULL pointer dereference when 
skb_dst_force clears the dst_entry.)
Merging netfilter/master (1286df269f49 netfilter: xt_hashlimit: use s->file 
instead of s->private)
Merging ipvs/master (feb9f55c33e5 netfilter: nft_dynset: allow dynamic updates 
of non-anonymous set)
Merging wireless-drivers/master (5b394b2ddf03 Linux 4.19-rc1)
Merging mac80211/master (c42055105785 mac80211: fix TX status reporting for 
ieee80211s)
Merging rdma-fixes/for-rc (9f34519a8235 cxgb4: fix abort_req_rss6 struct)
Merging sound-current/for-linus (49434c6c575d ALSA: emu10k1: fix possible info 
leak to userspace on SNDRV_EMU10K1_IOCTL_INFO)
Merging sound-asoc-fixes/for-linus (de7609683fef Merge branch 'asoc-4.19' into 
asoc-linus)
Merging regmap-fixes/for-linus (57361846b52b Linux 4.19-rc2)
Merging regulator-fixes/for-linus (b832dd4f2c04 Merge branch 'regulator-4.19' 
into regulator-linus)
Merging spi-fixes/for-linus (9029858be9ef Merge branch 'spi-4.19' into 
spi-linus)
Merging pci-current/for-linus (9d27e39d309c PCI: Fix enabling of PASID on RC 
integrated endpoints)
Merging driver-core.current/driver-core-linus (11da3a7f84f1 Linux 4.19-rc3)
Merging tty.current/tty-linus (7f2bf7840b74 tty: hvc: hvc_write() fix break 
condition)
Merging usb.current/usb-linus (df3aa13c7bbb Revert "cdc-acm: implement 
put_char() and flush_chars()")
Merging usb-gadget-fixes/fixes (d9707490077b usb: dwc2: Fix call location of 
dwc2_check_core_endianness)
Merging usb-serial-fixes/usb-linus (5dfdd24eb3d3 USB: serial: ti

[PATCH] MAINTAINERS: Clarify UIO vs UACCESS maintainer

2018-09-12 Thread Dan Williams
The UIO file mask in MAINTAINERS was incorrectly directing UACCESS
(include/linux/uio.h) patches to Greg.

Tag Al as the UACCESS maintainer as Ingo and others have explicitly
required his ack before taking architecture patches that touch
lib/iov_iter.c.

Cc: Al Viro 
Reported-by: Greg Kroah-Hartman 
Signed-off-by: Dan Williams 
---
Al, let me know if this is ok. Alternatively we could just fix the file
mask for UIO and not add a new UACCESS section.

 MAINTAINERS |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index d870cb57c887..be6c29cfeb55 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15344,13 +15344,19 @@ F:arch/x86/um/
 F: fs/hostfs/
 F: fs/hppfs/
 
+USERSPACE ACCESS (UACCESS)
+M: Alexander Viro 
+S: Maintained
+F: lib/iov_iter.c
+F: include/linux/uio.h
+
 USERSPACE I/O (UIO)
 M: Greg Kroah-Hartman 
 S: Maintained
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
 F: Documentation/driver-api/uio-howto.rst
 F: drivers/uio/
-F: include/linux/uio*.h
+F: include/linux/uio_driver.h
 
 UTIL-LINUX PACKAGE
 M: Karel Zak 



[PATCH] MAINTAINERS: Clarify UIO vs UACCESS maintainer

2018-09-12 Thread Dan Williams
The UIO file mask in MAINTAINERS was incorrectly directing UACCESS
(include/linux/uio.h) patches to Greg.

Tag Al as the UACCESS maintainer as Ingo and others have explicitly
required his ack before taking architecture patches that touch
lib/iov_iter.c.

Cc: Al Viro 
Reported-by: Greg Kroah-Hartman 
Signed-off-by: Dan Williams 
---
Al, let me know if this is ok. Alternatively we could just fix the file
mask for UIO and not add a new UACCESS section.

 MAINTAINERS |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index d870cb57c887..be6c29cfeb55 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15344,13 +15344,19 @@ F:arch/x86/um/
 F: fs/hostfs/
 F: fs/hppfs/
 
+USERSPACE ACCESS (UACCESS)
+M: Alexander Viro 
+S: Maintained
+F: lib/iov_iter.c
+F: include/linux/uio.h
+
 USERSPACE I/O (UIO)
 M: Greg Kroah-Hartman 
 S: Maintained
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
 F: Documentation/driver-api/uio-howto.rst
 F: drivers/uio/
-F: include/linux/uio*.h
+F: include/linux/uio_driver.h
 
 UTIL-LINUX PACKAGE
 M: Karel Zak 



Re: [PATCH] arm64: dts: meson-axg-s400: Add chosen and memory nodes

2018-09-12 Thread Kevin Hilman
Neil Armstrong  writes:

> Add missing chosen and memory nodes.
>
> Signed-off-by: Neil Armstrong 

Applied to v4.20/dt64 with Martin's ack.

Thanks,

Kevin


Re: [PATCH] arm64: dts: meson-axg-s400: Add chosen and memory nodes

2018-09-12 Thread Kevin Hilman
Neil Armstrong  writes:

> Add missing chosen and memory nodes.
>
> Signed-off-by: Neil Armstrong 

Applied to v4.20/dt64 with Martin's ack.

Thanks,

Kevin


Re: [PATCH] arm64: dts: meson-axg: use the proper compatible for ethmac

2018-09-12 Thread Kevin Hilman
Neil Armstrong  writes:

> Use the correct compatible for the AXG ethernet mac node.
>
> Signed-off-by: Neil Armstrong 

Applied to v4.20/dt64 with Martin's ack,

Thanks,

Kevin


Re: [PATCH] arm64: dts: meson-axg: use the proper compatible for ethmac

2018-09-12 Thread Kevin Hilman
Neil Armstrong  writes:

> Use the correct compatible for the AXG ethernet mac node.
>
> Signed-off-by: Neil Armstrong 

Applied to v4.20/dt64 with Martin's ack,

Thanks,

Kevin


Re: [PATCH 0/3] arm64: dts: meson-axg: add pdm support

2018-09-12 Thread Kevin Hilman
Jerome Brunet  writes:

> This patchset adds pdm support for amlogic AXG SoC.
> It applies on top of the DT clean-up [0] I sent earlier

Applied to v4.20/dt64.

> The related ASoC PDM patches can be found here [1]. While the ASoC patches
> [2] are obviously needed to for the PDM to work, this series can be safely
> applied without it.

Thanks for the clear explanation of dependencies.

Kevin


Re: [PATCH 0/3] arm64: dts: meson-axg: add pdm support

2018-09-12 Thread Kevin Hilman
Jerome Brunet  writes:

> This patchset adds pdm support for amlogic AXG SoC.
> It applies on top of the DT clean-up [0] I sent earlier

Applied to v4.20/dt64.

> The related ASoC PDM patches can be found here [1]. While the ASoC patches
> [2] are obviously needed to for the PDM to work, this series can be safely
> applied without it.

Thanks for the clear explanation of dependencies.

Kevin


Re: [PATCH] arm64: defconfig: enable modules for amlogic s400 sound card

2018-09-12 Thread Kevin Hilman
Jerome Brunet  writes:

> Compile the necessary drivers as modules, including codecs, for the
> s400 sound card.
>
> Signed-off-by: Jerome Brunet 

Applied to v4.20/defconfig.

Thanks,

Kevin


Re: [PATCH] arm64: defconfig: enable modules for amlogic s400 sound card

2018-09-12 Thread Kevin Hilman
Jerome Brunet  writes:

> Compile the necessary drivers as modules, including codecs, for the
> s400 sound card.
>
> Signed-off-by: Jerome Brunet 

Applied to v4.20/defconfig.

Thanks,

Kevin


Re: [PATCH v3 2/3] soc: amlogic: add meson-canvas driver

2018-09-12 Thread Kevin Hilman
Maxime Jourdan  writes:

> Amlogic SoCs have a repository of 256 canvas which they use to
> describe pixel buffers.
>
> They contain metadata like width, height, block mode, endianness [..]
>
> Many IPs within those SoCs like vdec/vpu rely on those canvas to read/write
> pixels.
>
> Reviewed-by: Jerome Brunet 
> Tested-by: Neil Armstrong 
> Signed-off-by: Maxime Jourdan 

Applied patches 1,2 to v4.20/drivers and added an
"amlogic-drivers-canvas" tag as requested.

Kevin


Re: [PATCH v3 2/3] soc: amlogic: add meson-canvas driver

2018-09-12 Thread Kevin Hilman
Maxime Jourdan  writes:

> Amlogic SoCs have a repository of 256 canvas which they use to
> describe pixel buffers.
>
> They contain metadata like width, height, block mode, endianness [..]
>
> Many IPs within those SoCs like vdec/vpu rely on those canvas to read/write
> pixels.
>
> Reviewed-by: Jerome Brunet 
> Tested-by: Neil Armstrong 
> Signed-off-by: Maxime Jourdan 

Applied patches 1,2 to v4.20/drivers and added an
"amlogic-drivers-canvas" tag as requested.

Kevin


Re: [PATCH v3 3/3] ARM64: dts: meson-gx: add dmcbus and canvas nodes.

2018-09-12 Thread Kevin Hilman
Maxime Jourdan  writes:

> DMC is a small memory region with various registers,
> including the ones needed for the canvas module.
>
> Reviewed-by: Jerome Brunet 
> Signed-off-by: Maxime Jourdan 

Applied to v4.20/dt64 with s/ARM64/arm64/ as requested.

Thanks,

Kevin


Re: [PATCH v3 3/3] ARM64: dts: meson-gx: add dmcbus and canvas nodes.

2018-09-12 Thread Kevin Hilman
Maxime Jourdan  writes:

> DMC is a small memory region with various registers,
> including the ones needed for the canvas module.
>
> Reviewed-by: Jerome Brunet 
> Signed-off-by: Maxime Jourdan 

Applied to v4.20/dt64 with s/ARM64/arm64/ as requested.

Thanks,

Kevin


Re: [PATCH 1/2] ASoC: max9892x: Add documentation for reset-gpio support

2018-09-12 Thread Cheng-yi Chiang
On Wed, Sep 12, 2018 at 8:28 PM Mark Brown  wrote:
>
> On Wed, Sep 12, 2018 at 08:19:54PM +0800, Cheng-Yi Chiang wrote:
> > max98927 codec driver will support reset-gpio binding so it can toggle
> > reset line in its probe function.
>
> All GPIO properties are supposed to end -gpios even if there can only
> ever be a single GPIO.

Hi Mark. I see.
I will update this along with the comments of the change in max98927.c
if there is any.
Thanks!


Re: [PATCH 1/2] ASoC: max9892x: Add documentation for reset-gpio support

2018-09-12 Thread Cheng-yi Chiang
On Wed, Sep 12, 2018 at 8:28 PM Mark Brown  wrote:
>
> On Wed, Sep 12, 2018 at 08:19:54PM +0800, Cheng-Yi Chiang wrote:
> > max98927 codec driver will support reset-gpio binding so it can toggle
> > reset line in its probe function.
>
> All GPIO properties are supposed to end -gpios even if there can only
> ever be a single GPIO.

Hi Mark. I see.
I will update this along with the comments of the change in max98927.c
if there is any.
Thanks!


Re: [PATCH] pstore: fix incorrect persistent ram buffer mapping

2018-09-12 Thread Kees Cook
On Wed, Sep 12, 2018 at 6:21 PM, Yang, Bin  wrote:
> On Wed, 2018-09-12 at 10:44 -0700, Kees Cook wrote:
>> On Tue, Sep 11, 2018 at 8:36 PM, Bin Yang  wrote:
>> > persistent_ram_vmap() returns the page start vaddr.
>> > persistent_ram_iomap() supports non-page-aligned mapping.
>>
>> Oh, yes, good catch. This should probably be explicitly mentioned in
>> comments for these functions.
>>
>> > persistent_ram_buffer_map() always adds offset-in-page to the vaddr
>> > returned from these two functions, which causes incorrect mapping of
>> > non-page-aligned persistent ram buffer.
>>
>> How did you find this problem, and/or how was the problem manifesting?
>
> By default, ftrace_size is 4096 and max_ftrace_cnt is nr_cpu_ids. The
> zone_sz in ramoops_init_przs() is 4096/nr_cpu_ids which might not be
> page aligned. If the offset-in-page > 2048, the vaddr will be in next
> page. If the next page is not mapped, it will cause kernel panic.
>
> I just wanted to enable this driver on my board and did not change the
> default value of ftrace_size. It resulted kernel panic as below:
>
>
> [0.074231] BUG: unable to handle kernel paging request at
> a19e0081b000

Perfect, thanks! I've updated your commit log to include these details
now. Should be in linux-next shortly.

-Kees

-- 
Kees Cook
Pixel Security


Re: [PATCH] pstore: fix incorrect persistent ram buffer mapping

2018-09-12 Thread Kees Cook
On Wed, Sep 12, 2018 at 6:21 PM, Yang, Bin  wrote:
> On Wed, 2018-09-12 at 10:44 -0700, Kees Cook wrote:
>> On Tue, Sep 11, 2018 at 8:36 PM, Bin Yang  wrote:
>> > persistent_ram_vmap() returns the page start vaddr.
>> > persistent_ram_iomap() supports non-page-aligned mapping.
>>
>> Oh, yes, good catch. This should probably be explicitly mentioned in
>> comments for these functions.
>>
>> > persistent_ram_buffer_map() always adds offset-in-page to the vaddr
>> > returned from these two functions, which causes incorrect mapping of
>> > non-page-aligned persistent ram buffer.
>>
>> How did you find this problem, and/or how was the problem manifesting?
>
> By default, ftrace_size is 4096 and max_ftrace_cnt is nr_cpu_ids. The
> zone_sz in ramoops_init_przs() is 4096/nr_cpu_ids which might not be
> page aligned. If the offset-in-page > 2048, the vaddr will be in next
> page. If the next page is not mapped, it will cause kernel panic.
>
> I just wanted to enable this driver on my board and did not change the
> default value of ftrace_size. It resulted kernel panic as below:
>
>
> [0.074231] BUG: unable to handle kernel paging request at
> a19e0081b000

Perfect, thanks! I've updated your commit log to include these details
now. Should be in linux-next shortly.

-Kees

-- 
Kees Cook
Pixel Security


Re: [PATCH] arm64: dts: meson: Switch simple-mfd and syscon order

2018-09-12 Thread Kevin Hilman
On Wed, Sep 12, 2018 at 8:59 PM Kevin Hilman  wrote:
>
> Neil Armstrong  writes:
>
> > The order between "syscon" and "simple-mfd" is important because in these
> > particular cases, the node needs to be first a "simple-mfd" to expose
> > it's sub-nodes, and later on a "syscon" to permit other nodes to access
> > this register space through the "syscon" mechanism.
> >
> > Signed-off-by: Neil Armstrong 
>
> Applied to v4.20/dt64,
>

I spoke too soon, this doesn't apply cleanly on top of Jeromes
reorder/cleanup.  Please respin/resend.

Kevin


Re: [PATCH] arm64: dts: meson: Switch simple-mfd and syscon order

2018-09-12 Thread Kevin Hilman
On Wed, Sep 12, 2018 at 8:59 PM Kevin Hilman  wrote:
>
> Neil Armstrong  writes:
>
> > The order between "syscon" and "simple-mfd" is important because in these
> > particular cases, the node needs to be first a "simple-mfd" to expose
> > it's sub-nodes, and later on a "syscon" to permit other nodes to access
> > this register space through the "syscon" mechanism.
> >
> > Signed-off-by: Neil Armstrong 
>
> Applied to v4.20/dt64,
>

I spoke too soon, this doesn't apply cleanly on top of Jeromes
reorder/cleanup.  Please respin/resend.

Kevin


Re: [PATCH] arm64: dts: meson-axg: sort nodes consistently

2018-09-12 Thread Kevin Hilman
Jerome Brunet  writes:

> Sort DT nodes by address when possible, by node node name otherwise.
>
> Signed-off-by: Jerome Brunet 
> ---
>
> Hi Kevin,
>
> This patch is same kind of clean-up we already did on gxbb and gxl some
> time ago. In the same fashion, it ends up being and ugly and almost unreadable
> patch, sorry about that :( I don't think there was a way to avoid it.
>
> The patch applies on top v4.19-rc1 + 3 DT audio patches which are in your
> v4.19/dt64 branch [0]
>
> There should be no functional change after applying this patch.
> I've tested it in on the s400 and so far, so good.

Thanks for the cleanup,

Applied to v4.20/dt64,

Kevin


Re: [PATCH] arm64: dts: meson-axg: sort nodes consistently

2018-09-12 Thread Kevin Hilman
Jerome Brunet  writes:

> Sort DT nodes by address when possible, by node node name otherwise.
>
> Signed-off-by: Jerome Brunet 
> ---
>
> Hi Kevin,
>
> This patch is same kind of clean-up we already did on gxbb and gxl some
> time ago. In the same fashion, it ends up being and ugly and almost unreadable
> patch, sorry about that :( I don't think there was a way to avoid it.
>
> The patch applies on top v4.19-rc1 + 3 DT audio patches which are in your
> v4.19/dt64 branch [0]
>
> There should be no functional change after applying this patch.
> I've tested it in on the s400 and so far, so good.

Thanks for the cleanup,

Applied to v4.20/dt64,

Kevin


Re: [PATCH] arm64: dts: meson: libretech: update board model

2018-09-12 Thread Kevin Hilman
Jerome Brunet  writes:

> There is actually several different libretech board with the CC suffix
> so the model name is not appropriate here. Update to something more
> specific
>
> Reported-by: Da Xue 
> Signed-off-by: Jerome Brunet 

Applied to v4.20/dt64

Kevin


Re: [PATCH] arm64: dts: meson: libretech: update board model

2018-09-12 Thread Kevin Hilman
Jerome Brunet  writes:

> There is actually several different libretech board with the CC suffix
> so the model name is not appropriate here. Update to something more
> specific
>
> Reported-by: Da Xue 
> Signed-off-by: Jerome Brunet 

Applied to v4.20/dt64

Kevin


Re: [PATCH] arm64: dts: meson: Switch simple-mfd and syscon order

2018-09-12 Thread Chen-Yu Tsai
On Thu, Jul 26, 2018 at 10:51 PM Neil Armstrong  wrote:
>
> Hi,
>
> On 26/07/2018 16:41, Yixun Lan wrote:
> > HI Neil
> >
> > On 07/26/2018 10:13 PM, Neil Armstrong wrote:
> >> The order between "syscon" and "simple-mfd" is important because in these
> >> particular cases, the node needs to be first a "simple-mfd" to expose
> >> it's sub-nodes, and later on a "syscon" to permit other nodes to access
> >> this register space through the "syscon" mechanism.
> >>
> >
> > could you explain a bit which specific case that it need compatible
> > "simple-mfd" come first? is this a problem in kernel side? because I see
> > you have a comment below about problem in U-Boot..
>
> It's not a problem for Linux, but Linux is just an implementation, the device 
> tree
> should work on multiple OSs like U-Boot or BSD kernels. We should base 
> ourselves on
> the bindings documentation and the Device tree specification to specify the 
> HW.
>
> In this case, we need to switch the order to specify it correctly.

syscon on Linux works because syscon is not a full blown device driver in
the driver model. It is just a set of APIs wrapping regmap.

> >
> >
> > also while Rob review the mmc-clkc patch, he raise a suggestion to  drop
> > "syscon" in drivers/mfd/syscon.c, see [1], will that solve or affect
> > your problem?
>
> Rob wants us to drop the "syscon" because he wants us to move all nodes
> depending of HHI as subnode, which is impossible for HDMI and the VPU power 
> controller,
> they are only "syscon" clients, their own registers are not in HHI.

You can have whatever device driver this is bound to export regmaps for clients
to consume. This gives you finer control over what registers can be accessed.

See the following example.

Provider: 
https://elixir.bootlin.com/linux/v4.19-rc3/source/drivers/clk/sunxi-ng/ccu-sun8i-r40.c#L1315
Client: 
https://elixir.bootlin.com/linux/v4.19-rc3/source/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c#L1035

Hope this helps.

ChenYu

> Neil
>
> >
> > [1]
> > https://lkml.kernel.org/r/CAL_Jsq+r+7BaJAPBn3L26sdxATVyDiuC=v3xe+yz0-27q0r...@mail.gmail.com
> >
> >> Signed-off-by: Neil Armstrong 
> >> ---
> >> This also has a consequence for U-Boot since the U-Boot DM is much simpler
> >> and can only associate a single device to a node, thus here we want these
> >> nodes to be an mfd bus to be able to probe the sub-nodes.
> >>
> >>  arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 4 ++--
> >>  arch/arm64/boot/dts/amlogic/meson-gx.dtsi  | 4 ++--
> >>  2 files changed, 4 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi 
> >> b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
> >> index 6adc8d3..3f0de9d 100644
> >> --- a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
> >> +++ b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
> >> @@ -342,7 +342,7 @@
> >>  ranges = <0x0 0x0 0x0 0xff63c000 0x0 0x1c00>;
> >>
> >>  sysctrl: system-controller@0 {
> >> -compatible = "amlogic,meson-axg-hhi-sysctrl", 
> >> "syscon", "simple-mfd";
> >> +compatible = "amlogic,meson-axg-hhi-sysctrl", 
> >> "simple-mfd", "syscon";
> >>  reg = <0 0 0 0x400>;
> >>
> >>  clkc: clock-controller {
> >> @@ -1180,7 +1180,7 @@
> >>  ranges = <0x0 0x0 0x0 0xff80 0x0 0x10>;
> >>
> >>  sysctrl_AO: sys-ctrl@0 {
> >> -compatible = "amlogic,meson-axg-ao-sysctrl", 
> >> "syscon", "simple-mfd";
> >> +compatible = "amlogic,meson-axg-ao-sysctrl", 
> >> "simple-mfd", "syscon";
> >>  reg =  <0x0 0x0 0x0 0x100>;
> >>
> >>  clkc_AO: clock-controller {
> >> diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi 
> >> b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
> >> index b8dc4db..d88699f 100644
> >> --- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
> >> +++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
> >> @@ -344,7 +344,7 @@
> >>  ranges = <0x0 0x0 0x0 0xc810 0x0 0x10>;
> >>
> >>  sysctrl_AO: sys-ctrl@0 {
> >> -compatible = "amlogic,meson-gx-ao-sysctrl", 
> >> "syscon", "simple-mfd";
> >> +compatible = "amlogic,meson-gx-ao-sysctrl", 
> >> "simple-mfd", "syscon";
> >>  reg =  <0x0 0x0 0x0 0x100>;
> >>
> >>  pwrc_vpu: power-controller-vpu {
> >> @@ -431,7 +431,7 @@
> >>  ranges = <0x0 0x0 0x0 0xc883c000 0x0 0x2000>;
> >>
> >>  sysctrl: system-controller@0 {
> >> -compatible = "amlogic,meson-gx-hhi-sysctrl", 
> >> "syscon", "simple-mfd";
> >> +compatible = "amlogic,meson-gx-hhi-sysctrl", 
> >> "simple-mfd", "syscon";
> >>  reg = <0 0 

Re: [PATCH] arm64: dts: meson: Switch simple-mfd and syscon order

2018-09-12 Thread Chen-Yu Tsai
On Thu, Jul 26, 2018 at 10:51 PM Neil Armstrong  wrote:
>
> Hi,
>
> On 26/07/2018 16:41, Yixun Lan wrote:
> > HI Neil
> >
> > On 07/26/2018 10:13 PM, Neil Armstrong wrote:
> >> The order between "syscon" and "simple-mfd" is important because in these
> >> particular cases, the node needs to be first a "simple-mfd" to expose
> >> it's sub-nodes, and later on a "syscon" to permit other nodes to access
> >> this register space through the "syscon" mechanism.
> >>
> >
> > could you explain a bit which specific case that it need compatible
> > "simple-mfd" come first? is this a problem in kernel side? because I see
> > you have a comment below about problem in U-Boot..
>
> It's not a problem for Linux, but Linux is just an implementation, the device 
> tree
> should work on multiple OSs like U-Boot or BSD kernels. We should base 
> ourselves on
> the bindings documentation and the Device tree specification to specify the 
> HW.
>
> In this case, we need to switch the order to specify it correctly.

syscon on Linux works because syscon is not a full blown device driver in
the driver model. It is just a set of APIs wrapping regmap.

> >
> >
> > also while Rob review the mmc-clkc patch, he raise a suggestion to  drop
> > "syscon" in drivers/mfd/syscon.c, see [1], will that solve or affect
> > your problem?
>
> Rob wants us to drop the "syscon" because he wants us to move all nodes
> depending of HHI as subnode, which is impossible for HDMI and the VPU power 
> controller,
> they are only "syscon" clients, their own registers are not in HHI.

You can have whatever device driver this is bound to export regmaps for clients
to consume. This gives you finer control over what registers can be accessed.

See the following example.

Provider: 
https://elixir.bootlin.com/linux/v4.19-rc3/source/drivers/clk/sunxi-ng/ccu-sun8i-r40.c#L1315
Client: 
https://elixir.bootlin.com/linux/v4.19-rc3/source/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c#L1035

Hope this helps.

ChenYu

> Neil
>
> >
> > [1]
> > https://lkml.kernel.org/r/CAL_Jsq+r+7BaJAPBn3L26sdxATVyDiuC=v3xe+yz0-27q0r...@mail.gmail.com
> >
> >> Signed-off-by: Neil Armstrong 
> >> ---
> >> This also has a consequence for U-Boot since the U-Boot DM is much simpler
> >> and can only associate a single device to a node, thus here we want these
> >> nodes to be an mfd bus to be able to probe the sub-nodes.
> >>
> >>  arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 4 ++--
> >>  arch/arm64/boot/dts/amlogic/meson-gx.dtsi  | 4 ++--
> >>  2 files changed, 4 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi 
> >> b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
> >> index 6adc8d3..3f0de9d 100644
> >> --- a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
> >> +++ b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
> >> @@ -342,7 +342,7 @@
> >>  ranges = <0x0 0x0 0x0 0xff63c000 0x0 0x1c00>;
> >>
> >>  sysctrl: system-controller@0 {
> >> -compatible = "amlogic,meson-axg-hhi-sysctrl", 
> >> "syscon", "simple-mfd";
> >> +compatible = "amlogic,meson-axg-hhi-sysctrl", 
> >> "simple-mfd", "syscon";
> >>  reg = <0 0 0 0x400>;
> >>
> >>  clkc: clock-controller {
> >> @@ -1180,7 +1180,7 @@
> >>  ranges = <0x0 0x0 0x0 0xff80 0x0 0x10>;
> >>
> >>  sysctrl_AO: sys-ctrl@0 {
> >> -compatible = "amlogic,meson-axg-ao-sysctrl", 
> >> "syscon", "simple-mfd";
> >> +compatible = "amlogic,meson-axg-ao-sysctrl", 
> >> "simple-mfd", "syscon";
> >>  reg =  <0x0 0x0 0x0 0x100>;
> >>
> >>  clkc_AO: clock-controller {
> >> diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi 
> >> b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
> >> index b8dc4db..d88699f 100644
> >> --- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
> >> +++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
> >> @@ -344,7 +344,7 @@
> >>  ranges = <0x0 0x0 0x0 0xc810 0x0 0x10>;
> >>
> >>  sysctrl_AO: sys-ctrl@0 {
> >> -compatible = "amlogic,meson-gx-ao-sysctrl", 
> >> "syscon", "simple-mfd";
> >> +compatible = "amlogic,meson-gx-ao-sysctrl", 
> >> "simple-mfd", "syscon";
> >>  reg =  <0x0 0x0 0x0 0x100>;
> >>
> >>  pwrc_vpu: power-controller-vpu {
> >> @@ -431,7 +431,7 @@
> >>  ranges = <0x0 0x0 0x0 0xc883c000 0x0 0x2000>;
> >>
> >>  sysctrl: system-controller@0 {
> >> -compatible = "amlogic,meson-gx-hhi-sysctrl", 
> >> "syscon", "simple-mfd";
> >> +compatible = "amlogic,meson-gx-hhi-sysctrl", 
> >> "simple-mfd", "syscon";
> >>  reg = <0 0 

[PATCH] HID: logitech: fix a used uninitialized GCC warning

2018-09-12 Thread zhong jiang
Fix the following compile warning:

drivers/hid/hid-logitech-hidpp.c: In function ‘hi_res_scroll_enable’:
drivers/hid/hid-logitech-hidpp.c:2714:54: warning: ‘multiplier’ may be used 
uninitialized in this function [-Wmaybe-uninitialized]
  hidpp->vertical_wheel_counter.resolution_multiplier = multiplier;

Signed-off-by: zhong jiang 
---
 drivers/hid/hid-logitech-hidpp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 5f0c080..83c43dd 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -2696,7 +2696,7 @@ static int hi_res_scroll_look_up_microns(__u32 product_id)
 static int hi_res_scroll_enable(struct hidpp_device *hidpp)
 {
int ret;
-   u8 multiplier;
+   u8 uninitialized_var(multiplier);
 
if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2121) {
ret = hidpp_hrw_set_wheel_mode(hidpp, false, true, false);
-- 
1.7.12.4



[PATCH] HID: logitech: fix a used uninitialized GCC warning

2018-09-12 Thread zhong jiang
Fix the following compile warning:

drivers/hid/hid-logitech-hidpp.c: In function ‘hi_res_scroll_enable’:
drivers/hid/hid-logitech-hidpp.c:2714:54: warning: ‘multiplier’ may be used 
uninitialized in this function [-Wmaybe-uninitialized]
  hidpp->vertical_wheel_counter.resolution_multiplier = multiplier;

Signed-off-by: zhong jiang 
---
 drivers/hid/hid-logitech-hidpp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 5f0c080..83c43dd 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -2696,7 +2696,7 @@ static int hi_res_scroll_look_up_microns(__u32 product_id)
 static int hi_res_scroll_enable(struct hidpp_device *hidpp)
 {
int ret;
-   u8 multiplier;
+   u8 uninitialized_var(multiplier);
 
if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2121) {
ret = hidpp_hrw_set_wheel_mode(hidpp, false, true, false);
-- 
1.7.12.4



Re: [PATCH] include/linux/compiler-clang.h: define __naked

2018-09-12 Thread Miguel Ojeda
Hi again,

On Wed, Sep 12, 2018 at 6:19 AM, Miguel Ojeda
 wrote:
>
> I will do a bigger one tomorrow or so and see if there are any
> important differences. Regardless of what we do, I will send the
> __naked patches separately as well (requested by Nick on GitHub).

So I did a comparison with a full allyesconfig between -rc2 and -rc2 +
v4. I find quite a lot binary differences, but not a single objdump -d
difference (object file by object file) just by fixing UTS_RELEASE to
the same value, so I guess that is a very good sign in case someone
wants to pick the entire series sooner than expected. Regardless, I
will send the separate __naked patches.

I should note that, at some point in one of my allyesconfig builds I got this:

  UPD include/generated/compile.h
  CC  init/version.o
  AR  init/built-in.a
  AR  built-in.a
  LD  vmlinux.o
  MODPOST vmlinux.o
ld: drivers/edac/amd64_edac.o(.text+0x200031d2): reloc against
`__asan_load4_noabort': error 4
ld: final link failed: Nonrepresentable section on output
Makefile:1035: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1

Running make (without cleaning) didn't reproduce it, and the other
allyesconfig builds didn't suffer any problem either. Maybe my
hardware is failing, but I wanted to let you know nevertheless.

Cheers,
Miguel


Re: [PATCH] include/linux/compiler-clang.h: define __naked

2018-09-12 Thread Miguel Ojeda
Hi again,

On Wed, Sep 12, 2018 at 6:19 AM, Miguel Ojeda
 wrote:
>
> I will do a bigger one tomorrow or so and see if there are any
> important differences. Regardless of what we do, I will send the
> __naked patches separately as well (requested by Nick on GitHub).

So I did a comparison with a full allyesconfig between -rc2 and -rc2 +
v4. I find quite a lot binary differences, but not a single objdump -d
difference (object file by object file) just by fixing UTS_RELEASE to
the same value, so I guess that is a very good sign in case someone
wants to pick the entire series sooner than expected. Regardless, I
will send the separate __naked patches.

I should note that, at some point in one of my allyesconfig builds I got this:

  UPD include/generated/compile.h
  CC  init/version.o
  AR  init/built-in.a
  AR  built-in.a
  LD  vmlinux.o
  MODPOST vmlinux.o
ld: drivers/edac/amd64_edac.o(.text+0x200031d2): reloc against
`__asan_load4_noabort': error 4
ld: final link failed: Nonrepresentable section on output
Makefile:1035: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1

Running make (without cleaning) didn't reproduce it, and the other
allyesconfig builds didn't suffer any problem either. Maybe my
hardware is failing, but I wanted to let you know nevertheless.

Cheers,
Miguel


Re: [PATCH] ARM64: dts: meson-gx: increase default shared CMA pool size

2018-09-12 Thread Kevin Hilman
Christian Hewitt  writes:

> Devices using the new V4L2 mem2mem vdec require a larger CMA pool. As
> nearly all GX* devices are video/media focused and will use it, set a
> larger (256MB) default value.
>
> Signed-off-by: Christian Hewitt 

Applied to v4.20/dt64,

Kevin


Re: [PATCH] ARM64: dts: meson-gx: increase default shared CMA pool size

2018-09-12 Thread Kevin Hilman
Christian Hewitt  writes:

> Devices using the new V4L2 mem2mem vdec require a larger CMA pool. As
> nearly all GX* devices are video/media focused and will use it, set a
> larger (256MB) default value.
>
> Signed-off-by: Christian Hewitt 

Applied to v4.20/dt64,

Kevin


Re: [PATCH] arm64: dts: meson: Switch simple-mfd and syscon order

2018-09-12 Thread Kevin Hilman
Neil Armstrong  writes:

> The order between "syscon" and "simple-mfd" is important because in these
> particular cases, the node needs to be first a "simple-mfd" to expose
> it's sub-nodes, and later on a "syscon" to permit other nodes to access
> this register space through the "syscon" mechanism.
>
> Signed-off-by: Neil Armstrong 

Applied to v4.20/dt64,

Kevin


Re: [PATCH] arm64: dts: meson: Switch simple-mfd and syscon order

2018-09-12 Thread Kevin Hilman
Neil Armstrong  writes:

> The order between "syscon" and "simple-mfd" is important because in these
> particular cases, the node needs to be first a "simple-mfd" to expose
> it's sub-nodes, and later on a "syscon" to permit other nodes to access
> this register space through the "syscon" mechanism.
>
> Signed-off-by: Neil Armstrong 

Applied to v4.20/dt64,

Kevin


Re: [PATCH] firmware: meson_sm: Add serial number sysfs entry

2018-09-12 Thread Kevin Hilman
Neil Armstrong  writes:

> The Amlogic Meson SoC Secure Monitor implements a call to retrieve an unique
> SoC ID starting from the GX Family and all new families.
>
> The serial number is simply exposed as a sysfs entry under the firmware
> sysfs directory.
>
> Signed-off-by: Neil Armstrong 

Applied to v4.20/drivers,

Thanks,

Kevin


Re: [PATCH] firmware: meson_sm: Add serial number sysfs entry

2018-09-12 Thread Kevin Hilman
Neil Armstrong  writes:

> The Amlogic Meson SoC Secure Monitor implements a call to retrieve an unique
> SoC ID starting from the GX Family and all new families.
>
> The serial number is simply exposed as a sysfs entry under the firmware
> sysfs directory.
>
> Signed-off-by: Neil Armstrong 

Applied to v4.20/drivers,

Thanks,

Kevin


[PATCH] iio: proximity: lidar-v2: replace i2c block access method with the one already implemented.

2018-09-12 Thread Song Qiang
This driver tries to access a block of data on a i2c bus and it tries
to manually make a device command frame and a consecutively read frame,
then uses i2c_transfer() to read data. But this has already been
implemented in i2c_smbus_read_i2c_block_data().
Sorry for not having this device by my hand, which is a little expansive
for me, but I have another i2c device and tested with both i2c_transfer()
and i2c_smbus_read_i2c_block_data() and they all ends the same.
I'm not familiar with the SMBus, don't know if the lidar_smbus_xfer()
function is the same as i2c_smbus_read_block_data()? The original code
is commented with something I'm not sure, but I think if it's a standard
SMBus, it should be able to use in here.
Hoping for someone to explain.

Signed-off-by: Song Qiang 
---
 .../iio/proximity/pulsedlight-lidar-lite-v2.c  | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c 
b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
index 47af54f14756..ca880ba8e820 100644
--- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
+++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
@@ -63,23 +63,7 @@ static const struct iio_chan_spec lidar_channels[] = {
 
 static int lidar_i2c_xfer(struct lidar_data *data, u8 reg, u8 *val, int len)
 {
-   struct i2c_client *client = data->client;
-   struct i2c_msg msg[2];
-   int ret;
-
-   msg[0].addr = client->addr;
-   msg[0].flags = client->flags | I2C_M_STOP;
-   msg[0].len = 1;
-   msg[0].buf  = (char *) 
-
-   msg[1].addr = client->addr;
-   msg[1].flags = client->flags | I2C_M_RD;
-   msg[1].len = len;
-   msg[1].buf = (char *) val;
-
-   ret = i2c_transfer(client->adapter, msg, 2);
-
-   return (ret == 2) ? 0 : -EIO;
+   return i2c_smbus_read_i2c_block_data(data->client, reg, len, val);
 }
 
 static int lidar_smbus_xfer(struct lidar_data *data, u8 reg, u8 *val, int len)
-- 
2.17.1



[PATCH] iio: proximity: lidar-v2: replace i2c block access method with the one already implemented.

2018-09-12 Thread Song Qiang
This driver tries to access a block of data on a i2c bus and it tries
to manually make a device command frame and a consecutively read frame,
then uses i2c_transfer() to read data. But this has already been
implemented in i2c_smbus_read_i2c_block_data().
Sorry for not having this device by my hand, which is a little expansive
for me, but I have another i2c device and tested with both i2c_transfer()
and i2c_smbus_read_i2c_block_data() and they all ends the same.
I'm not familiar with the SMBus, don't know if the lidar_smbus_xfer()
function is the same as i2c_smbus_read_block_data()? The original code
is commented with something I'm not sure, but I think if it's a standard
SMBus, it should be able to use in here.
Hoping for someone to explain.

Signed-off-by: Song Qiang 
---
 .../iio/proximity/pulsedlight-lidar-lite-v2.c  | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c 
b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
index 47af54f14756..ca880ba8e820 100644
--- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
+++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
@@ -63,23 +63,7 @@ static const struct iio_chan_spec lidar_channels[] = {
 
 static int lidar_i2c_xfer(struct lidar_data *data, u8 reg, u8 *val, int len)
 {
-   struct i2c_client *client = data->client;
-   struct i2c_msg msg[2];
-   int ret;
-
-   msg[0].addr = client->addr;
-   msg[0].flags = client->flags | I2C_M_STOP;
-   msg[0].len = 1;
-   msg[0].buf  = (char *) 
-
-   msg[1].addr = client->addr;
-   msg[1].flags = client->flags | I2C_M_RD;
-   msg[1].len = len;
-   msg[1].buf = (char *) val;
-
-   ret = i2c_transfer(client->adapter, msg, 2);
-
-   return (ret == 2) ? 0 : -EIO;
+   return i2c_smbus_read_i2c_block_data(data->client, reg, len, val);
 }
 
 static int lidar_smbus_xfer(struct lidar_data *data, u8 reg, u8 *val, int len)
-- 
2.17.1



Re: [PATCH] RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo

2018-09-12 Thread Anup Patel
On Wed, Sep 12, 2018 at 10:17 PM Atish Patra  wrote:
>
> On 9/12/18 7:38 AM, Anup Patel wrote:
> > Currently, /proc/cpuinfo show logical CPU ID as Hart ID which
> > is in-correct. This patch shows CPU ID and Hart ID separately
> > in /proc/cpuinfo using cpuid_to_hardid_map().
> >
> > With this patch, contents of /proc/cpuinfo looks as follows:
> > cpu   : 0
> > hart  : 1
> > isa   : rv64imafdcsu
> > mmu   : sv48
> >
> > cpu   : 1
> > hart  : 0
> > isa   : rv64imafdcsu
> > mmu   : sv48
> >
> > cpu   : 2
> > hart  : 3
> > isa   : rv64imafdcsu
> > mmu   : sv48
> >
> > cpu   : 3
> > hart  : 2
> > isa   : rv64imafdcsu
> > mmu   : sv48
> >
> > Signed-off-by: Anup Patel 
> > ---
> >   arch/riscv/kernel/cpu.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
> > index f0f0ec2737b7..7c1342e242e6 100644
> > --- a/arch/riscv/kernel/cpu.c
> > +++ b/arch/riscv/kernel/cpu.c
> > @@ -87,7 +87,8 @@ static int c_show(struct seq_file *m, void *v)
> >  NULL);
> >   const char *compat, *isa, *mmu;
> >
> > - seq_printf(m, "hart\t: %lu\n", cpu_id);
> > + seq_printf(m, "cpu\t: %lu\n", cpu_id);
> > + seq_printf(m, "hart\t: %lu\n", cpuid_to_hardid_map(cpu_id));
> >   if (!of_property_read_string(node, "riscv,isa", )
> >   && isa[0] == 'r'
> >   && isa[1] == 'v')
> >
>
> The extra hart information will not be parsed by lscpu which will make
> the cpu information inconsistent between lscpu & /proc/cpuinfo.
>
> Should we patch lscpu as well to show correct hart id as well ?

Yes, we should certainly patch lscpu to parse CPU ID and
HART ID differently.

Regards,
Anup


Re: [PATCH] RISC-V: Show CPU ID and Hart ID separately in /proc/cpuinfo

2018-09-12 Thread Anup Patel
On Wed, Sep 12, 2018 at 10:17 PM Atish Patra  wrote:
>
> On 9/12/18 7:38 AM, Anup Patel wrote:
> > Currently, /proc/cpuinfo show logical CPU ID as Hart ID which
> > is in-correct. This patch shows CPU ID and Hart ID separately
> > in /proc/cpuinfo using cpuid_to_hardid_map().
> >
> > With this patch, contents of /proc/cpuinfo looks as follows:
> > cpu   : 0
> > hart  : 1
> > isa   : rv64imafdcsu
> > mmu   : sv48
> >
> > cpu   : 1
> > hart  : 0
> > isa   : rv64imafdcsu
> > mmu   : sv48
> >
> > cpu   : 2
> > hart  : 3
> > isa   : rv64imafdcsu
> > mmu   : sv48
> >
> > cpu   : 3
> > hart  : 2
> > isa   : rv64imafdcsu
> > mmu   : sv48
> >
> > Signed-off-by: Anup Patel 
> > ---
> >   arch/riscv/kernel/cpu.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
> > index f0f0ec2737b7..7c1342e242e6 100644
> > --- a/arch/riscv/kernel/cpu.c
> > +++ b/arch/riscv/kernel/cpu.c
> > @@ -87,7 +87,8 @@ static int c_show(struct seq_file *m, void *v)
> >  NULL);
> >   const char *compat, *isa, *mmu;
> >
> > - seq_printf(m, "hart\t: %lu\n", cpu_id);
> > + seq_printf(m, "cpu\t: %lu\n", cpu_id);
> > + seq_printf(m, "hart\t: %lu\n", cpuid_to_hardid_map(cpu_id));
> >   if (!of_property_read_string(node, "riscv,isa", )
> >   && isa[0] == 'r'
> >   && isa[1] == 'v')
> >
>
> The extra hart information will not be parsed by lscpu which will make
> the cpu information inconsistent between lscpu & /proc/cpuinfo.
>
> Should we patch lscpu as well to show correct hart id as well ?

Yes, we should certainly patch lscpu to parse CPU ID and
HART ID differently.

Regards,
Anup


[PATCH V2] hid: hid-core: Fix a sleep-in-atomic-context bug in __hid_request()

2018-09-12 Thread Jia-Ju Bai
hid_alloc_report_buf() has to be called with GFP_ATOMIC in 
__hid_request(), because there are the following callchains 
leading to __hid_request() being an atomic context:

picolcd_send_and_wait (acquire a spinlock)
  hid_hw_request
__hid_request
  hid_alloc_report_buf(GFP_KERNEL)

picolcd_reset (acquire a spinlock)
  hid_hw_request
__hid_request
  hid_alloc_report_buf(GFP_KERNEL)

lg4ff_play (acquire a spinlock)
  hid_hw_request
__hid_request
  hid_alloc_report_buf(GFP_KERNEL)

lg4ff_set_autocenter_ffex (acquire a spinlock)
  hid_hw_request
__hid_request
  hid_alloc_report_buf(GFP_KERNEL)

This bug is found by my static analysis tool DSAC.

Signed-off-by: Jia-Ju Bai 
---
v2:
* Make the description more human readable.
  Thanks Jiri for good advice.
---
 drivers/hid/hid-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 3942ee61bd1c..c886af00c8c9 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1442,7 +1442,7 @@ void __hid_request(struct hid_device *hid, struct 
hid_report *report,
int ret;
u32 len;
 
-   buf = hid_alloc_report_buf(report, GFP_KERNEL);
+   buf = hid_alloc_report_buf(report, GFP_ATOMIC);
if (!buf)
return;
 
-- 
2.17.0



[PATCH V2] hid: hid-core: Fix a sleep-in-atomic-context bug in __hid_request()

2018-09-12 Thread Jia-Ju Bai
hid_alloc_report_buf() has to be called with GFP_ATOMIC in 
__hid_request(), because there are the following callchains 
leading to __hid_request() being an atomic context:

picolcd_send_and_wait (acquire a spinlock)
  hid_hw_request
__hid_request
  hid_alloc_report_buf(GFP_KERNEL)

picolcd_reset (acquire a spinlock)
  hid_hw_request
__hid_request
  hid_alloc_report_buf(GFP_KERNEL)

lg4ff_play (acquire a spinlock)
  hid_hw_request
__hid_request
  hid_alloc_report_buf(GFP_KERNEL)

lg4ff_set_autocenter_ffex (acquire a spinlock)
  hid_hw_request
__hid_request
  hid_alloc_report_buf(GFP_KERNEL)

This bug is found by my static analysis tool DSAC.

Signed-off-by: Jia-Ju Bai 
---
v2:
* Make the description more human readable.
  Thanks Jiri for good advice.
---
 drivers/hid/hid-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 3942ee61bd1c..c886af00c8c9 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1442,7 +1442,7 @@ void __hid_request(struct hid_device *hid, struct 
hid_report *report,
int ret;
u32 len;
 
-   buf = hid_alloc_report_buf(report, GFP_KERNEL);
+   buf = hid_alloc_report_buf(report, GFP_ATOMIC);
if (!buf)
return;
 
-- 
2.17.0



[GIT PULL] PCI fixes for v4.19

2018-09-12 Thread Bjorn Helgaas
PCI fixes:

  - Add Tyrel Datwyler as maintainer for PPC64 RPA hotplug (Tyrel Datwyler)

  - Add Gustavo Pimentel as DesignWare PCI maintainer (Joao Pinto)

  - Fix a Switchtec Spectre v1 vulnerability (Gustavo A. R. Silva)

  - Revert an unnecessary Intel 300 ACS quirk (Mika Westerberg)

  - Fix pciehp hot-add/powerfault detection that left indicators in wrong
state (Keith Busch)

  - Fix pci_reset_bus() logic error (Dennis Dalessandro)

  - Revert IB/hfi1 PCI reset change that caused a deadlock (Dennis
Dalessandro)

  - Allow enabling PASID on Root Complex Integrated Endpoints (Felix
Kuehling)


The following changes since commit 5b394b2ddf0347bef56e50c69a58773c94343ff3:

  Linux 4.19-rc1 (2018-08-26 14:11:59 -0700)

are available in the Git repository at:

  ssh://g...@gitolite.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git 
tags/pci-v4.19-fixes-1

for you to fetch changes up to 9d27e39d309c93025ae6aa97236af15bef2a5f1f:

  PCI: Fix enabling of PASID on RC integrated endpoints (2018-09-11 21:46:49 
-0500)


pci-v4.19-fixes-1


Dennis Dalessandro (2):
  PCI: Fix faulty logic in pci_reset_bus()
  IB/hfi1,PCI: Allow bus reset while probing

Felix Kuehling (1):
  PCI: Fix enabling of PASID on RC integrated endpoints

Gustavo A. R. Silva (1):
  switchtec: Fix Spectre v1 vulnerability

Joao Pinto (1):
  MAINTAINERS: Add Gustavo Pimentel as DesignWare PCI maintainer

Keith Busch (1):
  PCI: pciehp: Fix hot-add vs powerfault detection order

Mika Westerberg (1):
  Revert "PCI: Add ACS quirk for Intel 300 series"

Tyrel Datwyler (1):
  MAINTAINERS: Add entries for PPC64 RPA PCI hotplug drivers

 MAINTAINERS   | 16 +++-
 drivers/infiniband/hw/hfi1/pcie.c | 11 ---
 drivers/pci/hotplug/pciehp_hpc.c  | 18 +-
 drivers/pci/pci.c |  3 ++-
 drivers/pci/probe.c   |  5 -
 drivers/pci/quirks.c  |  6 --
 drivers/pci/switch/switchtec.c|  4 
 include/linux/pci.h   |  3 +++
 8 files changed, 41 insertions(+), 25 deletions(-)


[GIT PULL] PCI fixes for v4.19

2018-09-12 Thread Bjorn Helgaas
PCI fixes:

  - Add Tyrel Datwyler as maintainer for PPC64 RPA hotplug (Tyrel Datwyler)

  - Add Gustavo Pimentel as DesignWare PCI maintainer (Joao Pinto)

  - Fix a Switchtec Spectre v1 vulnerability (Gustavo A. R. Silva)

  - Revert an unnecessary Intel 300 ACS quirk (Mika Westerberg)

  - Fix pciehp hot-add/powerfault detection that left indicators in wrong
state (Keith Busch)

  - Fix pci_reset_bus() logic error (Dennis Dalessandro)

  - Revert IB/hfi1 PCI reset change that caused a deadlock (Dennis
Dalessandro)

  - Allow enabling PASID on Root Complex Integrated Endpoints (Felix
Kuehling)


The following changes since commit 5b394b2ddf0347bef56e50c69a58773c94343ff3:

  Linux 4.19-rc1 (2018-08-26 14:11:59 -0700)

are available in the Git repository at:

  ssh://g...@gitolite.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git 
tags/pci-v4.19-fixes-1

for you to fetch changes up to 9d27e39d309c93025ae6aa97236af15bef2a5f1f:

  PCI: Fix enabling of PASID on RC integrated endpoints (2018-09-11 21:46:49 
-0500)


pci-v4.19-fixes-1


Dennis Dalessandro (2):
  PCI: Fix faulty logic in pci_reset_bus()
  IB/hfi1,PCI: Allow bus reset while probing

Felix Kuehling (1):
  PCI: Fix enabling of PASID on RC integrated endpoints

Gustavo A. R. Silva (1):
  switchtec: Fix Spectre v1 vulnerability

Joao Pinto (1):
  MAINTAINERS: Add Gustavo Pimentel as DesignWare PCI maintainer

Keith Busch (1):
  PCI: pciehp: Fix hot-add vs powerfault detection order

Mika Westerberg (1):
  Revert "PCI: Add ACS quirk for Intel 300 series"

Tyrel Datwyler (1):
  MAINTAINERS: Add entries for PPC64 RPA PCI hotplug drivers

 MAINTAINERS   | 16 +++-
 drivers/infiniband/hw/hfi1/pcie.c | 11 ---
 drivers/pci/hotplug/pciehp_hpc.c  | 18 +-
 drivers/pci/pci.c |  3 ++-
 drivers/pci/probe.c   |  5 -
 drivers/pci/quirks.c  |  6 --
 drivers/pci/switch/switchtec.c|  4 
 include/linux/pci.h   |  3 +++
 8 files changed, 41 insertions(+), 25 deletions(-)


Re: mmotm 2018-09-12-16-40 uploaded (psi)

2018-09-12 Thread Stephen Rothwell
Hi Johannes,

On Wed, 12 Sep 2018 21:42:22 -0400 Johannes Weiner  wrote:
>
> Thanks for the report.
> 
> On Wed, Sep 12, 2018 at 05:45:08PM -0700, Randy Dunlap wrote:
> > Multiple build errors when CONFIG_SMP is not set: (this is on i386 fwiw)
> > 
> > in the psi (pressure) patches, I guess:
> > 
> > In file included from ../kernel/sched/sched.h:1367:0,
> >  from ../kernel/sched/core.c:8:
> > ../kernel/sched/stats.h: In function 'psi_task_tick':
> > ../kernel/sched/stats.h:135:33: error: 'struct rq' has no member named 'cpu'
> >psi_memstall_tick(rq->curr, rq->cpu);  
> 
> This needs to use the SMP/UP config-aware accessor.
> 
> Signed-off-by: Johannes Weiner 
> ---
> 
> diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
> index 2e07d8f59b3e..4904c4677000 100644
> --- a/kernel/sched/stats.h
> +++ b/kernel/sched/stats.h
> @@ -132,7 +132,7 @@ static inline void psi_task_tick(struct rq *rq)
>   return;
>  
>   if (unlikely(rq->curr->flags & PF_MEMSTALL))
> - psi_memstall_tick(rq->curr, rq->cpu);
> + psi_memstall_tick(rq->curr, cpu_of(rq));
>  }
>  #else /* CONFIG_PSI */
>  static inline void psi_enqueue(struct task_struct *p, bool wakeup) {}

I will add this to linux-next today.

-- 
Cheers,
Stephen Rothwell


pgpwLH5nyL3F5.pgp
Description: OpenPGP digital signature


Re: [BISECTED] Regression: Solidrun Clearfog Base won't boot since "PCI: mvebu: Only remap I/O space if configured"

2018-09-12 Thread Baruch Siach
Hi Russell,

Russell King - ARM Linux writes:
> On Wed, Sep 12, 2018 at 09:49:41PM +0300, Baruch Siach wrote:
>> I reproduced the same Oops on Clearfog Base without any taint:
>> 
>> [1.476401] Internal error: Oops - undefined instruction: 0 [#1] SMP ARM
> ...
>> [1.855954] Code: e2844004 e5972000 e352 0aee (e7f001f2)
>
> That is a BUG().  Please turn on verbose bug reporting to get more
> information about the cause.
>
> There are two possibilities:
>
> BUG_ON(addr >= end);
>
> and
>
> BUG_ON(!pte_none(*pte));
>
> It's probably the latter - the region is probably already mapped, that
> being the PCI IO region.

That is the one. Enabling CONFIG_DEBUG_BUGVERBOSE shows:

[1.481927] kernel BUG at lib/ioremap.c:72!
[1.486118] Internal error: Oops - BUG: 0 [#1] SMP ARM
[1.491269] CPU: 0 PID: 1246 Comm: kworker/0:2 Not tainted 4.19.0-rc3 #146
...

baruch

> The original driver was setup to call pci_ioremap_io() as the very
> last thing - and as the driver is non-removable, we were guaranteed
> to never tear down this mapping (which is sensible, it's published
> to userspace.)
>
> However, the current code calls pci_ioremap_io() much earlier, in
> a path where probe failures can occur.  This breaks pci_ioremap_io()'s
> requirements - it must not be called more than once.  So:
>
> ee1604381a37 ("PCI: mvebu: Only remap I/O space if configured")
>
> is basically incorrect - pci_ioremap_io() needs to move back to a
> place where it is only called in a path which will never fail.
> However, looking at the generic host bits, I'm not sure such a place
> exists in the new effort to make stuff more generic.

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: mmotm 2018-09-12-16-40 uploaded (psi)

2018-09-12 Thread Stephen Rothwell
Hi Johannes,

On Wed, 12 Sep 2018 21:42:22 -0400 Johannes Weiner  wrote:
>
> Thanks for the report.
> 
> On Wed, Sep 12, 2018 at 05:45:08PM -0700, Randy Dunlap wrote:
> > Multiple build errors when CONFIG_SMP is not set: (this is on i386 fwiw)
> > 
> > in the psi (pressure) patches, I guess:
> > 
> > In file included from ../kernel/sched/sched.h:1367:0,
> >  from ../kernel/sched/core.c:8:
> > ../kernel/sched/stats.h: In function 'psi_task_tick':
> > ../kernel/sched/stats.h:135:33: error: 'struct rq' has no member named 'cpu'
> >psi_memstall_tick(rq->curr, rq->cpu);  
> 
> This needs to use the SMP/UP config-aware accessor.
> 
> Signed-off-by: Johannes Weiner 
> ---
> 
> diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
> index 2e07d8f59b3e..4904c4677000 100644
> --- a/kernel/sched/stats.h
> +++ b/kernel/sched/stats.h
> @@ -132,7 +132,7 @@ static inline void psi_task_tick(struct rq *rq)
>   return;
>  
>   if (unlikely(rq->curr->flags & PF_MEMSTALL))
> - psi_memstall_tick(rq->curr, rq->cpu);
> + psi_memstall_tick(rq->curr, cpu_of(rq));
>  }
>  #else /* CONFIG_PSI */
>  static inline void psi_enqueue(struct task_struct *p, bool wakeup) {}

I will add this to linux-next today.

-- 
Cheers,
Stephen Rothwell


pgpwLH5nyL3F5.pgp
Description: OpenPGP digital signature


Re: [BISECTED] Regression: Solidrun Clearfog Base won't boot since "PCI: mvebu: Only remap I/O space if configured"

2018-09-12 Thread Baruch Siach
Hi Russell,

Russell King - ARM Linux writes:
> On Wed, Sep 12, 2018 at 09:49:41PM +0300, Baruch Siach wrote:
>> I reproduced the same Oops on Clearfog Base without any taint:
>> 
>> [1.476401] Internal error: Oops - undefined instruction: 0 [#1] SMP ARM
> ...
>> [1.855954] Code: e2844004 e5972000 e352 0aee (e7f001f2)
>
> That is a BUG().  Please turn on verbose bug reporting to get more
> information about the cause.
>
> There are two possibilities:
>
> BUG_ON(addr >= end);
>
> and
>
> BUG_ON(!pte_none(*pte));
>
> It's probably the latter - the region is probably already mapped, that
> being the PCI IO region.

That is the one. Enabling CONFIG_DEBUG_BUGVERBOSE shows:

[1.481927] kernel BUG at lib/ioremap.c:72!
[1.486118] Internal error: Oops - BUG: 0 [#1] SMP ARM
[1.491269] CPU: 0 PID: 1246 Comm: kworker/0:2 Not tainted 4.19.0-rc3 #146
...

baruch

> The original driver was setup to call pci_ioremap_io() as the very
> last thing - and as the driver is non-removable, we were guaranteed
> to never tear down this mapping (which is sensible, it's published
> to userspace.)
>
> However, the current code calls pci_ioremap_io() much earlier, in
> a path where probe failures can occur.  This breaks pci_ioremap_io()'s
> requirements - it must not be called more than once.  So:
>
> ee1604381a37 ("PCI: mvebu: Only remap I/O space if configured")
>
> is basically incorrect - pci_ioremap_io() needs to move back to a
> place where it is only called in a path which will never fail.
> However, looking at the generic host bits, I'm not sure such a place
> exists in the new effort to make stuff more generic.

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


Re: [BUG] [Resend] Possible sleep-in-atomic-context bugs involving regmap_lock_mutex()

2018-09-12 Thread Jia-Ju Bai

Thanks for the reply :)

On 2018/9/11 1:41, Mark Brown wrote:

On Thu, Aug 30, 2018 at 10:34:20AM +0800, Jia-Ju Bai wrote:


My static tool DSAC reports many sleep-in-atomic-context bugs involving
regmap_lock_mutex(), so I wonder whether this function is possible to be
executed in atomic context.

Have you actually analyzed the code paths that are really taken here?
Static tools really don't cope very well with the pluggable locking in
regmap.  If there are problems I'd suggest reporting them to the authors
of the drivers using them, it's not really anything to do with regmap if
they've messed up their locking.


Okay, I will send the reports to the developers for these drivers.


Best wishes,
Jia-Ju Bai


Re: [BUG] [Resend] Possible sleep-in-atomic-context bugs involving regmap_lock_mutex()

2018-09-12 Thread Jia-Ju Bai

Thanks for the reply :)

On 2018/9/11 1:41, Mark Brown wrote:

On Thu, Aug 30, 2018 at 10:34:20AM +0800, Jia-Ju Bai wrote:


My static tool DSAC reports many sleep-in-atomic-context bugs involving
regmap_lock_mutex(), so I wonder whether this function is possible to be
executed in atomic context.

Have you actually analyzed the code paths that are really taken here?
Static tools really don't cope very well with the pluggable locking in
regmap.  If there are problems I'd suggest reporting them to the authors
of the drivers using them, it's not really anything to do with regmap if
they've messed up their locking.


Okay, I will send the reports to the developers for these drivers.


Best wishes,
Jia-Ju Bai


[RFC PATCH] irq/affinity: Mark the pre/post vectors as regular interrupts

2018-09-12 Thread Dou Liyang
From: Dou Liyang 

As Kashyap and Sumit reported, in MSI/-x subsystem, the pre/post vectors
may be used to some extra reply queues for performance. the best way to
map the pre/post vectors is map them to the local numa node.

But, current Linux can't do that, because

  The pre and post vectors are marked managed and their affinity mask
  is set to the irq default affinity mask.

  The default affinity mask is by default ALL cpus, but it can be tweaked
  both on the kernel command line and via proc.

  If that mask is only a subset of CPUs and all of them go offline
  then these vectors are shutdown in managed mode.

So, clear these affinity mask and check it in alloc_desc() to leave them
as regular interrupts which can be affinity controlled and also can move
freely on hotplug.

Note: will break the validation of affinity mask(s)

Reported-by: Kashyap Desai 
Reported-by: Sumit Saxena 
Suggested-by: Thomas Gleixner 
Signed-off-by: Dou Liyang 
---
 kernel/irq/affinity.c |  9 ++---
 kernel/irq/irqdesc.c  | 24 ++--
 2 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c
index f4f29b9d90ee..ba35a5050dd2 100644
--- a/kernel/irq/affinity.c
+++ b/kernel/irq/affinity.c
@@ -204,7 +204,7 @@ irq_create_affinity_masks(int nvecs, const struct 
irq_affinity *affd)
 
/* Fill out vectors at the beginning that don't need affinity */
for (curvec = 0; curvec < affd->pre_vectors; curvec++)
-   cpumask_copy(masks + curvec, irq_default_affinity);
+   cpumask_clear(masks + curvec);
 
/* Stabilize the cpumasks */
get_online_cpus();
@@ -234,10 +234,13 @@ irq_create_affinity_masks(int nvecs, const struct 
irq_affinity *affd)
/* Fill out vectors at the end that don't need affinity */
if (usedvecs >= affvecs)
curvec = affd->pre_vectors + affvecs;
-   else
+   else {
curvec = affd->pre_vectors + usedvecs;
+   for (; curvec < affd->pre_vectors + affvecs; curvec++)
+   cpumask_copy(masks + curvec, irq_default_affinity);
+   }
for (; curvec < nvecs; curvec++)
-   cpumask_copy(masks + curvec, irq_default_affinity);
+   cpumask_clear(masks + curvec);
 
 outnodemsk:
free_node_to_cpumask(node_to_cpumask);
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 578d0e5f1b5b..5cffa791a20b 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -453,24 +453,20 @@ static int alloc_descs(unsigned int start, unsigned int 
cnt, int node,
 {
const struct cpumask *mask = NULL;
struct irq_desc *desc;
-   unsigned int flags;
+   unsigned int flags = 0;
int i;
 
-   /* Validate affinity mask(s) */
-   if (affinity) {
-   for (i = 0, mask = affinity; i < cnt; i++, mask++) {
-   if (cpumask_empty(mask))
-   return -EINVAL;
-   }
-   }
-
-   flags = affinity ? IRQD_AFFINITY_MANAGED | IRQD_MANAGED_SHUTDOWN : 0;
-   mask = NULL;
-
for (i = 0; i < cnt; i++) {
if (affinity) {
-   node = cpu_to_node(cpumask_first(affinity));
-   mask = affinity;
+   if (cpumask_empty(affinity)) {
+   flags = 0;
+   mask = NULL;
+   } else {
+   flags = IRQD_AFFINITY_MANAGED |
+   IRQD_MANAGED_SHUTDOWN;
+   mask = affinity;
+   node = cpu_to_node(cpumask_first(affinity));
+   }
affinity++;
}
desc = alloc_desc(start + i, node, flags, mask, owner);
-- 
2.14.3




[RFC PATCH] irq/affinity: Mark the pre/post vectors as regular interrupts

2018-09-12 Thread Dou Liyang
From: Dou Liyang 

As Kashyap and Sumit reported, in MSI/-x subsystem, the pre/post vectors
may be used to some extra reply queues for performance. the best way to
map the pre/post vectors is map them to the local numa node.

But, current Linux can't do that, because

  The pre and post vectors are marked managed and their affinity mask
  is set to the irq default affinity mask.

  The default affinity mask is by default ALL cpus, but it can be tweaked
  both on the kernel command line and via proc.

  If that mask is only a subset of CPUs and all of them go offline
  then these vectors are shutdown in managed mode.

So, clear these affinity mask and check it in alloc_desc() to leave them
as regular interrupts which can be affinity controlled and also can move
freely on hotplug.

Note: will break the validation of affinity mask(s)

Reported-by: Kashyap Desai 
Reported-by: Sumit Saxena 
Suggested-by: Thomas Gleixner 
Signed-off-by: Dou Liyang 
---
 kernel/irq/affinity.c |  9 ++---
 kernel/irq/irqdesc.c  | 24 ++--
 2 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c
index f4f29b9d90ee..ba35a5050dd2 100644
--- a/kernel/irq/affinity.c
+++ b/kernel/irq/affinity.c
@@ -204,7 +204,7 @@ irq_create_affinity_masks(int nvecs, const struct 
irq_affinity *affd)
 
/* Fill out vectors at the beginning that don't need affinity */
for (curvec = 0; curvec < affd->pre_vectors; curvec++)
-   cpumask_copy(masks + curvec, irq_default_affinity);
+   cpumask_clear(masks + curvec);
 
/* Stabilize the cpumasks */
get_online_cpus();
@@ -234,10 +234,13 @@ irq_create_affinity_masks(int nvecs, const struct 
irq_affinity *affd)
/* Fill out vectors at the end that don't need affinity */
if (usedvecs >= affvecs)
curvec = affd->pre_vectors + affvecs;
-   else
+   else {
curvec = affd->pre_vectors + usedvecs;
+   for (; curvec < affd->pre_vectors + affvecs; curvec++)
+   cpumask_copy(masks + curvec, irq_default_affinity);
+   }
for (; curvec < nvecs; curvec++)
-   cpumask_copy(masks + curvec, irq_default_affinity);
+   cpumask_clear(masks + curvec);
 
 outnodemsk:
free_node_to_cpumask(node_to_cpumask);
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 578d0e5f1b5b..5cffa791a20b 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -453,24 +453,20 @@ static int alloc_descs(unsigned int start, unsigned int 
cnt, int node,
 {
const struct cpumask *mask = NULL;
struct irq_desc *desc;
-   unsigned int flags;
+   unsigned int flags = 0;
int i;
 
-   /* Validate affinity mask(s) */
-   if (affinity) {
-   for (i = 0, mask = affinity; i < cnt; i++, mask++) {
-   if (cpumask_empty(mask))
-   return -EINVAL;
-   }
-   }
-
-   flags = affinity ? IRQD_AFFINITY_MANAGED | IRQD_MANAGED_SHUTDOWN : 0;
-   mask = NULL;
-
for (i = 0; i < cnt; i++) {
if (affinity) {
-   node = cpu_to_node(cpumask_first(affinity));
-   mask = affinity;
+   if (cpumask_empty(affinity)) {
+   flags = 0;
+   mask = NULL;
+   } else {
+   flags = IRQD_AFFINITY_MANAGED |
+   IRQD_MANAGED_SHUTDOWN;
+   mask = affinity;
+   node = cpu_to_node(cpumask_first(affinity));
+   }
affinity++;
}
desc = alloc_desc(start + i, node, flags, mask, owner);
-- 
2.14.3




Re: [RFC 00/60] Coscheduling for Linux

2018-09-12 Thread Nishanth Aravamudan
On 13.09.2018 [01:18:14 +0200], Jan H. Schönherr wrote:
> On 09/12/2018 09:34 PM, Jan H. Schönherr wrote:
> > That said, I see a hang, too. It seems to happen, when there is a
> > cpu.scheduled!=0 group that is not a direct child of the root task group.
> > You seem to have "/sys/fs/cgroup/cpu/machine" as an intermediate group.
> > (The case ==0 within !=0 within the root task group works for me.)
> > 
> > I'm going to dive into the code.
> 
> With the patch below (which technically changes patch 55/60), the hang
> I experienced is gone.
> 
> Please let me know, if it works for you as well.

Yep, this does fix the soft lockups for me, thanks! However, if I do a:

# find /sys/fs/cgroup/cpu/machine -mindepth 2 -maxdepth 2 -name cpu.scheduled 
-exec /bin/sh -c "echo 1 > {} " \;

which should co-schedule all the cgroups for emulator and vcpu threads,
I see the same warning I mentioned in my other e-mail:

[10469.832822] [ cut here ]
[10469.837555] rq->clock_update_flags < RQCF_ACT_SKIP
[10469.837574] WARNING: CPU: 89 PID: 49630 at kernel/sched/sched.h:1303 
assert_clock_updated.isra.82.part.83+0x15/0x18
[10469.853042] Modules linked in: act_police cls_basic ebtable_filter ebtables 
ip6table_filter iptable_filter nbd ip6table_raw ip6_tables xt_CT iptable_raw 
ip_tables s
[10469.924590]  xxhash raid10 raid0 multipath linear raid456 async_raid6_recov 
async_memcpy async_pq async_xor async_tx xor raid6_pq ses libcrc32c raid1 
enclosure scsi
[10469.945010] CPU: 89 PID: 49630 Comm: sh Tainted: G   O  
4.19.0-rc2-amazon-cosched+ #2
[10469.960061] Hardware name: Dell Inc. PowerEdge R640/0W23H8, BIOS 1.4.9 
06/29/2018
[10469.967657] RIP: 0010:assert_clock_updated.isra.82.part.83+0x15/0x18
[10469.974126] Code: 0f 85 75 ff ff ff 48 83 c4 08 5b 5d 41 5c 41 5d 41 5e 41 
5f c3 48 c7 c7 28 30 eb 8d 31 c0 c6 05 67 18 27 01 01 e8 14 e0 fb ff <0f> 0b c3 
48 8b 970
[10469.993018] RSP: 0018:abc0b534fca8 EFLAGS: 00010096
[10469.998341] RAX: 0026 RBX: 9d74d12ede00 RCX: 0006
[10470.005559] RDX:  RSI: 0096 RDI: 9d74dfb16620
[10470.012780] RBP: 9d74df562e00 R08: 0796 R09: abc0b534fc48
[10470.020005] R10:  R11:  R12: 9d74d2849800
[10470.027226] R13: 0001 R14: 9d74df562e00 R15: 0001
[10470.034445] FS:  7fea86812740() GS:9d74dfb0() 
knlGS:
[10470.042678] CS:  0010 DS:  ES:  CR0: 80050033
[10470.048511] CR2: 5620f00314d8 CR3: 002cc55ea004 CR4: 007626e0
[10470.055739] DR0:  DR1:  DR2: 
[10470.062965] DR3:  DR6: fffe0ff0 DR7: 0400
[10470.070186] PKRU: 5554
[10470.072976] Call Trace:
[10470.075508]  update_curr+0x19f/0x1c0
[10470.079211]  dequeue_entity+0x21/0x8c0
[10470.083056]  dequeue_entity_fair+0x46/0x1c0
[10470.087321]  sdrq_update_root+0x35d/0x480
[10470.091420]  cosched_set_scheduled+0x80/0x1c0
[10470.095892]  cpu_scheduled_write_u64+0x26/0x30
[10470.100427]  cgroup_file_write+0xe3/0x140
[10470.104523]  kernfs_fop_write+0x110/0x190
[10470.108624]  __vfs_write+0x26/0x170
[10470.112236]  ? __audit_syscall_entry+0x101/0x130
[10470.116943]  ? _cond_resched+0x15/0x30
[10470.120781]  ? __sb_start_write+0x41/0x80
[10470.124871]  vfs_write+0xad/0x1a0
[10470.128268]  ksys_write+0x42/0x90
[10470.131668]  do_syscall_64+0x55/0x110
[10470.135421]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[10470.140558] RIP: 0033:0x7fea863253c0
[10470.144213] Code: 73 01 c3 48 8b 0d c8 2a 2d 00 f7 d8 64 89 01 48 83 c8 ff 
c3 66 0f 1f 44 00 00 83 3d bd 8c 2d 00 00 75 10 b8 01 00 00 00 0f 05 <48> 3d 01 
f0 ff ff4
[10470.163114] RSP: 002b:7ffe7cb22d18 EFLAGS: 0246 ORIG_RAX: 
0001
[10470.170783] RAX: ffda RBX: 5620f002f4d0 RCX: 7fea863253c0
[10470.178002] RDX: 0002 RSI: 5620f002f4d0 RDI: 0001
[10470.185222] RBP: 0002 R08: 0001 R09: 006b
[10470.192486] R10: 0008 R11: 0246 R12: 0001
[10470.199705] R13: 0002 R14: 7fff R15: 0002
[10470.206923] ---[ end trace fbf46e2c721c7acb ]---

Thanks,
Nish


Re: [RFC 00/60] Coscheduling for Linux

2018-09-12 Thread Nishanth Aravamudan
On 13.09.2018 [01:18:14 +0200], Jan H. Schönherr wrote:
> On 09/12/2018 09:34 PM, Jan H. Schönherr wrote:
> > That said, I see a hang, too. It seems to happen, when there is a
> > cpu.scheduled!=0 group that is not a direct child of the root task group.
> > You seem to have "/sys/fs/cgroup/cpu/machine" as an intermediate group.
> > (The case ==0 within !=0 within the root task group works for me.)
> > 
> > I'm going to dive into the code.
> 
> With the patch below (which technically changes patch 55/60), the hang
> I experienced is gone.
> 
> Please let me know, if it works for you as well.

Yep, this does fix the soft lockups for me, thanks! However, if I do a:

# find /sys/fs/cgroup/cpu/machine -mindepth 2 -maxdepth 2 -name cpu.scheduled 
-exec /bin/sh -c "echo 1 > {} " \;

which should co-schedule all the cgroups for emulator and vcpu threads,
I see the same warning I mentioned in my other e-mail:

[10469.832822] [ cut here ]
[10469.837555] rq->clock_update_flags < RQCF_ACT_SKIP
[10469.837574] WARNING: CPU: 89 PID: 49630 at kernel/sched/sched.h:1303 
assert_clock_updated.isra.82.part.83+0x15/0x18
[10469.853042] Modules linked in: act_police cls_basic ebtable_filter ebtables 
ip6table_filter iptable_filter nbd ip6table_raw ip6_tables xt_CT iptable_raw 
ip_tables s
[10469.924590]  xxhash raid10 raid0 multipath linear raid456 async_raid6_recov 
async_memcpy async_pq async_xor async_tx xor raid6_pq ses libcrc32c raid1 
enclosure scsi
[10469.945010] CPU: 89 PID: 49630 Comm: sh Tainted: G   O  
4.19.0-rc2-amazon-cosched+ #2
[10469.960061] Hardware name: Dell Inc. PowerEdge R640/0W23H8, BIOS 1.4.9 
06/29/2018
[10469.967657] RIP: 0010:assert_clock_updated.isra.82.part.83+0x15/0x18
[10469.974126] Code: 0f 85 75 ff ff ff 48 83 c4 08 5b 5d 41 5c 41 5d 41 5e 41 
5f c3 48 c7 c7 28 30 eb 8d 31 c0 c6 05 67 18 27 01 01 e8 14 e0 fb ff <0f> 0b c3 
48 8b 970
[10469.993018] RSP: 0018:abc0b534fca8 EFLAGS: 00010096
[10469.998341] RAX: 0026 RBX: 9d74d12ede00 RCX: 0006
[10470.005559] RDX:  RSI: 0096 RDI: 9d74dfb16620
[10470.012780] RBP: 9d74df562e00 R08: 0796 R09: abc0b534fc48
[10470.020005] R10:  R11:  R12: 9d74d2849800
[10470.027226] R13: 0001 R14: 9d74df562e00 R15: 0001
[10470.034445] FS:  7fea86812740() GS:9d74dfb0() 
knlGS:
[10470.042678] CS:  0010 DS:  ES:  CR0: 80050033
[10470.048511] CR2: 5620f00314d8 CR3: 002cc55ea004 CR4: 007626e0
[10470.055739] DR0:  DR1:  DR2: 
[10470.062965] DR3:  DR6: fffe0ff0 DR7: 0400
[10470.070186] PKRU: 5554
[10470.072976] Call Trace:
[10470.075508]  update_curr+0x19f/0x1c0
[10470.079211]  dequeue_entity+0x21/0x8c0
[10470.083056]  dequeue_entity_fair+0x46/0x1c0
[10470.087321]  sdrq_update_root+0x35d/0x480
[10470.091420]  cosched_set_scheduled+0x80/0x1c0
[10470.095892]  cpu_scheduled_write_u64+0x26/0x30
[10470.100427]  cgroup_file_write+0xe3/0x140
[10470.104523]  kernfs_fop_write+0x110/0x190
[10470.108624]  __vfs_write+0x26/0x170
[10470.112236]  ? __audit_syscall_entry+0x101/0x130
[10470.116943]  ? _cond_resched+0x15/0x30
[10470.120781]  ? __sb_start_write+0x41/0x80
[10470.124871]  vfs_write+0xad/0x1a0
[10470.128268]  ksys_write+0x42/0x90
[10470.131668]  do_syscall_64+0x55/0x110
[10470.135421]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[10470.140558] RIP: 0033:0x7fea863253c0
[10470.144213] Code: 73 01 c3 48 8b 0d c8 2a 2d 00 f7 d8 64 89 01 48 83 c8 ff 
c3 66 0f 1f 44 00 00 83 3d bd 8c 2d 00 00 75 10 b8 01 00 00 00 0f 05 <48> 3d 01 
f0 ff ff4
[10470.163114] RSP: 002b:7ffe7cb22d18 EFLAGS: 0246 ORIG_RAX: 
0001
[10470.170783] RAX: ffda RBX: 5620f002f4d0 RCX: 7fea863253c0
[10470.178002] RDX: 0002 RSI: 5620f002f4d0 RDI: 0001
[10470.185222] RBP: 0002 R08: 0001 R09: 006b
[10470.192486] R10: 0008 R11: 0246 R12: 0001
[10470.199705] R13: 0002 R14: 7fff R15: 0002
[10470.206923] ---[ end trace fbf46e2c721c7acb ]---

Thanks,
Nish


[PATCH] x86: common: fix unused variable warning

2018-09-12 Thread zhong jiang
Fix the following compile warning:

rch/x86/kernel/cpu/common.c: In function 'syscall_init':
arch/x86/kernel/cpu/common.c:1534:6: warning: unused variable 'cpu' 
[-Wunused-variable]
  int cpu = smp_processor_id();

Signed-off-by: zhong jiang 
---
 arch/x86/kernel/cpu/common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 0e3e803..0b283e5 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1531,8 +1531,6 @@ static __init int setup_clearcpuid(char *arg)
 /* May not be marked __init: used by software suspend */
 void syscall_init(void)
 {
-   int cpu = smp_processor_id();
-
wrmsr(MSR_STAR, 0, (__USER32_CS << 16) | __KERNEL_CS);
wrmsrl(MSR_LSTAR, (unsigned long)entry_SYSCALL_64);
 
@@ -1545,7 +1543,8 @@ void syscall_init(void)
 * AMD doesn't allow SYSENTER in long mode (either 32- or 64-bit).
 */
wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS);
-   wrmsrl_safe(MSR_IA32_SYSENTER_ESP, (unsigned long)(cpu_entry_stack(cpu) 
+ 1));
+   wrmsrl_safe(MSR_IA32_SYSENTER_ESP,
+   (unsigned long)(cpu_entry_stack(smp_processor_id()) + 1));
wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (u64)entry_SYSENTER_compat);
 #else
wrmsrl(MSR_CSTAR, (unsigned long)ignore_sysret);
-- 
1.7.12.4



[PATCH] x86: common: fix unused variable warning

2018-09-12 Thread zhong jiang
Fix the following compile warning:

rch/x86/kernel/cpu/common.c: In function 'syscall_init':
arch/x86/kernel/cpu/common.c:1534:6: warning: unused variable 'cpu' 
[-Wunused-variable]
  int cpu = smp_processor_id();

Signed-off-by: zhong jiang 
---
 arch/x86/kernel/cpu/common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 0e3e803..0b283e5 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1531,8 +1531,6 @@ static __init int setup_clearcpuid(char *arg)
 /* May not be marked __init: used by software suspend */
 void syscall_init(void)
 {
-   int cpu = smp_processor_id();
-
wrmsr(MSR_STAR, 0, (__USER32_CS << 16) | __KERNEL_CS);
wrmsrl(MSR_LSTAR, (unsigned long)entry_SYSCALL_64);
 
@@ -1545,7 +1543,8 @@ void syscall_init(void)
 * AMD doesn't allow SYSENTER in long mode (either 32- or 64-bit).
 */
wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS);
-   wrmsrl_safe(MSR_IA32_SYSENTER_ESP, (unsigned long)(cpu_entry_stack(cpu) 
+ 1));
+   wrmsrl_safe(MSR_IA32_SYSENTER_ESP,
+   (unsigned long)(cpu_entry_stack(smp_processor_id()) + 1));
wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (u64)entry_SYSENTER_compat);
 #else
wrmsrl(MSR_CSTAR, (unsigned long)ignore_sysret);
-- 
1.7.12.4



[PATCH 11/50] ipwireless: switch to ->[sg]et_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 drivers/tty/ipwireless/tty.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
index 1ef751c27ac6..fad3401e604d 100644
--- a/drivers/tty/ipwireless/tty.c
+++ b/drivers/tty/ipwireless/tty.c
@@ -248,22 +248,29 @@ static int ipw_write_room(struct tty_struct *linux_tty)
return room;
 }
 
-static int ipwireless_get_serial_info(struct ipw_tty *tty,
- struct serial_struct __user *retinfo)
+static int ipwireless_get_serial_info(struct tty_struct *linux_tty,
+ struct serial_struct *ss)
 {
-   struct serial_struct tmp;
+   struct ipw_tty *tty = linux_tty->driver_data;
 
-   memset(, 0, sizeof(tmp));
-   tmp.type = PORT_UNKNOWN;
-   tmp.line = tty->index;
-   tmp.baud_base = 115200;
+   if (!tty)
+   return -ENODEV;
 
-   if (copy_to_user(retinfo, , sizeof(*retinfo)))
-   return -EFAULT;
+   if (!tty->port.count)
+   return -EINVAL;
 
+   ss->type = PORT_UNKNOWN;
+   ss->line = tty->index;
+   ss->baud_base = 115200;
return 0;
 }
 
+static int ipwireless_set_serial_info(struct tty_struct *linux_tty,
+ struct serial_struct *ss)
+{
+   return 0;   /* Keeps the PCMCIA scripts happy. */
+}
+
 static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
 {
struct ipw_tty *tty = linux_tty->driver_data;
@@ -386,15 +393,6 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
return -EINVAL;
 
/* FIXME: Exactly how is the tty object locked here .. */
-
-   switch (cmd) {
-   case TIOCGSERIAL:
-   return ipwireless_get_serial_info(tty, (void __user *) arg);
-
-   case TIOCSSERIAL:
-   return 0;   /* Keeps the PCMCIA scripts happy. */
-   }
-
if (tty->tty_type == TTYTYPE_MODEM) {
switch (cmd) {
case PPPIOCGCHAN:
@@ -561,6 +559,8 @@ static const struct tty_operations tty_ops = {
.chars_in_buffer = ipw_chars_in_buffer,
.tiocmget = ipw_tiocmget,
.tiocmset = ipw_tiocmset,
+   .set_serial = ipwireless_set_serial_info,
+   .get_serial = ipwireless_get_serial_info,
 };
 
 int ipwireless_tty_init(void)
-- 
2.11.0



[PATCH 11/50] ipwireless: switch to ->[sg]et_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 drivers/tty/ipwireless/tty.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
index 1ef751c27ac6..fad3401e604d 100644
--- a/drivers/tty/ipwireless/tty.c
+++ b/drivers/tty/ipwireless/tty.c
@@ -248,22 +248,29 @@ static int ipw_write_room(struct tty_struct *linux_tty)
return room;
 }
 
-static int ipwireless_get_serial_info(struct ipw_tty *tty,
- struct serial_struct __user *retinfo)
+static int ipwireless_get_serial_info(struct tty_struct *linux_tty,
+ struct serial_struct *ss)
 {
-   struct serial_struct tmp;
+   struct ipw_tty *tty = linux_tty->driver_data;
 
-   memset(, 0, sizeof(tmp));
-   tmp.type = PORT_UNKNOWN;
-   tmp.line = tty->index;
-   tmp.baud_base = 115200;
+   if (!tty)
+   return -ENODEV;
 
-   if (copy_to_user(retinfo, , sizeof(*retinfo)))
-   return -EFAULT;
+   if (!tty->port.count)
+   return -EINVAL;
 
+   ss->type = PORT_UNKNOWN;
+   ss->line = tty->index;
+   ss->baud_base = 115200;
return 0;
 }
 
+static int ipwireless_set_serial_info(struct tty_struct *linux_tty,
+ struct serial_struct *ss)
+{
+   return 0;   /* Keeps the PCMCIA scripts happy. */
+}
+
 static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
 {
struct ipw_tty *tty = linux_tty->driver_data;
@@ -386,15 +393,6 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
return -EINVAL;
 
/* FIXME: Exactly how is the tty object locked here .. */
-
-   switch (cmd) {
-   case TIOCGSERIAL:
-   return ipwireless_get_serial_info(tty, (void __user *) arg);
-
-   case TIOCSSERIAL:
-   return 0;   /* Keeps the PCMCIA scripts happy. */
-   }
-
if (tty->tty_type == TTYTYPE_MODEM) {
switch (cmd) {
case PPPIOCGCHAN:
@@ -561,6 +559,8 @@ static const struct tty_operations tty_ops = {
.chars_in_buffer = ipw_chars_in_buffer,
.tiocmget = ipw_tiocmget,
.tiocmset = ipw_tiocmset,
+   .set_serial = ipwireless_set_serial_info,
+   .get_serial = ipwireless_get_serial_info,
 };
 
 int ipwireless_tty_init(void)
-- 
2.11.0



[PATCH 06/50] simserial: switch to ->[sg]et_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 arch/ia64/hp/sim/simserial.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 663388a73d4e..de5e69162ad5 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -297,18 +297,25 @@ static void rs_unthrottle(struct tty_struct * tty)
printk(KERN_INFO "simrs_unthrottle called\n");
 }
 
+static int rs_setserial(struct tty_struct *tty, struct serial_struct *ss)
+{
+   return 0;
+}
+
+static int rs_getserial(struct tty_struct *tty, struct serial_struct *ss)
+{
+   return 0;
+}
+
 static int rs_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long 
arg)
 {
-   if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
-   (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
+   if ((cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
(cmd != TIOCMIWAIT)) {
if (tty_io_error(tty))
return -EIO;
}
 
switch (cmd) {
-   case TIOCGSERIAL:
-   case TIOCSSERIAL:
case TIOCSERGSTRUCT:
case TIOCMIWAIT:
return 0;
@@ -448,6 +455,8 @@ static const struct tty_operations hp_ops = {
.throttle = rs_throttle,
.unthrottle = rs_unthrottle,
.send_xchar = rs_send_xchar,
+   .set_serial = rs_setserial,
+   .get_serial = rs_getserial,
.hangup = rs_hangup,
.proc_show = rs_proc_show,
 };
-- 
2.11.0



[PATCH 04/50] mos7720: bury dead TIOCM... in ->ioctl()

2018-09-12 Thread Al Viro
From: Al Viro 

These ioctls never reach driver's ->ioctl() - tty_ioctl() handles
them on its own.  ->tiocm[gs]et() is what actually gets called,
and mos7720 provides those, with results equivalent to what the
unreachable code would be doing when called.

Signed-off-by: Al Viro 
---
 drivers/usb/serial/mos7720.c | 52 
 1 file changed, 52 deletions(-)

diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 27109522fd8b..4c06357b3ef8 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -1786,51 +1786,6 @@ static int mos7720_tiocmset(struct tty_struct *tty,
return 0;
 }
 
-static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd,
- unsigned int __user *value)
-{
-   unsigned int mcr;
-   unsigned int arg;
-
-   struct usb_serial_port *port;
-
-   if (mos7720_port == NULL)
-   return -1;
-
-   port = (struct usb_serial_port *)mos7720_port->port;
-   mcr = mos7720_port->shadowMCR;
-
-   if (copy_from_user(, value, sizeof(int)))
-   return -EFAULT;
-
-   switch (cmd) {
-   case TIOCMBIS:
-   if (arg & TIOCM_RTS)
-   mcr |= UART_MCR_RTS;
-   if (arg & TIOCM_DTR)
-   mcr |= UART_MCR_RTS;
-   if (arg & TIOCM_LOOP)
-   mcr |= UART_MCR_LOOP;
-   break;
-
-   case TIOCMBIC:
-   if (arg & TIOCM_RTS)
-   mcr &= ~UART_MCR_RTS;
-   if (arg & TIOCM_DTR)
-   mcr &= ~UART_MCR_RTS;
-   if (arg & TIOCM_LOOP)
-   mcr &= ~UART_MCR_LOOP;
-   break;
-
-   }
-
-   mos7720_port->shadowMCR = mcr;
-   write_mos_reg(port->serial, port->port_number, MOS7720_MCR,
- mos7720_port->shadowMCR);
-
-   return 0;
-}
-
 static int get_serial_info(struct moschip_port *mos7720_port,
   struct serial_struct __user *retinfo)
 {
@@ -1868,13 +1823,6 @@ static int mos7720_ioctl(struct tty_struct *tty,
return get_lsr_info(tty, mos7720_port,
(unsigned int __user *)arg);
 
-   /* FIXME: These should be using the mode methods */
-   case TIOCMBIS:
-   case TIOCMBIC:
-   dev_dbg(>dev, "%s TIOCMSET/TIOCMBIC/TIOCMSET\n", 
__func__);
-   return set_modem_info(mos7720_port, cmd,
- (unsigned int __user *)arg);
-
case TIOCGSERIAL:
dev_dbg(>dev, "%s TIOCGSERIAL\n", __func__);
return get_serial_info(mos7720_port,
-- 
2.11.0



[PATCH 10/50] cyclades: switch to ->[sg]et_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 drivers/tty/cyclades.c | 77 --
 1 file changed, 37 insertions(+), 40 deletions(-)

diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index 6d3c58051ce3..4562c8060d09 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -2257,44 +2257,45 @@ static void cy_set_line_char(struct cyclades_port 
*info, struct tty_struct *tty)
}
 }  /* set_line_char */
 
-static int cy_get_serial_info(struct cyclades_port *info,
-   struct serial_struct __user *retinfo)
+static int cy_get_serial_info(struct tty_struct *tty,
+   struct serial_struct *ss)
 {
+   struct cyclades_port *info = tty->driver_data;
struct cyclades_card *cinfo = info->card;
-   struct serial_struct tmp = {
-   .type = info->type,
-   .line = info->line,
-   .port = (info->card - cy_card) * 0x100 + info->line -
-   cinfo->first_line,
-   .irq = cinfo->irq,
-   .flags = info->port.flags,
-   .close_delay = info->port.close_delay,
-   .closing_wait = info->port.closing_wait,
-   .baud_base = info->baud,
-   .custom_divisor = info->custom_divisor,
-   };
-   return copy_to_user(retinfo, , sizeof(*retinfo)) ? -EFAULT : 0;
+
+   if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
+   return -ENODEV;
+   ss->type = info->type;
+   ss->line = info->line;
+   ss->port = (info->card - cy_card) * 0x100 + info->line -
+   cinfo->first_line;
+   ss->irq = cinfo->irq;
+   ss->flags = info->port.flags;
+   ss->close_delay = info->port.close_delay;
+   ss->closing_wait = info->port.closing_wait;
+   ss->baud_base = info->baud;
+   ss->custom_divisor = info->custom_divisor;
+   return 0;
 }
 
-static int
-cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty,
-   struct serial_struct __user *new_info)
+static int cy_set_serial_info(struct tty_struct *tty,
+   struct serial_struct *ss)
 {
-   struct serial_struct new_serial;
+   struct cyclades_port *info = tty->driver_data;
int old_flags;
int ret;
 
-   if (copy_from_user(_serial, new_info, sizeof(new_serial)))
-   return -EFAULT;
+   if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
+   return -ENODEV;
 
mutex_lock(>port.mutex);
 
old_flags = info->port.flags;
 
if (!capable(CAP_SYS_ADMIN)) {
-   if (new_serial.close_delay != info->port.close_delay ||
-   new_serial.baud_base != info->baud ||
-   (new_serial.flags & ASYNC_FLAGS &
+   if (ss->close_delay != info->port.close_delay ||
+   ss->baud_base != info->baud ||
+   (ss->flags & ASYNC_FLAGS &
~ASYNC_USR_MASK) !=
(info->port.flags & ASYNC_FLAGS & 
~ASYNC_USR_MASK))
{
@@ -2302,9 +2303,9 @@ cy_set_serial_info(struct cyclades_port *info, struct 
tty_struct *tty,
return -EPERM;
}
info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) |
-   (new_serial.flags & ASYNC_USR_MASK);
-   info->baud = new_serial.baud_base;
-   info->custom_divisor = new_serial.custom_divisor;
+   (ss->flags & ASYNC_USR_MASK);
+   info->baud = ss->baud_base;
+   info->custom_divisor = ss->custom_divisor;
goto check_and_exit;
}
 
@@ -2313,18 +2314,18 @@ cy_set_serial_info(struct cyclades_port *info, struct 
tty_struct *tty,
 * At this point, we start making changes.
 */
 
-   info->baud = new_serial.baud_base;
-   info->custom_divisor = new_serial.custom_divisor;
+   info->baud = ss->baud_base;
+   info->custom_divisor = ss->custom_divisor;
info->port.flags = (info->port.flags & ~ASYNC_FLAGS) |
-   (new_serial.flags & ASYNC_FLAGS);
-   info->port.close_delay = new_serial.close_delay * HZ / 100;
-   info->port.closing_wait = new_serial.closing_wait * HZ / 100;
+   (ss->flags & ASYNC_FLAGS);
+   info->port.close_delay = ss->close_delay * HZ / 100;
+   info->port.closing_wait = ss->closing_wait * HZ / 100;
 
 check_and_exit:
if (tty_port_initialized(>port)) {
-   if ((new_serial.flags ^ old_flags) & ASYNC_SPD_MASK) {
+   if ((ss->flags ^ old_flags) & ASYNC_SPD_MASK) {
/* warn about deprecation unless clearing */
-   if (new_serial.flags & ASYNC_SPD_MASK)
+

[PATCH 06/50] simserial: switch to ->[sg]et_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 arch/ia64/hp/sim/simserial.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 663388a73d4e..de5e69162ad5 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -297,18 +297,25 @@ static void rs_unthrottle(struct tty_struct * tty)
printk(KERN_INFO "simrs_unthrottle called\n");
 }
 
+static int rs_setserial(struct tty_struct *tty, struct serial_struct *ss)
+{
+   return 0;
+}
+
+static int rs_getserial(struct tty_struct *tty, struct serial_struct *ss)
+{
+   return 0;
+}
+
 static int rs_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long 
arg)
 {
-   if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
-   (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
+   if ((cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
(cmd != TIOCMIWAIT)) {
if (tty_io_error(tty))
return -EIO;
}
 
switch (cmd) {
-   case TIOCGSERIAL:
-   case TIOCSSERIAL:
case TIOCSERGSTRUCT:
case TIOCMIWAIT:
return 0;
@@ -448,6 +455,8 @@ static const struct tty_operations hp_ops = {
.throttle = rs_throttle,
.unthrottle = rs_unthrottle,
.send_xchar = rs_send_xchar,
+   .set_serial = rs_setserial,
+   .get_serial = rs_getserial,
.hangup = rs_hangup,
.proc_show = rs_proc_show,
 };
-- 
2.11.0



[PATCH 04/50] mos7720: bury dead TIOCM... in ->ioctl()

2018-09-12 Thread Al Viro
From: Al Viro 

These ioctls never reach driver's ->ioctl() - tty_ioctl() handles
them on its own.  ->tiocm[gs]et() is what actually gets called,
and mos7720 provides those, with results equivalent to what the
unreachable code would be doing when called.

Signed-off-by: Al Viro 
---
 drivers/usb/serial/mos7720.c | 52 
 1 file changed, 52 deletions(-)

diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 27109522fd8b..4c06357b3ef8 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -1786,51 +1786,6 @@ static int mos7720_tiocmset(struct tty_struct *tty,
return 0;
 }
 
-static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd,
- unsigned int __user *value)
-{
-   unsigned int mcr;
-   unsigned int arg;
-
-   struct usb_serial_port *port;
-
-   if (mos7720_port == NULL)
-   return -1;
-
-   port = (struct usb_serial_port *)mos7720_port->port;
-   mcr = mos7720_port->shadowMCR;
-
-   if (copy_from_user(, value, sizeof(int)))
-   return -EFAULT;
-
-   switch (cmd) {
-   case TIOCMBIS:
-   if (arg & TIOCM_RTS)
-   mcr |= UART_MCR_RTS;
-   if (arg & TIOCM_DTR)
-   mcr |= UART_MCR_RTS;
-   if (arg & TIOCM_LOOP)
-   mcr |= UART_MCR_LOOP;
-   break;
-
-   case TIOCMBIC:
-   if (arg & TIOCM_RTS)
-   mcr &= ~UART_MCR_RTS;
-   if (arg & TIOCM_DTR)
-   mcr &= ~UART_MCR_RTS;
-   if (arg & TIOCM_LOOP)
-   mcr &= ~UART_MCR_LOOP;
-   break;
-
-   }
-
-   mos7720_port->shadowMCR = mcr;
-   write_mos_reg(port->serial, port->port_number, MOS7720_MCR,
- mos7720_port->shadowMCR);
-
-   return 0;
-}
-
 static int get_serial_info(struct moschip_port *mos7720_port,
   struct serial_struct __user *retinfo)
 {
@@ -1868,13 +1823,6 @@ static int mos7720_ioctl(struct tty_struct *tty,
return get_lsr_info(tty, mos7720_port,
(unsigned int __user *)arg);
 
-   /* FIXME: These should be using the mode methods */
-   case TIOCMBIS:
-   case TIOCMBIC:
-   dev_dbg(>dev, "%s TIOCMSET/TIOCMBIC/TIOCMSET\n", 
__func__);
-   return set_modem_info(mos7720_port, cmd,
- (unsigned int __user *)arg);
-
case TIOCGSERIAL:
dev_dbg(>dev, "%s TIOCGSERIAL\n", __func__);
return get_serial_info(mos7720_port,
-- 
2.11.0



[PATCH 10/50] cyclades: switch to ->[sg]et_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 drivers/tty/cyclades.c | 77 --
 1 file changed, 37 insertions(+), 40 deletions(-)

diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index 6d3c58051ce3..4562c8060d09 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -2257,44 +2257,45 @@ static void cy_set_line_char(struct cyclades_port 
*info, struct tty_struct *tty)
}
 }  /* set_line_char */
 
-static int cy_get_serial_info(struct cyclades_port *info,
-   struct serial_struct __user *retinfo)
+static int cy_get_serial_info(struct tty_struct *tty,
+   struct serial_struct *ss)
 {
+   struct cyclades_port *info = tty->driver_data;
struct cyclades_card *cinfo = info->card;
-   struct serial_struct tmp = {
-   .type = info->type,
-   .line = info->line,
-   .port = (info->card - cy_card) * 0x100 + info->line -
-   cinfo->first_line,
-   .irq = cinfo->irq,
-   .flags = info->port.flags,
-   .close_delay = info->port.close_delay,
-   .closing_wait = info->port.closing_wait,
-   .baud_base = info->baud,
-   .custom_divisor = info->custom_divisor,
-   };
-   return copy_to_user(retinfo, , sizeof(*retinfo)) ? -EFAULT : 0;
+
+   if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
+   return -ENODEV;
+   ss->type = info->type;
+   ss->line = info->line;
+   ss->port = (info->card - cy_card) * 0x100 + info->line -
+   cinfo->first_line;
+   ss->irq = cinfo->irq;
+   ss->flags = info->port.flags;
+   ss->close_delay = info->port.close_delay;
+   ss->closing_wait = info->port.closing_wait;
+   ss->baud_base = info->baud;
+   ss->custom_divisor = info->custom_divisor;
+   return 0;
 }
 
-static int
-cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty,
-   struct serial_struct __user *new_info)
+static int cy_set_serial_info(struct tty_struct *tty,
+   struct serial_struct *ss)
 {
-   struct serial_struct new_serial;
+   struct cyclades_port *info = tty->driver_data;
int old_flags;
int ret;
 
-   if (copy_from_user(_serial, new_info, sizeof(new_serial)))
-   return -EFAULT;
+   if (serial_paranoia_check(info, tty->name, "cy_ioctl"))
+   return -ENODEV;
 
mutex_lock(>port.mutex);
 
old_flags = info->port.flags;
 
if (!capable(CAP_SYS_ADMIN)) {
-   if (new_serial.close_delay != info->port.close_delay ||
-   new_serial.baud_base != info->baud ||
-   (new_serial.flags & ASYNC_FLAGS &
+   if (ss->close_delay != info->port.close_delay ||
+   ss->baud_base != info->baud ||
+   (ss->flags & ASYNC_FLAGS &
~ASYNC_USR_MASK) !=
(info->port.flags & ASYNC_FLAGS & 
~ASYNC_USR_MASK))
{
@@ -2302,9 +2303,9 @@ cy_set_serial_info(struct cyclades_port *info, struct 
tty_struct *tty,
return -EPERM;
}
info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) |
-   (new_serial.flags & ASYNC_USR_MASK);
-   info->baud = new_serial.baud_base;
-   info->custom_divisor = new_serial.custom_divisor;
+   (ss->flags & ASYNC_USR_MASK);
+   info->baud = ss->baud_base;
+   info->custom_divisor = ss->custom_divisor;
goto check_and_exit;
}
 
@@ -2313,18 +2314,18 @@ cy_set_serial_info(struct cyclades_port *info, struct 
tty_struct *tty,
 * At this point, we start making changes.
 */
 
-   info->baud = new_serial.baud_base;
-   info->custom_divisor = new_serial.custom_divisor;
+   info->baud = ss->baud_base;
+   info->custom_divisor = ss->custom_divisor;
info->port.flags = (info->port.flags & ~ASYNC_FLAGS) |
-   (new_serial.flags & ASYNC_FLAGS);
-   info->port.close_delay = new_serial.close_delay * HZ / 100;
-   info->port.closing_wait = new_serial.closing_wait * HZ / 100;
+   (ss->flags & ASYNC_FLAGS);
+   info->port.close_delay = ss->close_delay * HZ / 100;
+   info->port.closing_wait = ss->closing_wait * HZ / 100;
 
 check_and_exit:
if (tty_port_initialized(>port)) {
-   if ((new_serial.flags ^ old_flags) & ASYNC_SPD_MASK) {
+   if ((ss->flags ^ old_flags) & ASYNC_SPD_MASK) {
/* warn about deprecation unless clearing */
-   if (new_serial.flags & ASYNC_SPD_MASK)
+

[PATCH 01/50] presence of RS485 ioctls has been unconditional since 2014

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 fs/compat_ioctl.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index a9b00942e87d..53bc3659dcef 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -749,12 +749,8 @@ COMPATIBLE_IOCTL(TIOCOUTQ)
 COMPATIBLE_IOCTL(TIOCSPGRP)
 COMPATIBLE_IOCTL(TIOCGPGRP)
 COMPATIBLE_IOCTL(TIOCSERGETLSR)
-#ifdef TIOCSRS485
 COMPATIBLE_IOCTL(TIOCSRS485)
-#endif
-#ifdef TIOCGRS485
 COMPATIBLE_IOCTL(TIOCGRS485)
-#endif
 #ifdef TCGETS2
 COMPATIBLE_IOCTL(TCGETS2)
 COMPATIBLE_IOCTL(TCSETS2)
-- 
2.11.0



[PATCH 01/50] presence of RS485 ioctls has been unconditional since 2014

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 fs/compat_ioctl.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index a9b00942e87d..53bc3659dcef 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -749,12 +749,8 @@ COMPATIBLE_IOCTL(TIOCOUTQ)
 COMPATIBLE_IOCTL(TIOCSPGRP)
 COMPATIBLE_IOCTL(TIOCGPGRP)
 COMPATIBLE_IOCTL(TIOCSERGETLSR)
-#ifdef TIOCSRS485
 COMPATIBLE_IOCTL(TIOCSRS485)
-#endif
-#ifdef TIOCGRS485
 COMPATIBLE_IOCTL(TIOCGRS485)
-#endif
 #ifdef TCGETS2
 COMPATIBLE_IOCTL(TCGETS2)
 COMPATIBLE_IOCTL(TCSETS2)
-- 
2.11.0



[PATCH 02/50] move compat handling of tty ioctls to tty_compat_ioctl()

2018-09-12 Thread Al Viro
From: Al Viro 

ioctls that are
* callable only via tty_ioctl()
* not driver-specific
* not demand data structure conversions
* either always need passing arg as is or always demand compat_ptr()
get intercepted in tty_compat_ioctl() from the very beginning and
redirecter to tty_ioctl().  As the result, their entries in fs/compat_ioctl.c
(some of those had been missing, BTW) got removed, as well as
n_tty_compat_ioctl_helper() (now it's never called with any cmd it would 
accept).

Signed-off-by: Al Viro 
---
 drivers/tty/tty_io.c| 77 +++--
 drivers/tty/tty_ioctl.c | 16 --
 fs/compat_ioctl.c   | 51 
 include/linux/tty.h |  2 --
 4 files changed, 75 insertions(+), 71 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 32bc3e3fe4d3..c2168b43df0f 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2668,6 +2668,81 @@ static long tty_compat_ioctl(struct file *file, unsigned 
int cmd,
struct tty_ldisc *ld;
int retval = -ENOIOCTLCMD;
 
+   switch (cmd) {
+   case TIOCSTI:
+   case TIOCGWINSZ:
+   case TIOCSWINSZ:
+   case TIOCGEXCL:
+   case TIOCGETD:
+   case TIOCSETD:
+   case TIOCGDEV:
+   case TIOCMGET:
+   case TIOCMSET:
+   case TIOCMBIC:
+   case TIOCMBIS:
+   case TIOCGICOUNT:
+   case TIOCGPGRP:
+   case TIOCSPGRP:
+   case TIOCGSID:
+   case TIOCSERGETLSR:
+   case TIOCGRS485:
+   case TIOCSRS485:
+#ifdef TIOCGETP
+   case TIOCGETP:
+   case TIOCSETP:
+   case TIOCSETN:
+#endif
+#ifdef TIOCGETC
+   case TIOCGETC:
+   case TIOCSETC:
+#endif
+#ifdef TIOCGLTC
+   case TIOCGLTC:
+   case TIOCSLTC:
+#endif
+   case TCSETSF:
+   case TCSETSW:
+   case TCSETS:
+   case TCGETS:
+#ifdef TCGETS2
+   case TCGETS2:
+   case TCSETSF2:
+   case TCSETSW2:
+   case TCSETS2:
+#endif
+   case TCGETA:
+   case TCSETAF:
+   case TCSETAW:
+   case TCSETA:
+   case TIOCGLCKTRMIOS:
+   case TIOCSLCKTRMIOS:
+#ifdef TCGETX
+   case TCGETX:
+   case TCSETX:
+   case TCSETXW:
+   case TCSETXF:
+#endif
+   case TIOCGSOFTCAR:
+   case TIOCSSOFTCAR:
+   return tty_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
+   case TIOCCONS:
+   case TIOCEXCL:
+   case TIOCNXCL:
+   case TIOCVHANGUP:
+   case TIOCSBRK:
+   case TIOCCBRK:
+   case TCSBRK:
+   case TCSBRKP:
+   case TCFLSH:
+   case TIOCGPTPEER:
+   case TIOCNOTTY:
+   case TIOCSCTTY:
+   case TCXONC:
+   case TIOCMIWAIT:
+   case TIOCSERCONFIG:
+   return tty_ioctl(file, cmd, arg);
+   }
+
if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl"))
return -EINVAL;
 
@@ -2682,8 +2757,6 @@ static long tty_compat_ioctl(struct file *file, unsigned 
int cmd,
return hung_up_tty_compat_ioctl(file, cmd, arg);
if (ld->ops->compat_ioctl)
retval = ld->ops->compat_ioctl(tty, file, cmd, arg);
-   else
-   retval = n_tty_compat_ioctl_helper(tty, file, cmd, arg);
tty_ldisc_deref(ld);
 
return retval;
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index d99fec44036c..9245fffdbceb 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -941,19 +941,3 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file 
*file,
}
 }
 EXPORT_SYMBOL(n_tty_ioctl_helper);
-
-#ifdef CONFIG_COMPAT
-long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file,
-   unsigned int cmd, unsigned long arg)
-{
-   switch (cmd) {
-   case TIOCGLCKTRMIOS:
-   case TIOCSLCKTRMIOS:
-   return tty_mode_ioctl(tty, file, cmd, (unsigned long) 
compat_ptr(arg));
-   default:
-   return -ENOIOCTLCMD;
-   }
-}
-EXPORT_SYMBOL(n_tty_compat_ioctl_helper);
-#endif
-
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 53bc3659dcef..670b8cbd0896 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -711,52 +711,9 @@ COMPATIBLE_IOCTL(0x4B50)   /* KDGHWCLK - not in the 
kernel, but don't complain *
 COMPATIBLE_IOCTL(0x4B51)   /* KDSHWCLK - not in the kernel, but don't complain 
*/
 
 /* Big T */
-COMPATIBLE_IOCTL(TCGETA)
-COMPATIBLE_IOCTL(TCSETA)
-COMPATIBLE_IOCTL(TCSETAW)
-COMPATIBLE_IOCTL(TCSETAF)
-COMPATIBLE_IOCTL(TCSBRK)
-COMPATIBLE_IOCTL(TCXONC)
-COMPATIBLE_IOCTL(TCFLSH)
-COMPATIBLE_IOCTL(TCGETS)
-COMPATIBLE_IOCTL(TCSETS)
-COMPATIBLE_IOCTL(TCSETSW)
-COMPATIBLE_IOCTL(TCSETSF)
 COMPATIBLE_IOCTL(TIOCLINUX)
-COMPATIBLE_IOCTL(TIOCSBRK)
-COMPATIBLE_IOCTL(TIOCGDEV)
-COMPATIBLE_IOCTL(TIOCCBRK)
-COMPATIBLE_IOCTL(TIOCGSID)
-COMPATIBLE_IOCTL(TIOCGICOUNT)
-COMPATIBLE_IOCTL(TIOCGEXCL)
 /* Little t */
-COMPATIBLE_IOCTL(TIOCGETD)
-COMPATIBLE_IOCTL(TIOCSETD)

[PATCH 09/50] amiserial: switch to ->[sg]et_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 drivers/tty/amiserial.c | 83 ++---
 1 file changed, 38 insertions(+), 45 deletions(-)

diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 34dead614149..17fc8bb6c6b8 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -996,63 +996,60 @@ static void rs_unthrottle(struct tty_struct * tty)
  * 
  */
 
-static int get_serial_info(struct tty_struct *tty, struct serial_state *state,
-  struct serial_struct __user * retinfo)
+static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
 {
-   struct serial_struct tmp;
-   
-   memset(, 0, sizeof(tmp));
+   struct serial_state *state = tty->driver_data;
+
+   if (serial_paranoia_check(state, tty->name, "rs_ioctl"))
+   return -ENODEV;
+
tty_lock(tty);
-   tmp.line = tty->index;
-   tmp.port = state->port;
-   tmp.flags = state->tport.flags;
-   tmp.xmit_fifo_size = state->xmit_fifo_size;
-   tmp.baud_base = state->baud_base;
-   tmp.close_delay = state->tport.close_delay;
-   tmp.closing_wait = state->tport.closing_wait;
-   tmp.custom_divisor = state->custom_divisor;
+   ss->line = tty->index;
+   ss->port = state->port;
+   ss->flags = state->tport.flags;
+   ss->xmit_fifo_size = state->xmit_fifo_size;
+   ss->baud_base = state->baud_base;
+   ss->close_delay = state->tport.close_delay;
+   ss->closing_wait = state->tport.closing_wait;
+   ss->custom_divisor = state->custom_divisor;
tty_unlock(tty);
-   if (copy_to_user(retinfo,,sizeof(*retinfo)))
-   return -EFAULT;
return 0;
 }
 
-static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
-  struct serial_struct __user * new_info)
+static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
 {
+   struct serial_state *state = tty->driver_data;
struct tty_port *port = >tport;
-   struct serial_struct new_serial;
bool change_spd;
-   int retval = 0;
 
-   if (copy_from_user(_serial,new_info,sizeof(new_serial)))
-   return -EFAULT;
+   if (serial_paranoia_check(state, tty->name, "rs_ioctl"))
+   return -ENODEV;
 
tty_lock(tty);
-   change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) ||
-   new_serial.custom_divisor != state->custom_divisor;
-   if (new_serial.irq || new_serial.port != state->port ||
-   new_serial.xmit_fifo_size != state->xmit_fifo_size) {
+   change_spd = ((ss->flags ^ port->flags) & ASYNC_SPD_MASK) ||
+   ss->custom_divisor != state->custom_divisor;
+   if (ss->irq || ss->port != state->port ||
+   ss->xmit_fifo_size != state->xmit_fifo_size) {
tty_unlock(tty);
return -EINVAL;
}
   
if (!serial_isroot()) {
-   if ((new_serial.baud_base != state->baud_base) ||
-   (new_serial.close_delay != port->close_delay) ||
-   (new_serial.xmit_fifo_size != state->xmit_fifo_size) ||
-   ((new_serial.flags & ~ASYNC_USR_MASK) !=
+   if ((ss->baud_base != state->baud_base) ||
+   (ss->close_delay != port->close_delay) ||
+   (ss->xmit_fifo_size != state->xmit_fifo_size) ||
+   ((ss->flags & ~ASYNC_USR_MASK) !=
 (port->flags & ~ASYNC_USR_MASK))) {
tty_unlock(tty);
return -EPERM;
}
port->flags = ((port->flags & ~ASYNC_USR_MASK) |
-  (new_serial.flags & ASYNC_USR_MASK));
-   state->custom_divisor = new_serial.custom_divisor;
+  (ss->flags & ASYNC_USR_MASK));
+   state->custom_divisor = ss->custom_divisor;
goto check_and_exit;
}
 
-   if (new_serial.baud_base < 9600) {
+   if (ss->baud_base < 9600) {
tty_unlock(tty);
return -EINVAL;
}
@@ -1062,19 +1059,19 @@ static int set_serial_info(struct tty_struct *tty, 
struct serial_state *state,
 * At this point, we start making changes.
 */
 
-   state->baud_base = new_serial.baud_base;
+   state->baud_base = ss->baud_base;
port->flags = ((port->flags & ~ASYNC_FLAGS) |
-   (new_serial.flags & ASYNC_FLAGS));
-   state->custom_divisor = new_serial.custom_divisor;
-   port->close_delay = new_serial.close_delay * HZ/100;
-   port->closing_wait = new_serial.closing_wait * HZ/100;
+   (ss->flags & ASYNC_FLAGS));
+   state->custom_divisor = ss->custom_divisor;
+   port->close_delay = 

[PATCH 07/50] fwserial: switch to ->[sg]et_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 drivers/staging/fwserial/fwserial.c | 66 -
 1 file changed, 28 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/fwserial/fwserial.c 
b/drivers/staging/fwserial/fwserial.c
index fa0dd425b454..173f451b86b7 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -1209,42 +1209,40 @@ static int wait_msr_change(struct fwtty_port *port, 
unsigned long mask)
check_msr_delta(port, mask, ));
 }
 
-static int get_serial_info(struct fwtty_port *port,
-  struct serial_struct __user *info)
+static int get_serial_info(struct tty_struct *tty,
+  struct serial_struct *ss)
 {
-   struct serial_struct tmp;
-
-   memset(, 0, sizeof(tmp));
-
-   tmp.type =  PORT_UNKNOWN;
-   tmp.line =  port->port.tty->index;
-   tmp.flags = port->port.flags;
-   tmp.xmit_fifo_size = FWTTY_PORT_TXFIFO_LEN;
-   tmp.baud_base = 4;
-   tmp.close_delay = port->port.close_delay;
-
-   return (copy_to_user(info, , sizeof(*info))) ? -EFAULT : 0;
+   struct fwtty_port *port = tty->driver_data;
+   mutex_lock(>port.mutex);
+   ss->type =  PORT_UNKNOWN;
+   ss->line =  port->port.tty->index;
+   ss->flags = port->port.flags;
+   ss->xmit_fifo_size = FWTTY_PORT_TXFIFO_LEN;
+   ss->baud_base = 4;
+   ss->close_delay = port->port.close_delay;
+   mutex_unlock(>port.mutex);
+   return 0;
 }
 
-static int set_serial_info(struct fwtty_port *port,
-  struct serial_struct __user *info)
+static int set_serial_info(struct tty_struct *tty,
+  struct serial_struct *ss)
 {
-   struct serial_struct tmp;
-
-   if (copy_from_user(, info, sizeof(tmp)))
-   return -EFAULT;
+   struct fwtty_port *port = tty->driver_data;
 
-   if (tmp.irq != 0 || tmp.port != 0 || tmp.custom_divisor != 0 ||
-   tmp.baud_base != 4)
+   if (ss->irq != 0 || ss->port != 0 || ss->custom_divisor != 0 ||
+   ss->baud_base != 4)
return -EPERM;
 
+   mutex_lock(>port.mutex);
if (!capable(CAP_SYS_ADMIN)) {
-   if (((tmp.flags & ~ASYNC_USR_MASK) !=
-(port->port.flags & ~ASYNC_USR_MASK)))
+   if (((ss->flags & ~ASYNC_USR_MASK) !=
+(port->port.flags & ~ASYNC_USR_MASK))) {
+   mutex_unlock(>port.mutex);
return -EPERM;
-   } else {
-   port->port.close_delay = tmp.close_delay * HZ / 100;
+   }
}
+   port->port.close_delay = ss->close_delay * HZ / 100;
+   mutex_unlock(>port.mutex);
 
return 0;
 }
@@ -1256,18 +1254,6 @@ static int fwtty_ioctl(struct tty_struct *tty, unsigned 
int cmd,
int err;
 
switch (cmd) {
-   case TIOCGSERIAL:
-   mutex_lock(>port.mutex);
-   err = get_serial_info(port, (void __user *)arg);
-   mutex_unlock(>port.mutex);
-   break;
-
-   case TIOCSSERIAL:
-   mutex_lock(>port.mutex);
-   err = set_serial_info(port, (void __user *)arg);
-   mutex_unlock(>port.mutex);
-   break;
-
case TIOCMIWAIT:
err = wait_msr_change(port, arg);
break;
@@ -1557,6 +1543,8 @@ static const struct tty_operations fwtty_ops = {
.tiocmget = fwtty_tiocmget,
.tiocmset = fwtty_tiocmset,
.get_icount =   fwtty_get_icount,
+   .set_serial =   set_serial_info,
+   .get_serial =   get_serial_info,
.proc_show =fwtty_proc_show,
 };
 
@@ -1578,6 +1566,8 @@ static const struct tty_operations fwloop_ops = {
.tiocmget = fwtty_tiocmget,
.tiocmset = fwtty_tiocmset,
.get_icount =   fwtty_get_icount,
+   .set_serial =   set_serial_info,
+   .get_serial =   get_serial_info,
 };
 
 static inline int mgmt_pkt_expected_len(__be16 code)
-- 
2.11.0



[PATCH 02/50] move compat handling of tty ioctls to tty_compat_ioctl()

2018-09-12 Thread Al Viro
From: Al Viro 

ioctls that are
* callable only via tty_ioctl()
* not driver-specific
* not demand data structure conversions
* either always need passing arg as is or always demand compat_ptr()
get intercepted in tty_compat_ioctl() from the very beginning and
redirecter to tty_ioctl().  As the result, their entries in fs/compat_ioctl.c
(some of those had been missing, BTW) got removed, as well as
n_tty_compat_ioctl_helper() (now it's never called with any cmd it would 
accept).

Signed-off-by: Al Viro 
---
 drivers/tty/tty_io.c| 77 +++--
 drivers/tty/tty_ioctl.c | 16 --
 fs/compat_ioctl.c   | 51 
 include/linux/tty.h |  2 --
 4 files changed, 75 insertions(+), 71 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 32bc3e3fe4d3..c2168b43df0f 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2668,6 +2668,81 @@ static long tty_compat_ioctl(struct file *file, unsigned 
int cmd,
struct tty_ldisc *ld;
int retval = -ENOIOCTLCMD;
 
+   switch (cmd) {
+   case TIOCSTI:
+   case TIOCGWINSZ:
+   case TIOCSWINSZ:
+   case TIOCGEXCL:
+   case TIOCGETD:
+   case TIOCSETD:
+   case TIOCGDEV:
+   case TIOCMGET:
+   case TIOCMSET:
+   case TIOCMBIC:
+   case TIOCMBIS:
+   case TIOCGICOUNT:
+   case TIOCGPGRP:
+   case TIOCSPGRP:
+   case TIOCGSID:
+   case TIOCSERGETLSR:
+   case TIOCGRS485:
+   case TIOCSRS485:
+#ifdef TIOCGETP
+   case TIOCGETP:
+   case TIOCSETP:
+   case TIOCSETN:
+#endif
+#ifdef TIOCGETC
+   case TIOCGETC:
+   case TIOCSETC:
+#endif
+#ifdef TIOCGLTC
+   case TIOCGLTC:
+   case TIOCSLTC:
+#endif
+   case TCSETSF:
+   case TCSETSW:
+   case TCSETS:
+   case TCGETS:
+#ifdef TCGETS2
+   case TCGETS2:
+   case TCSETSF2:
+   case TCSETSW2:
+   case TCSETS2:
+#endif
+   case TCGETA:
+   case TCSETAF:
+   case TCSETAW:
+   case TCSETA:
+   case TIOCGLCKTRMIOS:
+   case TIOCSLCKTRMIOS:
+#ifdef TCGETX
+   case TCGETX:
+   case TCSETX:
+   case TCSETXW:
+   case TCSETXF:
+#endif
+   case TIOCGSOFTCAR:
+   case TIOCSSOFTCAR:
+   return tty_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
+   case TIOCCONS:
+   case TIOCEXCL:
+   case TIOCNXCL:
+   case TIOCVHANGUP:
+   case TIOCSBRK:
+   case TIOCCBRK:
+   case TCSBRK:
+   case TCSBRKP:
+   case TCFLSH:
+   case TIOCGPTPEER:
+   case TIOCNOTTY:
+   case TIOCSCTTY:
+   case TCXONC:
+   case TIOCMIWAIT:
+   case TIOCSERCONFIG:
+   return tty_ioctl(file, cmd, arg);
+   }
+
if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl"))
return -EINVAL;
 
@@ -2682,8 +2757,6 @@ static long tty_compat_ioctl(struct file *file, unsigned 
int cmd,
return hung_up_tty_compat_ioctl(file, cmd, arg);
if (ld->ops->compat_ioctl)
retval = ld->ops->compat_ioctl(tty, file, cmd, arg);
-   else
-   retval = n_tty_compat_ioctl_helper(tty, file, cmd, arg);
tty_ldisc_deref(ld);
 
return retval;
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index d99fec44036c..9245fffdbceb 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -941,19 +941,3 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file 
*file,
}
 }
 EXPORT_SYMBOL(n_tty_ioctl_helper);
-
-#ifdef CONFIG_COMPAT
-long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file,
-   unsigned int cmd, unsigned long arg)
-{
-   switch (cmd) {
-   case TIOCGLCKTRMIOS:
-   case TIOCSLCKTRMIOS:
-   return tty_mode_ioctl(tty, file, cmd, (unsigned long) 
compat_ptr(arg));
-   default:
-   return -ENOIOCTLCMD;
-   }
-}
-EXPORT_SYMBOL(n_tty_compat_ioctl_helper);
-#endif
-
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 53bc3659dcef..670b8cbd0896 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -711,52 +711,9 @@ COMPATIBLE_IOCTL(0x4B50)   /* KDGHWCLK - not in the 
kernel, but don't complain *
 COMPATIBLE_IOCTL(0x4B51)   /* KDSHWCLK - not in the kernel, but don't complain 
*/
 
 /* Big T */
-COMPATIBLE_IOCTL(TCGETA)
-COMPATIBLE_IOCTL(TCSETA)
-COMPATIBLE_IOCTL(TCSETAW)
-COMPATIBLE_IOCTL(TCSETAF)
-COMPATIBLE_IOCTL(TCSBRK)
-COMPATIBLE_IOCTL(TCXONC)
-COMPATIBLE_IOCTL(TCFLSH)
-COMPATIBLE_IOCTL(TCGETS)
-COMPATIBLE_IOCTL(TCSETS)
-COMPATIBLE_IOCTL(TCSETSW)
-COMPATIBLE_IOCTL(TCSETSF)
 COMPATIBLE_IOCTL(TIOCLINUX)
-COMPATIBLE_IOCTL(TIOCSBRK)
-COMPATIBLE_IOCTL(TIOCGDEV)
-COMPATIBLE_IOCTL(TIOCCBRK)
-COMPATIBLE_IOCTL(TIOCGSID)
-COMPATIBLE_IOCTL(TIOCGICOUNT)
-COMPATIBLE_IOCTL(TIOCGEXCL)
 /* Little t */
-COMPATIBLE_IOCTL(TIOCGETD)
-COMPATIBLE_IOCTL(TIOCSETD)

[PATCH 09/50] amiserial: switch to ->[sg]et_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 drivers/tty/amiserial.c | 83 ++---
 1 file changed, 38 insertions(+), 45 deletions(-)

diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 34dead614149..17fc8bb6c6b8 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -996,63 +996,60 @@ static void rs_unthrottle(struct tty_struct * tty)
  * 
  */
 
-static int get_serial_info(struct tty_struct *tty, struct serial_state *state,
-  struct serial_struct __user * retinfo)
+static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
 {
-   struct serial_struct tmp;
-   
-   memset(, 0, sizeof(tmp));
+   struct serial_state *state = tty->driver_data;
+
+   if (serial_paranoia_check(state, tty->name, "rs_ioctl"))
+   return -ENODEV;
+
tty_lock(tty);
-   tmp.line = tty->index;
-   tmp.port = state->port;
-   tmp.flags = state->tport.flags;
-   tmp.xmit_fifo_size = state->xmit_fifo_size;
-   tmp.baud_base = state->baud_base;
-   tmp.close_delay = state->tport.close_delay;
-   tmp.closing_wait = state->tport.closing_wait;
-   tmp.custom_divisor = state->custom_divisor;
+   ss->line = tty->index;
+   ss->port = state->port;
+   ss->flags = state->tport.flags;
+   ss->xmit_fifo_size = state->xmit_fifo_size;
+   ss->baud_base = state->baud_base;
+   ss->close_delay = state->tport.close_delay;
+   ss->closing_wait = state->tport.closing_wait;
+   ss->custom_divisor = state->custom_divisor;
tty_unlock(tty);
-   if (copy_to_user(retinfo,,sizeof(*retinfo)))
-   return -EFAULT;
return 0;
 }
 
-static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
-  struct serial_struct __user * new_info)
+static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
 {
+   struct serial_state *state = tty->driver_data;
struct tty_port *port = >tport;
-   struct serial_struct new_serial;
bool change_spd;
-   int retval = 0;
 
-   if (copy_from_user(_serial,new_info,sizeof(new_serial)))
-   return -EFAULT;
+   if (serial_paranoia_check(state, tty->name, "rs_ioctl"))
+   return -ENODEV;
 
tty_lock(tty);
-   change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) ||
-   new_serial.custom_divisor != state->custom_divisor;
-   if (new_serial.irq || new_serial.port != state->port ||
-   new_serial.xmit_fifo_size != state->xmit_fifo_size) {
+   change_spd = ((ss->flags ^ port->flags) & ASYNC_SPD_MASK) ||
+   ss->custom_divisor != state->custom_divisor;
+   if (ss->irq || ss->port != state->port ||
+   ss->xmit_fifo_size != state->xmit_fifo_size) {
tty_unlock(tty);
return -EINVAL;
}
   
if (!serial_isroot()) {
-   if ((new_serial.baud_base != state->baud_base) ||
-   (new_serial.close_delay != port->close_delay) ||
-   (new_serial.xmit_fifo_size != state->xmit_fifo_size) ||
-   ((new_serial.flags & ~ASYNC_USR_MASK) !=
+   if ((ss->baud_base != state->baud_base) ||
+   (ss->close_delay != port->close_delay) ||
+   (ss->xmit_fifo_size != state->xmit_fifo_size) ||
+   ((ss->flags & ~ASYNC_USR_MASK) !=
 (port->flags & ~ASYNC_USR_MASK))) {
tty_unlock(tty);
return -EPERM;
}
port->flags = ((port->flags & ~ASYNC_USR_MASK) |
-  (new_serial.flags & ASYNC_USR_MASK));
-   state->custom_divisor = new_serial.custom_divisor;
+  (ss->flags & ASYNC_USR_MASK));
+   state->custom_divisor = ss->custom_divisor;
goto check_and_exit;
}
 
-   if (new_serial.baud_base < 9600) {
+   if (ss->baud_base < 9600) {
tty_unlock(tty);
return -EINVAL;
}
@@ -1062,19 +1059,19 @@ static int set_serial_info(struct tty_struct *tty, 
struct serial_state *state,
 * At this point, we start making changes.
 */
 
-   state->baud_base = new_serial.baud_base;
+   state->baud_base = ss->baud_base;
port->flags = ((port->flags & ~ASYNC_FLAGS) |
-   (new_serial.flags & ASYNC_FLAGS));
-   state->custom_divisor = new_serial.custom_divisor;
-   port->close_delay = new_serial.close_delay * HZ/100;
-   port->closing_wait = new_serial.closing_wait * HZ/100;
+   (ss->flags & ASYNC_FLAGS));
+   state->custom_divisor = ss->custom_divisor;
+   port->close_delay = 

[PATCH 07/50] fwserial: switch to ->[sg]et_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 drivers/staging/fwserial/fwserial.c | 66 -
 1 file changed, 28 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/fwserial/fwserial.c 
b/drivers/staging/fwserial/fwserial.c
index fa0dd425b454..173f451b86b7 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -1209,42 +1209,40 @@ static int wait_msr_change(struct fwtty_port *port, 
unsigned long mask)
check_msr_delta(port, mask, ));
 }
 
-static int get_serial_info(struct fwtty_port *port,
-  struct serial_struct __user *info)
+static int get_serial_info(struct tty_struct *tty,
+  struct serial_struct *ss)
 {
-   struct serial_struct tmp;
-
-   memset(, 0, sizeof(tmp));
-
-   tmp.type =  PORT_UNKNOWN;
-   tmp.line =  port->port.tty->index;
-   tmp.flags = port->port.flags;
-   tmp.xmit_fifo_size = FWTTY_PORT_TXFIFO_LEN;
-   tmp.baud_base = 4;
-   tmp.close_delay = port->port.close_delay;
-
-   return (copy_to_user(info, , sizeof(*info))) ? -EFAULT : 0;
+   struct fwtty_port *port = tty->driver_data;
+   mutex_lock(>port.mutex);
+   ss->type =  PORT_UNKNOWN;
+   ss->line =  port->port.tty->index;
+   ss->flags = port->port.flags;
+   ss->xmit_fifo_size = FWTTY_PORT_TXFIFO_LEN;
+   ss->baud_base = 4;
+   ss->close_delay = port->port.close_delay;
+   mutex_unlock(>port.mutex);
+   return 0;
 }
 
-static int set_serial_info(struct fwtty_port *port,
-  struct serial_struct __user *info)
+static int set_serial_info(struct tty_struct *tty,
+  struct serial_struct *ss)
 {
-   struct serial_struct tmp;
-
-   if (copy_from_user(, info, sizeof(tmp)))
-   return -EFAULT;
+   struct fwtty_port *port = tty->driver_data;
 
-   if (tmp.irq != 0 || tmp.port != 0 || tmp.custom_divisor != 0 ||
-   tmp.baud_base != 4)
+   if (ss->irq != 0 || ss->port != 0 || ss->custom_divisor != 0 ||
+   ss->baud_base != 4)
return -EPERM;
 
+   mutex_lock(>port.mutex);
if (!capable(CAP_SYS_ADMIN)) {
-   if (((tmp.flags & ~ASYNC_USR_MASK) !=
-(port->port.flags & ~ASYNC_USR_MASK)))
+   if (((ss->flags & ~ASYNC_USR_MASK) !=
+(port->port.flags & ~ASYNC_USR_MASK))) {
+   mutex_unlock(>port.mutex);
return -EPERM;
-   } else {
-   port->port.close_delay = tmp.close_delay * HZ / 100;
+   }
}
+   port->port.close_delay = ss->close_delay * HZ / 100;
+   mutex_unlock(>port.mutex);
 
return 0;
 }
@@ -1256,18 +1254,6 @@ static int fwtty_ioctl(struct tty_struct *tty, unsigned 
int cmd,
int err;
 
switch (cmd) {
-   case TIOCGSERIAL:
-   mutex_lock(>port.mutex);
-   err = get_serial_info(port, (void __user *)arg);
-   mutex_unlock(>port.mutex);
-   break;
-
-   case TIOCSSERIAL:
-   mutex_lock(>port.mutex);
-   err = set_serial_info(port, (void __user *)arg);
-   mutex_unlock(>port.mutex);
-   break;
-
case TIOCMIWAIT:
err = wait_msr_change(port, arg);
break;
@@ -1557,6 +1543,8 @@ static const struct tty_operations fwtty_ops = {
.tiocmget = fwtty_tiocmget,
.tiocmset = fwtty_tiocmset,
.get_icount =   fwtty_get_icount,
+   .set_serial =   set_serial_info,
+   .get_serial =   get_serial_info,
.proc_show =fwtty_proc_show,
 };
 
@@ -1578,6 +1566,8 @@ static const struct tty_operations fwloop_ops = {
.tiocmget = fwtty_tiocmget,
.tiocmset = fwtty_tiocmset,
.get_icount =   fwtty_get_icount,
+   .set_serial =   set_serial_info,
+   .get_serial =   get_serial_info,
 };
 
 static inline int mgmt_pkt_expected_len(__be16 code)
-- 
2.11.0



[PATCH 03/50] tty_ioctl(): drop FIONBIO handling

2018-09-12 Thread Al Viro
From: Al Viro 

That code had been live for 11 weeks back in 1992, but it had been 26 years
since sys_ioctl() began handling FIONBIO on its own.  Time to to bury the body,
already...

Signed-off-by: Al Viro 
---
 drivers/tty/tty_io.c | 30 --
 1 file changed, 30 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index c2168b43df0f..2b34ccf269e0 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2288,34 +2288,6 @@ static int tioccons(struct file *file)
 }
 
 /**
- * fionbio -   non blocking ioctl
- * @file: file to set blocking value
- * @p: user parameter
- *
- * Historical tty interfaces had a blocking control ioctl before
- * the generic functionality existed. This piece of history is preserved
- * in the expected tty API of posix OS's.
- *
- * Locking: none, the open file handle ensures it won't go away.
- */
-
-static int fionbio(struct file *file, int __user *p)
-{
-   int nonblock;
-
-   if (get_user(nonblock, p))
-   return -EFAULT;
-
-   spin_lock(>f_lock);
-   if (nonblock)
-   file->f_flags |= O_NONBLOCK;
-   else
-   file->f_flags &= ~O_NONBLOCK;
-   spin_unlock(>f_lock);
-   return 0;
-}
-
-/**
  * tiocsetd-   set line discipline
  * @tty: tty device
  * @p: pointer to user data
@@ -2561,8 +2533,6 @@ long tty_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
return tiocswinsz(real_tty, p);
case TIOCCONS:
return real_tty != tty ? -EINVAL : tioccons(file);
-   case FIONBIO:
-   return fionbio(file, p);
case TIOCEXCL:
set_bit(TTY_EXCLUSIVE, >flags);
return 0;
-- 
2.11.0



[PATCH 08/50] greybus/uart: switch to ->[sg]et_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 drivers/staging/greybus/uart.c | 47 --
 1 file changed, 18 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 8a006323c3c1..3313cb0b60af 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -616,40 +616,33 @@ static void gb_tty_unthrottle(struct tty_struct *tty)
}
 }
 
-static int get_serial_info(struct gb_tty *gb_tty,
-  struct serial_struct __user *info)
+static int get_serial_info(struct tty_struct *tty,
+  struct serial_struct *ss)
 {
-   struct serial_struct tmp;
-
-   memset(, 0, sizeof(tmp));
-   tmp.type = PORT_16550A;
-   tmp.line = gb_tty->minor;
-   tmp.xmit_fifo_size = 16;
-   tmp.baud_base = 9600;
-   tmp.close_delay = gb_tty->port.close_delay / 10;
-   tmp.closing_wait =
+   struct gb_tty *gb_tty = tty->driver_data;
+
+   ss->type = PORT_16550A;
+   ss->line = gb_tty->minor;
+   ss->xmit_fifo_size = 16;
+   ss->baud_base = 9600;
+   ss->close_delay = gb_tty->port.close_delay / 10;
+   ss->closing_wait =
gb_tty->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
ASYNC_CLOSING_WAIT_NONE : gb_tty->port.closing_wait / 10;
-
-   if (copy_to_user(info, , sizeof(tmp)))
-   return -EFAULT;
return 0;
 }
 
-static int set_serial_info(struct gb_tty *gb_tty,
-  struct serial_struct __user *newinfo)
+static int set_serial_info(struct tty_struct *tty,
+  struct serial_struct *ss)
 {
-   struct serial_struct new_serial;
+   struct gb_tty *gb_tty = tty->driver_data;
unsigned int closing_wait;
unsigned int close_delay;
int retval = 0;
 
-   if (copy_from_user(_serial, newinfo, sizeof(new_serial)))
-   return -EFAULT;
-
-   close_delay = new_serial.close_delay * 10;
-   closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
-   ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;
+   close_delay = ss->close_delay * 10;
+   closing_wait = ss->closing_wait == ASYNC_CLOSING_WAIT_NONE ?
+   ASYNC_CLOSING_WAIT_NONE : ss->closing_wait * 10;
 
mutex_lock(_tty->port.mutex);
if (!capable(CAP_SYS_ADMIN)) {
@@ -728,12 +721,6 @@ static int gb_tty_ioctl(struct tty_struct *tty, unsigned 
int cmd,
struct gb_tty *gb_tty = tty->driver_data;
 
switch (cmd) {
-   case TIOCGSERIAL:
-   return get_serial_info(gb_tty,
-  (struct serial_struct __user *)arg);
-   case TIOCSSERIAL:
-   return set_serial_info(gb_tty,
-  (struct serial_struct __user *)arg);
case TIOCMIWAIT:
return wait_serial_change(gb_tty, arg);
}
@@ -818,6 +805,8 @@ static const struct tty_operations gb_ops = {
.tiocmget = gb_tty_tiocmget,
.tiocmset = gb_tty_tiocmset,
.get_icount =   gb_tty_get_icount,
+   .set_serial =   set_serial_info,
+   .get_serial =   get_serial_info,
 };
 
 static const struct tty_port_operations gb_port_ops = {
-- 
2.11.0



[PATCH 24/50] io_ti: switch to ->get_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 drivers/usb/serial/io_ti.c | 47 ++
 1 file changed, 14 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 6d1d6efa3055..c327d4cf7928 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2437,47 +2437,28 @@ static int edge_tiocmget(struct tty_struct *tty)
return result;
 }
 
-static int get_serial_info(struct edgeport_port *edge_port,
-   struct serial_struct __user *retinfo)
+static int get_serial_info(struct tty_struct *tty,
+   struct serial_struct *ss)
 {
-   struct serial_struct tmp;
+   struct usb_serial_port *port = tty->driver_data;
+   struct edgeport_port *edge_port = usb_get_serial_port_data(port);
unsigned cwait;
 
cwait = edge_port->port->port.closing_wait;
if (cwait != ASYNC_CLOSING_WAIT_NONE)
cwait = jiffies_to_msecs(cwait) / 10;
 
-   memset(, 0, sizeof(tmp));
-
-   tmp.type= PORT_16550A;
-   tmp.line= edge_port->port->minor;
-   tmp.port= edge_port->port->port_number;
-   tmp.irq = 0;
-   tmp.xmit_fifo_size  = edge_port->port->bulk_out_size;
-   tmp.baud_base   = 9600;
-   tmp.close_delay = 5*HZ;
-   tmp.closing_wait= cwait;
-
-   if (copy_to_user(retinfo, , sizeof(*retinfo)))
-   return -EFAULT;
+   ss->type= PORT_16550A;
+   ss->line= edge_port->port->minor;
+   ss->port= edge_port->port->port_number;
+   ss->irq = 0;
+   ss->xmit_fifo_size  = edge_port->port->bulk_out_size;
+   ss->baud_base   = 9600;
+   ss->close_delay = 5*HZ;
+   ss->closing_wait= cwait;
return 0;
 }
 
-static int edge_ioctl(struct tty_struct *tty,
-   unsigned int cmd, unsigned long arg)
-{
-   struct usb_serial_port *port = tty->driver_data;
-   struct edgeport_port *edge_port = usb_get_serial_port_data(port);
-
-   switch (cmd) {
-   case TIOCGSERIAL:
-   dev_dbg(>dev, "%s - TIOCGSERIAL\n", __func__);
-   return get_serial_info(edge_port,
-   (struct serial_struct __user *) arg);
-   }
-   return -ENOIOCTLCMD;
-}
-
 static void edge_break(struct tty_struct *tty, int break_state)
 {
struct usb_serial_port *port = tty->driver_data;
@@ -2738,7 +2719,7 @@ static struct usb_serial_driver edgeport_1port_device = {
.release= edge_release,
.port_probe = edge_port_probe,
.port_remove= edge_port_remove,
-   .ioctl  = edge_ioctl,
+   .get_serial = get_serial_info,
.set_termios= edge_set_termios,
.tiocmget   = edge_tiocmget,
.tiocmset   = edge_tiocmset,
@@ -2777,7 +2758,7 @@ static struct usb_serial_driver edgeport_2port_device = {
.release= edge_release,
.port_probe = edge_port_probe,
.port_remove= edge_port_remove,
-   .ioctl  = edge_ioctl,
+   .get_serial = get_serial_info,
.set_termios= edge_set_termios,
.tiocmget   = edge_tiocmget,
.tiocmset   = edge_tiocmset,
-- 
2.11.0



[PATCH 12/50] isicom: switch to ->[sg]et_serial()

2018-09-12 Thread Al Viro
From: Al Viro 

Signed-off-by: Al Viro 
---
 drivers/tty/isicom.c | 72 ++--
 1 file changed, 25 insertions(+), 47 deletions(-)

diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c
index 8d96e86966f1..e04a43e89f6b 100644
--- a/drivers/tty/isicom.c
+++ b/drivers/tty/isicom.c
@@ -1091,34 +1091,33 @@ static int isicom_tiocmset(struct tty_struct *tty,
 }
 
 static int isicom_set_serial_info(struct tty_struct *tty,
-   struct serial_struct __user *info)
+   struct serial_struct *ss)
 {
struct isi_port *port = tty->driver_data;
-   struct serial_struct newinfo;
int reconfig_port;
 
-   if (copy_from_user(, info, sizeof(newinfo)))
-   return -EFAULT;
+   if (isicom_paranoia_check(port, tty->name, "isicom_ioctl"))
+   return -ENODEV;
 
mutex_lock(>port.mutex);
reconfig_port = ((port->port.flags & ASYNC_SPD_MASK) !=
-   (newinfo.flags & ASYNC_SPD_MASK));
+   (ss->flags & ASYNC_SPD_MASK));
 
if (!capable(CAP_SYS_ADMIN)) {
-   if ((newinfo.close_delay != port->port.close_delay) ||
-   (newinfo.closing_wait != 
port->port.closing_wait) ||
-   ((newinfo.flags & ~ASYNC_USR_MASK) !=
+   if ((ss->close_delay != port->port.close_delay) ||
+   (ss->closing_wait != port->port.closing_wait) ||
+   ((ss->flags & ~ASYNC_USR_MASK) !=
(port->port.flags & ~ASYNC_USR_MASK))) {
mutex_unlock(>port.mutex);
return -EPERM;
}
port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
-   (newinfo.flags & ASYNC_USR_MASK));
+   (ss->flags & ASYNC_USR_MASK));
} else {
-   port->port.close_delay = newinfo.close_delay;
-   port->port.closing_wait = newinfo.closing_wait;
+   port->port.close_delay = ss->close_delay;
+   port->port.closing_wait = ss->closing_wait;
port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
-   (newinfo.flags & ASYNC_FLAGS));
+   (ss->flags & ASYNC_FLAGS));
}
if (reconfig_port) {
unsigned long flags;
@@ -1130,46 +1129,24 @@ static int isicom_set_serial_info(struct tty_struct 
*tty,
return 0;
 }
 
-static int isicom_get_serial_info(struct isi_port *port,
-   struct serial_struct __user *info)
-{
-   struct serial_struct out_info;
-
-   mutex_lock(>port.mutex);
-   memset(_info, 0, sizeof(out_info));
-/* out_info.type = ? */
-   out_info.line = port - isi_ports;
-   out_info.port = port->card->base;
-   out_info.irq = port->card->irq;
-   out_info.flags = port->port.flags;
-/* out_info.baud_base = ? */
-   out_info.close_delay = port->port.close_delay;
-   out_info.closing_wait = port->port.closing_wait;
-   mutex_unlock(>port.mutex);
-   if (copy_to_user(info, _info, sizeof(out_info)))
-   return -EFAULT;
-   return 0;
-}
-
-static int isicom_ioctl(struct tty_struct *tty,
-   unsigned int cmd, unsigned long arg)
+static int isicom_get_serial_info(struct tty_struct *tty,
+   struct serial_struct *ss)
 {
struct isi_port *port = tty->driver_data;
-   void __user *argp = (void __user *)arg;
 
if (isicom_paranoia_check(port, tty->name, "isicom_ioctl"))
return -ENODEV;
 
-   switch (cmd) {
-   case TIOCGSERIAL:
-   return isicom_get_serial_info(port, argp);
-
-   case TIOCSSERIAL:
-   return isicom_set_serial_info(tty, argp);
-
-   default:
-   return -ENOIOCTLCMD;
-   }
+   mutex_lock(>port.mutex);
+/* ss->type = ? */
+   ss->line = port - isi_ports;
+   ss->port = port->card->base;
+   ss->irq = port->card->irq;
+   ss->flags = port->port.flags;
+/* ss->baud_base = ? */
+   ss->close_delay = port->port.close_delay;
+   ss->closing_wait = port->port.closing_wait;
+   mutex_unlock(>port.mutex);
return 0;
 }
 
@@ -1273,7 +1250,6 @@ static const struct tty_operations isicom_ops = {
.flush_chars= isicom_flush_chars,
.write_room = isicom_write_room,
.chars_in_buffer= isicom_chars_in_buffer,
-   .ioctl  = isicom_ioctl,
.set_termios= isicom_set_termios,
.throttle   = isicom_throttle,
.unthrottle = isicom_unthrottle,
@@ -1284,6 +1260,8 @@ static const struct tty_operations isicom_ops = {
.tiocmget   = isicom_tiocmget,
.tiocmset   = isicom_tiocmset,

  1   2   3   4   5   6   7   8   9   10   >