[PATCH][v2] cpufreq: Bring CPUs up even if cpufreq_online failed

2017-04-08 Thread Chen Yu
There is a report that after
commit 27622b061eb4 ("cpufreq: Convert to hotplug state machine"),
the normal CPU offline/online cycle failed on some platforms.
According to the ftrace result, this problem was triggered on
platforms using acpi-freq as the default cpufreq driver,
and due to the lack of some ACPI freq method(_PCT eg), the
cpufreq_online failed and returned a negative value, thus the CPU
hotplug statemachine rollbacked the CPU online process. Actually
from the user's perspective the failure of cpufreq_online should
not prevent that CPU from being brought up, although cpufreq might
not work on that CPU. BTW, during system bootup the cpufreq_online
is not invoked via cpuhotplug statemachine but by the cpufreq device
creation process, thus the APs can be brought up although cpufreq_online
failed in that stage.

This patch ignores the return value of cpufreq_online/offline and
let the cpufreq framework to deal with the failure that, cpufreq_online()
will do a proper rollback in that case. And if the _PCT is missing,
the acpi cpufreq driver will print a warning if the corresponding
debug options have been enabled.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=194581
Fixes: 27622b061eb4 ("cpufreq: Convert to hotplug state machine")
Reported-and-tested-by: Tomasz Maciej Nowak 
Cc: "Rafael J. Wysocki" 
Cc: Viresh Kumar 
Cc: Sebastian Andrzej Siewior 
Cc: Len Brown 
Cc: linux...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Stable  # 4.9+
Signed-off-by: Chen Yu 
---
v2:
 - According to Rafael and Sebastian's suggestion, remove
   the error log in cpuhp_cpufreq_online/offline, and let
   the cpufreq_online and cpufreq_offline to print the warning
   and do the necessary rollback if they failed.
---
 drivers/cpufreq/cpufreq.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index bc96d42..0e3f649 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2398,6 +2398,20 @@ EXPORT_SYMBOL_GPL(cpufreq_boost_enabled);
  */
 static enum cpuhp_state hp_online;
 
+static int cpuhp_cpufreq_online(unsigned int cpu)
+{
+   cpufreq_online(cpu);
+
+   return 0;
+}
+
+static int cpuhp_cpufreq_offline(unsigned int cpu)
+{
+   cpufreq_offline(cpu);
+
+   return 0;
+}
+
 /**
  * cpufreq_register_driver - register a CPU Frequency driver
  * @driver_data: A struct cpufreq_driver containing the values#
@@ -2460,8 +2474,8 @@ int cpufreq_register_driver(struct cpufreq_driver 
*driver_data)
}
 
ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online",
-   cpufreq_online,
-   cpufreq_offline);
+   cpuhp_cpufreq_online,
+   cpuhp_cpufreq_offline);
if (ret < 0)
goto err_if_unreg;
hp_online = ret;
-- 
2.7.4



[PATCH][v2] cpufreq: Bring CPUs up even if cpufreq_online failed

2017-04-08 Thread Chen Yu
There is a report that after
commit 27622b061eb4 ("cpufreq: Convert to hotplug state machine"),
the normal CPU offline/online cycle failed on some platforms.
According to the ftrace result, this problem was triggered on
platforms using acpi-freq as the default cpufreq driver,
and due to the lack of some ACPI freq method(_PCT eg), the
cpufreq_online failed and returned a negative value, thus the CPU
hotplug statemachine rollbacked the CPU online process. Actually
from the user's perspective the failure of cpufreq_online should
not prevent that CPU from being brought up, although cpufreq might
not work on that CPU. BTW, during system bootup the cpufreq_online
is not invoked via cpuhotplug statemachine but by the cpufreq device
creation process, thus the APs can be brought up although cpufreq_online
failed in that stage.

This patch ignores the return value of cpufreq_online/offline and
let the cpufreq framework to deal with the failure that, cpufreq_online()
will do a proper rollback in that case. And if the _PCT is missing,
the acpi cpufreq driver will print a warning if the corresponding
debug options have been enabled.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=194581
Fixes: 27622b061eb4 ("cpufreq: Convert to hotplug state machine")
Reported-and-tested-by: Tomasz Maciej Nowak 
Cc: "Rafael J. Wysocki" 
Cc: Viresh Kumar 
Cc: Sebastian Andrzej Siewior 
Cc: Len Brown 
Cc: linux...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Stable  # 4.9+
Signed-off-by: Chen Yu 
---
v2:
 - According to Rafael and Sebastian's suggestion, remove
   the error log in cpuhp_cpufreq_online/offline, and let
   the cpufreq_online and cpufreq_offline to print the warning
   and do the necessary rollback if they failed.
---
 drivers/cpufreq/cpufreq.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index bc96d42..0e3f649 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2398,6 +2398,20 @@ EXPORT_SYMBOL_GPL(cpufreq_boost_enabled);
  */
 static enum cpuhp_state hp_online;
 
+static int cpuhp_cpufreq_online(unsigned int cpu)
+{
+   cpufreq_online(cpu);
+
+   return 0;
+}
+
+static int cpuhp_cpufreq_offline(unsigned int cpu)
+{
+   cpufreq_offline(cpu);
+
+   return 0;
+}
+
 /**
  * cpufreq_register_driver - register a CPU Frequency driver
  * @driver_data: A struct cpufreq_driver containing the values#
@@ -2460,8 +2474,8 @@ int cpufreq_register_driver(struct cpufreq_driver 
*driver_data)
}
 
ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online",
-   cpufreq_online,
-   cpufreq_offline);
+   cpuhp_cpufreq_online,
+   cpuhp_cpufreq_offline);
if (ret < 0)
goto err_if_unreg;
hp_online = ret;
-- 
2.7.4



net/core/dev.c:4508:19-26: ERROR: PTR_ERR applied after initialization to constant on line 4452

2017-04-08 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   78d91a75b40fcf6a08506d308abf2413a29b7e30
commit: 25393d3fc055b76587fcc91627aee8c345400c3a net: Prepare gro for packet 
consuming gro callbacks
date:   8 weeks ago


coccinelle warnings: (new ones prefixed by >>)

>> net/core/dev.c:4508:19-26: ERROR: PTR_ERR applied after initialization to 
>> constant on line 4452

vim +4508 net/core/dev.c

  4446  --pinfo->nr_frags * sizeof(pinfo->frags[0]));
  4447  }
  4448  }
  4449  
  4450  static enum gro_result dev_gro_receive(struct napi_struct *napi, struct 
sk_buff *skb)
  4451  {
> 4452  struct sk_buff **pp = NULL;
  4453  struct packet_offload *ptype;
  4454  __be16 type = skb->protocol;
  4455  struct list_head *head = _base;
  4456  int same_flow;
  4457  enum gro_result ret;
  4458  int grow;
  4459  
  4460  if (!(skb->dev->features & NETIF_F_GRO))
  4461  goto normal;
  4462  
  4463  if (skb->csum_bad)
  4464  goto normal;
  4465  
  4466  gro_list_prepare(napi, skb);
  4467  
  4468  rcu_read_lock();
  4469  list_for_each_entry_rcu(ptype, head, list) {
  4470  if (ptype->type != type || 
!ptype->callbacks.gro_receive)
  4471  continue;
  4472  
  4473  skb_set_network_header(skb, skb_gro_offset(skb));
  4474  skb_reset_mac_len(skb);
  4475  NAPI_GRO_CB(skb)->same_flow = 0;
  4476  NAPI_GRO_CB(skb)->flush = skb_is_gso(skb) || 
skb_has_frag_list(skb);
  4477  NAPI_GRO_CB(skb)->free = 0;
  4478  NAPI_GRO_CB(skb)->encap_mark = 0;
  4479  NAPI_GRO_CB(skb)->recursion_counter = 0;
  4480  NAPI_GRO_CB(skb)->is_fou = 0;
  4481  NAPI_GRO_CB(skb)->is_atomic = 1;
  4482  NAPI_GRO_CB(skb)->gro_remcsum_start = 0;
  4483  
  4484  /* Setup for GRO checksum validation */
  4485  switch (skb->ip_summed) {
  4486  case CHECKSUM_COMPLETE:
  4487  NAPI_GRO_CB(skb)->csum = skb->csum;
  4488  NAPI_GRO_CB(skb)->csum_valid = 1;
  4489  NAPI_GRO_CB(skb)->csum_cnt = 0;
  4490  break;
  4491  case CHECKSUM_UNNECESSARY:
  4492  NAPI_GRO_CB(skb)->csum_cnt = skb->csum_level + 
1;
  4493  NAPI_GRO_CB(skb)->csum_valid = 0;
  4494  break;
  4495  default:
  4496  NAPI_GRO_CB(skb)->csum_cnt = 0;
  4497  NAPI_GRO_CB(skb)->csum_valid = 0;
  4498  }
  4499  
  4500  pp = ptype->callbacks.gro_receive(>gro_list, skb);
  4501  break;
  4502  }
  4503  rcu_read_unlock();
  4504  
  4505  if (>list == head)
  4506  goto normal;
  4507  
> 4508  if (IS_ERR(pp) && PTR_ERR(pp) == -EINPROGRESS) {
  4509  ret = GRO_CONSUMED;
  4510  goto ok;
  4511  }

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


net/core/dev.c:4508:19-26: ERROR: PTR_ERR applied after initialization to constant on line 4452

2017-04-08 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   78d91a75b40fcf6a08506d308abf2413a29b7e30
commit: 25393d3fc055b76587fcc91627aee8c345400c3a net: Prepare gro for packet 
consuming gro callbacks
date:   8 weeks ago


coccinelle warnings: (new ones prefixed by >>)

>> net/core/dev.c:4508:19-26: ERROR: PTR_ERR applied after initialization to 
>> constant on line 4452

vim +4508 net/core/dev.c

  4446  --pinfo->nr_frags * sizeof(pinfo->frags[0]));
  4447  }
  4448  }
  4449  
  4450  static enum gro_result dev_gro_receive(struct napi_struct *napi, struct 
sk_buff *skb)
  4451  {
> 4452  struct sk_buff **pp = NULL;
  4453  struct packet_offload *ptype;
  4454  __be16 type = skb->protocol;
  4455  struct list_head *head = _base;
  4456  int same_flow;
  4457  enum gro_result ret;
  4458  int grow;
  4459  
  4460  if (!(skb->dev->features & NETIF_F_GRO))
  4461  goto normal;
  4462  
  4463  if (skb->csum_bad)
  4464  goto normal;
  4465  
  4466  gro_list_prepare(napi, skb);
  4467  
  4468  rcu_read_lock();
  4469  list_for_each_entry_rcu(ptype, head, list) {
  4470  if (ptype->type != type || 
!ptype->callbacks.gro_receive)
  4471  continue;
  4472  
  4473  skb_set_network_header(skb, skb_gro_offset(skb));
  4474  skb_reset_mac_len(skb);
  4475  NAPI_GRO_CB(skb)->same_flow = 0;
  4476  NAPI_GRO_CB(skb)->flush = skb_is_gso(skb) || 
skb_has_frag_list(skb);
  4477  NAPI_GRO_CB(skb)->free = 0;
  4478  NAPI_GRO_CB(skb)->encap_mark = 0;
  4479  NAPI_GRO_CB(skb)->recursion_counter = 0;
  4480  NAPI_GRO_CB(skb)->is_fou = 0;
  4481  NAPI_GRO_CB(skb)->is_atomic = 1;
  4482  NAPI_GRO_CB(skb)->gro_remcsum_start = 0;
  4483  
  4484  /* Setup for GRO checksum validation */
  4485  switch (skb->ip_summed) {
  4486  case CHECKSUM_COMPLETE:
  4487  NAPI_GRO_CB(skb)->csum = skb->csum;
  4488  NAPI_GRO_CB(skb)->csum_valid = 1;
  4489  NAPI_GRO_CB(skb)->csum_cnt = 0;
  4490  break;
  4491  case CHECKSUM_UNNECESSARY:
  4492  NAPI_GRO_CB(skb)->csum_cnt = skb->csum_level + 
1;
  4493  NAPI_GRO_CB(skb)->csum_valid = 0;
  4494  break;
  4495  default:
  4496  NAPI_GRO_CB(skb)->csum_cnt = 0;
  4497  NAPI_GRO_CB(skb)->csum_valid = 0;
  4498  }
  4499  
  4500  pp = ptype->callbacks.gro_receive(>gro_list, skb);
  4501  break;
  4502  }
  4503  rcu_read_unlock();
  4504  
  4505  if (>list == head)
  4506  goto normal;
  4507  
> 4508  if (IS_ERR(pp) && PTR_ERR(pp) == -EINPROGRESS) {
  4509  ret = GRO_CONSUMED;
  4510  goto ok;
  4511  }

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


[git pull] vfs fixes

2017-04-08 Thread Al Viro

The following changes since commit a71c9a1c779f2499fb2afc0553e543f18aff6edf:

  Linux 4.11-rc5 (2017-04-02 17:23:54 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git for-linus

for you to fetch changes up to a8e28440016bfb23bec266c4c66eacca6ea2d48b:

  Merge branch 'work.statx' into for-next (2017-04-03 01:06:59 -0400)


Al Viro (2):
  alpha: fix stack smashing in old_adjtimex(2)
  Merge branch 'work.statx' into for-next

Darrick J. Wong (1):
  xfs: report crtime and attribute flags to statx

David Howells (3):
  ext4: Add statx support
  statx: Reserve the top bit of the mask for future struct expansion
  statx: Include a mask for stx_attributes in struct statx

Eric Biggers (4):
  Documentation/filesystems: fix documentation for ->getattr()
  statx: reject unknown flags when using NULL path
  statx: remove incorrect part of vfs_statx() comment
  statx: optimize copy of struct statx to userspace

 Documentation/filesystems/Locking |  3 +-
 Documentation/filesystems/porting |  6 +++
 Documentation/filesystems/vfs.txt |  3 +-
 arch/alpha/kernel/osf_sys.c   |  2 +-
 fs/ext4/ext4.h|  1 +
 fs/ext4/file.c|  2 +-
 fs/ext4/inode.c   | 41 +--
 fs/ext4/namei.c   |  2 +
 fs/ext4/symlink.c |  3 ++
 fs/stat.c | 86 ++-
 fs/xfs/xfs_iops.c | 14 +++
 include/linux/stat.h  |  1 +
 include/uapi/linux/stat.h |  5 ++-
 samples/statx/test-statx.c| 12 --
 14 files changed, 120 insertions(+), 61 deletions(-)


[git pull] vfs fixes

2017-04-08 Thread Al Viro

The following changes since commit a71c9a1c779f2499fb2afc0553e543f18aff6edf:

  Linux 4.11-rc5 (2017-04-02 17:23:54 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git for-linus

for you to fetch changes up to a8e28440016bfb23bec266c4c66eacca6ea2d48b:

  Merge branch 'work.statx' into for-next (2017-04-03 01:06:59 -0400)


Al Viro (2):
  alpha: fix stack smashing in old_adjtimex(2)
  Merge branch 'work.statx' into for-next

Darrick J. Wong (1):
  xfs: report crtime and attribute flags to statx

David Howells (3):
  ext4: Add statx support
  statx: Reserve the top bit of the mask for future struct expansion
  statx: Include a mask for stx_attributes in struct statx

Eric Biggers (4):
  Documentation/filesystems: fix documentation for ->getattr()
  statx: reject unknown flags when using NULL path
  statx: remove incorrect part of vfs_statx() comment
  statx: optimize copy of struct statx to userspace

 Documentation/filesystems/Locking |  3 +-
 Documentation/filesystems/porting |  6 +++
 Documentation/filesystems/vfs.txt |  3 +-
 arch/alpha/kernel/osf_sys.c   |  2 +-
 fs/ext4/ext4.h|  1 +
 fs/ext4/file.c|  2 +-
 fs/ext4/inode.c   | 41 +--
 fs/ext4/namei.c   |  2 +
 fs/ext4/symlink.c |  3 ++
 fs/stat.c | 86 ++-
 fs/xfs/xfs_iops.c | 14 +++
 include/linux/stat.h  |  1 +
 include/uapi/linux/stat.h |  5 ++-
 samples/statx/test-statx.c| 12 --
 14 files changed, 120 insertions(+), 61 deletions(-)


Re: [PATCH v2 5/5] perf tools: Refactor the code to strip command name with {l,r}trim()

2017-04-08 Thread Taeung Song

Hi David,

On 04/09/2017 03:48 AM, David Ahern wrote:

On 4/7/17 8:52 PM, Taeung Song wrote:

After reading command name from /proc//status,
use ltrim() and rtrim() to strip command name, not using
just while loop, isspace() and etc.

Cc: David Ahern 
Cc: Don Zickus 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Signed-off-by: Taeung Song 
---
 tools/perf/util/event.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)



Acked-by: David Ahern 



Thank you!

 - Taeung


Re: [PATCH v2 5/5] perf tools: Refactor the code to strip command name with {l,r}trim()

2017-04-08 Thread Taeung Song

Hi David,

On 04/09/2017 03:48 AM, David Ahern wrote:

On 4/7/17 8:52 PM, Taeung Song wrote:

After reading command name from /proc//status,
use ltrim() and rtrim() to strip command name, not using
just while loop, isspace() and etc.

Cc: David Ahern 
Cc: Don Zickus 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Signed-off-by: Taeung Song 
---
 tools/perf/util/event.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)



Acked-by: David Ahern 



Thank you!

 - Taeung


Re: [PATCH 5/5] drivers: char: Replace bit operation functions with IDA allocator.

2017-04-08 Thread Varsha Rao
>> Replace bit operation functions with IDA allocator functions. As IDA
>> allocation is simpler.
>
> But why does this matter?

Few of the files in this driver is already using ida allocation. For maintaining
the uniformity I have used ida allocation.

Files using idr-ida interface
hw_random/virtio-rng.c
tpm/tpm-chip.c
ppdev.c
tpm/tpm-interface.c
tpm/tpm.h

>>   if (is_dynamic) {
>> - int i = find_first_zero_bit(misc_minors, DYNAMIC_MINORS);
>> + int i = ida_simple_get(_minors_ida, 0,
>> +DYNAMIC_MINORS, GFP_KERNEL);
>>
>>   if (i >= DYNAMIC_MINORS) {
>>   err = -EBUSY;
>>   goto out;
>> - }
>> + } else if (i < 0) {
>> + err = i;
>> + goto out;
>> + } else {
>>   misc->minor = DYNAMIC_MINORS - i - 1;
>> - set_bit(i, misc_minors);
>> + }
>
> Your indentation is now incorrect :(

I don't know but in the patch it has correct indentation as below.
-   set_bit(i, misc_minors);
+   }
  } else {
struct miscdevice *c;


>>   } else {
>>   struct miscdevice *c;
>>
>> @@ -222,7 +226,7 @@ int misc_register(struct miscdevice *misc)
>>   int i = DYNAMIC_MINORS - misc->minor - 1;
>>
>>   if (i < DYNAMIC_MINORS && i >= 0)
>> - clear_bit(i, misc_minors);
>> + ida_simple_remove(_minors_ida, i);
>>   misc->minor = MISC_DYNAMIC_MINOR;
>>   }
>>   err = PTR_ERR(misc->this_device);
>> @@ -258,7 +262,7 @@ void misc_deregister(struct miscdevice *misc)
>>   list_del(>list);
>>   device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
>>   if (i < DYNAMIC_MINORS && i >= 0)
>> - clear_bit(i, misc_minors);
>> + ida_simple_remove(_minors_ida, i);
>
> As much as I like the ida interface, I don't see why it is required to
> use it here, you have not provided any justification for this patch at
> all :(

Here by the usage of ida interface, allocation will be simpler, faster and
more space efficient. Also conversion  to it is simple. As I mentioned
earlier in this mail also to maintain uniformity of the driver.

Thanks,
Varsha Rao


Re: [PATCH 5/5] drivers: char: Replace bit operation functions with IDA allocator.

2017-04-08 Thread Varsha Rao
>> Replace bit operation functions with IDA allocator functions. As IDA
>> allocation is simpler.
>
> But why does this matter?

Few of the files in this driver is already using ida allocation. For maintaining
the uniformity I have used ida allocation.

Files using idr-ida interface
hw_random/virtio-rng.c
tpm/tpm-chip.c
ppdev.c
tpm/tpm-interface.c
tpm/tpm.h

>>   if (is_dynamic) {
>> - int i = find_first_zero_bit(misc_minors, DYNAMIC_MINORS);
>> + int i = ida_simple_get(_minors_ida, 0,
>> +DYNAMIC_MINORS, GFP_KERNEL);
>>
>>   if (i >= DYNAMIC_MINORS) {
>>   err = -EBUSY;
>>   goto out;
>> - }
>> + } else if (i < 0) {
>> + err = i;
>> + goto out;
>> + } else {
>>   misc->minor = DYNAMIC_MINORS - i - 1;
>> - set_bit(i, misc_minors);
>> + }
>
> Your indentation is now incorrect :(

I don't know but in the patch it has correct indentation as below.
-   set_bit(i, misc_minors);
+   }
  } else {
struct miscdevice *c;


>>   } else {
>>   struct miscdevice *c;
>>
>> @@ -222,7 +226,7 @@ int misc_register(struct miscdevice *misc)
>>   int i = DYNAMIC_MINORS - misc->minor - 1;
>>
>>   if (i < DYNAMIC_MINORS && i >= 0)
>> - clear_bit(i, misc_minors);
>> + ida_simple_remove(_minors_ida, i);
>>   misc->minor = MISC_DYNAMIC_MINOR;
>>   }
>>   err = PTR_ERR(misc->this_device);
>> @@ -258,7 +262,7 @@ void misc_deregister(struct miscdevice *misc)
>>   list_del(>list);
>>   device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
>>   if (i < DYNAMIC_MINORS && i >= 0)
>> - clear_bit(i, misc_minors);
>> + ida_simple_remove(_minors_ida, i);
>
> As much as I like the ida interface, I don't see why it is required to
> use it here, you have not provided any justification for this patch at
> all :(

Here by the usage of ida interface, allocation will be simpler, faster and
more space efficient. Also conversion  to it is simple. As I mentioned
earlier in this mail also to maintain uniformity of the driver.

Thanks,
Varsha Rao


Re: [PATCH] btrfs: scrub: use do_div() for 64-by-32 division

2017-04-08 Thread Adam Borowski
On Sat, Apr 08, 2017 at 11:07:37PM +0200, Adam Borowski wrote:
> Unbreaks ARM and possibly other 32-bit architectures.

Turns out those "other 32-bit architectures" happen to include i386.

A modular build:

ERROR: "__udivdi3" [fs/btrfs/btrfs.ko] undefined!

With the patch, i386 builds fine.

> Tested on amd64 where all is fine, and on arm (Odroid-U2) where scrub
> sometimes works, but, like most operations, randomly dies with some badness
> that doesn't look related: io_schedule, kunmap_high.  That badness wasn't
> there in 4.11-rc5, needs investigating, but since it's not connected to our
> issue at hand, I consider this patch sort-of tested.

Looks like current -next is pretty broken: while amd64 is ok, on an i386 box
(non-NX Pentium 4) it hangs very early during boot, way before filesystem
modules would be loaded.  Qemu boots but has random hangs.

So it looks like it's compile only for now...

-- 
⢀⣴⠾⠻⢶⣦⠀ Meow!
⣾⠁⢠⠒⠀⣿⡁
⢿⡄⠘⠷⠚⠋⠀ Collisions shmolisions, let's see them find a collision or second
⠈⠳⣄ preimage for double rot13!


Re: [PATCH] btrfs: scrub: use do_div() for 64-by-32 division

2017-04-08 Thread Adam Borowski
On Sat, Apr 08, 2017 at 11:07:37PM +0200, Adam Borowski wrote:
> Unbreaks ARM and possibly other 32-bit architectures.

Turns out those "other 32-bit architectures" happen to include i386.

A modular build:

ERROR: "__udivdi3" [fs/btrfs/btrfs.ko] undefined!

With the patch, i386 builds fine.

> Tested on amd64 where all is fine, and on arm (Odroid-U2) where scrub
> sometimes works, but, like most operations, randomly dies with some badness
> that doesn't look related: io_schedule, kunmap_high.  That badness wasn't
> there in 4.11-rc5, needs investigating, but since it's not connected to our
> issue at hand, I consider this patch sort-of tested.

Looks like current -next is pretty broken: while amd64 is ok, on an i386 box
(non-NX Pentium 4) it hangs very early during boot, way before filesystem
modules would be loaded.  Qemu boots but has random hangs.

So it looks like it's compile only for now...

-- 
⢀⣴⠾⠻⢶⣦⠀ Meow!
⣾⠁⢠⠒⠀⣿⡁
⢿⡄⠘⠷⠚⠋⠀ Collisions shmolisions, let's see them find a collision or second
⠈⠳⣄ preimage for double rot13!


Re: [Patch V2 2/2] x86/mm/numa: remove the numa_nodemask_from_meminfo()

2017-04-08 Thread Wei Yang
On Fri, Apr 7, 2017 at 2:48 AM, Borislav Petkov  wrote:
> On Thu, Apr 06, 2017 at 09:21:47PM +0300, Kirill A. Shutemov wrote:
>> > Long story short, something as trivial as this helps here:
>>
>> Yep. Works for me.
>>
>> Reported-and-tested-by: Kirill A. Shutemov 
>
> Thanks.
>
> Now, I'd really like to have more test coverage and be sure this
> "cleanup" doesn't break anything else so Wei, please grab tip/master,
> apply the oneliner from two messages ago, take Kirill's qemu cmdline
> and run all fake numa scenarios you can think of to make sure your
> cleanup doesn't break anything else.
>

Oops, sorry to bring in the regression with my cleanup.
I haven't noticed there is a kernel command line "numa=fake", which
is the cause of the crash I think.

So from my understanding, I am goting to do these tests:

1. all fake numa scenarios with Kirill's qemu command line
2. Real numa scenarios with following qemu command option
3. Baremetal

One more question, on the baremetal mathine, I can't change the
numa configuration, so there would be only one case. Do you have
some specific requirement?

Well, if I missed something, just let me know :-)

> Qemu can emulate real numa too, for example you can boot with:
>
> -smp 64 \
> -numa node,nodeid=0,cpus=1-8 \
> -numa node,nodeid=1,cpus=9-16 \
> -numa node,nodeid=2,cpus=17-24 \
> -numa node,nodeid=3,cpus=25-32 \
> -numa node,nodeid=4,cpus=0 \
> -numa node,nodeid=4,cpus=33-39 \
> -numa node,nodeid=5,cpus=40-47 \
> -numa node,nodeid=6,cpus=48-55 \
> -numa node,nodeid=7,cpus=56-63
>
> after configuring the kernel accordingly.
>
> Then, test baremetal too.
>
> numa_emulation() should give you an idea about possible options
> numa=fake takes. Documentation/x86/x86_64/boot-options.txt has some
> (all?) too.
>
> Thanks.
>
> --
> Regards/Gruss,
> Boris.
>
> Good mailing practices for 400: avoid top-posting and trim the reply.


Re: [Patch V2 2/2] x86/mm/numa: remove the numa_nodemask_from_meminfo()

2017-04-08 Thread Wei Yang
On Fri, Apr 7, 2017 at 2:48 AM, Borislav Petkov  wrote:
> On Thu, Apr 06, 2017 at 09:21:47PM +0300, Kirill A. Shutemov wrote:
>> > Long story short, something as trivial as this helps here:
>>
>> Yep. Works for me.
>>
>> Reported-and-tested-by: Kirill A. Shutemov 
>
> Thanks.
>
> Now, I'd really like to have more test coverage and be sure this
> "cleanup" doesn't break anything else so Wei, please grab tip/master,
> apply the oneliner from two messages ago, take Kirill's qemu cmdline
> and run all fake numa scenarios you can think of to make sure your
> cleanup doesn't break anything else.
>

Oops, sorry to bring in the regression with my cleanup.
I haven't noticed there is a kernel command line "numa=fake", which
is the cause of the crash I think.

So from my understanding, I am goting to do these tests:

1. all fake numa scenarios with Kirill's qemu command line
2. Real numa scenarios with following qemu command option
3. Baremetal

One more question, on the baremetal mathine, I can't change the
numa configuration, so there would be only one case. Do you have
some specific requirement?

Well, if I missed something, just let me know :-)

> Qemu can emulate real numa too, for example you can boot with:
>
> -smp 64 \
> -numa node,nodeid=0,cpus=1-8 \
> -numa node,nodeid=1,cpus=9-16 \
> -numa node,nodeid=2,cpus=17-24 \
> -numa node,nodeid=3,cpus=25-32 \
> -numa node,nodeid=4,cpus=0 \
> -numa node,nodeid=4,cpus=33-39 \
> -numa node,nodeid=5,cpus=40-47 \
> -numa node,nodeid=6,cpus=48-55 \
> -numa node,nodeid=7,cpus=56-63
>
> after configuring the kernel accordingly.
>
> Then, test baremetal too.
>
> numa_emulation() should give you an idea about possible options
> numa=fake takes. Documentation/x86/x86_64/boot-options.txt has some
> (all?) too.
>
> Thanks.
>
> --
> Regards/Gruss,
> Boris.
>
> Good mailing practices for 400: avoid top-posting and trim the reply.


audit regressions in 4.11

2017-04-08 Thread Seth Forshee
I've observed audit regressions in 4.11-rc when not using a userspace
audit daemon. The most obvious issue is that audit messages are not
appearing in dmesg anymore. If a sufficient number of audit messages are
generated the kernel will also start invoking the OOM killer.

It looks like previously, when there's no auditd in userspace kauditd
would call kauditd_hold_skb(), which prints the message using printk and
either frees the skb or queues it (with a limit on the number of queued
skb's by default).

Since 5b52330bbfe6 "audit: fix auditd/kernel connection state tracking"
when there's no auditd kauditd will instead use the retry queue, which
has no limit. But it will not process the retry queue when there's no
auditd, so messages pile up there indefinitely.

Thanks,
Seth


audit regressions in 4.11

2017-04-08 Thread Seth Forshee
I've observed audit regressions in 4.11-rc when not using a userspace
audit daemon. The most obvious issue is that audit messages are not
appearing in dmesg anymore. If a sufficient number of audit messages are
generated the kernel will also start invoking the OOM killer.

It looks like previously, when there's no auditd in userspace kauditd
would call kauditd_hold_skb(), which prints the message using printk and
either frees the skb or queues it (with a limit on the number of queued
skb's by default).

Since 5b52330bbfe6 "audit: fix auditd/kernel connection state tracking"
when there's no auditd kauditd will instead use the retry queue, which
has no limit. But it will not process the retry queue when there's no
auditd, so messages pile up there indefinitely.

Thanks,
Seth


Re: [PATCH v5 2/5] vfs: Add checks for filesystem timestamp limits

2017-04-08 Thread Deepa Dinamani
>> Allow read only mounts for filesystems that do not
>> have maximum timestamps beyond the y2038 expiry
>> timestamp.
>
> This option seems arbitrary and pointless.
>
> Nobody sane should ever enable it except for testing, but for testing
> it would be much better to simply specify what the limit should be:
> 2038 is not magical for all filesystems, because the base may be
> different.

Yes, the way the patch is right now, it is meant only for testing
y2038 readiness.
The feature is meant for system wide tests and not individual filesystem tests.

The original idea was to disallow writes on all filesystem mounts that
were not able to update times at the time of mount, meaning max time
supported by the filesystem should be greater than current system
time. But, then we end up with the problem of what to do about mounts
whose max time exceeds current time after mount. This can be handled
by some logic while updating inode times. But, maybe this level of
complexity is not required and we could just stick to the former use
case. And, just print a warning in the latter case. This is what
pushes the feature to be something more than y2038 readiness.

> And honestly, for testing, it would be much better to just make it a
> mount option rather than some crazy system-wide one.

The patch allows the y2038 number to be changed at compile time. I can
extend the sysctl and boot option to allow changing of this limit also
if that is preferred.

We also proposed the mount option route in the RFC. But, we received
no preferences/ comments. We proceeded with the sysctl option because
this allows us to extend this feature into disallowing writes on non
updatable time filesystems.

I could change this to providing a mount option instead if you think
that is better.

-Deepa


Re: [PATCH v5 2/5] vfs: Add checks for filesystem timestamp limits

2017-04-08 Thread Deepa Dinamani
>> Allow read only mounts for filesystems that do not
>> have maximum timestamps beyond the y2038 expiry
>> timestamp.
>
> This option seems arbitrary and pointless.
>
> Nobody sane should ever enable it except for testing, but for testing
> it would be much better to simply specify what the limit should be:
> 2038 is not magical for all filesystems, because the base may be
> different.

Yes, the way the patch is right now, it is meant only for testing
y2038 readiness.
The feature is meant for system wide tests and not individual filesystem tests.

The original idea was to disallow writes on all filesystem mounts that
were not able to update times at the time of mount, meaning max time
supported by the filesystem should be greater than current system
time. But, then we end up with the problem of what to do about mounts
whose max time exceeds current time after mount. This can be handled
by some logic while updating inode times. But, maybe this level of
complexity is not required and we could just stick to the former use
case. And, just print a warning in the latter case. This is what
pushes the feature to be something more than y2038 readiness.

> And honestly, for testing, it would be much better to just make it a
> mount option rather than some crazy system-wide one.

The patch allows the y2038 number to be changed at compile time. I can
extend the sysctl and boot option to allow changing of this limit also
if that is preferred.

We also proposed the mount option route in the RFC. But, we received
no preferences/ comments. We proceeded with the sysctl option because
this allows us to extend this feature into disallowing writes on non
updatable time filesystems.

I could change this to providing a mount option instead if you think
that is better.

-Deepa


[PATCH] mm/softoffline: Add page flag description in error paths

2017-04-08 Thread Anshuman Khandual
It helps to provide page flag description along with the raw value in
error paths during soft offline process. From sample experiments

Before the patch:

[  132.317977] soft offline: 0x6100: migration failed 1, type 388018
[  132.359057] soft offline: 0x7400: migration failed 1, type 388018

After the patch:

[   87.694325] soft offline: 0x5900: migration failed 1, type 388018 
(uptodate|dirty|head)
[   87.736273] soft offline: 0x6c00: migration failed 1, type 388018 
(uptodate|dirty|head)

Signed-off-by: Anshuman Khandual 
---
 mm/memory-failure.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 27f7210..fe64d77 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1543,8 +1543,8 @@ static int get_any_page(struct page *page, unsigned long 
pfn, int flags)
if (ret == 1 && !PageLRU(page)) {
/* Drop page reference which is from __get_any_page() */
put_hwpoison_page(page);
-   pr_info("soft_offline: %#lx: unknown non LRU page type 
%lx\n",
-   pfn, page->flags);
+   pr_info("soft_offline: %#lx: unknown non LRU page type 
%lx (%pGp)\n",
+   pfn, page->flags, >flags);
return -EIO;
}
}
@@ -1585,8 +1585,8 @@ static int soft_offline_huge_page(struct page *page, int 
flags)
ret = migrate_pages(, new_page, NULL, MPOL_MF_MOVE_ALL,
MIGRATE_SYNC, MR_MEMORY_FAILURE);
if (ret) {
-   pr_info("soft offline: %#lx: migration failed %d, type %lx\n",
-   pfn, ret, page->flags);
+   pr_info("soft offline: %#lx: migration failed %d, type %lx 
(%pGp)\n",
+   pfn, ret, page->flags, >flags);
/*
 * We know that soft_offline_huge_page() tries to migrate
 * only one hugepage pointed to by hpage, so we need not
@@ -1677,14 +1677,14 @@ static int __soft_offline_page(struct page *page, int 
flags)
if (!list_empty())
putback_movable_pages();
 
-   pr_info("soft offline: %#lx: migration failed %d, type 
%lx\n",
-   pfn, ret, page->flags);
+   pr_info("soft offline: %#lx: migration failed %d, type 
%lx (%pGp)\n",
+   pfn, ret, page->flags, >flags);
if (ret > 0)
ret = -EIO;
}
} else {
-   pr_info("soft offline: %#lx: isolation failed: %d, page count 
%d, type %lx\n",
-   pfn, ret, page_count(page), page->flags);
+   pr_info("soft offline: %#lx: isolation failed: %d, page count 
%d, type %lx (%pGp)\n",
+   pfn, ret, page_count(page), page->flags, >flags);
}
return ret;
 }
-- 
1.8.5.2



[PATCH] mm/softoffline: Add page flag description in error paths

2017-04-08 Thread Anshuman Khandual
It helps to provide page flag description along with the raw value in
error paths during soft offline process. From sample experiments

Before the patch:

[  132.317977] soft offline: 0x6100: migration failed 1, type 388018
[  132.359057] soft offline: 0x7400: migration failed 1, type 388018

After the patch:

[   87.694325] soft offline: 0x5900: migration failed 1, type 388018 
(uptodate|dirty|head)
[   87.736273] soft offline: 0x6c00: migration failed 1, type 388018 
(uptodate|dirty|head)

Signed-off-by: Anshuman Khandual 
---
 mm/memory-failure.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 27f7210..fe64d77 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1543,8 +1543,8 @@ static int get_any_page(struct page *page, unsigned long 
pfn, int flags)
if (ret == 1 && !PageLRU(page)) {
/* Drop page reference which is from __get_any_page() */
put_hwpoison_page(page);
-   pr_info("soft_offline: %#lx: unknown non LRU page type 
%lx\n",
-   pfn, page->flags);
+   pr_info("soft_offline: %#lx: unknown non LRU page type 
%lx (%pGp)\n",
+   pfn, page->flags, >flags);
return -EIO;
}
}
@@ -1585,8 +1585,8 @@ static int soft_offline_huge_page(struct page *page, int 
flags)
ret = migrate_pages(, new_page, NULL, MPOL_MF_MOVE_ALL,
MIGRATE_SYNC, MR_MEMORY_FAILURE);
if (ret) {
-   pr_info("soft offline: %#lx: migration failed %d, type %lx\n",
-   pfn, ret, page->flags);
+   pr_info("soft offline: %#lx: migration failed %d, type %lx 
(%pGp)\n",
+   pfn, ret, page->flags, >flags);
/*
 * We know that soft_offline_huge_page() tries to migrate
 * only one hugepage pointed to by hpage, so we need not
@@ -1677,14 +1677,14 @@ static int __soft_offline_page(struct page *page, int 
flags)
if (!list_empty())
putback_movable_pages();
 
-   pr_info("soft offline: %#lx: migration failed %d, type 
%lx\n",
-   pfn, ret, page->flags);
+   pr_info("soft offline: %#lx: migration failed %d, type 
%lx (%pGp)\n",
+   pfn, ret, page->flags, >flags);
if (ret > 0)
ret = -EIO;
}
} else {
-   pr_info("soft offline: %#lx: isolation failed: %d, page count 
%d, type %lx\n",
-   pfn, ret, page_count(page), page->flags);
+   pr_info("soft offline: %#lx: isolation failed: %d, page count 
%d, type %lx (%pGp)\n",
+   pfn, ret, page_count(page), page->flags, >flags);
}
return ret;
 }
-- 
1.8.5.2



Re: [PATCH] clk: zte: Mark pll config tables as const

2017-04-08 Thread Shawn Guo
On Sat, Apr 8, 2017 at 3:23 AM, Stephen Boyd  wrote:
>
> These should be const.
>
> Cc: Shawn Guo 
> Cc: Jun Nie 
> Signed-off-by: Stephen Boyd 

Acked-by: Shawn Guo 


Re: [PATCH] clk: zte: Mark pll config tables as const

2017-04-08 Thread Shawn Guo
On Sat, Apr 8, 2017 at 3:23 AM, Stephen Boyd  wrote:
>
> These should be const.
>
> Cc: Shawn Guo 
> Cc: Jun Nie 
> Signed-off-by: Stephen Boyd 

Acked-by: Shawn Guo 


Re: [RFC] calc_memmap_size() isn't accurate and one suggestion to improve

2017-04-08 Thread Wei Yang
On Mon, Apr 03, 2017 at 11:18:19AM +0200, Michal Hocko wrote:
>On Tue 28-03-17 09:11:37, Wei Yang wrote:
>> Hi, masters,
>> 
>> # What I found
>> 
>> I found the function calc_memmap_size() may not be that accurate to get the
>> pages for memmap.
>> 
>> The reason is:
>> 
>> > memmap is allocated on a node base,
>> > while the calculation is on a zone base
>> 
>> This applies both to SPARSEMEM and FLATMEM.
>> 
>> For example, on my laptop with 6G memory, all the memmap space is allocated
>> from ZONE_NORMAL.
>
>Please try to be more specific. Why is this a problem? Are you trying to
>fix some bad behavior or you want to make it more optimal?
>
>I am sorry I didn't look closer into your proposal but I am quite busy
>and other people are probably in a similar situation. If you want to get
>a proper feedback please try to state the problem and be explicit if it
>is user observable.

Michal

Glad to hear from you.

Sure, let me do more investigation on this and try some experiment to see
whether this change is observable.

Have a nice day~

>-- 
>Michal Hocko
>SUSE Labs

-- 
Wei Yang
Help you, Help me


signature.asc
Description: PGP signature


Re: [RFC] calc_memmap_size() isn't accurate and one suggestion to improve

2017-04-08 Thread Wei Yang
On Mon, Apr 03, 2017 at 11:18:19AM +0200, Michal Hocko wrote:
>On Tue 28-03-17 09:11:37, Wei Yang wrote:
>> Hi, masters,
>> 
>> # What I found
>> 
>> I found the function calc_memmap_size() may not be that accurate to get the
>> pages for memmap.
>> 
>> The reason is:
>> 
>> > memmap is allocated on a node base,
>> > while the calculation is on a zone base
>> 
>> This applies both to SPARSEMEM and FLATMEM.
>> 
>> For example, on my laptop with 6G memory, all the memmap space is allocated
>> from ZONE_NORMAL.
>
>Please try to be more specific. Why is this a problem? Are you trying to
>fix some bad behavior or you want to make it more optimal?
>
>I am sorry I didn't look closer into your proposal but I am quite busy
>and other people are probably in a similar situation. If you want to get
>a proper feedback please try to state the problem and be explicit if it
>is user observable.

Michal

Glad to hear from you.

Sure, let me do more investigation on this and try some experiment to see
whether this change is observable.

Have a nice day~

>-- 
>Michal Hocko
>SUSE Labs

-- 
Wei Yang
Help you, Help me


signature.asc
Description: PGP signature


[PATCH] ide: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/ide/ide-probe.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index a74ae8df..0235625 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1183,9 +1183,7 @@ static void ide_init_port_data(ide_hwif_t *hwif, unsigned 
int index)
 
spin_lock_init(>lock);
 
-   init_timer(>timer);
-   hwif->timer.function = _timer_expiry;
-   hwif->timer.data = (unsigned long)hwif;
+   setup_timer(>timer, _timer_expiry, (unsigned long)hwif);
 
init_completion(>gendev_rel_comp);
 
-- 
2.9.3



[PATCH] SGI-XP: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/misc/sgi-xp/xpc_main.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
index 7f32712..a1b6f75 100644
--- a/drivers/misc/sgi-xp/xpc_main.c
+++ b/drivers/misc/sgi-xp/xpc_main.c
@@ -931,10 +931,9 @@ xpc_setup_partitions(void)
part->act_state = XPC_P_AS_INACTIVE;
XPC_SET_REASON(part, 0, 0);
 
-   init_timer(>disengage_timer);
-   part->disengage_timer.function =
-   xpc_timeout_partition_disengage;
-   part->disengage_timer.data = (unsigned long)part;
+   setup_timer(>disengage_timer,
+   xpc_timeout_partition_disengage,
+   (unsigned long)part);
 
part->setup_state = XPC_P_SS_UNSET;
init_waitqueue_head(>teardown_wq);
-- 
2.9.3



[PATCH] ide: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/ide/ide-probe.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index a74ae8df..0235625 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1183,9 +1183,7 @@ static void ide_init_port_data(ide_hwif_t *hwif, unsigned 
int index)
 
spin_lock_init(>lock);
 
-   init_timer(>timer);
-   hwif->timer.function = _timer_expiry;
-   hwif->timer.data = (unsigned long)hwif;
+   setup_timer(>timer, _timer_expiry, (unsigned long)hwif);
 
init_completion(>gendev_rel_comp);
 
-- 
2.9.3



[PATCH] SGI-XP: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/misc/sgi-xp/xpc_main.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
index 7f32712..a1b6f75 100644
--- a/drivers/misc/sgi-xp/xpc_main.c
+++ b/drivers/misc/sgi-xp/xpc_main.c
@@ -931,10 +931,9 @@ xpc_setup_partitions(void)
part->act_state = XPC_P_AS_INACTIVE;
XPC_SET_REASON(part, 0, 0);
 
-   init_timer(>disengage_timer);
-   part->disengage_timer.function =
-   xpc_timeout_partition_disengage;
-   part->disengage_timer.data = (unsigned long)part;
+   setup_timer(>disengage_timer,
+   xpc_timeout_partition_disengage,
+   (unsigned long)part);
 
part->setup_state = XPC_P_SS_UNSET;
init_waitqueue_head(>teardown_wq);
-- 
2.9.3



[PATCH] i2c: img-scb: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/i2c/busses/i2c-img-scb.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
index db8e8b4..84fb35f 100644
--- a/drivers/i2c/busses/i2c-img-scb.c
+++ b/drivers/i2c/busses/i2c-img-scb.c
@@ -1362,9 +1362,8 @@ static int img_i2c_probe(struct platform_device *pdev)
}
 
/* Set up the exception check timer */
-   init_timer(>check_timer);
-   i2c->check_timer.function = img_i2c_check_timer;
-   i2c->check_timer.data = (unsigned long)i2c;
+   setup_timer(>check_timer, img_i2c_check_timer,
+   (unsigned long)i2c);
 
i2c->bitrate = timings[0].max_bitrate;
if (!of_property_read_u32(node, "clock-frequency", ))
-- 
2.9.3



[PATCH] i2c: img-scb: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/i2c/busses/i2c-img-scb.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
index db8e8b4..84fb35f 100644
--- a/drivers/i2c/busses/i2c-img-scb.c
+++ b/drivers/i2c/busses/i2c-img-scb.c
@@ -1362,9 +1362,8 @@ static int img_i2c_probe(struct platform_device *pdev)
}
 
/* Set up the exception check timer */
-   init_timer(>check_timer);
-   i2c->check_timer.function = img_i2c_check_timer;
-   i2c->check_timer.data = (unsigned long)i2c;
+   setup_timer(>check_timer, img_i2c_check_timer,
+   (unsigned long)i2c);
 
i2c->bitrate = timings[0].max_bitrate;
if (!of_property_read_u32(node, "clock-frequency", ))
-- 
2.9.3



[PATCH] dmaengine: ioat: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/dma/ioat/init.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c
index cc5259b..6ad4384 100644
--- a/drivers/dma/ioat/init.c
+++ b/drivers/dma/ioat/init.c
@@ -760,9 +760,7 @@ ioat_init_channel(struct ioatdma_device *ioat_dma,
dma_cookie_init(_chan->dma_chan);
list_add_tail(_chan->dma_chan.device_node, >channels);
ioat_dma->idx[idx] = ioat_chan;
-   init_timer(_chan->timer);
-   ioat_chan->timer.function = ioat_timer_event;
-   ioat_chan->timer.data = data;
+   setup_timer(_chan->timer, ioat_timer_event, data);
tasklet_init(_chan->cleanup_task, ioat_cleanup_event, data);
 }
 
-- 
2.9.3



[PATCH] dmaengine: ioat: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/dma/ioat/init.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c
index cc5259b..6ad4384 100644
--- a/drivers/dma/ioat/init.c
+++ b/drivers/dma/ioat/init.c
@@ -760,9 +760,7 @@ ioat_init_channel(struct ioatdma_device *ioat_dma,
dma_cookie_init(_chan->dma_chan);
list_add_tail(_chan->dma_chan.device_node, >channels);
ioat_dma->idx[idx] = ioat_chan;
-   init_timer(_chan->timer);
-   ioat_chan->timer.function = ioat_timer_event;
-   ioat_chan->timer.data = data;
+   setup_timer(_chan->timer, ioat_timer_event, data);
tasklet_init(_chan->cleanup_task, ioat_cleanup_event, data);
 }
 
-- 
2.9.3



[PATCH 4/4] Input: turbografx - use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/input/joystick/turbografx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/joystick/turbografx.c 
b/drivers/input/joystick/turbografx.c
index 77f575d..a1fdc75 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -200,9 +200,7 @@ static void tgfx_attach(struct parport *pp)
mutex_init(>sem);
tgfx->pd = pd;
tgfx->parportno = pp->number;
-   init_timer(>timer);
-   tgfx->timer.data = (long) tgfx;
-   tgfx->timer.function = tgfx_timer;
+   setup_timer(>timer, tgfx_timer, (long)tgfx);
 
for (i = 0; i < n_devs; i++) {
if (n_buttons[i] < 1)
-- 
2.9.3



[PATCH 2/4] Input: gameport - use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/input/gameport/gameport.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/input/gameport/gameport.c 
b/drivers/input/gameport/gameport.c
index 092cc41..cedc665 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -542,9 +542,8 @@ static void gameport_init_port(struct gameport *gameport)
 
INIT_LIST_HEAD(>node);
spin_lock_init(>timer_lock);
-   init_timer(>poll_timer);
-   gameport->poll_timer.function = gameport_run_poll_handler;
-   gameport->poll_timer.data = (unsigned long)gameport;
+   setup_timer(>poll_timer, gameport_run_poll_handler,
+   (unsigned long)gameport);
 }
 
 /*
-- 
2.9.3



[PATCH 3/4] Input: locomokbd - use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/input/keyboard/locomokbd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/input/keyboard/locomokbd.c 
b/drivers/input/keyboard/locomokbd.c
index c94d610..0d74312d 100644
--- a/drivers/input/keyboard/locomokbd.c
+++ b/drivers/input/keyboard/locomokbd.c
@@ -264,9 +264,8 @@ static int locomokbd_probe(struct locomo_dev *dev)
 
spin_lock_init(>lock);
 
-   init_timer(>timer);
-   locomokbd->timer.function = locomokbd_timer_callback;
-   locomokbd->timer.data = (unsigned long) locomokbd;
+   setup_timer(>timer, locomokbd_timer_callback,
+   (unsigned long)locomokbd);
 
locomokbd->suspend_jiffies = jiffies;
 
-- 
2.9.3



[PATCH 2/4] Input: gameport - use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/input/gameport/gameport.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/input/gameport/gameport.c 
b/drivers/input/gameport/gameport.c
index 092cc41..cedc665 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -542,9 +542,8 @@ static void gameport_init_port(struct gameport *gameport)
 
INIT_LIST_HEAD(>node);
spin_lock_init(>timer_lock);
-   init_timer(>poll_timer);
-   gameport->poll_timer.function = gameport_run_poll_handler;
-   gameport->poll_timer.data = (unsigned long)gameport;
+   setup_timer(>poll_timer, gameport_run_poll_handler,
+   (unsigned long)gameport);
 }
 
 /*
-- 
2.9.3



[PATCH 3/4] Input: locomokbd - use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/input/keyboard/locomokbd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/input/keyboard/locomokbd.c 
b/drivers/input/keyboard/locomokbd.c
index c94d610..0d74312d 100644
--- a/drivers/input/keyboard/locomokbd.c
+++ b/drivers/input/keyboard/locomokbd.c
@@ -264,9 +264,8 @@ static int locomokbd_probe(struct locomo_dev *dev)
 
spin_lock_init(>lock);
 
-   init_timer(>timer);
-   locomokbd->timer.function = locomokbd_timer_callback;
-   locomokbd->timer.data = (unsigned long) locomokbd;
+   setup_timer(>timer, locomokbd_timer_callback,
+   (unsigned long)locomokbd);
 
locomokbd->suspend_jiffies = jiffies;
 
-- 
2.9.3



[PATCH 4/4] Input: turbografx - use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/input/joystick/turbografx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/joystick/turbografx.c 
b/drivers/input/joystick/turbografx.c
index 77f575d..a1fdc75 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -200,9 +200,7 @@ static void tgfx_attach(struct parport *pp)
mutex_init(>sem);
tgfx->pd = pd;
tgfx->parportno = pp->number;
-   init_timer(>timer);
-   tgfx->timer.data = (long) tgfx;
-   tgfx->timer.function = tgfx_timer;
+   setup_timer(>timer, tgfx_timer, (long)tgfx);
 
for (i = 0; i < n_devs; i++) {
if (n_buttons[i] < 1)
-- 
2.9.3



[PATCH 1/4] Input: db9 - use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/input/joystick/db9.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c
index da32609..f4ad83e 100644
--- a/drivers/input/joystick/db9.c
+++ b/drivers/input/joystick/db9.c
@@ -609,9 +609,7 @@ static void db9_attach(struct parport *pp)
db9->pd = pd;
db9->mode = mode;
db9->parportno = pp->number;
-   init_timer(>timer);
-   db9->timer.data = (long) db9;
-   db9->timer.function = db9_timer;
+   setup_timer(>timer, db9_timer, (long)db9);
 
for (i = 0; i < (min(db9_mode->n_pads, DB9_MAX_DEVICES)); i++) {
 
-- 
2.9.3



[PATCH 1/4] Input: db9 - use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/input/joystick/db9.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c
index da32609..f4ad83e 100644
--- a/drivers/input/joystick/db9.c
+++ b/drivers/input/joystick/db9.c
@@ -609,9 +609,7 @@ static void db9_attach(struct parport *pp)
db9->pd = pd;
db9->mode = mode;
db9->parportno = pp->number;
-   init_timer(>timer);
-   db9->timer.data = (long) db9;
-   db9->timer.function = db9_timer;
+   setup_timer(>timer, db9_timer, (long)db9);
 
for (i = 0; i < (min(db9_mode->n_pads, DB9_MAX_DEVICES)); i++) {
 
-- 
2.9.3



[PATCH] Remove cpuset_update_active_cpus()'s parameter.

2017-04-08 Thread Rakib Mullick
In cpuset_update_active_cpus(), cpu_online isn't used anymore. Remove
it.

Signed-off-by: Rakib Mullick
---
 include/linux/cpuset.h | 4 ++--
 kernel/cgroup/cpuset.c | 2 +-
 kernel/sched/core.c| 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 611fce5..119a3f9 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -42,7 +42,7 @@ static inline void cpuset_dec(void)
 
 extern int cpuset_init(void);
 extern void cpuset_init_smp(void);
-extern void cpuset_update_active_cpus(bool cpu_online);
+extern void cpuset_update_active_cpus(void);
 extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask);
 extern void cpuset_cpus_allowed_fallback(struct task_struct *p);
 extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
@@ -155,7 +155,7 @@ static inline bool cpusets_enabled(void) { return false; }
 static inline int cpuset_init(void) { return 0; }
 static inline void cpuset_init_smp(void) {}
 
-static inline void cpuset_update_active_cpus(bool cpu_online)
+static inline void cpuset_update_active_cpus(void)
 {
partition_sched_domains(1, NULL, NULL);
 }
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 0f41292..d6e8ded 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2354,7 +2354,7 @@ static void cpuset_hotplug_workfn(struct work_struct 
*work)
rebuild_sched_domains();
 }
 
-void cpuset_update_active_cpus(bool cpu_online)
+void cpuset_update_active_cpus(void)
 {
/*
 * We're inside cpu hotplug critical region which usually nests
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3b31fc0..430b046 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5732,7 +5732,7 @@ static void cpuset_cpu_active(void)
 * cpuset configurations.
 */
}
-   cpuset_update_active_cpus(true);
+   cpuset_update_active_cpus();
 }
 
 static int cpuset_cpu_inactive(unsigned int cpu)
@@ -5755,7 +5755,7 @@ static int cpuset_cpu_inactive(unsigned int cpu)
 
if (overflow)
return -EBUSY;
-   cpuset_update_active_cpus(false);
+   cpuset_update_active_cpus();
} else {
num_cpus_frozen++;
partition_sched_domains(1, NULL, NULL);
-- 
2.9.3



[PATCH] Remove cpuset_update_active_cpus()'s parameter.

2017-04-08 Thread Rakib Mullick
In cpuset_update_active_cpus(), cpu_online isn't used anymore. Remove
it.

Signed-off-by: Rakib Mullick
---
 include/linux/cpuset.h | 4 ++--
 kernel/cgroup/cpuset.c | 2 +-
 kernel/sched/core.c| 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 611fce5..119a3f9 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -42,7 +42,7 @@ static inline void cpuset_dec(void)
 
 extern int cpuset_init(void);
 extern void cpuset_init_smp(void);
-extern void cpuset_update_active_cpus(bool cpu_online);
+extern void cpuset_update_active_cpus(void);
 extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask);
 extern void cpuset_cpus_allowed_fallback(struct task_struct *p);
 extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
@@ -155,7 +155,7 @@ static inline bool cpusets_enabled(void) { return false; }
 static inline int cpuset_init(void) { return 0; }
 static inline void cpuset_init_smp(void) {}
 
-static inline void cpuset_update_active_cpus(bool cpu_online)
+static inline void cpuset_update_active_cpus(void)
 {
partition_sched_domains(1, NULL, NULL);
 }
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 0f41292..d6e8ded 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2354,7 +2354,7 @@ static void cpuset_hotplug_workfn(struct work_struct 
*work)
rebuild_sched_domains();
 }
 
-void cpuset_update_active_cpus(bool cpu_online)
+void cpuset_update_active_cpus(void)
 {
/*
 * We're inside cpu hotplug critical region which usually nests
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3b31fc0..430b046 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5732,7 +5732,7 @@ static void cpuset_cpu_active(void)
 * cpuset configurations.
 */
}
-   cpuset_update_active_cpus(true);
+   cpuset_update_active_cpus();
 }
 
 static int cpuset_cpu_inactive(unsigned int cpu)
@@ -5755,7 +5755,7 @@ static int cpuset_cpu_inactive(unsigned int cpu)
 
if (overflow)
return -EBUSY;
-   cpuset_update_active_cpus(false);
+   cpuset_update_active_cpus();
} else {
num_cpus_frozen++;
partition_sched_domains(1, NULL, NULL);
-- 
2.9.3



[PATCH 04/12] [media] cx18: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/cx18/cx18-streams.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-streams.c 
b/drivers/media/pci/cx18/cx18-streams.c
index 7c93814..3c45e007 100644
--- a/drivers/media/pci/cx18/cx18-streams.c
+++ b/drivers/media/pci/cx18/cx18-streams.c
@@ -282,9 +282,7 @@ static void cx18_stream_init(struct cx18 *cx, int type)
INIT_WORK(>out_work_order, cx18_out_work_handler);
 
INIT_LIST_HEAD(>vb_capture);
-   s->vb_timeout.function = cx18_vb_timeout;
-   s->vb_timeout.data = (unsigned long)s;
-   init_timer(>vb_timeout);
+   setup_timer(>vb_timeout, cx18_vb_timeout, (unsigned long)s);
spin_lock_init(>vb_lock);
if (type == CX18_ENC_STREAM_TYPE_YUV) {
spin_lock_init(>vbuf_q_lock);
-- 
2.9.3



[PATCH 04/12] [media] cx18: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/cx18/cx18-streams.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-streams.c 
b/drivers/media/pci/cx18/cx18-streams.c
index 7c93814..3c45e007 100644
--- a/drivers/media/pci/cx18/cx18-streams.c
+++ b/drivers/media/pci/cx18/cx18-streams.c
@@ -282,9 +282,7 @@ static void cx18_stream_init(struct cx18 *cx, int type)
INIT_WORK(>out_work_order, cx18_out_work_handler);
 
INIT_LIST_HEAD(>vb_capture);
-   s->vb_timeout.function = cx18_vb_timeout;
-   s->vb_timeout.data = (unsigned long)s;
-   init_timer(>vb_timeout);
+   setup_timer(>vb_timeout, cx18_vb_timeout, (unsigned long)s);
spin_lock_init(>vb_lock);
if (type == CX18_ENC_STREAM_TYPE_YUV) {
spin_lock_init(>vbuf_q_lock);
-- 
2.9.3



[PATCH 08/12] [media] fsl-viu: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/platform/fsl-viu.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c
index ae8c6b3..97e164b 100644
--- a/drivers/media/platform/fsl-viu.c
+++ b/drivers/media/platform/fsl-viu.c
@@ -1466,9 +1466,8 @@ static int viu_of_probe(struct platform_device *op)
viu_dev->decoder = v4l2_i2c_new_subdev(_dev->v4l2_dev, ad,
"saa7113", VIU_VIDEO_DECODER_ADDR, NULL);
 
-   viu_dev->vidq.timeout.function = viu_vid_timeout;
-   viu_dev->vidq.timeout.data = (unsigned long)viu_dev;
-   init_timer(_dev->vidq.timeout);
+   setup_timer(_dev->vidq.timeout, viu_vid_timeout,
+   (unsigned long)viu_dev);
viu_dev->std = V4L2_STD_NTSC_M;
viu_dev->first = 1;
 
-- 
2.9.3



[PATCH 08/12] [media] fsl-viu: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/platform/fsl-viu.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c
index ae8c6b3..97e164b 100644
--- a/drivers/media/platform/fsl-viu.c
+++ b/drivers/media/platform/fsl-viu.c
@@ -1466,9 +1466,8 @@ static int viu_of_probe(struct platform_device *op)
viu_dev->decoder = v4l2_i2c_new_subdev(_dev->v4l2_dev, ad,
"saa7113", VIU_VIDEO_DECODER_ADDR, NULL);
 
-   viu_dev->vidq.timeout.function = viu_vid_timeout;
-   viu_dev->vidq.timeout.data = (unsigned long)viu_dev;
-   init_timer(_dev->vidq.timeout);
+   setup_timer(_dev->vidq.timeout, viu_vid_timeout,
+   (unsigned long)viu_dev);
viu_dev->std = V4L2_STD_NTSC_M;
viu_dev->first = 1;
 
-- 
2.9.3



[PATCH 12/12] [media] imon: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/rc/imon.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 89823d2..3489010 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -2412,9 +2412,8 @@ static struct imon_context *imon_init_intf1(struct 
usb_interface *intf,
mutex_lock(>lock);
 
if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) {
-   init_timer(>ttimer);
-   ictx->ttimer.data = (unsigned long)ictx;
-   ictx->ttimer.function = imon_touch_display_timeout;
+   setup_timer(>ttimer, imon_touch_display_timeout,
+   (unsigned long)ictx);
}
 
ictx->usbdev_intf1 = usb_get_dev(interface_to_usbdev(intf));
-- 
2.9.3



[PATCH 10/12] [media] c8sectpfe: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c 
b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
index 7652ce2..59280ac 100644
--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
@@ -865,9 +865,8 @@ static int c8sectpfe_probe(struct platform_device *pdev)
}
 
/* Setup timer interrupt */
-   init_timer(>timer);
-   fei->timer.function = c8sectpfe_timer_interrupt;
-   fei->timer.data = (unsigned long)fei;
+   setup_timer(>timer, c8sectpfe_timer_interrupt,
+   (unsigned long)fei);
 
mutex_init(>lock);
 
-- 
2.9.3



[PATCH 12/12] [media] imon: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/rc/imon.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 89823d2..3489010 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -2412,9 +2412,8 @@ static struct imon_context *imon_init_intf1(struct 
usb_interface *intf,
mutex_lock(>lock);
 
if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) {
-   init_timer(>ttimer);
-   ictx->ttimer.data = (unsigned long)ictx;
-   ictx->ttimer.function = imon_touch_display_timeout;
+   setup_timer(>ttimer, imon_touch_display_timeout,
+   (unsigned long)ictx);
}
 
ictx->usbdev_intf1 = usb_get_dev(interface_to_usbdev(intf));
-- 
2.9.3



[PATCH 10/12] [media] c8sectpfe: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c 
b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
index 7652ce2..59280ac 100644
--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
@@ -865,9 +865,8 @@ static int c8sectpfe_probe(struct platform_device *pdev)
}
 
/* Setup timer interrupt */
-   init_timer(>timer);
-   fei->timer.function = c8sectpfe_timer_interrupt;
-   fei->timer.data = (unsigned long)fei;
+   setup_timer(>timer, c8sectpfe_timer_interrupt,
+   (unsigned long)fei);
 
mutex_init(>lock);
 
-- 
2.9.3



[PATCH 09/12] [media] s5p-mfc: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index bb0a588..2c363aa 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1266,9 +1266,8 @@ static int s5p_mfc_probe(struct platform_device *pdev)
dev->hw_lock = 0;
INIT_WORK(>watchdog_work, s5p_mfc_watchdog_worker);
atomic_set(>watchdog_cnt, 0);
-   init_timer(>watchdog_timer);
-   dev->watchdog_timer.data = (unsigned long)dev;
-   dev->watchdog_timer.function = s5p_mfc_watchdog;
+   setup_timer(>watchdog_timer, s5p_mfc_watchdog,
+   (unsigned long)dev);
 
/* Initialize HW ops and commands based on MFC version */
s5p_mfc_init_hw_ops(dev);
-- 
2.9.3



[PATCH 09/12] [media] s5p-mfc: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index bb0a588..2c363aa 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1266,9 +1266,8 @@ static int s5p_mfc_probe(struct platform_device *pdev)
dev->hw_lock = 0;
INIT_WORK(>watchdog_work, s5p_mfc_watchdog_worker);
atomic_set(>watchdog_cnt, 0);
-   init_timer(>watchdog_timer);
-   dev->watchdog_timer.data = (unsigned long)dev;
-   dev->watchdog_timer.function = s5p_mfc_watchdog;
+   setup_timer(>watchdog_timer, s5p_mfc_watchdog,
+   (unsigned long)dev);
 
/* Initialize HW ops and commands based on MFC version */
s5p_mfc_init_hw_ops(dev);
-- 
2.9.3



[PATCH 06/12] [media] netup_unidvb: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/netup_unidvb/netup_unidvb_core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c 
b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
index 191bd82..983 100644
--- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
+++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
@@ -663,9 +663,8 @@ static int netup_unidvb_dma_init(struct netup_unidvb_dev 
*ndev, int num)
spin_lock_init(>lock);
INIT_WORK(>work, netup_unidvb_dma_worker);
INIT_LIST_HEAD(>free_buffers);
-   dma->timeout.function = netup_unidvb_dma_timeout;
-   dma->timeout.data = (unsigned long)dma;
-   init_timer(>timeout);
+   setup_timer(>timeout, netup_unidvb_dma_timeout,
+   (unsigned long)dma);
dma->ring_buffer_size = ndev->dma_size / 2;
dma->addr_virt = ndev->dma_virt + dma->ring_buffer_size * num;
dma->addr_phys = (dma_addr_t)((u64)ndev->dma_phys +
-- 
2.9.3



[PATCH 06/12] [media] netup_unidvb: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/netup_unidvb/netup_unidvb_core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c 
b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
index 191bd82..983 100644
--- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
+++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
@@ -663,9 +663,8 @@ static int netup_unidvb_dma_init(struct netup_unidvb_dev 
*ndev, int num)
spin_lock_init(>lock);
INIT_WORK(>work, netup_unidvb_dma_worker);
INIT_LIST_HEAD(>free_buffers);
-   dma->timeout.function = netup_unidvb_dma_timeout;
-   dma->timeout.data = (unsigned long)dma;
-   init_timer(>timeout);
+   setup_timer(>timeout, netup_unidvb_dma_timeout,
+   (unsigned long)dma);
dma->ring_buffer_size = ndev->dma_size / 2;
dma->addr_virt = ndev->dma_virt + dma->ring_buffer_size * num;
dma->addr_phys = (dma_addr_t)((u64)ndev->dma_phys +
-- 
2.9.3



[PATCH 07/12] [media] av7110: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/ttpci/av7110_ir.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/ttpci/av7110_ir.c 
b/drivers/media/pci/ttpci/av7110_ir.c
index 10e28f0..ca05198 100644
--- a/drivers/media/pci/ttpci/av7110_ir.c
+++ b/drivers/media/pci/ttpci/av7110_ir.c
@@ -333,9 +333,8 @@ int av7110_ir_init(struct av7110 *av7110)
av_list[av_cnt++] = av7110;
av7110_check_ir_config(av7110, true);
 
-   init_timer(>ir.keyup_timer);
-   av7110->ir.keyup_timer.function = av7110_emit_keyup;
-   av7110->ir.keyup_timer.data = (unsigned long) >ir;
+   setup_timer(>ir.keyup_timer, av7110_emit_keyup,
+   (unsigned long)>ir);
 
input_dev = input_allocate_device();
if (!input_dev)
-- 
2.9.3



[PATCH 03/12] [media] bt8xx: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/bt8xx/bttv-driver.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c 
b/drivers/media/pci/bt8xx/bttv-driver.c
index fb4aefb..ed319f1 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -4043,9 +4043,7 @@ static int bttv_probe(struct pci_dev *dev, const struct 
pci_device_id *pci_id)
INIT_LIST_HEAD(>capture);
INIT_LIST_HEAD(>vcapture);
 
-   init_timer(>timeout);
-   btv->timeout.function = bttv_irq_timeout;
-   btv->timeout.data = (unsigned long)btv;
+   setup_timer(>timeout, bttv_irq_timeout, (unsigned long)btv);
 
btv->i2c_rc = -1;
btv->tuner_type  = UNSET;
-- 
2.9.3



[PATCH 05/12] [media] ivtv: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/ivtv/ivtv-driver.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/ivtv/ivtv-driver.c 
b/drivers/media/pci/ivtv/ivtv-driver.c
index a71a03e..e8fa99b 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.c
+++ b/drivers/media/pci/ivtv/ivtv-driver.c
@@ -770,9 +770,8 @@ static int ivtv_init_struct1(struct ivtv *itv)
init_waitqueue_head(>event_waitq);
init_waitqueue_head(>vsync_waitq);
init_waitqueue_head(>dma_waitq);
-   init_timer(>dma_timer);
-   itv->dma_timer.function = ivtv_unfinished_dma;
-   itv->dma_timer.data = (unsigned long)itv;
+   setup_timer(>dma_timer, ivtv_unfinished_dma,
+   (unsigned long)itv);
 
itv->cur_dma_stream = -1;
itv->cur_pio_stream = -1;
-- 
2.9.3



[PATCH 07/12] [media] av7110: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/ttpci/av7110_ir.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/ttpci/av7110_ir.c 
b/drivers/media/pci/ttpci/av7110_ir.c
index 10e28f0..ca05198 100644
--- a/drivers/media/pci/ttpci/av7110_ir.c
+++ b/drivers/media/pci/ttpci/av7110_ir.c
@@ -333,9 +333,8 @@ int av7110_ir_init(struct av7110 *av7110)
av_list[av_cnt++] = av7110;
av7110_check_ir_config(av7110, true);
 
-   init_timer(>ir.keyup_timer);
-   av7110->ir.keyup_timer.function = av7110_emit_keyup;
-   av7110->ir.keyup_timer.data = (unsigned long) >ir;
+   setup_timer(>ir.keyup_timer, av7110_emit_keyup,
+   (unsigned long)>ir);
 
input_dev = input_allocate_device();
if (!input_dev)
-- 
2.9.3



[PATCH 03/12] [media] bt8xx: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/bt8xx/bttv-driver.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c 
b/drivers/media/pci/bt8xx/bttv-driver.c
index fb4aefb..ed319f1 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -4043,9 +4043,7 @@ static int bttv_probe(struct pci_dev *dev, const struct 
pci_device_id *pci_id)
INIT_LIST_HEAD(>capture);
INIT_LIST_HEAD(>vcapture);
 
-   init_timer(>timeout);
-   btv->timeout.function = bttv_irq_timeout;
-   btv->timeout.data = (unsigned long)btv;
+   setup_timer(>timeout, bttv_irq_timeout, (unsigned long)btv);
 
btv->i2c_rc = -1;
btv->tuner_type  = UNSET;
-- 
2.9.3



[PATCH 05/12] [media] ivtv: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/ivtv/ivtv-driver.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/ivtv/ivtv-driver.c 
b/drivers/media/pci/ivtv/ivtv-driver.c
index a71a03e..e8fa99b 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.c
+++ b/drivers/media/pci/ivtv/ivtv-driver.c
@@ -770,9 +770,8 @@ static int ivtv_init_struct1(struct ivtv *itv)
init_waitqueue_head(>event_waitq);
init_waitqueue_head(>vsync_waitq);
init_waitqueue_head(>dma_waitq);
-   init_timer(>dma_timer);
-   itv->dma_timer.function = ivtv_unfinished_dma;
-   itv->dma_timer.data = (unsigned long)itv;
+   setup_timer(>dma_timer, ivtv_unfinished_dma,
+   (unsigned long)itv);
 
itv->cur_dma_stream = -1;
itv->cur_pio_stream = -1;
-- 
2.9.3



[PATCH 11/12] [media] wl128x: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/radio/wl128x/fmdrv_common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index 74a1b3e..588e2d6 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -1550,9 +1550,8 @@ int fmc_prepare(struct fmdev *fmdev)
atomic_set(>tx_cnt, 1);
fmdev->resp_comp = NULL;
 
-   init_timer(>irq_info.timer);
-   fmdev->irq_info.timer.function = _timeout_handler;
-   fmdev->irq_info.timer.data = (unsigned long)fmdev;
+   setup_timer(>irq_info.timer, _timeout_handler,
+   (unsigned long)fmdev);
/*TODO: add FM_STIC_EVENT later */
fmdev->irq_info.mask = FM_MAL_EVENT;
 
-- 
2.9.3



[PATCH 11/12] [media] wl128x: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/radio/wl128x/fmdrv_common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c 
b/drivers/media/radio/wl128x/fmdrv_common.c
index 74a1b3e..588e2d6 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -1550,9 +1550,8 @@ int fmc_prepare(struct fmdev *fmdev)
atomic_set(>tx_cnt, 1);
fmdev->resp_comp = NULL;
 
-   init_timer(>irq_info.timer);
-   fmdev->irq_info.timer.function = _timeout_handler;
-   fmdev->irq_info.timer.data = (unsigned long)fmdev;
+   setup_timer(>irq_info.timer, _timeout_handler,
+   (unsigned long)fmdev);
/*TODO: add FM_STIC_EVENT later */
fmdev->irq_info.mask = FM_MAL_EVENT;
 
-- 
2.9.3



[PATCH 01/12] [media] saa7134: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/saa7134/saa7134-ts.c| 5 ++---
 drivers/media/pci/saa7134/saa7134-vbi.c   | 5 ++---
 drivers/media/pci/saa7134/saa7134-video.c | 5 ++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-ts.c 
b/drivers/media/pci/saa7134/saa7134-ts.c
index 578e03f..7414878 100644
--- a/drivers/media/pci/saa7134/saa7134-ts.c
+++ b/drivers/media/pci/saa7134/saa7134-ts.c
@@ -223,9 +223,8 @@ int saa7134_ts_init1(struct saa7134_dev *dev)
dev->ts.nr_packets = ts_nr_packets;
 
INIT_LIST_HEAD(>ts_q.queue);
-   init_timer(>ts_q.timeout);
-   dev->ts_q.timeout.function = saa7134_buffer_timeout;
-   dev->ts_q.timeout.data = (unsigned long)(>ts_q);
+   setup_timer(>ts_q.timeout, saa7134_buffer_timeout,
+   (unsigned long)(>ts_q));
dev->ts_q.dev  = dev;
dev->ts_q.need_two = 1;
dev->ts_started= 0;
diff --git a/drivers/media/pci/saa7134/saa7134-vbi.c 
b/drivers/media/pci/saa7134/saa7134-vbi.c
index 4619337..bcad9b2 100644
--- a/drivers/media/pci/saa7134/saa7134-vbi.c
+++ b/drivers/media/pci/saa7134/saa7134-vbi.c
@@ -181,9 +181,8 @@ struct vb2_ops saa7134_vbi_qops = {
 int saa7134_vbi_init1(struct saa7134_dev *dev)
 {
INIT_LIST_HEAD(>vbi_q.queue);
-   init_timer(>vbi_q.timeout);
-   dev->vbi_q.timeout.function = saa7134_buffer_timeout;
-   dev->vbi_q.timeout.data = (unsigned long)(>vbi_q);
+   setup_timer(>vbi_q.timeout, saa7134_buffer_timeout,
+   (unsigned long)(>vbi_q));
dev->vbi_q.dev  = dev;
 
if (vbibufs < 2)
diff --git a/drivers/media/pci/saa7134/saa7134-video.c 
b/drivers/media/pci/saa7134/saa7134-video.c
index 4b1c432..51d42bb 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -2145,9 +2145,8 @@ int saa7134_video_init1(struct saa7134_dev *dev)
dev->automute   = 0;
 
INIT_LIST_HEAD(>video_q.queue);
-   init_timer(>video_q.timeout);
-   dev->video_q.timeout.function = saa7134_buffer_timeout;
-   dev->video_q.timeout.data = (unsigned long)(>video_q);
+   setup_timer(>video_q.timeout, saa7134_buffer_timeout,
+   (unsigned long)(>video_q));
dev->video_q.dev  = dev;
dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
dev->width= 720;
-- 
2.9.3



[PATCH 02/12] [media] saa7146: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/common/saa7146/saa7146_vbi.c   | 5 ++---
 drivers/media/common/saa7146/saa7146_video.c | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/media/common/saa7146/saa7146_vbi.c 
b/drivers/media/common/saa7146/saa7146_vbi.c
index 4923751..3553ac4 100644
--- a/drivers/media/common/saa7146/saa7146_vbi.c
+++ b/drivers/media/common/saa7146/saa7146_vbi.c
@@ -365,9 +365,8 @@ static void vbi_init(struct saa7146_dev *dev, struct 
saa7146_vv *vv)
 
INIT_LIST_HEAD(>vbi_dmaq.queue);
 
-   init_timer(>vbi_dmaq.timeout);
-   vv->vbi_dmaq.timeout.function = saa7146_buffer_timeout;
-   vv->vbi_dmaq.timeout.data = (unsigned long)(>vbi_dmaq);
+   setup_timer(>vbi_dmaq.timeout, saa7146_buffer_timeout,
+   (unsigned long)(>vbi_dmaq));
vv->vbi_dmaq.dev  = dev;
 
init_waitqueue_head(>vbi_wq);
diff --git a/drivers/media/common/saa7146/saa7146_video.c 
b/drivers/media/common/saa7146/saa7146_video.c
index e034bcf..b3b29d4 100644
--- a/drivers/media/common/saa7146/saa7146_video.c
+++ b/drivers/media/common/saa7146/saa7146_video.c
@@ -1201,9 +1201,8 @@ static void video_init(struct saa7146_dev *dev, struct 
saa7146_vv *vv)
 {
INIT_LIST_HEAD(>video_dmaq.queue);
 
-   init_timer(>video_dmaq.timeout);
-   vv->video_dmaq.timeout.function = saa7146_buffer_timeout;
-   vv->video_dmaq.timeout.data = (unsigned long)(>video_dmaq);
+   setup_timer(>video_dmaq.timeout, saa7146_buffer_timeout,
+   (unsigned long)(>video_dmaq));
vv->video_dmaq.dev  = dev;
 
/* set some default values */
-- 
2.9.3



[PATCH 01/12] [media] saa7134: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/saa7134/saa7134-ts.c| 5 ++---
 drivers/media/pci/saa7134/saa7134-vbi.c   | 5 ++---
 drivers/media/pci/saa7134/saa7134-video.c | 5 ++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-ts.c 
b/drivers/media/pci/saa7134/saa7134-ts.c
index 578e03f..7414878 100644
--- a/drivers/media/pci/saa7134/saa7134-ts.c
+++ b/drivers/media/pci/saa7134/saa7134-ts.c
@@ -223,9 +223,8 @@ int saa7134_ts_init1(struct saa7134_dev *dev)
dev->ts.nr_packets = ts_nr_packets;
 
INIT_LIST_HEAD(>ts_q.queue);
-   init_timer(>ts_q.timeout);
-   dev->ts_q.timeout.function = saa7134_buffer_timeout;
-   dev->ts_q.timeout.data = (unsigned long)(>ts_q);
+   setup_timer(>ts_q.timeout, saa7134_buffer_timeout,
+   (unsigned long)(>ts_q));
dev->ts_q.dev  = dev;
dev->ts_q.need_two = 1;
dev->ts_started= 0;
diff --git a/drivers/media/pci/saa7134/saa7134-vbi.c 
b/drivers/media/pci/saa7134/saa7134-vbi.c
index 4619337..bcad9b2 100644
--- a/drivers/media/pci/saa7134/saa7134-vbi.c
+++ b/drivers/media/pci/saa7134/saa7134-vbi.c
@@ -181,9 +181,8 @@ struct vb2_ops saa7134_vbi_qops = {
 int saa7134_vbi_init1(struct saa7134_dev *dev)
 {
INIT_LIST_HEAD(>vbi_q.queue);
-   init_timer(>vbi_q.timeout);
-   dev->vbi_q.timeout.function = saa7134_buffer_timeout;
-   dev->vbi_q.timeout.data = (unsigned long)(>vbi_q);
+   setup_timer(>vbi_q.timeout, saa7134_buffer_timeout,
+   (unsigned long)(>vbi_q));
dev->vbi_q.dev  = dev;
 
if (vbibufs < 2)
diff --git a/drivers/media/pci/saa7134/saa7134-video.c 
b/drivers/media/pci/saa7134/saa7134-video.c
index 4b1c432..51d42bb 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -2145,9 +2145,8 @@ int saa7134_video_init1(struct saa7134_dev *dev)
dev->automute   = 0;
 
INIT_LIST_HEAD(>video_q.queue);
-   init_timer(>video_q.timeout);
-   dev->video_q.timeout.function = saa7134_buffer_timeout;
-   dev->video_q.timeout.data = (unsigned long)(>video_q);
+   setup_timer(>video_q.timeout, saa7134_buffer_timeout,
+   (unsigned long)(>video_q));
dev->video_q.dev  = dev;
dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
dev->width= 720;
-- 
2.9.3



[PATCH 02/12] [media] saa7146: use setup_timer

2017-04-08 Thread Geliang Tang
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang 
---
 drivers/media/common/saa7146/saa7146_vbi.c   | 5 ++---
 drivers/media/common/saa7146/saa7146_video.c | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/media/common/saa7146/saa7146_vbi.c 
b/drivers/media/common/saa7146/saa7146_vbi.c
index 4923751..3553ac4 100644
--- a/drivers/media/common/saa7146/saa7146_vbi.c
+++ b/drivers/media/common/saa7146/saa7146_vbi.c
@@ -365,9 +365,8 @@ static void vbi_init(struct saa7146_dev *dev, struct 
saa7146_vv *vv)
 
INIT_LIST_HEAD(>vbi_dmaq.queue);
 
-   init_timer(>vbi_dmaq.timeout);
-   vv->vbi_dmaq.timeout.function = saa7146_buffer_timeout;
-   vv->vbi_dmaq.timeout.data = (unsigned long)(>vbi_dmaq);
+   setup_timer(>vbi_dmaq.timeout, saa7146_buffer_timeout,
+   (unsigned long)(>vbi_dmaq));
vv->vbi_dmaq.dev  = dev;
 
init_waitqueue_head(>vbi_wq);
diff --git a/drivers/media/common/saa7146/saa7146_video.c 
b/drivers/media/common/saa7146/saa7146_video.c
index e034bcf..b3b29d4 100644
--- a/drivers/media/common/saa7146/saa7146_video.c
+++ b/drivers/media/common/saa7146/saa7146_video.c
@@ -1201,9 +1201,8 @@ static void video_init(struct saa7146_dev *dev, struct 
saa7146_vv *vv)
 {
INIT_LIST_HEAD(>video_dmaq.queue);
 
-   init_timer(>video_dmaq.timeout);
-   vv->video_dmaq.timeout.function = saa7146_buffer_timeout;
-   vv->video_dmaq.timeout.data = (unsigned long)(>video_dmaq);
+   setup_timer(>video_dmaq.timeout, saa7146_buffer_timeout,
+   (unsigned long)(>video_dmaq));
vv->video_dmaq.dev  = dev;
 
/* set some default values */
-- 
2.9.3



[PATCH] fs: drop duplicate header percpu-rwsem.h

2017-04-08 Thread Geliang Tang
Drop duplicate header percpu-rwsem.h from linux/fs.h.

Signed-off-by: Geliang Tang 
---
 include/linux/fs.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index f1d7347..7bff988 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -29,7 +29,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
-- 
2.9.3



[PATCH] fs: drop duplicate header percpu-rwsem.h

2017-04-08 Thread Geliang Tang
Drop duplicate header percpu-rwsem.h from linux/fs.h.

Signed-off-by: Geliang Tang 
---
 include/linux/fs.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index f1d7347..7bff988 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -29,7 +29,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
-- 
2.9.3



Re: [linux-sunxi] [PATCH 2/5] clk: sunxi-ng: allow set parent clock (PLL_CPUX) for CPUX clock on H3

2017-04-08 Thread Chen-Yu Tsai
Hi,

On Sun, Apr 9, 2017 at 2:50 AM, Icenowy Zheng  wrote:

The subject can just say "set CLK_SET_RATE_PARENT for CPUX clock on H3".

> The CPUX clock, which is the main clock of the ARM core on Allwinner H3,
> can be adjusted by changing the frequency of the PLL_CPUX clock.
>
> Allowing setting parent clock for the CPUX clock, thus the PLL_CPUX
> clock can be adjusted when adjusting the CPUX clock.
>

This paragraph needs some work, particularly the verbs you chose. In the
clk subsystem "setting parent clock" actually refers to re-parenting.

>From include/linux/clk-provider.h:

#define CLK_SET_RATE_PARENT BIT(2) /* propagate rate change up one level */

So what you want to say is to propagate rate changes to CPUX up one
level, so PLL_CPUX gets changed as well.

The precise wording could be something like:

The CPUX clock is the clock source for the ARM cores on the H3 SoC.
It is a mux clock fed by, amongst other fixed clock sources, the
configurable PLL_CPUX.

Set CLK_SET_RATE_PARENT on the CPUX clock, so rate changes to it
are propagated up one level to the PLL_CPUX clock.

ChenYu

> Signed-off-by: Icenowy Zheng 
> ---
>  drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c 
> b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> index 4cbc1b701b7c..90b4e26a70bc 100644
> --- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> @@ -135,7 +135,7 @@ static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_de_clk, 
> "pll-de",
>  static const char * const cpux_parents[] = { "osc32k", "osc24M",
>  "pll-cpux" , "pll-cpux" };
>  static SUNXI_CCU_MUX(cpux_clk, "cpux", cpux_parents,
> -0x050, 16, 2, CLK_IS_CRITICAL);
> +0x050, 16, 2, CLK_IS_CRITICAL | CLK_SET_RATE_PARENT);
>
>  static SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0);
>
> --
> 2.12.2
>
> --
> You received this message because you are subscribed to the Google Groups 
> "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to linux-sunxi+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH 2/5] clk: sunxi-ng: allow set parent clock (PLL_CPUX) for CPUX clock on H3

2017-04-08 Thread Chen-Yu Tsai
Hi,

On Sun, Apr 9, 2017 at 2:50 AM, Icenowy Zheng  wrote:

The subject can just say "set CLK_SET_RATE_PARENT for CPUX clock on H3".

> The CPUX clock, which is the main clock of the ARM core on Allwinner H3,
> can be adjusted by changing the frequency of the PLL_CPUX clock.
>
> Allowing setting parent clock for the CPUX clock, thus the PLL_CPUX
> clock can be adjusted when adjusting the CPUX clock.
>

This paragraph needs some work, particularly the verbs you chose. In the
clk subsystem "setting parent clock" actually refers to re-parenting.

>From include/linux/clk-provider.h:

#define CLK_SET_RATE_PARENT BIT(2) /* propagate rate change up one level */

So what you want to say is to propagate rate changes to CPUX up one
level, so PLL_CPUX gets changed as well.

The precise wording could be something like:

The CPUX clock is the clock source for the ARM cores on the H3 SoC.
It is a mux clock fed by, amongst other fixed clock sources, the
configurable PLL_CPUX.

Set CLK_SET_RATE_PARENT on the CPUX clock, so rate changes to it
are propagated up one level to the PLL_CPUX clock.

ChenYu

> Signed-off-by: Icenowy Zheng 
> ---
>  drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c 
> b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> index 4cbc1b701b7c..90b4e26a70bc 100644
> --- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> @@ -135,7 +135,7 @@ static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_de_clk, 
> "pll-de",
>  static const char * const cpux_parents[] = { "osc32k", "osc24M",
>  "pll-cpux" , "pll-cpux" };
>  static SUNXI_CCU_MUX(cpux_clk, "cpux", cpux_parents,
> -0x050, 16, 2, CLK_IS_CRITICAL);
> +0x050, 16, 2, CLK_IS_CRITICAL | CLK_SET_RATE_PARENT);
>
>  static SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0);
>
> --
> 2.12.2
>
> --
> You received this message because you are subscribed to the Google Groups 
> "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to linux-sunxi+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


[PATCH net-next,3/3] hv_netvsc: Exclude non-TCP port numbers from vRSS hashing

2017-04-08 Thread Haiyang Zhang
From: Haiyang Zhang 

Azure hosts are not supporting non-TCP port numbers in vRSS hashing for
now. For example, UDP packet loss rate will be high if port numbers are
also included in vRSS hash.

So, we created this patch to use only IP numbers for hashing in non-TCP
traffic.

Signed-off-by: Haiyang Zhang 
Reviewed-by: Stephen Hemminger 
---
 drivers/net/hyperv/netvsc_drv.c |   38 ++
 1 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index fad864f..d65ab05 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -191,6 +191,39 @@ static int netvsc_close(struct net_device *net)
return ppi;
 }
 
+/* Azure hosts don't support non-TCP port numbers in hashing yet. We compute
+ * hash for non-TCP traffic with only IP numbers.
+ */
+static inline u32 netvsc_get_hash(struct sk_buff *skb, struct sock *sk)
+{
+   struct flow_keys flow;
+   u32 hash;
+   static u32 hashrnd __read_mostly;
+
+   net_get_random_once(, sizeof(hashrnd));
+
+   if (!skb_flow_dissect_flow_keys(skb, , 0))
+   return 0;
+
+   if (flow.basic.ip_proto == IPPROTO_TCP) {
+   if (sk)
+   skb_set_hash_from_sk(skb, sk);
+
+   return skb_get_hash(skb);
+   } else {
+   if (flow.basic.n_proto == htons(ETH_P_IP))
+   hash = jhash2((u32 *), 2, hashrnd);
+   else if (flow.basic.n_proto == htons(ETH_P_IPV6))
+   hash = jhash2((u32 *), 8, hashrnd);
+   else
+   hash = 0;
+   }
+
+   skb_set_hash(skb, hash, PKT_HASH_TYPE_L3);
+
+   return hash;
+}
+
 static inline int netvsc_get_tx_queue(struct net_device *ndev,
  struct sk_buff *skb, int old_idx)
 {
@@ -198,10 +231,7 @@ static inline int netvsc_get_tx_queue(struct net_device 
*ndev,
struct sock *sk = skb->sk;
int q_idx;
 
-   if (sk)
-   skb_set_hash_from_sk(skb, sk);
-
-   q_idx = ndc->tx_send_table[skb_get_hash(skb) &
+   q_idx = ndc->tx_send_table[netvsc_get_hash(skb, sk) &
   (VRSS_SEND_TAB_SIZE - 1)];
 
/* If queue index changed record the new value */
-- 
1.7.1



[PATCH net-next,3/3] hv_netvsc: Exclude non-TCP port numbers from vRSS hashing

2017-04-08 Thread Haiyang Zhang
From: Haiyang Zhang 

Azure hosts are not supporting non-TCP port numbers in vRSS hashing for
now. For example, UDP packet loss rate will be high if port numbers are
also included in vRSS hash.

So, we created this patch to use only IP numbers for hashing in non-TCP
traffic.

Signed-off-by: Haiyang Zhang 
Reviewed-by: Stephen Hemminger 
---
 drivers/net/hyperv/netvsc_drv.c |   38 ++
 1 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index fad864f..d65ab05 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -191,6 +191,39 @@ static int netvsc_close(struct net_device *net)
return ppi;
 }
 
+/* Azure hosts don't support non-TCP port numbers in hashing yet. We compute
+ * hash for non-TCP traffic with only IP numbers.
+ */
+static inline u32 netvsc_get_hash(struct sk_buff *skb, struct sock *sk)
+{
+   struct flow_keys flow;
+   u32 hash;
+   static u32 hashrnd __read_mostly;
+
+   net_get_random_once(, sizeof(hashrnd));
+
+   if (!skb_flow_dissect_flow_keys(skb, , 0))
+   return 0;
+
+   if (flow.basic.ip_proto == IPPROTO_TCP) {
+   if (sk)
+   skb_set_hash_from_sk(skb, sk);
+
+   return skb_get_hash(skb);
+   } else {
+   if (flow.basic.n_proto == htons(ETH_P_IP))
+   hash = jhash2((u32 *), 2, hashrnd);
+   else if (flow.basic.n_proto == htons(ETH_P_IPV6))
+   hash = jhash2((u32 *), 8, hashrnd);
+   else
+   hash = 0;
+   }
+
+   skb_set_hash(skb, hash, PKT_HASH_TYPE_L3);
+
+   return hash;
+}
+
 static inline int netvsc_get_tx_queue(struct net_device *ndev,
  struct sk_buff *skb, int old_idx)
 {
@@ -198,10 +231,7 @@ static inline int netvsc_get_tx_queue(struct net_device 
*ndev,
struct sock *sk = skb->sk;
int q_idx;
 
-   if (sk)
-   skb_set_hash_from_sk(skb, sk);
-
-   q_idx = ndc->tx_send_table[skb_get_hash(skb) &
+   q_idx = ndc->tx_send_table[netvsc_get_hash(skb, sk) &
   (VRSS_SEND_TAB_SIZE - 1)];
 
/* If queue index changed record the new value */
-- 
1.7.1



[PATCH net-next,2/3] hv_netvsc: Fix the queue index computation in forwarding case

2017-04-08 Thread Haiyang Zhang
From: Haiyang Zhang 

If the outgoing skb has a RX queue mapping available, we use the queue
number directly, other than put it through Send Indirection Table.

Signed-off-by: Haiyang Zhang 
Reviewed-by: Stephen Hemminger 
---
 drivers/net/hyperv/hyperv_net.h |2 +-
 drivers/net/hyperv/netvsc_drv.c |   54 --
 2 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 4747ad4..768b3ae 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -633,7 +633,7 @@ struct nvsp_message {
 
 #define NETVSC_PACKET_SIZE  4096
 
-#define VRSS_SEND_TAB_SIZE 16
+#define VRSS_SEND_TAB_SIZE 16  /* must be power of 2 */
 #define VRSS_CHANNEL_MAX 64
 #define VRSS_CHANNEL_DEFAULT 8
 
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 0a129cb..fad864f 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -191,6 +191,27 @@ static int netvsc_close(struct net_device *net)
return ppi;
 }
 
+static inline int netvsc_get_tx_queue(struct net_device *ndev,
+ struct sk_buff *skb, int old_idx)
+{
+   const struct net_device_context *ndc = netdev_priv(ndev);
+   struct sock *sk = skb->sk;
+   int q_idx;
+
+   if (sk)
+   skb_set_hash_from_sk(skb, sk);
+
+   q_idx = ndc->tx_send_table[skb_get_hash(skb) &
+  (VRSS_SEND_TAB_SIZE - 1)];
+
+   /* If queue index changed record the new value */
+   if (q_idx != old_idx &&
+   sk && sk_fullsock(sk) && rcu_access_pointer(sk->sk_dst_cache))
+   sk_tx_queue_set(sk, q_idx);
+
+   return q_idx;
+}
+
 /*
  * Select queue for transmit.
  *
@@ -205,29 +226,22 @@ static int netvsc_close(struct net_device *net)
 static u16 netvsc_select_queue(struct net_device *ndev, struct sk_buff *skb,
void *accel_priv, select_queue_fallback_t fallback)
 {
-   struct net_device_context *net_device_ctx = netdev_priv(ndev);
unsigned int num_tx_queues = ndev->real_num_tx_queues;
-   struct sock *sk = skb->sk;
-   int q_idx = sk_tx_queue_get(sk);
-
-   if (q_idx < 0 || skb->ooo_okay || q_idx >= num_tx_queues) {
-   u16 hash;
-   int new_idx;
-
-   if (sk)
-   skb_set_hash_from_sk(skb, sk);
-
-   hash = __skb_tx_hash(ndev, skb, VRSS_SEND_TAB_SIZE);
+   int q_idx = sk_tx_queue_get(skb->sk);
 
-   new_idx = net_device_ctx->tx_send_table[hash] % num_tx_queues;
-
-   if (q_idx != new_idx && sk &&
-   sk_fullsock(sk) && rcu_access_pointer(sk->sk_dst_cache))
-   sk_tx_queue_set(sk, new_idx);
-
-   q_idx = new_idx;
+   if (q_idx < 0 || skb->ooo_okay) {
+   /* If forwarding a packet, we use the recorded queue when
+* available for better cache locality.
+*/
+   if (skb_rx_queue_recorded(skb))
+   q_idx = skb_get_rx_queue(skb);
+   else
+   q_idx = netvsc_get_tx_queue(ndev, skb, q_idx);
}
 
+   while (unlikely(q_idx >= num_tx_queues))
+   q_idx -= num_tx_queues;
+
return q_idx;
 }
 
-- 
1.7.1



[PATCH net-next,2/3] hv_netvsc: Fix the queue index computation in forwarding case

2017-04-08 Thread Haiyang Zhang
From: Haiyang Zhang 

If the outgoing skb has a RX queue mapping available, we use the queue
number directly, other than put it through Send Indirection Table.

Signed-off-by: Haiyang Zhang 
Reviewed-by: Stephen Hemminger 
---
 drivers/net/hyperv/hyperv_net.h |2 +-
 drivers/net/hyperv/netvsc_drv.c |   54 --
 2 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 4747ad4..768b3ae 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -633,7 +633,7 @@ struct nvsp_message {
 
 #define NETVSC_PACKET_SIZE  4096
 
-#define VRSS_SEND_TAB_SIZE 16
+#define VRSS_SEND_TAB_SIZE 16  /* must be power of 2 */
 #define VRSS_CHANNEL_MAX 64
 #define VRSS_CHANNEL_DEFAULT 8
 
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 0a129cb..fad864f 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -191,6 +191,27 @@ static int netvsc_close(struct net_device *net)
return ppi;
 }
 
+static inline int netvsc_get_tx_queue(struct net_device *ndev,
+ struct sk_buff *skb, int old_idx)
+{
+   const struct net_device_context *ndc = netdev_priv(ndev);
+   struct sock *sk = skb->sk;
+   int q_idx;
+
+   if (sk)
+   skb_set_hash_from_sk(skb, sk);
+
+   q_idx = ndc->tx_send_table[skb_get_hash(skb) &
+  (VRSS_SEND_TAB_SIZE - 1)];
+
+   /* If queue index changed record the new value */
+   if (q_idx != old_idx &&
+   sk && sk_fullsock(sk) && rcu_access_pointer(sk->sk_dst_cache))
+   sk_tx_queue_set(sk, q_idx);
+
+   return q_idx;
+}
+
 /*
  * Select queue for transmit.
  *
@@ -205,29 +226,22 @@ static int netvsc_close(struct net_device *net)
 static u16 netvsc_select_queue(struct net_device *ndev, struct sk_buff *skb,
void *accel_priv, select_queue_fallback_t fallback)
 {
-   struct net_device_context *net_device_ctx = netdev_priv(ndev);
unsigned int num_tx_queues = ndev->real_num_tx_queues;
-   struct sock *sk = skb->sk;
-   int q_idx = sk_tx_queue_get(sk);
-
-   if (q_idx < 0 || skb->ooo_okay || q_idx >= num_tx_queues) {
-   u16 hash;
-   int new_idx;
-
-   if (sk)
-   skb_set_hash_from_sk(skb, sk);
-
-   hash = __skb_tx_hash(ndev, skb, VRSS_SEND_TAB_SIZE);
+   int q_idx = sk_tx_queue_get(skb->sk);
 
-   new_idx = net_device_ctx->tx_send_table[hash] % num_tx_queues;
-
-   if (q_idx != new_idx && sk &&
-   sk_fullsock(sk) && rcu_access_pointer(sk->sk_dst_cache))
-   sk_tx_queue_set(sk, new_idx);
-
-   q_idx = new_idx;
+   if (q_idx < 0 || skb->ooo_okay) {
+   /* If forwarding a packet, we use the recorded queue when
+* available for better cache locality.
+*/
+   if (skb_rx_queue_recorded(skb))
+   q_idx = skb_get_rx_queue(skb);
+   else
+   q_idx = netvsc_get_tx_queue(ndev, skb, q_idx);
}
 
+   while (unlikely(q_idx >= num_tx_queues))
+   q_idx -= num_tx_queues;
+
return q_idx;
 }
 
-- 
1.7.1



[PATCH net-next,1/3] hv_netvsc: Use per socket hash when available

2017-04-08 Thread Haiyang Zhang
From: Haiyang Zhang 

The per socket hash is set when a socket is connected. Use it, when
available, to save CPU cycles on repeatedly computing hash on the same
connection.

Signed-off-by: Haiyang Zhang 
Reviewed-by: Stephen Hemminger 
---
 drivers/net/hyperv/netvsc_drv.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index f24c289..0a129cb 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -211,9 +211,14 @@ static u16 netvsc_select_queue(struct net_device *ndev, 
struct sk_buff *skb,
int q_idx = sk_tx_queue_get(sk);
 
if (q_idx < 0 || skb->ooo_okay || q_idx >= num_tx_queues) {
-   u16 hash = __skb_tx_hash(ndev, skb, VRSS_SEND_TAB_SIZE);
+   u16 hash;
int new_idx;
 
+   if (sk)
+   skb_set_hash_from_sk(skb, sk);
+
+   hash = __skb_tx_hash(ndev, skb, VRSS_SEND_TAB_SIZE);
+
new_idx = net_device_ctx->tx_send_table[hash] % num_tx_queues;
 
if (q_idx != new_idx && sk &&
-- 
1.7.1



[PATCH net-next,1/3] hv_netvsc: Use per socket hash when available

2017-04-08 Thread Haiyang Zhang
From: Haiyang Zhang 

The per socket hash is set when a socket is connected. Use it, when
available, to save CPU cycles on repeatedly computing hash on the same
connection.

Signed-off-by: Haiyang Zhang 
Reviewed-by: Stephen Hemminger 
---
 drivers/net/hyperv/netvsc_drv.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index f24c289..0a129cb 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -211,9 +211,14 @@ static u16 netvsc_select_queue(struct net_device *ndev, 
struct sk_buff *skb,
int q_idx = sk_tx_queue_get(sk);
 
if (q_idx < 0 || skb->ooo_okay || q_idx >= num_tx_queues) {
-   u16 hash = __skb_tx_hash(ndev, skb, VRSS_SEND_TAB_SIZE);
+   u16 hash;
int new_idx;
 
+   if (sk)
+   skb_set_hash_from_sk(skb, sk);
+
+   hash = __skb_tx_hash(ndev, skb, VRSS_SEND_TAB_SIZE);
+
new_idx = net_device_ctx->tx_send_table[hash] % num_tx_queues;
 
if (q_idx != new_idx && sk &&
-- 
1.7.1



Re: [RFC HMM CDM 0/3] Coherent Device Memory (CDM) on top of HMM

2017-04-08 Thread Balbir Singh
On Fri, 2017-04-07 at 16:28 -0400, Jérôme Glisse wrote:
> This patch serie implement coherent device memory using ZONE_DEVICE
> and adds new helper to the HMM framework to support this new kind
> of ZONE_DEVICE memory. This is on top of HMM v19 and you can find a
> branch here:
> 
> https://cgit.freedesktop.org/~glisse/linux/log/?h=hmm-cdm
> 
> It needs more special casing as it behaves differently from regular
> ZONE_DEVICE (persistent memory). Unlike the unaddressable memory
> type added with HMM patchset, the CDM type can be access by CPU.
> Because of this any page can be migrated to CDM memory, private
> anonymous or share memory (file back or not).
> 
> It is missing some features like allowing to direct device fault to
> directly allocates device memory (intention is to add new fields to
> vm_fault struct for this).
> 
> 
> This is mostly un-tested but i am posting now because i believe we
> want to start discussion on design consideration. So this differ from
> the NUMA approach by adding yet a new type to ZONE_DEVICE with more
> special casing. While it is a rather small patchset, i might have
> miss some code-path that might require more special casing (i and
> other need to audit mm to make sure that everytime mm is confronted
> so such page it behaves as we want).
> 
> So i believe question is do we want to keep on adding new type to
> ZONE_DEVICE and more special casing each of them or is a NUMA like
> approach better ?
> 
> 
> My personal belief is that the hierarchy of memory is getting deeper
> (DDR, HBM stack memory, persistent memory, device memory, ...) and
> it may make sense to try to mirror this complexity within mm concept.
> Generalizing the NUMA abstraction is probably the best starting point
> for this. I know there are strong feelings against changing NUMA so
> i believe now is the time to pick a direction.

Thanks for all your hard-work and effort on this.

I agree that NUMA is the best representation and in the we want
the mm to manage coherent memory. The device memory is very similar
to NUMA, it is cache coherent, can be simultaneously accessed from
both sides. Like you say, this will evolve, my current design proposal
is at

https://github.com/bsingharora/linux/commits/balbir/cdmv1

with HMM patches (v17) on top. The relevant commits are
c0750c30070e8537ca2ee3ddfce3c0bac7eaab26
dcb3ff6d7900ff644d08a3d1892b6c0ab6982021
9041c3fee859b40c1f9d3e60fd48e0f64ee69abb
b26b6e9f3b078a606a0eaada08bc187b96d966a5

I intend to rebase and repost them. The core motivation of this approach
compared to Anshuman's approach https://lwn.net/Articles/704403/ is
avoiding allocator changes, there are however mempolicy changes. Creating
N_COHERENT_MEMORY exclusive to N_MEMORY allows us to avoid changes in
the allocator paths, with the changes being controlled by mempolicy, where
an explicit node allocation works via changes to policy_zonelist() and policy_
nodemask(). This also isolates coherent memory from kswapd and other back-
ground processes, but direct reclaim and direct compaction, etc are expected
to work. The reason for isolation is performance to prevent wrong allocations
ending up on device memory, but there is no strict requirements, one could
easily use migrations to migrate misplaced memory.

>From a HMM perspective, we still find HMM useful for migration, specifically
your migrate_vma() API and the new propose migrate_dma() API that is a
part of this patchset. I think for isolation we prefer the NUMA approach.

We do find HMM useful for hardware that does not have
coherency, but for coherent devices we prefer the NUMA approach.

With HMM we'll start seeing ZONE_DEVICE pages mapped into user space and
that would mean a thorough audit of all code paths to make sure we are
ready for such a use case and enabling those use cases, like you've done
with patch 1. I've done a quick evaluation to check for features like
migration (page cache migration), fault handling to the right location
(direct page cache allocation in the coherent memory), mlock handling,
RSS accounting, memcg enforcement for pages not on LRU, etc.

> 
> Note that i don't think choosing one would mean we will be stuck with
> it, as long as we don't expose anything new (syscall) to userspace
> and hide thing through driver API then we keep our options open to
> change direction latter on.
>

I agree, but I think user space will need to adopt, for example using
malloc on a coherent device will not work, the user space will need to
have a driver supported way of accessing coherent memory.
 
> Nonetheless we need to make progress on this as they are hardware
> right around the corner and it would be a shame if we could not
> leverage such hardware with linux.
> 
>

I agree 100% 

Balbir Singh.


Re: [RFC HMM CDM 0/3] Coherent Device Memory (CDM) on top of HMM

2017-04-08 Thread Balbir Singh
On Fri, 2017-04-07 at 16:28 -0400, Jérôme Glisse wrote:
> This patch serie implement coherent device memory using ZONE_DEVICE
> and adds new helper to the HMM framework to support this new kind
> of ZONE_DEVICE memory. This is on top of HMM v19 and you can find a
> branch here:
> 
> https://cgit.freedesktop.org/~glisse/linux/log/?h=hmm-cdm
> 
> It needs more special casing as it behaves differently from regular
> ZONE_DEVICE (persistent memory). Unlike the unaddressable memory
> type added with HMM patchset, the CDM type can be access by CPU.
> Because of this any page can be migrated to CDM memory, private
> anonymous or share memory (file back or not).
> 
> It is missing some features like allowing to direct device fault to
> directly allocates device memory (intention is to add new fields to
> vm_fault struct for this).
> 
> 
> This is mostly un-tested but i am posting now because i believe we
> want to start discussion on design consideration. So this differ from
> the NUMA approach by adding yet a new type to ZONE_DEVICE with more
> special casing. While it is a rather small patchset, i might have
> miss some code-path that might require more special casing (i and
> other need to audit mm to make sure that everytime mm is confronted
> so such page it behaves as we want).
> 
> So i believe question is do we want to keep on adding new type to
> ZONE_DEVICE and more special casing each of them or is a NUMA like
> approach better ?
> 
> 
> My personal belief is that the hierarchy of memory is getting deeper
> (DDR, HBM stack memory, persistent memory, device memory, ...) and
> it may make sense to try to mirror this complexity within mm concept.
> Generalizing the NUMA abstraction is probably the best starting point
> for this. I know there are strong feelings against changing NUMA so
> i believe now is the time to pick a direction.

Thanks for all your hard-work and effort on this.

I agree that NUMA is the best representation and in the we want
the mm to manage coherent memory. The device memory is very similar
to NUMA, it is cache coherent, can be simultaneously accessed from
both sides. Like you say, this will evolve, my current design proposal
is at

https://github.com/bsingharora/linux/commits/balbir/cdmv1

with HMM patches (v17) on top. The relevant commits are
c0750c30070e8537ca2ee3ddfce3c0bac7eaab26
dcb3ff6d7900ff644d08a3d1892b6c0ab6982021
9041c3fee859b40c1f9d3e60fd48e0f64ee69abb
b26b6e9f3b078a606a0eaada08bc187b96d966a5

I intend to rebase and repost them. The core motivation of this approach
compared to Anshuman's approach https://lwn.net/Articles/704403/ is
avoiding allocator changes, there are however mempolicy changes. Creating
N_COHERENT_MEMORY exclusive to N_MEMORY allows us to avoid changes in
the allocator paths, with the changes being controlled by mempolicy, where
an explicit node allocation works via changes to policy_zonelist() and policy_
nodemask(). This also isolates coherent memory from kswapd and other back-
ground processes, but direct reclaim and direct compaction, etc are expected
to work. The reason for isolation is performance to prevent wrong allocations
ending up on device memory, but there is no strict requirements, one could
easily use migrations to migrate misplaced memory.

>From a HMM perspective, we still find HMM useful for migration, specifically
your migrate_vma() API and the new propose migrate_dma() API that is a
part of this patchset. I think for isolation we prefer the NUMA approach.

We do find HMM useful for hardware that does not have
coherency, but for coherent devices we prefer the NUMA approach.

With HMM we'll start seeing ZONE_DEVICE pages mapped into user space and
that would mean a thorough audit of all code paths to make sure we are
ready for such a use case and enabling those use cases, like you've done
with patch 1. I've done a quick evaluation to check for features like
migration (page cache migration), fault handling to the right location
(direct page cache allocation in the coherent memory), mlock handling,
RSS accounting, memcg enforcement for pages not on LRU, etc.

> 
> Note that i don't think choosing one would mean we will be stuck with
> it, as long as we don't expose anything new (syscall) to userspace
> and hide thing through driver API then we keep our options open to
> change direction latter on.
>

I agree, but I think user space will need to adopt, for example using
malloc on a coherent device will not work, the user space will need to
have a driver supported way of accessing coherent memory.
 
> Nonetheless we need to make progress on this as they are hardware
> right around the corner and it would be a shame if we could not
> leverage such hardware with linux.
> 
>

I agree 100% 

Balbir Singh.


[PATCH 06/10] nubus: Remove slot zero probe (from mac68k CVS)

2017-04-08 Thread Finn Thain
From: David Huggins-Daines 

Some long forgotten changes from the linux-mac68k CVS:

Remove the slot 0 (ROM) probing.
Remove the pointless White Screen Of Death crap.

The original commit is here:

http://linux-mac68k.cvs.sourceforge.net/viewvc/linux-mac68k/linux-mac68k/drivers/nubus/nubus.c?r1=1.22.2.1=1.22.2.2=linux-2_2

Signed-off-by: Finn Thain 
---
 drivers/nubus/nubus.c | 112 +++---
 1 file changed, 6 insertions(+), 106 deletions(-)

diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index ea9202d..ef3d7d1 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -13,7 +13,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -34,14 +33,6 @@ extern void oss_nubus_init(void);
 
 #define NUBUS_TEST_PATTERN 0x5A932BC7
 
-/* Define this if you like to live dangerously - it is known not to
-   work on pretty much every machine except the Quadra 630 and the LC
-   III. */
-#undef I_WANT_TO_PROBE_SLOT_ZERO
-
-/* This sometimes helps combat failure to boot */
-#undef TRY_TO_DODGE_WSOD
-
 /* Globals */
 
 struct nubus_dev*   nubus_devices;
@@ -471,10 +462,6 @@ static struct nubus_dev* __init
printk(KERN_INFO "  Function 0x%02x:\n", parent->type);
nubus_get_subdir(parent, );
 
-   /* Apple seems to have botched the ROM on the IIx */
-   if (slot == 0 && (unsigned long)dir.base % 2)
-   dir.base += 1;
-   
if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
printk(KERN_DEBUG "nubus_get_functional_resource: parent is 
0x%p, dir is 0x%p\n",
   parent->base, dir.base);
@@ -720,83 +707,6 @@ static int __init nubus_get_board_resource(struct 
nubus_board* board, int slot,
return 0;
 }
 
-/* Attempt to bypass the somewhat non-obvious arrangement of
-   sResources in the motherboard ROM */
-static void __init nubus_find_rom_dir(struct nubus_board* board)
-{
-   unsigned char* rp;
-   unsigned char* romdir;
-   struct nubus_dir dir;
-   struct nubus_dirent ent;
-
-   /* Check for the extra directory just under the format block */
-   rp = board->fblock;
-   nubus_rewind(, 4, board->lanes);
-   if (nubus_get_rom(, 4, board->lanes) != NUBUS_TEST_PATTERN) {
-   /* OK, the ROM was telling the truth */
-   board->directory = board->fblock;
-   nubus_move(>directory,
-  nubus_expand32(board->doffset),
-  board->lanes);
-   return;
-   }
-
-   /* On "slot zero", you have to walk down a few more
-  directories to get to the equivalent of a real card's root
-  directory.  We don't know what they were smoking when they
-  came up with this. */
-   romdir = nubus_rom_addr(board->slot);
-   nubus_rewind(, ROM_DIR_OFFSET, board->lanes);
-   dir.base = dir.ptr = romdir;
-   dir.done = 0;
-   dir.mask = board->lanes;
-
-   /* This one points to an "Unknown Macintosh" directory */
-   if (nubus_readdir(, ) == -1)
-   goto badrom;
-
-   if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
-   printk(KERN_INFO "nubus_get_rom_dir: entry %02x %06x\n", 
ent.type, ent.data);
-   /* This one takes us to where we want to go. */
-   if (nubus_readdir(, ) == -1) 
-   goto badrom;
-   if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
-   printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", 
ent.type, ent.data);
-   nubus_get_subdir(, );
-
-   /* Resource ID 01, also an "Unknown Macintosh" */
-   if (nubus_readdir(, ) == -1) 
-   goto badrom;
-   if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
-   printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", 
ent.type, ent.data);
-
-   /* FIXME: the first one is *not* always the right one.  We
-  suspect this has something to do with the ROM revision.
-  "The HORROR ROM" (LC-series) uses 0x7e, while "The HORROR
-  Continues" (Q630) uses 0x7b.  The DAFB Macs evidently use
-  something else.  Please run "Slots" on your Mac (see
-  include/linux/nubus.h for where to get this program) and
-  tell us where the 'SiDirPtr' for Slot 0 is.  If you feel
-  brave, you should also use MacsBug to walk down the ROM
-  directories like this function does and try to find the
-  path to that address... */
-   if (nubus_readdir(, ) == -1)
-   goto badrom;
-   if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
-   printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", 
ent.type, ent.data);
-   
-   /* Bwahahahaha... */
-   nubus_get_subdir(, );
-   board->directory = dir.base;
-   return;
-   
-   /* Even more evil laughter... */
- badrom:
-   board->directory = board->fblock;

[PATCH 05/10] nubus: Fix nubus_rewinddir (from mac68k CVS)

2017-04-08 Thread Finn Thain
From: David Huggins-Daines 

A long forgotten fix from the linux-mac68k CVS:

Initialize dir->done pointer in nubus_rewinddir().

The original commit is here:

http://linux-mac68k.cvs.sourceforge.net/viewvc/linux-mac68k/linux-mac68k/drivers/nubus/nubus.c?r1=1.22=1.22.2.1=linux-2_2

Signed-off-by: Finn Thain 
---
 drivers/nubus/nubus.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index 3319cf1..ea9202d 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -285,6 +285,8 @@ EXPORT_SYMBOL(nubus_readdir);
 int nubus_rewinddir(struct nubus_dir* dir)
 {
dir->ptr = dir->base;
+   dir->done = 0;
+
return 0;
 }
 EXPORT_SYMBOL(nubus_rewinddir);
-- 
2.10.2



[PATCH 10/10] nubus: Add MVC and VSC video card definitions

2017-04-08 Thread Finn Thain
Also move the NUBUS_DRHW_APPLE_JET definition, for numerical order.

Signed-off-by: Finn Thain 
---
 include/uapi/linux/nubus.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/nubus.h b/include/uapi/linux/nubus.h
index 77513d2..ac51606 100644
--- a/include/uapi/linux/nubus.h
+++ b/include/uapi/linux/nubus.h
@@ -113,13 +113,15 @@ enum nubus_drhw {
NUBUS_DRHW_SIGMA_CLRMAX   = 0x0007, /* Sigma Design ColorMax */
NUBUS_DRHW_APPLE_SE30 = 0x0009, /* Apple SE/30 video */
NUBUS_DRHW_APPLE_HRVC = 0x0013, /* Mac II High-Res Video Card */
+   NUBUS_DRHW_APPLE_MVC  = 0x0014, /* Mac II Monochrome Video Card */
NUBUS_DRHW_APPLE_PVC  = 0x0017, /* Mac II Portrait Video Card */
NUBUS_DRHW_APPLE_RBV1 = 0x0018, /* IIci RBV video */
NUBUS_DRHW_APPLE_MDC  = 0x0019, /* Macintosh Display Card */
+   NUBUS_DRHW_APPLE_VSC  = 0x0020, /* Duo MiniDock ViSC framebuffer */
NUBUS_DRHW_APPLE_SONORA   = 0x0022, /* Sonora built-in video */
+   NUBUS_DRHW_APPLE_JET  = 0x0029, /* Jet framebuffer (DuoDock) */
NUBUS_DRHW_APPLE_24AC = 0x002b, /* Mac 24AC Video Card */
NUBUS_DRHW_APPLE_VALKYRIE = 0x002e,
-   NUBUS_DRHW_APPLE_JET  = 0x0029, /* Jet framebuffer (DuoDock) */
NUBUS_DRHW_SMAC_GFX   = 0x0105, /* SuperMac GFX */
NUBUS_DRHW_RASTER_CB264   = 0x013B, /* RasterOps ColorBoard 264 */
NUBUS_DRHW_MICRON_XCEED   = 0x0146, /* Micron Exceed color */
-- 
2.10.2



[PATCH 05/10] nubus: Fix nubus_rewinddir (from mac68k CVS)

2017-04-08 Thread Finn Thain
From: David Huggins-Daines 

A long forgotten fix from the linux-mac68k CVS:

Initialize dir->done pointer in nubus_rewinddir().

The original commit is here:

http://linux-mac68k.cvs.sourceforge.net/viewvc/linux-mac68k/linux-mac68k/drivers/nubus/nubus.c?r1=1.22=1.22.2.1=linux-2_2

Signed-off-by: Finn Thain 
---
 drivers/nubus/nubus.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index 3319cf1..ea9202d 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -285,6 +285,8 @@ EXPORT_SYMBOL(nubus_readdir);
 int nubus_rewinddir(struct nubus_dir* dir)
 {
dir->ptr = dir->base;
+   dir->done = 0;
+
return 0;
 }
 EXPORT_SYMBOL(nubus_rewinddir);
-- 
2.10.2



[PATCH 10/10] nubus: Add MVC and VSC video card definitions

2017-04-08 Thread Finn Thain
Also move the NUBUS_DRHW_APPLE_JET definition, for numerical order.

Signed-off-by: Finn Thain 
---
 include/uapi/linux/nubus.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/nubus.h b/include/uapi/linux/nubus.h
index 77513d2..ac51606 100644
--- a/include/uapi/linux/nubus.h
+++ b/include/uapi/linux/nubus.h
@@ -113,13 +113,15 @@ enum nubus_drhw {
NUBUS_DRHW_SIGMA_CLRMAX   = 0x0007, /* Sigma Design ColorMax */
NUBUS_DRHW_APPLE_SE30 = 0x0009, /* Apple SE/30 video */
NUBUS_DRHW_APPLE_HRVC = 0x0013, /* Mac II High-Res Video Card */
+   NUBUS_DRHW_APPLE_MVC  = 0x0014, /* Mac II Monochrome Video Card */
NUBUS_DRHW_APPLE_PVC  = 0x0017, /* Mac II Portrait Video Card */
NUBUS_DRHW_APPLE_RBV1 = 0x0018, /* IIci RBV video */
NUBUS_DRHW_APPLE_MDC  = 0x0019, /* Macintosh Display Card */
+   NUBUS_DRHW_APPLE_VSC  = 0x0020, /* Duo MiniDock ViSC framebuffer */
NUBUS_DRHW_APPLE_SONORA   = 0x0022, /* Sonora built-in video */
+   NUBUS_DRHW_APPLE_JET  = 0x0029, /* Jet framebuffer (DuoDock) */
NUBUS_DRHW_APPLE_24AC = 0x002b, /* Mac 24AC Video Card */
NUBUS_DRHW_APPLE_VALKYRIE = 0x002e,
-   NUBUS_DRHW_APPLE_JET  = 0x0029, /* Jet framebuffer (DuoDock) */
NUBUS_DRHW_SMAC_GFX   = 0x0105, /* SuperMac GFX */
NUBUS_DRHW_RASTER_CB264   = 0x013B, /* RasterOps ColorBoard 264 */
NUBUS_DRHW_MICRON_XCEED   = 0x0146, /* Micron Exceed color */
-- 
2.10.2



[PATCH 06/10] nubus: Remove slot zero probe (from mac68k CVS)

2017-04-08 Thread Finn Thain
From: David Huggins-Daines 

Some long forgotten changes from the linux-mac68k CVS:

Remove the slot 0 (ROM) probing.
Remove the pointless White Screen Of Death crap.

The original commit is here:

http://linux-mac68k.cvs.sourceforge.net/viewvc/linux-mac68k/linux-mac68k/drivers/nubus/nubus.c?r1=1.22.2.1=1.22.2.2=linux-2_2

Signed-off-by: Finn Thain 
---
 drivers/nubus/nubus.c | 112 +++---
 1 file changed, 6 insertions(+), 106 deletions(-)

diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index ea9202d..ef3d7d1 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -13,7 +13,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -34,14 +33,6 @@ extern void oss_nubus_init(void);
 
 #define NUBUS_TEST_PATTERN 0x5A932BC7
 
-/* Define this if you like to live dangerously - it is known not to
-   work on pretty much every machine except the Quadra 630 and the LC
-   III. */
-#undef I_WANT_TO_PROBE_SLOT_ZERO
-
-/* This sometimes helps combat failure to boot */
-#undef TRY_TO_DODGE_WSOD
-
 /* Globals */
 
 struct nubus_dev*   nubus_devices;
@@ -471,10 +462,6 @@ static struct nubus_dev* __init
printk(KERN_INFO "  Function 0x%02x:\n", parent->type);
nubus_get_subdir(parent, );
 
-   /* Apple seems to have botched the ROM on the IIx */
-   if (slot == 0 && (unsigned long)dir.base % 2)
-   dir.base += 1;
-   
if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
printk(KERN_DEBUG "nubus_get_functional_resource: parent is 
0x%p, dir is 0x%p\n",
   parent->base, dir.base);
@@ -720,83 +707,6 @@ static int __init nubus_get_board_resource(struct 
nubus_board* board, int slot,
return 0;
 }
 
-/* Attempt to bypass the somewhat non-obvious arrangement of
-   sResources in the motherboard ROM */
-static void __init nubus_find_rom_dir(struct nubus_board* board)
-{
-   unsigned char* rp;
-   unsigned char* romdir;
-   struct nubus_dir dir;
-   struct nubus_dirent ent;
-
-   /* Check for the extra directory just under the format block */
-   rp = board->fblock;
-   nubus_rewind(, 4, board->lanes);
-   if (nubus_get_rom(, 4, board->lanes) != NUBUS_TEST_PATTERN) {
-   /* OK, the ROM was telling the truth */
-   board->directory = board->fblock;
-   nubus_move(>directory,
-  nubus_expand32(board->doffset),
-  board->lanes);
-   return;
-   }
-
-   /* On "slot zero", you have to walk down a few more
-  directories to get to the equivalent of a real card's root
-  directory.  We don't know what they were smoking when they
-  came up with this. */
-   romdir = nubus_rom_addr(board->slot);
-   nubus_rewind(, ROM_DIR_OFFSET, board->lanes);
-   dir.base = dir.ptr = romdir;
-   dir.done = 0;
-   dir.mask = board->lanes;
-
-   /* This one points to an "Unknown Macintosh" directory */
-   if (nubus_readdir(, ) == -1)
-   goto badrom;
-
-   if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
-   printk(KERN_INFO "nubus_get_rom_dir: entry %02x %06x\n", 
ent.type, ent.data);
-   /* This one takes us to where we want to go. */
-   if (nubus_readdir(, ) == -1) 
-   goto badrom;
-   if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
-   printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", 
ent.type, ent.data);
-   nubus_get_subdir(, );
-
-   /* Resource ID 01, also an "Unknown Macintosh" */
-   if (nubus_readdir(, ) == -1) 
-   goto badrom;
-   if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
-   printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", 
ent.type, ent.data);
-
-   /* FIXME: the first one is *not* always the right one.  We
-  suspect this has something to do with the ROM revision.
-  "The HORROR ROM" (LC-series) uses 0x7e, while "The HORROR
-  Continues" (Q630) uses 0x7b.  The DAFB Macs evidently use
-  something else.  Please run "Slots" on your Mac (see
-  include/linux/nubus.h for where to get this program) and
-  tell us where the 'SiDirPtr' for Slot 0 is.  If you feel
-  brave, you should also use MacsBug to walk down the ROM
-  directories like this function does and try to find the
-  path to that address... */
-   if (nubus_readdir(, ) == -1)
-   goto badrom;
-   if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
-   printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", 
ent.type, ent.data);
-   
-   /* Bwahahahaha... */
-   nubus_get_subdir(, );
-   board->directory = dir.base;
-   return;
-   
-   /* Even more evil laughter... */
- badrom:
-   board->directory = board->fblock;
-   nubus_move(>directory, 

[PATCH 07/10] nubus: Clean up printk calls (from mac68k CVS)

2017-04-08 Thread Finn Thain
From: David Huggins-Daines 

Some long forgotten changes from the linux-mac68k CVS:

Fix swapped DrvrSW and DrvrHW values in printk message.
Suppress debug printk messages.
Avoid console_loglevel misuse.

The original commits are these:

http://linux-mac68k.cvs.sourceforge.net/viewvc/linux-mac68k/linux-mac68k/drivers/nubus/nubus.c?r1=1.22.2.1=1.22.2.2=linux-2_2
http://linux-mac68k.cvs.sourceforge.net/viewvc/linux-mac68k/linux-mac68k/drivers/nubus/nubus.c?r1=1.21=1.22=linux-2_2

The CVS commits fell short of removing all of the misuse of
console_loglevel in nubus_add_board() so I finished the job.
I've also added some missing message severity levels and converted
a printk loop to the MAC address "%pM" format specifier.

Signed-off-by: Finn Thain 
---
 drivers/nubus/nubus.c | 149 ++
 1 file changed, 65 insertions(+), 84 deletions(-)

diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index ef3d7d1..1acf31c 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -94,7 +94,7 @@ static void nubus_rewind(unsigned char **ptr, int len, int 
map)
 
/* Sanity check */
if(len > 65536)
-   printk(KERN_ERR "rewind of 0x%08x!\n", len);
+   pr_err("rewind of 0x%08x!\n", len);
while(len)
{
do
@@ -111,7 +111,7 @@ static void nubus_advance(unsigned char **ptr, int len, int 
map)
 {
unsigned char *p = *ptr;
if(len>65536)
-   printk(KERN_ERR "advance of 0x%08x!\n", len);
+   pr_err("advance of 0x%08x!\n", len);
while(len)
{
while(not_useful(p,map))
@@ -366,14 +366,14 @@ static int __init nubus_show_display_resource(struct 
nubus_dev* dev,
 {
switch (ent->type) {
case NUBUS_RESID_GAMMADIR:
-   printk(KERN_INFO "gamma directory offset: 0x%06x\n", 
ent->data);
+   pr_info("gamma directory offset: 0x%06x\n", ent->data);
break;
case 0x0080 ... 0x0085:
-   printk(KERN_INFO "mode %02X info offset: 0x%06x\n",
+   pr_info("mode %02X info offset: 0x%06x\n",
   ent->type, ent->data);
break;
default:
-   printk(KERN_INFO "unknown resource %02X, data 0x%06x\n",
+   pr_info("unknown resource %02X, data 0x%06x\n",
   ent->type, ent->data);
}
return 0;
@@ -386,18 +386,13 @@ static int __init nubus_show_network_resource(struct 
nubus_dev* dev,
case NUBUS_RESID_MAC_ADDRESS:
{
char addr[6];
-   int i;

nubus_get_rsrc_mem(addr, ent, 6);
-   printk(KERN_INFO "MAC address: ");
-   for (i = 0; i < 6; i++)
-   printk("%02x%s", addr[i] & 0xff,
-  i == 5 ? "" : ":");
-   printk("\n");
+   pr_info("MAC address: %pM\n", addr);
break;
}
default:
-   printk(KERN_INFO "unknown resource %02X, data 0x%06x\n",
+   pr_info("unknown resource %02X, data 0x%06x\n",
   ent->type, ent->data);
}
return 0;
@@ -411,7 +406,7 @@ static int __init nubus_show_cpu_resource(struct nubus_dev* 
dev,
{
unsigned long meminfo[2];
nubus_get_rsrc_mem(, ent, 8);
-   printk(KERN_INFO "memory: [ 0x%08lx 0x%08lx ]\n",
+   pr_info("memory: [ 0x%08lx 0x%08lx ]\n",
   meminfo[0], meminfo[1]);
break;
}
@@ -419,12 +414,12 @@ static int __init nubus_show_cpu_resource(struct 
nubus_dev* dev,
{
unsigned long rominfo[2];
nubus_get_rsrc_mem(, ent, 8);
-   printk(KERN_INFO "ROM:[ 0x%08lx 0x%08lx ]\n",
+   pr_info("ROM:[ 0x%08lx 0x%08lx ]\n",
   rominfo[0], rominfo[1]);
break;
}
default:
-   printk(KERN_INFO "unknown resource %02X, data 0x%06x\n",
+   pr_info("unknown resource %02X, data 0x%06x\n",
   ent->type, ent->data);
}
return 0;
@@ -444,7 +439,7 @@ static int __init nubus_show_private_resource(struct 
nubus_dev* dev,
nubus_show_cpu_resource(dev, ent);
break;
default:
-   printk(KERN_INFO "unknown resource %02X, data 0x%06x\n",
+   pr_info("unknown resource %02X, data 0x%06x\n",
   ent->type, ent->data);
}
return 0;
@@ -459,12 +454,11 @@ static struct nubus_dev* __init
struct nubus_dirent ent;
struct nubus_dev*   dev;

-   printk(KERN_INFO "  Function 0x%02x:\n", parent->type);
+   pr_info("  Function 

[PATCH 09/10] nubus: Clean up whitespace

2017-04-08 Thread Finn Thain
Signed-off-by: Finn Thain 
---
 drivers/nubus/nubus.c | 284 --
 1 file changed, 134 insertions(+), 150 deletions(-)

diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index eac5ec2..bb81347 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -35,8 +35,8 @@ extern void oss_nubus_init(void);
 
 /* Globals */
 
-struct nubus_dev*   nubus_devices;
-struct nubus_board* nubus_boards;
+struct nubus_dev *nubus_devices;
+struct nubus_board *nubus_boards;
 
 /* Meaning of "bytelanes":
 
@@ -60,26 +60,26 @@ struct nubus_board* nubus_boards;
 
Etcetera, etcetera.  Hopefully this clears up some confusion over
what the following code actually does.  */
- 
+
 static inline int not_useful(void *p, int map)
 {
-   unsigned long pv=(unsigned long)p;
+   unsigned long pv = (unsigned long)p;
+
pv &= 3;
-   if(map & (1< 0)
+   if (len > 0)
nubus_advance(ptr, len, map);
-   else if(len < 0)
+   else if (len < 0)
nubus_rewind(ptr, -len, map);
 
if (((unsigned long)*ptr & 0xFF00) != slot_space)
@@ -140,23 +136,24 @@ static void nubus_move(unsigned char **ptr, int len, int 
map)
 
 static inline long nubus_expand32(long foo)
 {
-   if(foo & 0x0080)/* 24bit negative */
+   if (foo & 0x0080)   /* 24bit negative */
foo |= 0xFF00;
return foo;
 }
 
 static inline void *nubus_rom_addr(int slot)
-{  
+{
/*
 *  Returns the first byte after the card. We then walk
 *  backwards to get the lane register and the config
 */
-   return (void *)(0xF100+(slot<<24));
+   return (void *)(0xF100 + (slot << 24));
 }
 
 static unsigned char *nubus_dirptr(const struct nubus_dirent *nd)
 {
unsigned char *p = nd->base;
+
/* Essentially, just step over the bytelanes using whatever
   offset we might have found */
nubus_move(, nubus_expand32(nd->data), nd->mask);
@@ -167,36 +164,36 @@ static unsigned char *nubus_dirptr(const struct 
nubus_dirent *nd)
 /* These two are for pulling resource data blocks (i.e. stuff that's
pointed to with offsets) out of the card ROM. */
 
-void nubus_get_rsrc_mem(void *dest, const struct nubus_dirent* dirent,
+void nubus_get_rsrc_mem(void *dest, const struct nubus_dirent *dirent,
int len)
 {
unsigned char *t = (unsigned char *)dest;
unsigned char *p = nubus_dirptr(dirent);
-   while(len)
-   {
+
+   while (len) {
*t++ = nubus_get_rom(, 1, dirent->mask);
len--;
}
 }
 EXPORT_SYMBOL(nubus_get_rsrc_mem);
 
-void nubus_get_rsrc_str(void *dest, const struct nubus_dirent* dirent,
+void nubus_get_rsrc_str(void *dest, const struct nubus_dirent *dirent,
int len)
 {
-   unsigned char *t=(unsigned char *)dest;
+   unsigned char *t = (unsigned char *)dest;
unsigned char *p = nubus_dirptr(dirent);
-   while(len)
-   {
+
+   while (len) {
*t = nubus_get_rom(, 1, dirent->mask);
-   if(!*t++)
+   if (!*t++)
break;
len--;
}
 }
 EXPORT_SYMBOL(nubus_get_rsrc_str);
 
-int nubus_get_root_dir(const struct nubus_board* board,
-  struct nubus_dir* dir)
+int 

[PATCH 07/10] nubus: Clean up printk calls (from mac68k CVS)

2017-04-08 Thread Finn Thain
From: David Huggins-Daines 

Some long forgotten changes from the linux-mac68k CVS:

Fix swapped DrvrSW and DrvrHW values in printk message.
Suppress debug printk messages.
Avoid console_loglevel misuse.

The original commits are these:

http://linux-mac68k.cvs.sourceforge.net/viewvc/linux-mac68k/linux-mac68k/drivers/nubus/nubus.c?r1=1.22.2.1=1.22.2.2=linux-2_2
http://linux-mac68k.cvs.sourceforge.net/viewvc/linux-mac68k/linux-mac68k/drivers/nubus/nubus.c?r1=1.21=1.22=linux-2_2

The CVS commits fell short of removing all of the misuse of
console_loglevel in nubus_add_board() so I finished the job.
I've also added some missing message severity levels and converted
a printk loop to the MAC address "%pM" format specifier.

Signed-off-by: Finn Thain 
---
 drivers/nubus/nubus.c | 149 ++
 1 file changed, 65 insertions(+), 84 deletions(-)

diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index ef3d7d1..1acf31c 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -94,7 +94,7 @@ static void nubus_rewind(unsigned char **ptr, int len, int 
map)
 
/* Sanity check */
if(len > 65536)
-   printk(KERN_ERR "rewind of 0x%08x!\n", len);
+   pr_err("rewind of 0x%08x!\n", len);
while(len)
{
do
@@ -111,7 +111,7 @@ static void nubus_advance(unsigned char **ptr, int len, int 
map)
 {
unsigned char *p = *ptr;
if(len>65536)
-   printk(KERN_ERR "advance of 0x%08x!\n", len);
+   pr_err("advance of 0x%08x!\n", len);
while(len)
{
while(not_useful(p,map))
@@ -366,14 +366,14 @@ static int __init nubus_show_display_resource(struct 
nubus_dev* dev,
 {
switch (ent->type) {
case NUBUS_RESID_GAMMADIR:
-   printk(KERN_INFO "gamma directory offset: 0x%06x\n", 
ent->data);
+   pr_info("gamma directory offset: 0x%06x\n", ent->data);
break;
case 0x0080 ... 0x0085:
-   printk(KERN_INFO "mode %02X info offset: 0x%06x\n",
+   pr_info("mode %02X info offset: 0x%06x\n",
   ent->type, ent->data);
break;
default:
-   printk(KERN_INFO "unknown resource %02X, data 0x%06x\n",
+   pr_info("unknown resource %02X, data 0x%06x\n",
   ent->type, ent->data);
}
return 0;
@@ -386,18 +386,13 @@ static int __init nubus_show_network_resource(struct 
nubus_dev* dev,
case NUBUS_RESID_MAC_ADDRESS:
{
char addr[6];
-   int i;

nubus_get_rsrc_mem(addr, ent, 6);
-   printk(KERN_INFO "MAC address: ");
-   for (i = 0; i < 6; i++)
-   printk("%02x%s", addr[i] & 0xff,
-  i == 5 ? "" : ":");
-   printk("\n");
+   pr_info("MAC address: %pM\n", addr);
break;
}
default:
-   printk(KERN_INFO "unknown resource %02X, data 0x%06x\n",
+   pr_info("unknown resource %02X, data 0x%06x\n",
   ent->type, ent->data);
}
return 0;
@@ -411,7 +406,7 @@ static int __init nubus_show_cpu_resource(struct nubus_dev* 
dev,
{
unsigned long meminfo[2];
nubus_get_rsrc_mem(, ent, 8);
-   printk(KERN_INFO "memory: [ 0x%08lx 0x%08lx ]\n",
+   pr_info("memory: [ 0x%08lx 0x%08lx ]\n",
   meminfo[0], meminfo[1]);
break;
}
@@ -419,12 +414,12 @@ static int __init nubus_show_cpu_resource(struct 
nubus_dev* dev,
{
unsigned long rominfo[2];
nubus_get_rsrc_mem(, ent, 8);
-   printk(KERN_INFO "ROM:[ 0x%08lx 0x%08lx ]\n",
+   pr_info("ROM:[ 0x%08lx 0x%08lx ]\n",
   rominfo[0], rominfo[1]);
break;
}
default:
-   printk(KERN_INFO "unknown resource %02X, data 0x%06x\n",
+   pr_info("unknown resource %02X, data 0x%06x\n",
   ent->type, ent->data);
}
return 0;
@@ -444,7 +439,7 @@ static int __init nubus_show_private_resource(struct 
nubus_dev* dev,
nubus_show_cpu_resource(dev, ent);
break;
default:
-   printk(KERN_INFO "unknown resource %02X, data 0x%06x\n",
+   pr_info("unknown resource %02X, data 0x%06x\n",
   ent->type, ent->data);
}
return 0;
@@ -459,12 +454,11 @@ static struct nubus_dev* __init
struct nubus_dirent ent;
struct nubus_dev*   dev;

-   printk(KERN_INFO "  Function 0x%02x:\n", parent->type);
+   pr_info("  Function 0x%02x:\n", parent->type);

[PATCH 09/10] nubus: Clean up whitespace

2017-04-08 Thread Finn Thain
Signed-off-by: Finn Thain 
---
 drivers/nubus/nubus.c | 284 --
 1 file changed, 134 insertions(+), 150 deletions(-)

diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index eac5ec2..bb81347 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -35,8 +35,8 @@ extern void oss_nubus_init(void);
 
 /* Globals */
 
-struct nubus_dev*   nubus_devices;
-struct nubus_board* nubus_boards;
+struct nubus_dev *nubus_devices;
+struct nubus_board *nubus_boards;
 
 /* Meaning of "bytelanes":
 
@@ -60,26 +60,26 @@ struct nubus_board* nubus_boards;
 
Etcetera, etcetera.  Hopefully this clears up some confusion over
what the following code actually does.  */
- 
+
 static inline int not_useful(void *p, int map)
 {
-   unsigned long pv=(unsigned long)p;
+   unsigned long pv = (unsigned long)p;
+
pv &= 3;
-   if(map & (1< 0)
+   if (len > 0)
nubus_advance(ptr, len, map);
-   else if(len < 0)
+   else if (len < 0)
nubus_rewind(ptr, -len, map);
 
if (((unsigned long)*ptr & 0xFF00) != slot_space)
@@ -140,23 +136,24 @@ static void nubus_move(unsigned char **ptr, int len, int 
map)
 
 static inline long nubus_expand32(long foo)
 {
-   if(foo & 0x0080)/* 24bit negative */
+   if (foo & 0x0080)   /* 24bit negative */
foo |= 0xFF00;
return foo;
 }
 
 static inline void *nubus_rom_addr(int slot)
-{  
+{
/*
 *  Returns the first byte after the card. We then walk
 *  backwards to get the lane register and the config
 */
-   return (void *)(0xF100+(slot<<24));
+   return (void *)(0xF100 + (slot << 24));
 }
 
 static unsigned char *nubus_dirptr(const struct nubus_dirent *nd)
 {
unsigned char *p = nd->base;
+
/* Essentially, just step over the bytelanes using whatever
   offset we might have found */
nubus_move(, nubus_expand32(nd->data), nd->mask);
@@ -167,36 +164,36 @@ static unsigned char *nubus_dirptr(const struct 
nubus_dirent *nd)
 /* These two are for pulling resource data blocks (i.e. stuff that's
pointed to with offsets) out of the card ROM. */
 
-void nubus_get_rsrc_mem(void *dest, const struct nubus_dirent* dirent,
+void nubus_get_rsrc_mem(void *dest, const struct nubus_dirent *dirent,
int len)
 {
unsigned char *t = (unsigned char *)dest;
unsigned char *p = nubus_dirptr(dirent);
-   while(len)
-   {
+
+   while (len) {
*t++ = nubus_get_rom(, 1, dirent->mask);
len--;
}
 }
 EXPORT_SYMBOL(nubus_get_rsrc_mem);
 
-void nubus_get_rsrc_str(void *dest, const struct nubus_dirent* dirent,
+void nubus_get_rsrc_str(void *dest, const struct nubus_dirent *dirent,
int len)
 {
-   unsigned char *t=(unsigned char *)dest;
+   unsigned char *t = (unsigned char *)dest;
unsigned char *p = nubus_dirptr(dirent);
-   while(len)
-   {
+
+   while (len) {
*t = nubus_get_rom(, 1, dirent->mask);
-   if(!*t++)
+   if (!*t++)
break;
len--;
}
 }
 EXPORT_SYMBOL(nubus_get_rsrc_str);
 
-int nubus_get_root_dir(const struct nubus_board* board,
-  struct nubus_dir* dir)
+int nubus_get_root_dir(const struct nubus_board *board,
+  struct nubus_dir *dir)
 {
dir->ptr = dir->base = board->directory;
dir->done = 0;
@@ -206,8 +203,8 @@ int nubus_get_root_dir(const struct nubus_board* board,
 EXPORT_SYMBOL(nubus_get_root_dir);
 
 /* This is a slyly renamed version of the above */
-int nubus_get_func_dir(const struct nubus_dev* dev,
-  struct nubus_dir* dir)
+int nubus_get_func_dir(const struct nubus_dev *dev,
+  struct nubus_dir *dir)
 {
dir->ptr = dir->base = dev->directory;
dir->done = 0;
@@ -216,11 +213,11 @@ int nubus_get_func_dir(const struct nubus_dev* dev,
 }
 EXPORT_SYMBOL(nubus_get_func_dir);
 
-int nubus_get_board_dir(const struct nubus_board* board,
-   struct nubus_dir* dir)
+int nubus_get_board_dir(const struct nubus_board *board,
+   struct nubus_dir *dir)
 {
struct nubus_dirent ent;
-   
+
dir->ptr = dir->base = board->directory;
dir->done = 0;
dir->mask = board->lanes;
@@ -248,6 +245,7 @@ EXPORT_SYMBOL(nubus_get_subdir);
 int nubus_readdir(struct nubus_dir *nd, struct nubus_dirent *ent)
 {
u32 resid;
+
if (nd->done)
return -1;
 
@@ -258,27 +256,25 @@ int nubus_readdir(struct nubus_dir *nd, struct 
nubus_dirent *ent)
resid = nubus_get_rom(>ptr, 4, nd->mask);
 
/* EOL marker, as per the Apple docs */
-   if((resid&0xff00) == 0xff00)
-   {
+   if ((resid & 0xff00) == 0xff00) {
  

[PATCH 08/10] nubus: Fix pointer validation

2017-04-08 Thread Finn Thain
Fix bounds checking on slot-space pointer movement.
Remove redundant test for zero byte-lanes value.
Fix broken byte-lanes vs. address validation.

Signed-off-by: Finn Thain 
---
 drivers/nubus/nubus.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index 1acf31c..eac5ec2 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -92,9 +92,6 @@ static void nubus_rewind(unsigned char **ptr, int len, int 
map)
 {
unsigned char *p=*ptr;
 
-   /* Sanity check */
-   if(len > 65536)
-   pr_err("rewind of 0x%08x!\n", len);
while(len)
{
do
@@ -110,8 +107,7 @@ static void nubus_rewind(unsigned char **ptr, int len, int 
map)
 static void nubus_advance(unsigned char **ptr, int len, int map)
 {
unsigned char *p = *ptr;
-   if(len>65536)
-   pr_err("advance of 0x%08x!\n", len);
+
while(len)
{
while(not_useful(p,map))
@@ -124,10 +120,15 @@ static void nubus_advance(unsigned char **ptr, int len, 
int map)
 
 static void nubus_move(unsigned char **ptr, int len, int map)
 {
+   unsigned long slot_space = (unsigned long)*ptr & 0xFF00;
+
if(len > 0)
nubus_advance(ptr, len, map);
else if(len < 0)
nubus_rewind(ptr, -len, map);
+
+   if (((unsigned long)*ptr & 0xFF00) != slot_space)
+   pr_err("%s: moved out of slot address space!\n", __func__);
 }
 
 /* Now, functions to read the sResource tree */
@@ -822,8 +823,6 @@ void __init nubus_probe_slot(int slot)
continue;
 
dp = *rp;
-   if(dp == 0)
-   continue;
 
/* The last byte of the format block consists of two
   nybbles which are "mirror images" of each other.
@@ -832,7 +831,7 @@ void __init nubus_probe_slot(int slot)
continue;
/* Check that this value is actually *on* one of the
   bytelanes it claims are valid! */
-   if ((dp & 0x0F) >= (1<

[PATCH 08/10] nubus: Fix pointer validation

2017-04-08 Thread Finn Thain
Fix bounds checking on slot-space pointer movement.
Remove redundant test for zero byte-lanes value.
Fix broken byte-lanes vs. address validation.

Signed-off-by: Finn Thain 
---
 drivers/nubus/nubus.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index 1acf31c..eac5ec2 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -92,9 +92,6 @@ static void nubus_rewind(unsigned char **ptr, int len, int 
map)
 {
unsigned char *p=*ptr;
 
-   /* Sanity check */
-   if(len > 65536)
-   pr_err("rewind of 0x%08x!\n", len);
while(len)
{
do
@@ -110,8 +107,7 @@ static void nubus_rewind(unsigned char **ptr, int len, int 
map)
 static void nubus_advance(unsigned char **ptr, int len, int map)
 {
unsigned char *p = *ptr;
-   if(len>65536)
-   pr_err("advance of 0x%08x!\n", len);
+
while(len)
{
while(not_useful(p,map))
@@ -124,10 +120,15 @@ static void nubus_advance(unsigned char **ptr, int len, 
int map)
 
 static void nubus_move(unsigned char **ptr, int len, int map)
 {
+   unsigned long slot_space = (unsigned long)*ptr & 0xFF00;
+
if(len > 0)
nubus_advance(ptr, len, map);
else if(len < 0)
nubus_rewind(ptr, -len, map);
+
+   if (((unsigned long)*ptr & 0xFF00) != slot_space)
+   pr_err("%s: moved out of slot address space!\n", __func__);
 }
 
 /* Now, functions to read the sResource tree */
@@ -822,8 +823,6 @@ void __init nubus_probe_slot(int slot)
continue;
 
dp = *rp;
-   if(dp == 0)
-   continue;
 
/* The last byte of the format block consists of two
   nybbles which are "mirror images" of each other.
@@ -832,7 +831,7 @@ void __init nubus_probe_slot(int slot)
continue;
/* Check that this value is actually *on* one of the
   bytelanes it claims are valid! */
-   if ((dp & 0x0F) >= (1<

[PATCH 04/10] m68k/mac: Clarify IOP message alloc/free confusion

2017-04-08 Thread Finn Thain
The alloc/free metaphor used for IOP messages is misleading and can
cause mistakes like the pointless msg2 temporary variable. Use a more
meaningful name to help simplify the code.

Signed-off-by: Finn Thain 
---
 arch/m68k/mac/iop.c | 19 ++-
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/arch/m68k/mac/iop.c b/arch/m68k/mac/iop.c
index 1746cfc..4c1e606 100644
--- a/arch/m68k/mac/iop.c
+++ b/arch/m68k/mac/iop.c
@@ -210,7 +210,7 @@ static int iop_alive(volatile struct mac_iop *iop)
return retval;
 }
 
-static struct iop_msg *iop_alloc_msg(void)
+static struct iop_msg *iop_get_unused_msg(void)
 {
int i;
unsigned long flags;
@@ -229,11 +229,6 @@ static struct iop_msg *iop_alloc_msg(void)
return NULL;
 }
 
-static void iop_free_msg(struct iop_msg *msg)
-{
-   msg->status = IOP_MSGSTATUS_UNUSED;
-}
-
 /*
  * This is called by the startup code before anything else. Its purpose
  * is to find and initialize the IOPs early in the boot sequence, so that
@@ -372,7 +367,7 @@ void iop_complete_message(struct iop_msg *msg)
   IOP_ADDR_RECV_STATE + chan, IOP_MSG_COMPLETE);
iop_interrupt(iop_base[msg->iop_num]);
 
-   iop_free_msg(msg);
+   msg->status = IOP_MSGSTATUS_UNUSED;
 }
 
 /*
@@ -403,7 +398,7 @@ static void iop_do_send(struct iop_msg *msg)
 static void iop_handle_send(uint iop_num, uint chan)
 {
volatile struct mac_iop *iop = iop_base[iop_num];
-   struct iop_msg *msg,*msg2;
+   struct iop_msg *msg;
int i,offset;
 
iop_pr_debug("iop_num %d chan %d\n", iop_num, chan);
@@ -418,10 +413,8 @@ static void iop_handle_send(uint iop_num, uint chan)
msg->reply[i] = iop_readb(iop, offset);
}
if (msg->handler) (*msg->handler)(msg);
-   msg2 = msg;
+   msg->status = IOP_MSGSTATUS_UNUSED;
msg = msg->next;
-   iop_free_msg(msg2);
-
iop_send_queue[iop_num][chan] = msg;
if (msg) iop_do_send(msg);
 }
@@ -439,7 +432,7 @@ static void iop_handle_recv(uint iop_num, uint chan)
 
iop_pr_debug("iop_num %d chan %d\n", iop_num, chan);
 
-   msg = iop_alloc_msg();
+   msg = iop_get_unused_msg();
msg->iop_num = iop_num;
msg->channel = chan;
msg->status = IOP_MSGSTATUS_UNSOL;
@@ -484,7 +477,7 @@ int iop_send_message(uint iop_num, uint chan, void 
*privdata,
if (chan >= NUM_IOP_CHAN) return -EINVAL;
if (msg_len > IOP_MSG_LEN) return -EINVAL;
 
-   msg = iop_alloc_msg();
+   msg = iop_get_unused_msg();
if (!msg) return -ENOMEM;
 
msg->next = NULL;
-- 
2.10.2



[PATCH 02/10] m68k/mac: Modernize printing of kernel messages

2017-04-08 Thread Finn Thain
From: Geert Uytterhoeven 

Convert from printk() to pr_*().

[Adjusted log message severity levels and retained bootinfo log. -- FT]

Signed-off-by: Finn Thain 
---
 arch/m68k/mac/config.c | 12 +---
 arch/m68k/mac/misc.c   | 23 +--
 2 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index 9dc65a4..661892d 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -150,7 +150,7 @@ static void mac_cache_card_flush(int writeback)
 void __init config_mac(void)
 {
if (!MACH_IS_MAC)
-   printk(KERN_ERR "ERROR: no Mac, but config_mac() called!!\n");
+   pr_err("ERROR: no Mac, but config_mac() called!!\n");
 
mach_sched_init = mac_sched_init;
mach_init_IRQ = mac_init_IRQ;
@@ -837,8 +837,7 @@ static void __init mac_identify(void)
/* no bootinfo model id -> NetBSD booter was used! */
/* XXX FIXME: breaks for model > 31 */
model = (mac_bi_data.cpuid >> 2) & 63;
-   printk(KERN_WARNING "No bootinfo model ID, using cpuid instead "
-  "(obsolete bootloader?)\n");
+   pr_warn("No bootinfo model ID, using cpuid instead (obsolete 
bootloader?)\n");
}
 
macintosh_config = mac_data_table;
@@ -880,14 +879,13 @@ static void __init mac_identify(void)
 */
iop_preinit();
 
-   printk(KERN_INFO "Detected Macintosh model: %d\n", model);
+   pr_info("Detected Macintosh model: %d\n", model);
 
/*
 * Report booter data:
 */
printk(KERN_DEBUG " Penguin bootinfo data:\n");
-   printk(KERN_DEBUG " Video: addr 0x%lx "
-   "row 0x%lx depth %lx dimensions %ld x %ld\n",
+   printk(KERN_DEBUG " Video: addr 0x%lx row 0x%lx depth %lx dimensions 
%ld x %ld\n",
mac_bi_data.videoaddr, mac_bi_data.videorow,
mac_bi_data.videodepth, mac_bi_data.dimensions & 0x,
mac_bi_data.dimensions >> 16);
@@ -912,7 +910,7 @@ static void __init mac_identify(void)
 
 static void __init mac_report_hardware(void)
 {
-   printk(KERN_INFO "Apple Macintosh %s\n", macintosh_config->name);
+   pr_info("Apple Macintosh %s\n", macintosh_config->name);
 }
 
 static void mac_get_model(char *str)
diff --git a/arch/m68k/mac/misc.c b/arch/m68k/mac/misc.c
index 5b01704..8aa8792 100644
--- a/arch/m68k/mac/misc.c
+++ b/arch/m68k/mac/misc.c
@@ -281,8 +281,7 @@ static long via_read_time(void)
last_result.idata = result.idata;
}
 
-   pr_err("via_read_time: failed to read a stable value; "
-  "got 0x%08lx then 0x%08lx\n",
+   pr_err("via_read_time: failed to read a stable value; got 0x%08lx then 
0x%08lx\n",
   last_result.idata, result.idata);
 
return 0;
@@ -465,7 +464,7 @@ void mac_poweroff(void)
 #endif
}
local_irq_enable();
-   printk("It is now safe to turn off your Macintosh.\n");
+   pr_crit("It is now safe to turn off your Macintosh.\n");
while(1);
 }
 
@@ -556,7 +555,7 @@ void mac_reset(void)
 
/* should never get here */
local_irq_enable();
-   printk ("Restart failed.  Please restart manually.\n");
+   pr_crit("Restart failed. Please restart manually.\n");
while(1);
 }
 
@@ -661,17 +660,13 @@ int mac_hwclk(int op, struct rtc_time *t)
unmktime(now, 0,
 >tm_year, >tm_mon, >tm_mday,
 >tm_hour, >tm_min, >tm_sec);
-#if 0
-   printk("mac_hwclk: read %04d-%02d-%-2d %02d:%02d:%02d\n",
-   t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
-   t->tm_hour, t->tm_min, t->tm_sec);
-#endif
+   pr_debug("%s: read %04d-%02d-%-2d %02d:%02d:%02d\n",
+__func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
+t->tm_hour, t->tm_min, t->tm_sec);
} else { /* write */
-#if 0
-   printk("mac_hwclk: tried to write %04d-%02d-%-2d 
%02d:%02d:%02d\n",
-   t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
-   t->tm_hour, t->tm_min, t->tm_sec);
-#endif
+   pr_debug("%s: tried to write %04d-%02d-%-2d %02d:%02d:%02d\n",
+__func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
+t->tm_hour, t->tm_min, t->tm_sec);
 
now = mktime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
 t->tm_hour, t->tm_min, t->tm_sec);
-- 
2.10.2



[PATCH 04/10] m68k/mac: Clarify IOP message alloc/free confusion

2017-04-08 Thread Finn Thain
The alloc/free metaphor used for IOP messages is misleading and can
cause mistakes like the pointless msg2 temporary variable. Use a more
meaningful name to help simplify the code.

Signed-off-by: Finn Thain 
---
 arch/m68k/mac/iop.c | 19 ++-
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/arch/m68k/mac/iop.c b/arch/m68k/mac/iop.c
index 1746cfc..4c1e606 100644
--- a/arch/m68k/mac/iop.c
+++ b/arch/m68k/mac/iop.c
@@ -210,7 +210,7 @@ static int iop_alive(volatile struct mac_iop *iop)
return retval;
 }
 
-static struct iop_msg *iop_alloc_msg(void)
+static struct iop_msg *iop_get_unused_msg(void)
 {
int i;
unsigned long flags;
@@ -229,11 +229,6 @@ static struct iop_msg *iop_alloc_msg(void)
return NULL;
 }
 
-static void iop_free_msg(struct iop_msg *msg)
-{
-   msg->status = IOP_MSGSTATUS_UNUSED;
-}
-
 /*
  * This is called by the startup code before anything else. Its purpose
  * is to find and initialize the IOPs early in the boot sequence, so that
@@ -372,7 +367,7 @@ void iop_complete_message(struct iop_msg *msg)
   IOP_ADDR_RECV_STATE + chan, IOP_MSG_COMPLETE);
iop_interrupt(iop_base[msg->iop_num]);
 
-   iop_free_msg(msg);
+   msg->status = IOP_MSGSTATUS_UNUSED;
 }
 
 /*
@@ -403,7 +398,7 @@ static void iop_do_send(struct iop_msg *msg)
 static void iop_handle_send(uint iop_num, uint chan)
 {
volatile struct mac_iop *iop = iop_base[iop_num];
-   struct iop_msg *msg,*msg2;
+   struct iop_msg *msg;
int i,offset;
 
iop_pr_debug("iop_num %d chan %d\n", iop_num, chan);
@@ -418,10 +413,8 @@ static void iop_handle_send(uint iop_num, uint chan)
msg->reply[i] = iop_readb(iop, offset);
}
if (msg->handler) (*msg->handler)(msg);
-   msg2 = msg;
+   msg->status = IOP_MSGSTATUS_UNUSED;
msg = msg->next;
-   iop_free_msg(msg2);
-
iop_send_queue[iop_num][chan] = msg;
if (msg) iop_do_send(msg);
 }
@@ -439,7 +432,7 @@ static void iop_handle_recv(uint iop_num, uint chan)
 
iop_pr_debug("iop_num %d chan %d\n", iop_num, chan);
 
-   msg = iop_alloc_msg();
+   msg = iop_get_unused_msg();
msg->iop_num = iop_num;
msg->channel = chan;
msg->status = IOP_MSGSTATUS_UNSOL;
@@ -484,7 +477,7 @@ int iop_send_message(uint iop_num, uint chan, void 
*privdata,
if (chan >= NUM_IOP_CHAN) return -EINVAL;
if (msg_len > IOP_MSG_LEN) return -EINVAL;
 
-   msg = iop_alloc_msg();
+   msg = iop_get_unused_msg();
if (!msg) return -ENOMEM;
 
msg->next = NULL;
-- 
2.10.2



[PATCH 02/10] m68k/mac: Modernize printing of kernel messages

2017-04-08 Thread Finn Thain
From: Geert Uytterhoeven 

Convert from printk() to pr_*().

[Adjusted log message severity levels and retained bootinfo log. -- FT]

Signed-off-by: Finn Thain 
---
 arch/m68k/mac/config.c | 12 +---
 arch/m68k/mac/misc.c   | 23 +--
 2 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index 9dc65a4..661892d 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -150,7 +150,7 @@ static void mac_cache_card_flush(int writeback)
 void __init config_mac(void)
 {
if (!MACH_IS_MAC)
-   printk(KERN_ERR "ERROR: no Mac, but config_mac() called!!\n");
+   pr_err("ERROR: no Mac, but config_mac() called!!\n");
 
mach_sched_init = mac_sched_init;
mach_init_IRQ = mac_init_IRQ;
@@ -837,8 +837,7 @@ static void __init mac_identify(void)
/* no bootinfo model id -> NetBSD booter was used! */
/* XXX FIXME: breaks for model > 31 */
model = (mac_bi_data.cpuid >> 2) & 63;
-   printk(KERN_WARNING "No bootinfo model ID, using cpuid instead "
-  "(obsolete bootloader?)\n");
+   pr_warn("No bootinfo model ID, using cpuid instead (obsolete 
bootloader?)\n");
}
 
macintosh_config = mac_data_table;
@@ -880,14 +879,13 @@ static void __init mac_identify(void)
 */
iop_preinit();
 
-   printk(KERN_INFO "Detected Macintosh model: %d\n", model);
+   pr_info("Detected Macintosh model: %d\n", model);
 
/*
 * Report booter data:
 */
printk(KERN_DEBUG " Penguin bootinfo data:\n");
-   printk(KERN_DEBUG " Video: addr 0x%lx "
-   "row 0x%lx depth %lx dimensions %ld x %ld\n",
+   printk(KERN_DEBUG " Video: addr 0x%lx row 0x%lx depth %lx dimensions 
%ld x %ld\n",
mac_bi_data.videoaddr, mac_bi_data.videorow,
mac_bi_data.videodepth, mac_bi_data.dimensions & 0x,
mac_bi_data.dimensions >> 16);
@@ -912,7 +910,7 @@ static void __init mac_identify(void)
 
 static void __init mac_report_hardware(void)
 {
-   printk(KERN_INFO "Apple Macintosh %s\n", macintosh_config->name);
+   pr_info("Apple Macintosh %s\n", macintosh_config->name);
 }
 
 static void mac_get_model(char *str)
diff --git a/arch/m68k/mac/misc.c b/arch/m68k/mac/misc.c
index 5b01704..8aa8792 100644
--- a/arch/m68k/mac/misc.c
+++ b/arch/m68k/mac/misc.c
@@ -281,8 +281,7 @@ static long via_read_time(void)
last_result.idata = result.idata;
}
 
-   pr_err("via_read_time: failed to read a stable value; "
-  "got 0x%08lx then 0x%08lx\n",
+   pr_err("via_read_time: failed to read a stable value; got 0x%08lx then 
0x%08lx\n",
   last_result.idata, result.idata);
 
return 0;
@@ -465,7 +464,7 @@ void mac_poweroff(void)
 #endif
}
local_irq_enable();
-   printk("It is now safe to turn off your Macintosh.\n");
+   pr_crit("It is now safe to turn off your Macintosh.\n");
while(1);
 }
 
@@ -556,7 +555,7 @@ void mac_reset(void)
 
/* should never get here */
local_irq_enable();
-   printk ("Restart failed.  Please restart manually.\n");
+   pr_crit("Restart failed. Please restart manually.\n");
while(1);
 }
 
@@ -661,17 +660,13 @@ int mac_hwclk(int op, struct rtc_time *t)
unmktime(now, 0,
 >tm_year, >tm_mon, >tm_mday,
 >tm_hour, >tm_min, >tm_sec);
-#if 0
-   printk("mac_hwclk: read %04d-%02d-%-2d %02d:%02d:%02d\n",
-   t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
-   t->tm_hour, t->tm_min, t->tm_sec);
-#endif
+   pr_debug("%s: read %04d-%02d-%-2d %02d:%02d:%02d\n",
+__func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
+t->tm_hour, t->tm_min, t->tm_sec);
} else { /* write */
-#if 0
-   printk("mac_hwclk: tried to write %04d-%02d-%-2d 
%02d:%02d:%02d\n",
-   t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
-   t->tm_hour, t->tm_min, t->tm_sec);
-#endif
+   pr_debug("%s: tried to write %04d-%02d-%-2d %02d:%02d:%02d\n",
+__func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
+t->tm_hour, t->tm_min, t->tm_sec);
 
now = mktime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
 t->tm_hour, t->tm_min, t->tm_sec);
-- 
2.10.2



[PATCH 01/10] m68k/mac: IOP - Modernize printing of kernel messages

2017-04-08 Thread Finn Thain
From: Geert Uytterhoeven 

  - Introduce helpers for printing debug messages, incl. dummies for
validating format strings when debugging is disabled,
  - Convert from printk() to pr_*(),
  - Add missing continuations,
  - Drop superfluous casts.

[Renamed pr_iop* macros, adjusted log message severity and
eliminated DEBUG_IOP. -- FT]

Signed-off-by: Finn Thain 
---
 arch/m68k/mac/iop.c | 74 +
 1 file changed, 29 insertions(+), 45 deletions(-)

diff --git a/arch/m68k/mac/iop.c b/arch/m68k/mac/iop.c
index 7990b6f..1746cfc 100644
--- a/arch/m68k/mac/iop.c
+++ b/arch/m68k/mac/iop.c
@@ -115,7 +115,17 @@
 #include 
 #include 
 
-/*#define DEBUG_IOP*/
+#ifdef DEBUG
+#define iop_pr_debug(fmt, ...) \
+   printk(KERN_DEBUG "%s: " fmt, __func__, ##__VA_ARGS__)
+#define iop_pr_cont(fmt, ...) \
+   printk(KERN_CONT fmt, ##__VA_ARGS__)
+#else
+#define iop_pr_debug(fmt, ...) \
+   no_printk(KERN_DEBUG "%s: " fmt, __func__, ##__VA_ARGS__)
+#define iop_pr_cont(fmt, ...) \
+   no_printk(KERN_CONT fmt, ##__VA_ARGS__)
+#endif
 
 /* Non-zero if the IOPs are present */
 
@@ -268,10 +278,10 @@ void __init iop_init(void)
int i;
 
if (iop_scc_present) {
-   printk("IOP: detected SCC IOP at %p\n", iop_base[IOP_NUM_SCC]);
+   pr_info("IOP: detected SCC IOP at %p\n", iop_base[IOP_NUM_SCC]);
}
if (iop_ism_present) {
-   printk("IOP: detected ISM IOP at %p\n", iop_base[IOP_NUM_ISM]);
+   pr_info("IOP: detected ISM IOP at %p\n", iop_base[IOP_NUM_ISM]);
iop_start(iop_base[IOP_NUM_ISM]);
iop_alive(iop_base[IOP_NUM_ISM]); /* clears the alive flag */
}
@@ -310,9 +320,9 @@ void __init iop_register_interrupts(void)
pr_err("Couldn't register ISM IOP interrupt\n");
}
if (!iop_alive(iop_base[IOP_NUM_ISM])) {
-   printk("IOP: oh my god, they killed the ISM IOP!\n");
+   pr_warn("IOP: oh my god, they killed the ISM IOP!\n");
} else {
-   printk("IOP: the ISM IOP seems to be alive.\n");
+   pr_warn("IOP: the ISM IOP seems to be alive.\n");
}
}
 }
@@ -349,9 +359,8 @@ void iop_complete_message(struct iop_msg *msg)
int chan = msg->channel;
int i,offset;
 
-#ifdef DEBUG_IOP
-   printk("iop_complete(%p): iop %d chan %d\n", msg, msg->iop_num, 
msg->channel);
-#endif
+   iop_pr_debug("msg %p iop_num %d channel %d\n", msg, msg->iop_num,
+msg->channel);
 
offset = IOP_ADDR_RECV_MSG + (msg->channel * IOP_MSG_LEN);
 
@@ -397,9 +406,7 @@ static void iop_handle_send(uint iop_num, uint chan)
struct iop_msg *msg,*msg2;
int i,offset;
 
-#ifdef DEBUG_IOP
-   printk("iop_handle_send: iop %d channel %d\n", iop_num, chan);
-#endif
+   iop_pr_debug("iop_num %d chan %d\n", iop_num, chan);
 
iop_writeb(iop, IOP_ADDR_SEND_STATE + chan, IOP_MSG_IDLE);
 
@@ -430,9 +437,7 @@ static void iop_handle_recv(uint iop_num, uint chan)
int i,offset;
struct iop_msg *msg;
 
-#ifdef DEBUG_IOP
-   printk("iop_handle_recv: iop %d channel %d\n", iop_num, chan);
-#endif
+   iop_pr_debug("iop_num %d chan %d\n", iop_num, chan);
 
msg = iop_alloc_msg();
msg->iop_num = iop_num;
@@ -454,14 +459,9 @@ static void iop_handle_recv(uint iop_num, uint chan)
if (msg->handler) {
(*msg->handler)(msg);
} else {
-#ifdef DEBUG_IOP
-   printk("iop_handle_recv: unclaimed message on iop %d channel 
%d\n", iop_num, chan);
-   printk("iop_handle_recv:");
-   for (i = 0 ; i < IOP_MSG_LEN ; i++) {
-   printk(" %02X", (uint) msg->message[i]);
-   }
-   printk("\n");
-#endif
+   iop_pr_debug("unclaimed message on iop_num %d chan %d\n",
+iop_num, chan);
+   iop_pr_debug("%*ph\n", IOP_MSG_LEN, msg->message);
iop_complete_message(msg);
}
 }
@@ -574,50 +574,34 @@ irqreturn_t iop_ism_irq(int irq, void *dev_id)
volatile struct mac_iop *iop = iop_base[iop_num];
int i,state;
 
-#ifdef DEBUG_IOP
-   printk("iop_ism_irq: status = %02X\n", (uint) iop->status_ctrl);
-#endif
+   iop_pr_debug("status %02X\n", iop->status_ctrl);
 
/* INT0 indicates a state change on an outgoing message channel */
 
if (iop->status_ctrl & IOP_INT0) {
iop->status_ctrl = IOP_INT0 | IOP_RUN | IOP_AUTOINC;
-#ifdef DEBUG_IOP
-   printk("iop_ism_irq: new status = %02X, send states",
-   (uint) iop->status_ctrl);
-#endif
+   iop_pr_debug("new status %02X, send states", iop->status_ctrl);
for (i = 0 ; i < NUM_IOP_CHAN  

[PATCH 00/10] mac68k: Miscellaneous fixes, cleanup and modernization

2017-04-08 Thread Finn Thain
This series has various patches from several different people. Two printk
modernization patches were originally from Geert Uytterhoeven and three
Nubus patches were originally committed to the Linux/mac68k CVS by
David Huggins-Daines.


Finn Thain (10):
  m68k/mac: IOP - Modernize printing of kernel messages
  m68k/mac: Modernize printing of kernel messages
  m68k/mac: Adopt platform_device_register_simple()
  m68k/mac: Clarify IOP message alloc/free confusion
  nubus: Fix nubus_rewinddir (from mac68k CVS)
  nubus: Remove slot zero probe (from mac68k CVS)
  nubus: Clean up printk calls (from mac68k CVS)
  nubus: Fix pointer validation
  nubus: Clean up whitespace
  nubus: Add MVC and VSC video card definitions

 arch/m68k/mac/config.c |  61 ++---
 arch/m68k/mac/iop.c|  93 +++-
 arch/m68k/mac/misc.c   |  23 +-
 drivers/nubus/nubus.c  | 556 +
 include/uapi/linux/nubus.h |   4 +-
 5 files changed, 275 insertions(+), 462 deletions(-)

-- 
2.10.2



[PATCH 01/10] m68k/mac: IOP - Modernize printing of kernel messages

2017-04-08 Thread Finn Thain
From: Geert Uytterhoeven 

  - Introduce helpers for printing debug messages, incl. dummies for
validating format strings when debugging is disabled,
  - Convert from printk() to pr_*(),
  - Add missing continuations,
  - Drop superfluous casts.

[Renamed pr_iop* macros, adjusted log message severity and
eliminated DEBUG_IOP. -- FT]

Signed-off-by: Finn Thain 
---
 arch/m68k/mac/iop.c | 74 +
 1 file changed, 29 insertions(+), 45 deletions(-)

diff --git a/arch/m68k/mac/iop.c b/arch/m68k/mac/iop.c
index 7990b6f..1746cfc 100644
--- a/arch/m68k/mac/iop.c
+++ b/arch/m68k/mac/iop.c
@@ -115,7 +115,17 @@
 #include 
 #include 
 
-/*#define DEBUG_IOP*/
+#ifdef DEBUG
+#define iop_pr_debug(fmt, ...) \
+   printk(KERN_DEBUG "%s: " fmt, __func__, ##__VA_ARGS__)
+#define iop_pr_cont(fmt, ...) \
+   printk(KERN_CONT fmt, ##__VA_ARGS__)
+#else
+#define iop_pr_debug(fmt, ...) \
+   no_printk(KERN_DEBUG "%s: " fmt, __func__, ##__VA_ARGS__)
+#define iop_pr_cont(fmt, ...) \
+   no_printk(KERN_CONT fmt, ##__VA_ARGS__)
+#endif
 
 /* Non-zero if the IOPs are present */
 
@@ -268,10 +278,10 @@ void __init iop_init(void)
int i;
 
if (iop_scc_present) {
-   printk("IOP: detected SCC IOP at %p\n", iop_base[IOP_NUM_SCC]);
+   pr_info("IOP: detected SCC IOP at %p\n", iop_base[IOP_NUM_SCC]);
}
if (iop_ism_present) {
-   printk("IOP: detected ISM IOP at %p\n", iop_base[IOP_NUM_ISM]);
+   pr_info("IOP: detected ISM IOP at %p\n", iop_base[IOP_NUM_ISM]);
iop_start(iop_base[IOP_NUM_ISM]);
iop_alive(iop_base[IOP_NUM_ISM]); /* clears the alive flag */
}
@@ -310,9 +320,9 @@ void __init iop_register_interrupts(void)
pr_err("Couldn't register ISM IOP interrupt\n");
}
if (!iop_alive(iop_base[IOP_NUM_ISM])) {
-   printk("IOP: oh my god, they killed the ISM IOP!\n");
+   pr_warn("IOP: oh my god, they killed the ISM IOP!\n");
} else {
-   printk("IOP: the ISM IOP seems to be alive.\n");
+   pr_warn("IOP: the ISM IOP seems to be alive.\n");
}
}
 }
@@ -349,9 +359,8 @@ void iop_complete_message(struct iop_msg *msg)
int chan = msg->channel;
int i,offset;
 
-#ifdef DEBUG_IOP
-   printk("iop_complete(%p): iop %d chan %d\n", msg, msg->iop_num, 
msg->channel);
-#endif
+   iop_pr_debug("msg %p iop_num %d channel %d\n", msg, msg->iop_num,
+msg->channel);
 
offset = IOP_ADDR_RECV_MSG + (msg->channel * IOP_MSG_LEN);
 
@@ -397,9 +406,7 @@ static void iop_handle_send(uint iop_num, uint chan)
struct iop_msg *msg,*msg2;
int i,offset;
 
-#ifdef DEBUG_IOP
-   printk("iop_handle_send: iop %d channel %d\n", iop_num, chan);
-#endif
+   iop_pr_debug("iop_num %d chan %d\n", iop_num, chan);
 
iop_writeb(iop, IOP_ADDR_SEND_STATE + chan, IOP_MSG_IDLE);
 
@@ -430,9 +437,7 @@ static void iop_handle_recv(uint iop_num, uint chan)
int i,offset;
struct iop_msg *msg;
 
-#ifdef DEBUG_IOP
-   printk("iop_handle_recv: iop %d channel %d\n", iop_num, chan);
-#endif
+   iop_pr_debug("iop_num %d chan %d\n", iop_num, chan);
 
msg = iop_alloc_msg();
msg->iop_num = iop_num;
@@ -454,14 +459,9 @@ static void iop_handle_recv(uint iop_num, uint chan)
if (msg->handler) {
(*msg->handler)(msg);
} else {
-#ifdef DEBUG_IOP
-   printk("iop_handle_recv: unclaimed message on iop %d channel 
%d\n", iop_num, chan);
-   printk("iop_handle_recv:");
-   for (i = 0 ; i < IOP_MSG_LEN ; i++) {
-   printk(" %02X", (uint) msg->message[i]);
-   }
-   printk("\n");
-#endif
+   iop_pr_debug("unclaimed message on iop_num %d chan %d\n",
+iop_num, chan);
+   iop_pr_debug("%*ph\n", IOP_MSG_LEN, msg->message);
iop_complete_message(msg);
}
 }
@@ -574,50 +574,34 @@ irqreturn_t iop_ism_irq(int irq, void *dev_id)
volatile struct mac_iop *iop = iop_base[iop_num];
int i,state;
 
-#ifdef DEBUG_IOP
-   printk("iop_ism_irq: status = %02X\n", (uint) iop->status_ctrl);
-#endif
+   iop_pr_debug("status %02X\n", iop->status_ctrl);
 
/* INT0 indicates a state change on an outgoing message channel */
 
if (iop->status_ctrl & IOP_INT0) {
iop->status_ctrl = IOP_INT0 | IOP_RUN | IOP_AUTOINC;
-#ifdef DEBUG_IOP
-   printk("iop_ism_irq: new status = %02X, send states",
-   (uint) iop->status_ctrl);
-#endif
+   iop_pr_debug("new status %02X, send states", iop->status_ctrl);
for (i = 0 ; i < NUM_IOP_CHAN  ; i++) {
state = 

[PATCH 00/10] mac68k: Miscellaneous fixes, cleanup and modernization

2017-04-08 Thread Finn Thain
This series has various patches from several different people. Two printk
modernization patches were originally from Geert Uytterhoeven and three
Nubus patches were originally committed to the Linux/mac68k CVS by
David Huggins-Daines.


Finn Thain (10):
  m68k/mac: IOP - Modernize printing of kernel messages
  m68k/mac: Modernize printing of kernel messages
  m68k/mac: Adopt platform_device_register_simple()
  m68k/mac: Clarify IOP message alloc/free confusion
  nubus: Fix nubus_rewinddir (from mac68k CVS)
  nubus: Remove slot zero probe (from mac68k CVS)
  nubus: Clean up printk calls (from mac68k CVS)
  nubus: Fix pointer validation
  nubus: Clean up whitespace
  nubus: Add MVC and VSC video card definitions

 arch/m68k/mac/config.c |  61 ++---
 arch/m68k/mac/iop.c|  93 +++-
 arch/m68k/mac/misc.c   |  23 +-
 drivers/nubus/nubus.c  | 556 +
 include/uapi/linux/nubus.h |   4 +-
 5 files changed, 275 insertions(+), 462 deletions(-)

-- 
2.10.2



[PATCH 03/10] m68k/mac: Adopt platform_device_register_simple()

2017-04-08 Thread Finn Thain
These changes save 1014 bytes according to scripts/bloat-o-meter.

Signed-off-by: Finn Thain 
---
 arch/m68k/mac/config.c | 49 -
 1 file changed, 12 insertions(+), 37 deletions(-)

diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index 661892d..22123f7 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -919,15 +919,6 @@ static void mac_get_model(char *str)
strcat(str, macintosh_config->name);
 }
 
-static struct resource swim_rsrc = { .flags = IORESOURCE_MEM };
-
-static struct platform_device swim_pdev = {
-   .name   = "swim",
-   .id = -1,
-   .num_resources  = 1,
-   .resource   = _rsrc,
-};
-
 static const struct resource mac_scsi_iifx_rsrc[] __initconst = {
{
.flags = IORESOURCE_IRQ,
@@ -992,26 +983,6 @@ static const struct resource mac_scsi_ccl_rsrc[] 
__initconst = {
},
 };
 
-static struct platform_device esp_0_pdev = {
-   .name   = "mac_esp",
-   .id = 0,
-};
-
-static struct platform_device esp_1_pdev = {
-   .name   = "mac_esp",
-   .id = 1,
-};
-
-static struct platform_device sonic_pdev = {
-   .name   = "macsonic",
-   .id = -1,
-};
-
-static struct platform_device mace_pdev = {
-   .name   = "macmace",
-   .id = -1,
-};
-
 int __init mac_platform_init(void)
 {
u8 *swim_base;
@@ -1043,9 +1014,13 @@ int __init mac_platform_init(void)
}
 
if (swim_base) {
-   swim_rsrc.start = (resource_size_t) swim_base,
-   swim_rsrc.end   = (resource_size_t) swim_base + 0x2000,
-   platform_device_register(_pdev);
+   struct resource swim_rsrc = {
+   .flags = IORESOURCE_MEM,
+   .start = (resource_size_t)swim_base,
+   .end   = (resource_size_t)swim_base + 0x2000,
+   };
+
+   platform_device_register_simple("swim", -1, _rsrc, 1);
}
 
/*
@@ -1055,13 +1030,13 @@ int __init mac_platform_init(void)
switch (macintosh_config->scsi_type) {
case MAC_SCSI_QUADRA:
case MAC_SCSI_QUADRA3:
-   platform_device_register(_0_pdev);
+   platform_device_register_simple("mac_esp", 0, NULL, 0);
break;
case MAC_SCSI_QUADRA2:
-   platform_device_register(_0_pdev);
+   platform_device_register_simple("mac_esp", 0, NULL, 0);
if ((macintosh_config->ident == MAC_MODEL_Q900) ||
(macintosh_config->ident == MAC_MODEL_Q950))
-   platform_device_register(_1_pdev);
+   platform_device_register_simple("mac_esp", 1, NULL, 0);
break;
case MAC_SCSI_IIFX:
/* Addresses from The Guide to Mac Family Hardware.
@@ -1127,10 +1102,10 @@ int __init mac_platform_init(void)
 
switch (macintosh_config->ether_type) {
case MAC_ETHER_SONIC:
-   platform_device_register(_pdev);
+   platform_device_register_simple("macsonic", -1, NULL, 0);
break;
case MAC_ETHER_MACE:
-   platform_device_register(_pdev);
+   platform_device_register_simple("macmace", -1, NULL, 0);
break;
}
 
-- 
2.10.2



[PATCH 03/10] m68k/mac: Adopt platform_device_register_simple()

2017-04-08 Thread Finn Thain
These changes save 1014 bytes according to scripts/bloat-o-meter.

Signed-off-by: Finn Thain 
---
 arch/m68k/mac/config.c | 49 -
 1 file changed, 12 insertions(+), 37 deletions(-)

diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index 661892d..22123f7 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -919,15 +919,6 @@ static void mac_get_model(char *str)
strcat(str, macintosh_config->name);
 }
 
-static struct resource swim_rsrc = { .flags = IORESOURCE_MEM };
-
-static struct platform_device swim_pdev = {
-   .name   = "swim",
-   .id = -1,
-   .num_resources  = 1,
-   .resource   = _rsrc,
-};
-
 static const struct resource mac_scsi_iifx_rsrc[] __initconst = {
{
.flags = IORESOURCE_IRQ,
@@ -992,26 +983,6 @@ static const struct resource mac_scsi_ccl_rsrc[] 
__initconst = {
},
 };
 
-static struct platform_device esp_0_pdev = {
-   .name   = "mac_esp",
-   .id = 0,
-};
-
-static struct platform_device esp_1_pdev = {
-   .name   = "mac_esp",
-   .id = 1,
-};
-
-static struct platform_device sonic_pdev = {
-   .name   = "macsonic",
-   .id = -1,
-};
-
-static struct platform_device mace_pdev = {
-   .name   = "macmace",
-   .id = -1,
-};
-
 int __init mac_platform_init(void)
 {
u8 *swim_base;
@@ -1043,9 +1014,13 @@ int __init mac_platform_init(void)
}
 
if (swim_base) {
-   swim_rsrc.start = (resource_size_t) swim_base,
-   swim_rsrc.end   = (resource_size_t) swim_base + 0x2000,
-   platform_device_register(_pdev);
+   struct resource swim_rsrc = {
+   .flags = IORESOURCE_MEM,
+   .start = (resource_size_t)swim_base,
+   .end   = (resource_size_t)swim_base + 0x2000,
+   };
+
+   platform_device_register_simple("swim", -1, _rsrc, 1);
}
 
/*
@@ -1055,13 +1030,13 @@ int __init mac_platform_init(void)
switch (macintosh_config->scsi_type) {
case MAC_SCSI_QUADRA:
case MAC_SCSI_QUADRA3:
-   platform_device_register(_0_pdev);
+   platform_device_register_simple("mac_esp", 0, NULL, 0);
break;
case MAC_SCSI_QUADRA2:
-   platform_device_register(_0_pdev);
+   platform_device_register_simple("mac_esp", 0, NULL, 0);
if ((macintosh_config->ident == MAC_MODEL_Q900) ||
(macintosh_config->ident == MAC_MODEL_Q950))
-   platform_device_register(_1_pdev);
+   platform_device_register_simple("mac_esp", 1, NULL, 0);
break;
case MAC_SCSI_IIFX:
/* Addresses from The Guide to Mac Family Hardware.
@@ -1127,10 +1102,10 @@ int __init mac_platform_init(void)
 
switch (macintosh_config->ether_type) {
case MAC_ETHER_SONIC:
-   platform_device_register(_pdev);
+   platform_device_register_simple("macsonic", -1, NULL, 0);
break;
case MAC_ETHER_MACE:
-   platform_device_register(_pdev);
+   platform_device_register_simple("macmace", -1, NULL, 0);
break;
}
 
-- 
2.10.2



  1   2   3   4   5   >