[PATCH 1/2] decnet: dn_rtmsg: constify nf_hook_ops structures

2017-07-29 Thread Julia Lawall
The nf_hook_ops structure is only passed as the second argument to
nf_register_net_hook or nf_unregister_net_hook, both of which are
declared as const.  Thus the nf_hook_ops structure itself can be
const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct nf_hook_ops i@p = { ... };

@ok1@
identifier r.i;
expression e;
position p;
@@
 \(nf_register_net_hook\|nf_unregister_net_hook\)(e,&i@p)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct nf_hook_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct nf_hook_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 net/decnet/netfilter/dn_rtmsg.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/decnet/netfilter/dn_rtmsg.c b/net/decnet/netfilter/dn_rtmsg.c
index aa8ffec..ab395e5 100644
--- a/net/decnet/netfilter/dn_rtmsg.c
+++ b/net/decnet/netfilter/dn_rtmsg.c
@@ -115,7 +115,7 @@ static inline void dnrmg_receive_user_skb(struct sk_buff 
*skb)
RCV_SKB_FAIL(-EINVAL);
 }
 
-static struct nf_hook_ops dnrmg_ops __read_mostly = {
+static const struct nf_hook_ops dnrmg_ops = {
.hook   = dnrmg_hook,
.pf = NFPROTO_DECNET,
.hooknum= NF_DN_ROUTE,



[PATCH 0/2] constify nf_hook_ops structures

2017-07-29 Thread Julia Lawall
The nf_hook_ops structure is only passed as the second argument to
nf_register_net_hook or nf_unregister_net_hook, both of which are
declared as const.  Thus the nf_hook_ops structure itself can be
const.

Done with the help of Coccinelle.

---

 net/decnet/netfilter/dn_rtmsg.c|2 +-
 net/ipv4/netfilter/ipt_CLUSTERIP.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


[PATCH 2/2] netfilter: ipt_CLUSTERIP: constify nf_hook_ops structures

2017-07-29 Thread Julia Lawall
The nf_hook_ops structure is only passed as the second argument to
nf_register_net_hook or nf_unregister_net_hook, both of which are
declared as const.  Thus the nf_hook_ops structure itself can be
const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct nf_hook_ops i@p = { ... };

@ok1@
identifier r.i;
expression e;
position p;
@@
 \(nf_register_net_hook\|nf_unregister_net_hook\)(e,&i@p)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct nf_hook_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct nf_hook_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 net/ipv4/netfilter/ipt_CLUSTERIP.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c 
b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index efaa04d..17b4ca5 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -625,7 +625,7 @@ static void arp_print(struct arp_payload *payload)
return NF_ACCEPT;
 }
 
-static struct nf_hook_ops cip_arp_ops __read_mostly = {
+static const struct nf_hook_ops cip_arp_ops = {
.hook = arp_mangle,
.pf = NFPROTO_ARP,
.hooknum = NF_ARP_OUT,



Re: [PATCH] clk: Remove recursion in clk_core_{prepare,enable}()

2017-07-29 Thread kbuild test robot
Hi Stephen,

[auto build test WARNING on clk/clk-next]
[also build test WARNING on v4.13-rc2 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Stephen-Boyd/clk-Remove-recursion-in-clk_core_-prepare-enable/20170728-114840
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: x86_64-randconfig-v0-07291446 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers//clk/clk.c: In function 'clk_core_enable':
>> drivers//clk/clk.c:658: warning: unused variable 'prev'

vim +/prev +658 drivers//clk/clk.c

   654  
   655  static int clk_core_enable(struct clk_core *core)
   656  {
   657  int ret = 0;
 > 658  struct clk_core *tmp, *parent, *prev;
   659  LIST_HEAD(head);
   660  
   661  lockdep_assert_held(&enable_lock);
   662  
   663  while (core) {
   664  list_add(&core->enable_list, &head);
   665  /* Stop once we see a clk that is already enabled */
   666  if (core->enable_count)
   667  break;
   668  core = core->parent;
   669  }
   670  
   671  list_for_each_entry_safe(core, tmp, &head, enable_list) {
   672  list_del_init(&core->enable_list);
   673  
   674  if (WARN_ON(core->prepare_count == 0)) {
   675  ret = -ESHUTDOWN;
   676  goto err;
   677  }
   678  
   679  if (core->enable_count == 0) {
   680  trace_clk_enable_rcuidle(core);
   681  
   682  if (core->ops->enable)
   683  ret = core->ops->enable(core->hw);
   684  
   685  trace_clk_enable_complete_rcuidle(core);
   686  
   687  if (ret)
   688  goto err;
   689  }
   690  
   691  core->enable_count++;
   692  }
   693  
   694  return 0;
   695  err:
   696  parent = core->parent;
   697  list_for_each_entry_safe_continue(core, tmp, &head, enable_list)
   698  list_del_init(&core->enable_list);
   699  clk_core_disable(parent);
   700  return ret;
   701  }
   702  

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


.config.gz
Description: application/gzip


Re: Send a large patch right now or is it better to do it later?

2017-07-29 Thread Dan Carpenter
On Fri, Jul 28, 2017 at 05:16:56PM +0200, Marcus Wolf wrote:
> Hi Greg,
>  
> according to the proposals of Walter Harms, I revised the rf69.c: I replaced
> some macros with inline functions and removed some obsolete ifdefs. According 
> to
> walter this will improve the resource situation. In addition the readybility 
> is
> enhanced, since lines got shorter. It's a quite big change, that touched 
> nearly
> every function in that file.

Just send your patches, we can't discuss them without seeing them.

> I was testing the new code for a while now and did not observer a problem so
> far. But I don't have a kind of unit test, so my tests for sure didn't cover
> everything.

Any sort of testing is probably better than 70% of staging patches.  :P

>  
> Is it a good time, to submit such a change in these days, or is it prefrable 
> to
> submit it later?

It doesn't matter when you send patches.

> In adition, I am a bit afraid of my current mailtool doing something
> unexpected...
>  
> If you like, I can give it a try!
>  
> Cheers,
>  
> Marcus
> P.S. Can you process diffs fom SVN, too, or is it mandatory to create the diff
> with git?

The patches have to be able to be applied with `cat email.txt | git am`.
If you're renaming or moving files, then use git diff.  Otherwise it's
all fine.

regards,
dan carpenter



[PATCH 2/5] Fix "ERROR: code indent should use tabs where possible"

2017-07-29 Thread SZ Lin
ERROR: code indent should use tabs where possible
+^I^I "Need to wait for TPM to finish\n");$

Signed-off-by: SZ Lin 
---
 drivers/char/tpm/tpm_ibmvtpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
index f01d083eced2..23913fc86158 100644
--- a/drivers/char/tpm/tpm_ibmvtpm.c
+++ b/drivers/char/tpm/tpm_ibmvtpm.c
@@ -127,7 +127,7 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, 
size_t count)
 
if (ibmvtpm->tpm_processing_cmd) {
dev_info(ibmvtpm->dev,
-"Need to wait for TPM to finish\n");
+   "Need to wait for TPM to finish\n");
/* wait for previous command to finish */
sig = wait_event_interruptible(ibmvtpm->wq, 
!ibmvtpm->tpm_processing_cmd);
if (sig)
-- 
2.13.3



[PATCH 5/5] Use __func__ instead of function name

2017-07-29 Thread SZ Lin
Fix following checkpatch.pl warning:
WARNING: Prefer using '"%s...", __func__' to using
the function's name, in a string

Signed-off-by: SZ Lin 
---
 drivers/char/tpm/tpm_ibmvtpm.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
index e75a674b44ac..2d33acc43e25 100644
--- a/drivers/char/tpm/tpm_ibmvtpm.c
+++ b/drivers/char/tpm/tpm_ibmvtpm.c
@@ -151,7 +151,7 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, 
size_t count)
rc = ibmvtpm_send_crq(ibmvtpm->vdev, be64_to_cpu(word[0]),
  be64_to_cpu(word[1]));
if (rc != H_SUCCESS) {
-   dev_err(ibmvtpm->dev, "tpm_ibmvtpm_send failed rc=%d\n", rc);
+   dev_err(ibmvtpm->dev, "%s failed rc=%d\n", __func__, rc);
rc = 0;
ibmvtpm->tpm_processing_cmd = false;
} else
@@ -193,7 +193,7 @@ static int ibmvtpm_crq_get_rtce_size(struct ibmvtpm_dev 
*ibmvtpm)
  cpu_to_be64(buf[1]));
if (rc != H_SUCCESS)
dev_err(ibmvtpm->dev,
-   "ibmvtpm_crq_get_rtce_size failed rc=%d\n", rc);
+   "%s failed rc=%d\n", __func__, rc);
 
return rc;
 }
@@ -221,7 +221,7 @@ static int ibmvtpm_crq_get_version(struct ibmvtpm_dev 
*ibmvtpm)
  cpu_to_be64(buf[1]));
if (rc != H_SUCCESS)
dev_err(ibmvtpm->dev,
-   "ibmvtpm_crq_get_version failed rc=%d\n", rc);
+   "%s failed rc=%d\n", __func__, rc);
 
return rc;
 }
@@ -241,7 +241,7 @@ static int ibmvtpm_crq_send_init_complete(struct 
ibmvtpm_dev *ibmvtpm)
rc = ibmvtpm_send_crq(ibmvtpm->vdev, INIT_CRQ_COMP_CMD, 0);
if (rc != H_SUCCESS)
dev_err(ibmvtpm->dev,
-   "ibmvtpm_crq_send_init_complete failed rc=%d\n", rc);
+   "%s rc=%d\n", __func__, rc);
 
return rc;
 }
@@ -261,7 +261,7 @@ static int ibmvtpm_crq_send_init(struct ibmvtpm_dev 
*ibmvtpm)
rc = ibmvtpm_send_crq(ibmvtpm->vdev, INIT_CRQ_CMD, 0);
if (rc != H_SUCCESS)
dev_err(ibmvtpm->dev,
-   "ibmvtpm_crq_send_init failed rc=%d\n", rc);
+   "%s failed rc=%d\n", __func__, rc);
 
return rc;
 }
@@ -351,7 +351,7 @@ static int tpm_ibmvtpm_suspend(struct device *dev)
  cpu_to_be64(buf[1]));
if (rc != H_SUCCESS)
dev_err(ibmvtpm->dev,
-   "tpm_ibmvtpm_suspend failed rc=%d\n", rc);
+   "%s failed rc=%d\n", __func__, rc);
 
return rc;
 }
-- 
2.13.3



[PATCH 0/5] tpm: tpm_ibmvtpm: - style fix

2017-07-29 Thread SZ Lin
Fix styling WARNINGs and Errors of tpm_ibmvtpm.c driver by using checkpatch.pl

SZ Lin (5):
  Fix packed and aligned attribute warnings.
  Fix "ERROR: code indent should use tabs where possible"
  Fix 'void function return statements are not generally useful' warning
  Remove unneccessary 'out of memory' message
  Use __func__ instead of function name

 drivers/char/tpm/tpm_ibmvtpm.c | 23 +--
 drivers/char/tpm/tpm_ibmvtpm.h |  2 +-
 2 files changed, 10 insertions(+), 15 deletions(-)

--
2.13.3



[PATCH 3/5] Fix 'void function return statements are not generally useful' warning

2017-07-29 Thread SZ Lin
WARNING: void function return statements are not generally useful
+   return;
+}

Signed-off-by: SZ Lin 
---
 drivers/char/tpm/tpm_ibmvtpm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
index 23913fc86158..e53b9fb517d9 100644
--- a/drivers/char/tpm/tpm_ibmvtpm.c
+++ b/drivers/char/tpm/tpm_ibmvtpm.c
@@ -531,7 +531,6 @@ static void ibmvtpm_crq_process(struct ibmvtpm_crq *crq,
return;
}
}
-   return;
 }
 
 /**
-- 
2.13.3



[PATCH 1/5] Fix packed and aligned attribute warnings.

2017-07-29 Thread SZ Lin
WARNING: __packed is preferred over __attribute__((packed))
+} __attribute__((packed, aligned(8)));

WARNING: __aligned(size) is preferred over __attribute__((aligned(size)))
+} __attribute__((packed, aligned(8)));

Signed-off-by: SZ Lin 
---
 drivers/char/tpm/tpm_ibmvtpm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_ibmvtpm.h b/drivers/char/tpm/tpm_ibmvtpm.h
index 91dfe766d080..9f708ca3dc84 100644
--- a/drivers/char/tpm/tpm_ibmvtpm.h
+++ b/drivers/char/tpm/tpm_ibmvtpm.h
@@ -25,7 +25,7 @@ struct ibmvtpm_crq {
__be16 len;
__be32 data;
__be64 reserved;
-} __attribute__((packed, aligned(8)));
+} __packed __aligned(8);
 
 struct ibmvtpm_crq_queue {
struct ibmvtpm_crq *crq_addr;
-- 
2.13.3



[PATCH 4/5] Remove unneccessary 'out of memory' message

2017-07-29 Thread SZ Lin
WARNING: Possible unnecessary 'out of memory' message
+   if (!ibmvtpm->rtce_buf) {
+   dev_err(ibmvtpm->dev, "Failed to allocate 
memory for rtce buffer\n");

WARNING: Possible unnecessary 'out of memory' message
+   if (!ibmvtpm) {
+   dev_err(dev, "kzalloc for ibmvtpm failed\n");

Signed-off-by: SZ Lin 
---
 drivers/char/tpm/tpm_ibmvtpm.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
index e53b9fb517d9..e75a674b44ac 100644
--- a/drivers/char/tpm/tpm_ibmvtpm.c
+++ b/drivers/char/tpm/tpm_ibmvtpm.c
@@ -501,10 +501,8 @@ static void ibmvtpm_crq_process(struct ibmvtpm_crq *crq,
ibmvtpm->rtce_size = be16_to_cpu(crq->len);
ibmvtpm->rtce_buf = kmalloc(ibmvtpm->rtce_size,
GFP_ATOMIC);
-   if (!ibmvtpm->rtce_buf) {
-   dev_err(ibmvtpm->dev, "Failed to allocate 
memory for rtce buffer\n");
+   if (!ibmvtpm->rtce_buf)
return;
-   }
 
ibmvtpm->rtce_dma_handle = dma_map_single(ibmvtpm->dev,
ibmvtpm->rtce_buf, ibmvtpm->rtce_size,
@@ -584,10 +582,8 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev,
return PTR_ERR(chip);
 
ibmvtpm = kzalloc(sizeof(struct ibmvtpm_dev), GFP_KERNEL);
-   if (!ibmvtpm) {
-   dev_err(dev, "kzalloc for ibmvtpm failed\n");
+   if (!ibmvtpm)
goto cleanup;
-   }
 
ibmvtpm->dev = dev;
ibmvtpm->vdev = vio_dev;
-- 
2.13.3



Re: wake_wide mechanism clarification

2017-07-29 Thread Joel Fernandes
Hi Mike,

I have take spent some time understanding the email thread and
previous discussions. Unfortunately the second condition we are
checking for in the wake_wide still didn't make sense to me (mentioned
below) :-(

On Fri, Jun 30, 2017 at 10:02 AM, Mike Galbraith
 wrote:
> On Fri, 2017-06-30 at 10:28 -0400, Josef Bacik wrote:
>> On Thu, Jun 29, 2017 at 08:04:59PM -0700, Joel Fernandes wrote:
>>
>> > That makes sense that we multiply slave's flips by a factor because
>> > its low, but I still didn't get why the factor is chosen to be
>> > llc_size instead of something else for the multiplication with slave
>> > (slave * factor).
>
>> Yeah I don't know why llc_size was chosen...
>
> static void update_top_cache_domain(int cpu)
> {
> struct sched_domain_shared *sds = NULL;
> struct sched_domain *sd;
> int id = cpu;
> int size = 1;
>
> sd = highest_flag_domain(cpu, SD_SHARE_PKG_RESOURCES);
> if (sd) {
> id = cpumask_first(sched_domain_span(sd));
> size = cpumask_weight(sched_domain_span(sd));
> sds = sd->shared;
> }
>
> rcu_assign_pointer(per_cpu(sd_llc, cpu), sd);
> per_cpu(sd_llc_size, cpu) = size;
>
> The goal of wake wide was to approximate when pulling would be a futile
> consolidation effort and counterproductive to scaling.  'course with
> ever increasing socket size, any 1:N waker is ever more likely to run
> out of CPU for its one and only self (slamming into scaling wall)
> before it needing to turn its minions loose to conquer the world.

Actually the original question was why do we have the second condition
as "master < slave * factor", instead of "master < factor". that's
what didn't make sense to me. Why don't we return 0 from wake_wide if
master < factor ?

Infact, as the factor is set to the llc_size, I think the condition
that makes sense to me is:

if ((master + slave) < llc_size)
  return 0;

In other words, if the master flips and the slave flips are totally
higher than the llc_size, then we are most likely waking up too many
tasks as affine and should then switch to wide to prevent overloading.

Digging further into the original patch from Michael Wang (I also CC'd
him), this was the code (before you had changed it to master/slave):

wakee->nr_wakee_switch > factor &&
waker->nr_wakee_switch > (factor * wakee->nr_wakee_switch)

To explain the second condition above, Michael Wang said the following in [1]

"Furthermore, if waker also has a high 'nr_wakee_switch', imply that multiple
tasks rely on it, then waker's higher latency will damage all of them, pull
wakee seems to be a bad deal."

Again I didn't follow why the second condition couldn't just be:
waker->nr_wakee_switch > factor, or, (waker->nr_wakee_switch +
wakee->nr_wakee_switch) > factor, based on the above explanation from
Micheal Wang that I quoted.
and why he's instead doing the whole multiplication thing there that I
was talking about earlier: "factor * wakee->nr_wakee_switch".

Rephrasing my question in another way, why are we talking the ratio of
master/slave instead of the sum when comparing if its > factor? I am
surely missing something here.

Just taking an example:

Say we have llc_size = 3, we have 3 masters M1, M2 and M3. M1 has 8
slaves, M2 has 4 slaves and M3 has 4 slaves. Only 1 slave is common
between all 3 masters. Also to make it a bit more interesting, let s8
wake up some random task T0. A diagram to show the master/slave
relation ships could look like:

+-+
| |
++   +--+ M2  |
||   |  | |
|M1  |   |  +--+--+
||   |  |  |  |   |
||   |  |  |  |   s15
+--+--+--+--+--+--+---+--+---+  v  v  v
   |  |  |  |  |  |   |  |  s9 s10 s11
   v  v  v  v  v  v   v  v
   s1 s2 s3 s4 s5 s6  s7 s8 ---> T0
 ^
 |
   +-+---+
   | |
   | M3  |
   | |
   +--+--+-
   |  |  ||
   v  v  vv
  s12 s13 s14 s16


Lets consider the case of M1 waking up s8. As per the above diagram,
M1 has 8 flips and s8 has 4 flips.

With llc_size = 3, the condition

(slave < factor) would return FALSE, so then we would turn to the
(master < slave * factor) condition. This would be TRUE (8 < 4 * 3),
so wake_wide would return 0 and would cause s8 to be woken up as
affine with relation to M1's core.

So basically, it seems the heuristic is saying (with help of the
second condition - master < slave * factor). that Its a good idea for
s8 to be affine-woken-up with respect to M1's core. Why is it a good
idea to do that? It seems to me M1 h

[PATCH] [BUGFIX] gpio: reject invalid gpio before getting gpio_desc

2017-07-29 Thread Masami Hiramatsu
Check user-given gpio number and reject it before
calling gpio_to_desc() because gpio_to_desc() is
for kernel driver and it expects given gpio number
is valid (means 0 to 511).
If given number is invalid, gpio_to_desc() calls
WARN() and dump registers and stack for debug.
This means user can easily kick WARN() just by
writing invalid gpio number (e.g. 512) to
/sys/class/gpio/export.
This bug has been introduced by commit 0e9a5edf5d01
("gpio: fix deferred probe detection for legacy API")

Signed-off-by: Masami Hiramatsu 
Fixes: commit 0e9a5edf5d01 ("gpio: fix deferred probe detection for legacy API")
---
 drivers/gpio/gpiolib-sysfs.c |   13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index 4b44dd97c07f..4efb11fd1c22 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -2,6 +2,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -443,14 +444,16 @@ static ssize_t export_store(struct class *class,
const char *buf, size_t len)
 {
longgpio;
-   struct gpio_desc*desc;
+   struct gpio_desc*desc = NULL;
int status;
 
status = kstrtol(buf, 0, &gpio);
if (status < 0)
goto done;
 
-   desc = gpio_to_desc(gpio);
+   if (gpio_is_valid(gpio))
+   desc = gpio_to_desc(gpio);
+
/* reject invalid GPIOs */
if (!desc) {
pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);
@@ -485,14 +488,16 @@ static ssize_t unexport_store(struct class *class,
const char *buf, size_t len)
 {
longgpio;
-   struct gpio_desc*desc;
+   struct gpio_desc*desc = NULL;
int status;
 
status = kstrtol(buf, 0, &gpio);
if (status < 0)
goto done;
 
-   desc = gpio_to_desc(gpio);
+   if (gpio_is_valid(gpio))
+   desc = gpio_to_desc(gpio);
+
/* reject bogus commands (gpio_unexport ignores them) */
if (!desc) {
pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);



Re: [PATCH v2 4/4] clk: meson: gxbb-aoclk: Add CEC 32k clock

2017-07-29 Thread Chris Moore

Hi,

Sorry I forgot to reply to all in my previous post :(
I hope this corrects things.

Le 28/07/2017 à 11:53, Neil Armstrong a écrit :

[snip]

+static long aoclk_cec_32k_round_rate(struct clk_hw *hw, unsigned long 
rate,

+ unsigned long *prate)
+{
+const struct cec_32k_freq_table *freq = find_cec_32k_freq(rate,
+  *prate);
+
+/* If invalid return first one */
+if (!freq)
+return freq[0].target_rate;


Wouldn't this dereference a null pointer (or am I being stupid this 
morning)?



+
+return freq->target_rate;
+}
+
+static int aoclk_cec_32k_set_rate(struct clk_hw *hw, unsigned long rate,
+  unsigned long parent_rate)
+{
+const struct cec_32k_freq_table *freq = find_cec_32k_freq(rate,
+  parent_rate);
+struct aoclk_cec_32k *cec_32k = to_aoclk_cec_32k(hw);
+u32 reg = 0;
+
+if (!freq)
+return -EINVAL;
+
+/* Disable clock */
+regmap_update_bits(cec_32k->regmap, AO_RTC_ALT_CLK_CNTL0,
+   CLK_CNTL0_IN_GATE_EN | CLK_CNTL0_OUT_GATE_EN, 0);
+
+if (freq->dualdiv)
+reg = CLK_CNTL0_DUALDIV_EN |
+  FIELD_PREP(CLK_CNTL0_N1_MASK, freq->n1 - 1) |
+  FIELD_PREP(CLK_CNTL0_N2_MASK, freq->n2 - 1);
+else
+reg = FIELD_PREP(CLK_CNTL0_N1_MASK, freq->n1 - 1);
+


Suggestion:

+reg = FIELD_PREP(CLK_CNTL0_N1_MASK, freq->n1 - 1);
+if (freq->dualdiv)
+reg |= CLK_CNTL0_DUALDIV_EN |
+   FIELD_PREP(CLK_CNTL0_N2_MASK, freq->n2 - 1);

is shorter but maybe generates the same code.


+ regmap_write(cec_32k->regmap, AO_RTC_ALT_CLK_CNTL0, reg);
+
+if (freq->dualdiv)
+reg = FIELD_PREP(CLK_CNTL1_M1_MASK, freq->m1 - 1) |
+  FIELD_PREP(CLK_CNTL1_M2_MASK, freq->m2 - 1);
+else
+reg = FIELD_PREP(CLK_CNTL1_M1_MASK, freq->m1 - 1);
+


Idem:

+reg = FIELD_PREP(CLK_CNTL1_M1_MASK, freq->m1 - 1);
+if (freq->dualdiv)
+reg |= FIELD_PREP(CLK_CNTL1_M2_MASK, freq->m2 - 1);

Cheers,
Chris


Re: [PATCH] PM / Domains: Ensure genpd name is set before creating debugfs entry

2017-07-29 Thread Ulf Hansson
On 28 July 2017 at 20:55, Dave Gerlach  wrote:
> Hi,
> On 07/28/2017 01:48 PM, Dave Gerlach wrote:
>> Commit b6a1d093f96b ("PM / Domains: Extend generic power domain
>> debugfs") extends the existing generic power domain debugfs to provide
>> more information about each genpd, however it creates a debugfs
>> directory for each based on the name of the genpd. While it is a good
>> idea to populate the name field of each genpd, up until this commit it
>> was not required. However, attempting to call debugfs_create_dir with a
>> null name value causes a NULL pointer dereference panic.
>>
>> In order to keep things working as they did before the aforementioned
>> patch, check to see if name has been populated and if not, skip creating
>> the extended debugfs info path and warn that name is needed to get this
>> extended info.
>>
>> Fixes: b6a1d093f96b ("PM / Domains: Extend generic power domain debugfs")
>> Signed-off-by: Dave Gerlach 
>> ---
>
> As changelog describes, commit b6a1d093f96b ("PM / Domains: Extend generic 
> power
> domain debugfs") currently causes a NULL pointer dereference panic if no name 
> is
> assigned for a struct generic_pm_domain registered with the framework. Before
> this patch no name was required, so this patch is a first attempt to keep 
> things
> that way and just warn the user that they can't get extended debugfs info
> without providing a genpd name.
>
> Of course a name is always a good idea, so I'm not sure if this patch is how 
> we
> want to go about preventing this panic or perhaps just making the name 
> mandatory
> and checking during probe, but I figured I'd kick the discussion off with a
> suggestion by sending this patch.

Instead of making it mandatory, why not assign ->name a generic name
(genpd0, genpd1, genpd2, etc ) in case it isn't set.

In that way, all debugfs prints using ->name, should at least show
something... and the bug you report should also be fixed..

Kind regards
Uffe


Re: [B.A.T.M.A.N.] [PATCH][V2] batman-adv: fix various spelling mistakes

2017-07-29 Thread Sven Eckelmann
On Montag, 26. Juni 2017 11:26:44 CEST Colin King wrote:
> From: Colin Ian King 
> 
> Trivial fix to spelling mistakes in batadv_dbg debug messages and
> also in a comment and ensure comment line is not wider than 80
> characters
> 
> "ourselve" -> "ourselves"
> "surpressed" -> "suppressed"
> "troughput" -> "throughput"
> 
> Signed-off-by: Colin Ian King 


Applied as f25cbb2a6ac1ce702d8c39222bc13c24a69bb5ef [1]

Thanks,
Sven

[1] 
https://git.open-mesh.org/linux-merge.git/commit/f25cbb2a6ac1ce702d8c39222bc13c24a69bb5ef

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


Re: wake_wide mechanism clarification

2017-07-29 Thread Joel Fernandes
+Michael Wang on his current email address (old one bounced). (my
reply was to Mike Galbraith but I also meant to CC Michael Wang for
the discussion). Thanks

On Sat, Jul 29, 2017 at 1:01 AM, Joel Fernandes  wrote:
> Hi Mike,
>
> I have take spent some time understanding the email thread and
> previous discussions. Unfortunately the second condition we are
> checking for in the wake_wide still didn't make sense to me (mentioned
> below) :-(
>
> On Fri, Jun 30, 2017 at 10:02 AM, Mike Galbraith
>  wrote:
>> On Fri, 2017-06-30 at 10:28 -0400, Josef Bacik wrote:
>>> On Thu, Jun 29, 2017 at 08:04:59PM -0700, Joel Fernandes wrote:
>>>
>>> > That makes sense that we multiply slave's flips by a factor because
>>> > its low, but I still didn't get why the factor is chosen to be
>>> > llc_size instead of something else for the multiplication with slave
>>> > (slave * factor).
>>
>>> Yeah I don't know why llc_size was chosen...
>>
>> static void update_top_cache_domain(int cpu)
>> {
>> struct sched_domain_shared *sds = NULL;
>> struct sched_domain *sd;
>> int id = cpu;
>> int size = 1;
>>
>> sd = highest_flag_domain(cpu, SD_SHARE_PKG_RESOURCES);
>> if (sd) {
>> id = cpumask_first(sched_domain_span(sd));
>> size = cpumask_weight(sched_domain_span(sd));
>> sds = sd->shared;
>> }
>>
>> rcu_assign_pointer(per_cpu(sd_llc, cpu), sd);
>> per_cpu(sd_llc_size, cpu) = size;
>>
>> The goal of wake wide was to approximate when pulling would be a futile
>> consolidation effort and counterproductive to scaling.  'course with
>> ever increasing socket size, any 1:N waker is ever more likely to run
>> out of CPU for its one and only self (slamming into scaling wall)
>> before it needing to turn its minions loose to conquer the world.
>
> Actually the original question was why do we have the second condition
> as "master < slave * factor", instead of "master < factor". that's
> what didn't make sense to me. Why don't we return 0 from wake_wide if
> master < factor ?
>
> Infact, as the factor is set to the llc_size, I think the condition
> that makes sense to me is:
>
> if ((master + slave) < llc_size)
>   return 0;
>
> In other words, if the master flips and the slave flips are totally
> higher than the llc_size, then we are most likely waking up too many
> tasks as affine and should then switch to wide to prevent overloading.
>
> Digging further into the original patch from Michael Wang (I also CC'd
> him), this was the code (before you had changed it to master/slave):
>
> wakee->nr_wakee_switch > factor &&
> waker->nr_wakee_switch > (factor * wakee->nr_wakee_switch)
>
> To explain the second condition above, Michael Wang said the following in [1]
>
> "Furthermore, if waker also has a high 'nr_wakee_switch', imply that multiple
> tasks rely on it, then waker's higher latency will damage all of them, pull
> wakee seems to be a bad deal."
>
> Again I didn't follow why the second condition couldn't just be:
> waker->nr_wakee_switch > factor, or, (waker->nr_wakee_switch +
> wakee->nr_wakee_switch) > factor, based on the above explanation from
> Micheal Wang that I quoted.
> and why he's instead doing the whole multiplication thing there that I
> was talking about earlier: "factor * wakee->nr_wakee_switch".
>
> Rephrasing my question in another way, why are we talking the ratio of
> master/slave instead of the sum when comparing if its > factor? I am
> surely missing something here.
>
> Just taking an example:
>
> Say we have llc_size = 3, we have 3 masters M1, M2 and M3. M1 has 8
> slaves, M2 has 4 slaves and M3 has 4 slaves. Only 1 slave is common
> between all 3 masters. Also to make it a bit more interesting, let s8
> wake up some random task T0. A diagram to show the master/slave
> relation ships could look like:
>
> +-+
> | |
> ++   +--+ M2  |
> ||   |  | |
> |M1  |   |  +--+--+
> ||   |  |  |  |   |
> ||   |  |  |  |   s15
> +--+--+--+--+--+--+---+--+---+  v  v  v
>|  |  |  |  |  |   |  |  s9 s10 s11
>v  v  v  v  v  v   v  v
>s1 s2 s3 s4 s5 s6  s7 s8 ---> T0
>  ^
>  |
>+-+---+
>| |
>| M3  |
>| |
>+--+--+-
>|  |  ||
>v  v  vv
>   s12 s13 s14 s16
>
>
> Lets consider the case of M1 waking up s8. As per the above diagram,
> M1 has 8 flips and s8 has 4 flips.
>
> With llc_size = 3, the condition
>
> (slave < factor) would return FALSE, so then we would turn to the
> (master < 

Re: [PATCH 1/2] ata: mediatek: add support for MediaTek SATA controller

2017-07-29 Thread kbuild test robot
Hi Ryder,

[auto build test WARNING on tj-libata/for-next]
[also build test WARNING on v4.13-rc2 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Ryder-Lee/Add-support-for-MediaTek-AHCI-SATA/20170728-164513
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tj/libata.git for-next
config: arm64-allyesconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm64 

All warnings (new ones prefixed by >>):

   drivers/ata/ahci_mtk.c: In function 'mtk_ahci_platform_resets':
>> drivers/ata/ahci_mtk.c:60:32: warning: comparison of constant '-517' with 
>> boolean expression is always false [-Wbool-compare]
 if (IS_ERR(drv_data->axi_rst) == -EPROBE_DEFER)
   ^~
   drivers/ata/ahci_mtk.c:64:31: warning: comparison of constant '-517' with 
boolean expression is always false [-Wbool-compare]
 if (IS_ERR(drv_data->sw_rst) == -EPROBE_DEFER)
  ^~
   drivers/ata/ahci_mtk.c:68:32: warning: comparison of constant '-517' with 
boolean expression is always false [-Wbool-compare]
 if (IS_ERR(drv_data->reg_rst) == -EPROBE_DEFER)
   ^~
>> drivers/ata/ahci_mtk.c:60:6: warning: ignoring return value of 'IS_ERR', 
>> declared with attribute warn_unused_result [-Wunused-result]
 if (IS_ERR(drv_data->axi_rst) == -EPROBE_DEFER)
 ^
   drivers/ata/ahci_mtk.c:64:6: warning: ignoring return value of 'IS_ERR', 
declared with attribute warn_unused_result [-Wunused-result]
 if (IS_ERR(drv_data->sw_rst) == -EPROBE_DEFER)
 ^~~~
   drivers/ata/ahci_mtk.c:68:6: warning: ignoring return value of 'IS_ERR', 
declared with attribute warn_unused_result [-Wunused-result]
 if (IS_ERR(drv_data->reg_rst) == -EPROBE_DEFER)
 ^

vim +60 drivers/ata/ahci_mtk.c

51  
52  static int mtk_ahci_platform_resets(struct ahci_host_priv *hpriv,
53  struct device *dev)
54  {
55  struct mtk_ahci_drv_data *drv_data = hpriv->plat_data;
56  int err;
57  
58  /* reset AXI bus and phy part */
59  drv_data->axi_rst = devm_reset_control_get_optional(dev, 
"axi-rst");
  > 60  if (IS_ERR(drv_data->axi_rst) == -EPROBE_DEFER)
61  return -EPROBE_DEFER;
62  
63  drv_data->sw_rst = devm_reset_control_get_optional(dev, 
"sw-rst");
64  if (IS_ERR(drv_data->sw_rst) == -EPROBE_DEFER)
65  return -EPROBE_DEFER;
66  
67  drv_data->reg_rst = devm_reset_control_get_optional(dev, 
"reg-rst");
68  if (IS_ERR(drv_data->reg_rst) == -EPROBE_DEFER)
69  return -EPROBE_DEFER;
70  
71  err = reset_control_assert(drv_data->axi_rst);
72  if (err) {
73  dev_err(dev, "assert axi bus failed\n");
74  return err;
75  }
76  
77  err = reset_control_assert(drv_data->sw_rst);
78  if (err) {
79  dev_err(dev, "assert phy digital part failed\n");
80  return err;
81  }
82  
83  err = reset_control_assert(drv_data->reg_rst);
84  if (err) {
85  dev_err(dev, "assert phy register part failed\n");
86  return err;
87  }
88  
89  err = reset_control_deassert(drv_data->reg_rst);
90  if (err) {
91  dev_err(dev, "deassert phy register part failed\n");
92  return err;
93  }
94  
95  err = reset_control_deassert(drv_data->sw_rst);
96  if (err) {
97  dev_err(dev, "deassert phy digital part failed\n");
98  return err;
99  }
   100  
   101  err = reset_control_deassert(drv_data->axi_rst);
   102  if (err) {
   103  dev_err(dev, "deassert axi bus failed\n");
   104  return err;
   105  }
   106  
   107  return 0;
   108  }
   109  

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


.config.gz
Description: application/gzip


[PATCH 1/1] usb: xhci: Add debugfs interface for xHCI driver

2017-07-29 Thread Lu Baolu
This adds debugfs consumer for xHCI driver. The debugfs entries
read all host registers, device/endpoint contexts, command ring,
event ring and various endpoint rings. With these entries, users
can check the registers and memory spaces used by a host during
run time, or save all the information with a simple 'cp -r' for
post-mortem programs.

The file hierarchy looks like this.

[root of debugfs]
|__usb
|[e,u,o]hci <-[root for other HCIs]
|xhci   <---[root for xHCI]
|__:00:14.0 <--[xHCI host name]
|reg-cap<[capability registers]
|reg-op <---[operational registers]
|reg-runtime<---[runtime registers]
|reg-ext-#cap_name  <[extended capability regs]
|command-ring   <---[root for command ring]
|__cycle<--[ring cycle]
|__dequeue  <[ring dequeue pointer]
|__enqueue  <[ring enqueue pointer]
|__trbs <---[ring trbs]
|event-ring <-[root for event ring]
|__cycle<--[ring cycle]
|__dequeue  <[ring dequeue pointer]
|__enqueue  <[ring enqueue pointer]
|__trbs <---[ring trbs]
|devices<[root for devices]
|__#slot_id <---[root for a device]
|name   <-[device name]
|slot-context   <[slot context]
|ep-context <---[endpoint contexts]
|ep#ep_index<[root for an endpoint]
|__cycle<--[ring cycle]
|__dequeue  <[ring dequeue pointer]
|__enqueue  <[ring enqueue pointer]
|__trbs <---[ring trbs]

Signed-off-by: Lu Baolu 
---
 drivers/usb/host/Makefile   |   4 +
 drivers/usb/host/xhci-debugfs.c | 552 
 drivers/usb/host/xhci-debugfs.h | 137 ++
 drivers/usb/host/xhci-mem.c |   4 +-
 drivers/usb/host/xhci.c |  21 +-
 drivers/usb/host/xhci.h |   9 +
 6 files changed, 723 insertions(+), 4 deletions(-)
 create mode 100644 drivers/usb/host/xhci-debugfs.c
 create mode 100644 drivers/usb/host/xhci-debugfs.h

diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index cf2691f..b2a7f05 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -25,6 +25,10 @@ ifneq ($(CONFIG_USB_XHCI_RCAR), )
xhci-plat-hcd-y += xhci-rcar.o
 endif
 
+ifneq ($(CONFIG_DEBUG_FS),)
+   xhci-hcd-y  += xhci-debugfs.o
+endif
+
 obj-$(CONFIG_USB_WHCI_HCD) += whci/
 
 obj-$(CONFIG_USB_PCI)  += pci-quirks.o
diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c
new file mode 100644
index 000..7588ac6
--- /dev/null
+++ b/drivers/usb/host/xhci-debugfs.c
@@ -0,0 +1,552 @@
+/*
+ * xhci-debugfs.c - xHCI debugfs interface
+ *
+ * Copyright (C) 2017 Intel Corporation
+ *
+ * Author: Lu Baolu 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+
+#include "xhci.h"
+#include "xhci-debugfs.h"
+
+static const struct debugfs_reg32 xhci_cap_regs[] = {
+   dump_register(CAPLENGTH),
+   dump_register(HCSPARAMS1),
+   dump_register(HCSPARAMS2),
+   dump_register(HCSPARAMS3),
+   dump_register(HCCPARAMS1),
+   dump_register(DOORBELLOFF),
+   dump_register(RUNTIMEOFF),
+   dump_register(HCCPARAMS2),
+};
+
+static const struct debugfs_reg32 xhci_op_regs[] = {
+   dump_register(USBCMD),
+   dump_register(USBSTS),
+   dump_register(PAGESIZE),
+   dump_register(DNCTRL),
+   dump_register(CRCR),
+   dump_register(DCBAAP_LOW),
+   dump_register(DCBAAP_HIGH),
+   dump_register(CONFIG),
+};
+
+static const struct debugfs_reg32 xhci_runtime_regs[] = {
+   dump_register(MFINDEX),
+   dump_register(IR0_IMAN),
+   dump_register(IR0_IMOD),
+   dump_register(IR0_ERSTSZ),
+   dump_register(IR0_ERSTBA_LOW),
+   dump_register(IR0_ERSTBA_HIGH),
+   dump_register(IR0_ERDP_LOW),
+   dump_register(IR0_ERDP_HIGH),
+};
+
+static const struct debugfs_reg32 xhci_extcap_legsup[] = {
+   dump_register(EXTCAP_USBLEGSUP),
+   dump_register(EXTCAP_USBLEGCTLSTS),
+};
+
+static const struct debugfs_reg32 xhci_extcap_protocol[] = {
+   dump_register(EXTCAP_REVISION),
+   dump_register(EXTCAP_NAME),
+   dump_register(EXTCAP_PORTINFO),
+   dump_register(EXTCA

Re: [PATCH V8 1/6] PM / Domains: Add support to select performance-state of domains

2017-07-29 Thread Ulf Hansson
On 28 July 2017 at 13:00, Viresh Kumar  wrote:
> On 21-07-17, 10:35, Ulf Hansson wrote:
>> >> > +/*
>> >> > + * Returns true if anyone in genpd's parent hierarchy has
>> >> > + * set_performance_state() set.
>> >> > + */
>> >> > +static bool genpd_has_set_performance_state(struct generic_pm_domain 
>> >> > *genpd)
>> >> > +{
>> >>
>> >> So this function will be become in-directly called by generic drivers
>> >> that supports DVFS of the genpd for their devices.
>> >>
>> >> I think the data you validate here would be better to be pre-validated
>> >> at pm_genpd_init() and at pm_genpd_add|remove_subdomain() and the
>> >> result stored in a variable in the genpd struct. Especially when a
>> >> subdomain is added, that is a point when you can verify the
>> >> *_performance_state() callbacks, and thus make sure it's a correct
>> >> setup from the topology point of view.
>
> Looks like I have to keep this routine as is and your solution may not
> work well. :(
>
>> > Something like this ?
>> >
>> > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
>> > index 4a898e095a1d..182c1911ea9c 100644
>> > --- a/drivers/base/power/domain.c
>> > +++ b/drivers/base/power/domain.c
>> > @@ -466,25 +466,6 @@ static int genpd_dev_pm_qos_notifier(struct 
>> > notifier_block *nb,
>> > return NOTIFY_DONE;
>> >  }
>> >
>> > -/*
>> > - * Returns true if anyone in genpd's parent hierarchy has
>> > - * set_performance_state() set.
>> > - */
>> > -static bool genpd_has_set_performance_state(struct generic_pm_domain 
>> > *genpd)
>> > -{
>> > -   struct gpd_link *link;
>> > -
>> > -   if (genpd->set_performance_state)
>> > -   return true;
>> > -
>> > -   list_for_each_entry(link, &genpd->slave_links, slave_node) {
>> > -   if (genpd_has_set_performance_state(link->master))
>> > -   return true;
>> > -   }
>> > -
>> > -   return false;
>> > -}
>> > -
>> >  /**
>> >   * pm_genpd_has_performance_state - Checks if power domain does 
>> > performance
>> >   * state management.
>> > @@ -507,7 +488,7 @@ bool pm_genpd_has_performance_state(struct device *dev)
>> >
>> > /* The parent domain must have set get_performance_state() */
>> > if (!IS_ERR(genpd) && genpd->get_performance_state) {
>> > -   if (genpd_has_set_performance_state(genpd))
>> > +   if (genpd->can_set_performance_state)
>> > return true;
>> >
>> > /*
>> > @@ -1594,6 +1575,8 @@ static int genpd_add_subdomain(struct 
>> > generic_pm_domain *genpd,
>> > if (genpd_status_on(subdomain))
>> > genpd_sd_counter_inc(genpd);
>> >
>> > +   subdomain->can_set_performance_state += 
>> > genpd->can_set_performance_state;
>> > +
>> >   out:
>> > genpd_unlock(genpd);
>> > genpd_unlock(subdomain);
>> > @@ -1654,6 +1637,8 @@ int pm_genpd_remove_subdomain(struct 
>> > generic_pm_domain *genpd,
>> > if (genpd_status_on(subdomain))
>> > genpd_sd_counter_dec(genpd);
>> >
>> > +   subdomain->can_set_performance_state -= 
>> > genpd->can_set_performance_state;
>> > +
>> > ret = 0;
>> > break;
>> > }
>> > @@ -1721,6 +1706,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
>> > genpd->max_off_time_changed = true;
>> > genpd->provider = NULL;
>> > genpd->has_provider = false;
>> > +   genpd->can_set_performance_state = !!genpd->set_performance_state;
>> > genpd->domain.ops.runtime_suspend = genpd_runtime_suspend;
>> > genpd->domain.ops.runtime_resume = genpd_runtime_resume;
>> > genpd->domain.ops.prepare = pm_genpd_prepare;
>> > diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
>> > index bf90177208a2..995d0cb1bc14 100644
>> > --- a/include/linux/pm_domain.h
>> > +++ b/include/linux/pm_domain.h
>> > @@ -64,6 +64,7 @@ struct generic_pm_domain {
>> > unsigned int suspended_count;   /* System suspend device counter */
>> > unsigned int prepared_count;/* Suspend counter of prepared 
>> > devices */
>> > unsigned int performance_state; /* Max requested performance state 
>> > */
>> > +   unsigned int can_set_performance_state; /* Number of parent 
>> > domains supporting set state */
>> > int (*power_off)(struct generic_pm_domain *domain);
>> > int (*power_on)(struct generic_pm_domain *domain);
>> > int (*get_performance_state)(struct device *dev, unsigned long 
>> > rate);
>> >
>>
>> Yes!
>
> The above diff will work fine only for the case where the master
> domain has all its masters set properly before genpd_add_subdomain()
> is called for the subdomain, as the genpd->can_set_performance_state
> count wouldn't change after that. But if the masters of the
> master are linked to the master after genpd_add_subdomain() is called
> for the subdomain, then we wouldn't be update the

Re: [PATCH] Staging: pi433: fix some warnings detected using sparse

2017-07-29 Thread Elia Geretto
On Fri, 2017-07-28 at 17:17 +0300, Dan Carpenter wrote:
> On Fri, Jul 28, 2017 at 02:56:26PM +0200, Elia Geretto wrote:
> > This patch corrects some visibility issues regarding some functions
> > and
> > solves a warning related to a non-matching union. After this patch,
> > sparse produces only one other warning regarding a bitwise
> > operator;
> > however, this behaviour seems to be intended.
> 
> I can't understand this changelog at all  :/  What are we fixing
> exactly?  It seems like we're fixing something about bitwise
> operators...  I guess let me check the Sparse warnings...  Here they
> are
> from the latest linux-next:
> 
> drivers/staging/pi433/pi433_if.c:211:9: warning: mixing different
> enum types
> drivers/staging/pi433/pi433_if.c:211:9: int enum
> optionOnOff  versus
> drivers/staging/pi433/pi433_if.c:211:9: int enum packetFormat 
> drivers/staging/pi433/pi433_if.c:211:9: warning: mixing different
> enum types
> drivers/staging/pi433/pi433_if.c:211:9: int enum
> optionOnOff  versus
> drivers/staging/pi433/pi433_if.c:211:9: int enum packetFormat 
> drivers/staging/pi433/pi433_if.c:268:9: warning: mixing different
> enum types
> drivers/staging/pi433/pi433_if.c:268:9: int enum
> optionOnOff  versus
> drivers/staging/pi433/pi433_if.c:268:9: int enum packetFormat 
> drivers/staging/pi433/pi433_if.c:268:9: warning: mixing different
> enum types
> drivers/staging/pi433/pi433_if.c:268:9: int enum
> optionOnOff  versus
> drivers/staging/pi433/pi433_if.c:268:9: int enum packetFormat 
> drivers/staging/pi433/pi433_if.c:317:1: warning: symbol
> 'pi433_receive' was not declared. Should it be static?
> drivers/staging/pi433/pi433_if.c:467:1: warning: symbol
> 'pi433_tx_thread' was not declared. Should it be static?
> drivers/staging/pi433/pi433_if.c:1155:36: error: incompatible types
> for operation (<)
> drivers/staging/pi433/pi433_if.c:1155:36:left side has type
> struct task_struct *tx_task_struct
> drivers/staging/pi433/pi433_if.c:1155:36:right side has type int
> drivers/staging/pi433/rf69.c:206:17: warning: dubious: x & !y
> drivers/staging/pi433/rf69.c:436:5: warning: symbol
> 'rf69_set_bandwidth_intern' was not declared. Should it be static?
> 
> Each type of fix should be sent as a separate fix with a better
> changelog.  People have already done the "static" fixes and IS_ERR()
> fixes, so don't worry about those.  But I don't think anyway has
> fixed
> the enum issues so resend that.  Also the bitwise thing is a real
> bug,
> but there is already a fix for that, it just hasn't been merged yet.
> 
> > 
> > Signed-off-by: Elia Geretto 
> > ---
> >  drivers/staging/pi433/pi433_if.c | 17 +++--
> >  drivers/staging/pi433/rf69.c |  4 +++-
> >  2 files changed, 14 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/staging/pi433/pi433_if.c
> > b/drivers/staging/pi433/pi433_if.c
> > index d9328ce5ec1d..f8219a53ce60 100644
> > --- a/drivers/staging/pi433/pi433_if.c
> > +++ b/drivers/staging/pi433/pi433_if.c
> > @@ -208,7 +208,10 @@ rf69_set_rx_cfg(struct pi433_device *dev,
> > struct pi433_rx_cfg *rx_cfg)
> > {
> > SET_CHECKED(rf69_set_fifo_fill_condition(dev->spi, 
> > always));
> > }
> > -   SET_CHECKED(rf69_set_packet_format  (dev->spi, rx_cfg-
> > >enable_length_byte));
> > +   if (rx_cfg->enable_length_byte == optionOn)
> > +   SET_CHECKED(rf69_set_packet_format(dev->spi,
> > packetLengthVar));
> > +   else
> > +   SET_CHECKED(rf69_set_packet_format(dev->spi,
> > packetLengthFix));
> 
> The SET_CHECKED() macro is total garbage.  It has a hidden return and
> it calls the rf69_set_packet_format() twice on error it expands to:
> 
>   if (rf69_set_packet_format(dev->spi, rx_cfg-
> >enable_length_byte)) < 0)
>   return rf69_set_packet_format(dev->spi, rx_cfg-
> >enable_length_byte);
> 
> Mega turbo barf!  Kill it with fire!
> 
> regards,
> dan carpenter
> 

I will resend a separate patch containing the enum work; I apologize
for the unclear changelog, I am still trying to understand how much in
detail I should go. Next time I will be more precise.

Regards,
Elia Geretto


Re: [PATCH 2/2] mm: replace TIF_MEMDIE checks by tsk_is_oom_victim

2017-07-29 Thread kbuild test robot
Hi Michal,

[auto build test ERROR on cgroup/for-next]
[also build test ERROR on v4.13-rc2 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Michal-Hocko/mm-oom-do-not-rely-on-TIF_MEMDIE-for-memory-reserves-access/20170728-101955
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next
config: i386-randconfig-c0-07291424 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   In file included from include/linux/ioport.h:12:0,
from include/linux/device.h:16,
from include/linux/node.h:17,
from include/linux/cpu.h:16,
from kernel/cgroup/cpuset.c:25:
   kernel/cgroup/cpuset.c: In function '__cpuset_node_allowed':
>> include/linux/compiler.h:123:18: error: implicit declaration of function 
>> 'tsk_is_oom_victim' [-Werror=implicit-function-declaration]
   static struct ftrace_likely_data  \
 ^
   include/linux/compiler.h:156:30: note: in definition of macro '__trace_if'
 if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
 ^
   kernel/cgroup/cpuset.c:2546:2: note: in expansion of macro 'if'
 if (unlikely(tsk_is_oom_victim(current)))
 ^
   include/linux/compiler.h:146:24: note: in expansion of macro 
'__branch_check__'
#  define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x)))
   ^
   kernel/cgroup/cpuset.c:2546:6: note: in expansion of macro 'unlikely'
 if (unlikely(tsk_is_oom_victim(current)))
 ^
   cc1: some warnings being treated as errors
--
   In file included from include/linux/ioport.h:12:0,
from include/linux/device.h:16,
from include/linux/node.h:17,
from include/linux/cpu.h:16,
from kernel//cgroup/cpuset.c:25:
   kernel//cgroup/cpuset.c: In function '__cpuset_node_allowed':
>> include/linux/compiler.h:123:18: error: implicit declaration of function 
>> 'tsk_is_oom_victim' [-Werror=implicit-function-declaration]
   static struct ftrace_likely_data  \
 ^
   include/linux/compiler.h:156:30: note: in definition of macro '__trace_if'
 if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
 ^
   kernel//cgroup/cpuset.c:2546:2: note: in expansion of macro 'if'
 if (unlikely(tsk_is_oom_victim(current)))
 ^
   include/linux/compiler.h:146:24: note: in expansion of macro 
'__branch_check__'
#  define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x)))
   ^
   kernel//cgroup/cpuset.c:2546:6: note: in expansion of macro 'unlikely'
 if (unlikely(tsk_is_oom_victim(current)))
 ^
   cc1: some warnings being treated as errors

vim +/tsk_is_oom_victim +123 include/linux/compiler.h

1f0d69a9 Steven Rostedt  2008-11-12  120  
d45ae1f7 Steven Rostedt (VMware  2017-01-17  121) #define __branch_check__(x, 
expect, is_constant) ({   \
1f0d69a9 Steven Rostedt  2008-11-12  122int 
__r;\
134e6a03 Steven Rostedt (VMware  2017-01-19 @123)   static 
struct ftrace_likely_data\
1f0d69a9 Steven Rostedt  2008-11-12  124
__attribute__((__aligned__(4))) \
45b79749 Steven Rostedt  2008-11-21  125
__attribute__((section("_ftrace_annotated_branch"))) \
1f0d69a9 Steven Rostedt  2008-11-12  126
__f = { \
134e6a03 Steven Rostedt (VMware  2017-01-19  127)   
.data.func = __func__,  \
134e6a03 Steven Rostedt (VMware  2017-01-19  128)   
.data.file = __FILE__,  \
134e6a03 Steven Rostedt (VMware  2017-01-19  129)   
.data.line = __LINE__,  \
1f0d69a9 Steven Rostedt  2008-11-12  130};  
\
d45ae1f7 Steven Rostedt (VMware  2017-01-17  131)   __r 
= __builtin_expect(!!(x), expect);  \
d45ae1f7 Steven Rostedt (VMware  2017-01-17  132)   
ftrace_likely_update(&__f, __r, \
d45ae1f7 Steven Rostedt (VMware  2017-01-17  133)   
 expect, is_constant);  \
1f0d69a9 Steven Rostedt  2008-11-12  134
__r;\
1f0d69a9 Steven Rostedt  2008-11-12  135})
1f0d69a9 Steven Rostedt  2008-11-12  136  

:: T

Re: [PATCH 0/2] constify nf_hook_ops structures

2017-07-29 Thread Florian Westphal
Julia Lawall  wrote:
> The nf_hook_ops structure is only passed as the second argument to
> nf_register_net_hook or nf_unregister_net_hook, both of which are
> declared as const.  Thus the nf_hook_ops structure itself can be
> const.

Right, also see
http://patchwork.ozlabs.org/patch/793767/

This series misses most of them (all arrays perhaps)?


Re: [PATCH 0/2] constify nf_hook_ops structures

2017-07-29 Thread Julia Lawall


On Sat, 29 Jul 2017, Florian Westphal wrote:

> Julia Lawall  wrote:
> > The nf_hook_ops structure is only passed as the second argument to
> > nf_register_net_hook or nf_unregister_net_hook, both of which are
> > declared as const.  Thus the nf_hook_ops structure itself can be
> > const.
>
> Right, also see
> http://patchwork.ozlabs.org/patch/793767/
>
> This series misses most of them (all arrays perhaps)?

Yes, my rule doesn't look for arrays.  I guess they are all done already
anyway?

thanks,
julia


> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


Re: [PATCH 1/1] staging: pi433: fix problem with division in rf69_set_deviation

2017-07-29 Thread Marcus Wolf
Hi Greg,
 
already had a discussion concerning that patch with Dan yesterday.
I really don't know what's going on there. I detached the patch once more from
my outbox and had a very close look in an editor and looked at it with a
difftool. In my outbox the patch is fine. I really don't knwo why it reaches you
crapped.
 
Since there are contsant problems with my patches, I will stop sending patches
for a while. As soon as I can find time to deeply confess with the tooling, I
will start over with trying.
 
Concerning this patch: You can use Arnds Patch from yesterday instead:
[PATCH] staging: pi433: use div_u64 for 64-bit division
It's a bit different to my patch, but according to yesterdays discussion, it
should also fix the problem.
 
Sorry for any inconvenience,
 
Marcus
 

> Greg KH  hat am 29. Juli 2017 um 02:01
> geschrieben:
>
>
> On Thu, Jul 20, 2017 at 05:56:36PM +0200, Marcus Wolf wrote:
> > Fixes problem with division in rf69_set_deviation
> >
> > Fixes: 874bcba65f9a ("staging: pi433: New driver")
> > Signed-off-by: Marcus Wolf 
> >
> > diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
> > --- a/drivers/staging/pi433/rf69.c
> > +++ b/drivers/staging/pi433/rf69.c
> > @@ -221,7 +221,7 @@ int rf69_set_frequency(struct spi_device *spi, u32
> > frequency)
>
> Patch is line-wrapped and does not apply :(
>


Re: [PATCH v2] fortify: Use WARN instead of BUG for now

2017-07-29 Thread kbuild test robot
Hi Kees,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.13-rc2 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Kees-Cook/fortify-Use-WARN-instead-of-BUG-for-now/20170728-091210
config: ia64-sim_defconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   lib/string.o: In function `fortify_overflow':
>> lib/string.c:984: undefined reference to `warn_slowpath_fmt'

vim +984 lib/string.c

   981  
   982  void fortify_overflow(const char *name)
   983  {
 > 984  WARN(1, "detected buffer overflow in %s\n", name);

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


.config.gz
Description: application/gzip


Re: [PATCH 1/1][staging-next] staging: pi433: Make functions rf69_set_dc_cut_off_frequency_intern static

2017-07-29 Thread Marcus Wolf
Hi Greg,
 
also had a very close look to this patch. Even in your reply I can't find any
problems with line wraps or other corruptions :-/

But we have alternative patches, solving these problems as well.
You e.g. could use the patch
[PATCH] Make functions rf69_set_bandwidth_intern and
rf69_set_dc_cut_off_frequency_intern static 
from Colin King 21/07/2017.
It's doing exactly the same, my patch should have done.
But be careful - tonight you added patch
staging: pi433: Make functions rf69_set_bandwidth_intern static"
Clins patch includes that changes as well!

Once again sorry for my crappy patches,

Marcus


Re: [PATCH 3/3] mm/sched: memdelay: memory health interface for systems and workloads

2017-07-29 Thread Peter Zijlstra
So no, this doesn't have a change in hell of making it.

On Thu, Jul 27, 2017 at 11:30:10AM -0400, Johannes Weiner wrote:
> +static void domain_cpu_update(struct memdelay_domain *md, int cpu,
> +   int old, int new)
> +{
> + enum memdelay_domain_state state;
> + struct memdelay_domain_cpu *mdc;
> + unsigned long now, delta;
> + unsigned long flags;
> +
> + mdc = per_cpu_ptr(md->mdcs, cpu);
> + spin_lock_irqsave(&mdc->lock, flags);

Afaict this is inside scheduler locks, this cannot be a spinlock. Also,
do we really want to add more atomics there?

> + if (old) {
> + WARN_ONCE(!mdc->tasks[old], "cpu=%d old=%d new=%d counter=%d\n",
> +   cpu, old, new, mdc->tasks[old]);
> + mdc->tasks[old] -= 1;
> + }
> + if (new)
> + mdc->tasks[new] += 1;
> +
> + /*
> +  * The domain is somewhat delayed when a number of tasks are
> +  * delayed but there are still others running the workload.
> +  *
> +  * The domain is fully delayed when all non-idle tasks on the
> +  * CPU are delayed, or when a delayed task is actively running
> +  * and preventing productive tasks from making headway.
> +  *
> +  * The state times then add up over all CPUs in the domain: if
> +  * the domain is fully blocked on one CPU and there is another
> +  * one running the workload, the domain is considered fully
> +  * blocked 50% of the time.
> +  */
> + if (!mdc->tasks[MTS_DELAYED_ACTIVE] && !mdc->tasks[MTS_DELAYED])
> + state = MDS_NONE;
> + else if (mdc->tasks[MTS_WORKING])
> + state = MDS_SOME;
> + else
> + state = MDS_FULL;
> +
> + if (mdc->state == state)
> + goto unlock;
> +
> + now = ktime_to_ns(ktime_get());

ktime_get_ns(), also no ktime in scheduler code.

> + delta = now - mdc->state_start;
> +
> + domain_move_clock(md);
> + md->times[mdc->state] += delta;
> +
> + mdc->state = state;
> + mdc->state_start = now;
> +unlock:
> + spin_unlock_irqrestore(&mdc->lock, flags);
> +}
> +
> +static struct memdelay_domain *memcg_domain(struct mem_cgroup *memcg)
> +{
> +#ifdef CONFIG_MEMCG
> + if (!mem_cgroup_disabled())
> + return memcg->memdelay_domain;
> +#endif
> + return &memdelay_global_domain;
> +}
> +
> +/**
> + * memdelay_task_change - note a task changing its delay/work state
> + * @task: the task changing state
> + * @delayed: 1 when task enters delayed state, -1 when it leaves
> + * @working: 1 when task enters working state, -1 when it leaves
> + * @active_delay: 1 when task enters active delay, -1 when it leaves
> + *
> + * Updates the task's domain counters to reflect a change in the
> + * task's delayed/working state.
> + */
> +void memdelay_task_change(struct task_struct *task, int old, int new)
> +{
> + int cpu = task_cpu(task);
> + struct mem_cgroup *memcg;
> + unsigned long delay = 0;
> +
> +#ifdef CONFIG_DEBUG_VM
> + WARN_ONCE(task->memdelay_state != old,
> +   "cpu=%d task=%p state=%d (in_iowait=%d PF_MEMDELAYED=%d) 
> old=%d new=%d\n",
> +   cpu, task, task->memdelay_state, task->in_iowait,
> +   !!(task->flags & PF_MEMDELAY), old, new);
> + task->memdelay_state = new;
> +#endif
> +
> + /* Account when tasks are entering and leaving delays */
> + if (old < MTS_DELAYED && new >= MTS_DELAYED) {
> + task->memdelay_start = ktime_to_ms(ktime_get());
> + } else if (old >= MTS_DELAYED && new < MTS_DELAYED) {
> + delay = ktime_to_ms(ktime_get()) - task->memdelay_start;
> + task->memdelay_total += delay;
> + }

Scheduler stuff will _NOT_ user ktime_get() and will _NOT_ do pointless
divisions into ms.

> +
> + /* Account domain state changes */
> + rcu_read_lock();
> + memcg = mem_cgroup_from_task(task);
> + do {
> + struct memdelay_domain *md;
> +
> + md = memcg_domain(memcg);
> + md->aggregate += delay;
> + domain_cpu_update(md, cpu, old, new);
> + } while (memcg && (memcg = parent_mem_cgroup(memcg)));
> + rcu_read_unlock();

We are _NOT_ going to do a 3rd cgroup iteration for every task action.

> +};


[PATCH] watchdog: moxart_wdt: Replace decimal permissions with 4 digit octal

2017-07-29 Thread SZ Lin
ERROR: Use 4 digit octal (0777) not decimal permissions

This error was detected by checkpatch.pl

Signed-off-by: SZ Lin 
---
 drivers/watchdog/moxart_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/moxart_wdt.c b/drivers/watchdog/moxart_wdt.c
index 2c4a73d1e214..05684aa89b88 100644
--- a/drivers/watchdog/moxart_wdt.c
+++ b/drivers/watchdog/moxart_wdt.c
@@ -170,7 +170,7 @@ static struct platform_driver moxart_wdt_driver = {
 };
 module_platform_driver(moxart_wdt_driver);
 
-module_param(heartbeat, int, 0);
+module_param(heartbeat, int, );
 MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds");
 
 MODULE_DESCRIPTION("MOXART watchdog driver");
-- 
2.13.3



[PATCH] dlm: constify kset_uevent_ops structure

2017-07-29 Thread Julia Lawall
The kset_uevent_ops structure is only passed as the second argument
to kset_create_and_add, which is declared as const.  Thus the
kset_uevent_ops structure itself can be const.

Done with the help of Coccinelle.

// 
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct kset_uevent_ops i@p = { ... };

@ok1@
identifier r.i;
expression e;
position p;
@@
 kset_create_and_add(e,&i@p,...)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct kset_uevent_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct kset_uevent_ops i = { ... };
// 

Signed-off-by: Julia Lawall 

---
 fs/dlm/lockspace.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index 9ebfa05..78a7c85 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -235,7 +235,7 @@ static int dlm_uevent(struct kset *kset, struct kobject 
*kobj,
return 0;
 }
 
-static struct kset_uevent_ops dlm_uevent_ops = {
+static const struct kset_uevent_ops dlm_uevent_ops = {
.uevent = dlm_uevent,
 };
 



Re: [PATCH 2/2] sched: Implement interface for cgroup unified hierarchy

2017-07-29 Thread Peter Zijlstra
On Thu, Jul 20, 2017 at 02:48:08PM -0400, Tejun Heo wrote:
> There are a couple interface issues which can be addressed in cgroup2
> interface.
> 
> * Stats from cpuacct being reported separately from the cpu stats.
> 
> * Use of different time units.  Writable control knobs use
>   microseconds, some stat fields use nanoseconds while other cpuacct
>   stat fields use centiseconds.
> 
> * Control knobs which can't be used in the root cgroup still show up
>   in the root.
> 
> * Control knob names and semantics aren't consistent with other
>   controllers.
> 
> This patchset implements cpu controller's interface on cgroup2 which
> adheres to the controller file conventions described in
> Documentation/cgroups/cgroup-v2.txt.  Overall, the following changes
> are made.
> 
> * cpuacct is implictly enabled and disabled by cpu and its information
>   is reported through "cpu.stat" which now uses microseconds for all
>   time durations.  All time duration fields now have "_usec" appended
>   to them for clarity.
> 
>   Note that cpuacct.usage_percpu is currently not included in
>   "cpu.stat".  If this information is actually called for, it will be
>   added later.
> 
> * "cpu.shares" is replaced with "cpu.weight" and operates on the
>   standard scale defined by CGROUP_WEIGHT_MIN/DFL/MAX (1, 100, 1).
>   The weight is scaled to scheduler weight so that 100 maps to 1024
>   and the ratio relationship is preserved - if weight is W and its
>   scaled value is S, W / 100 == S / 1024.  While the mapped range is a
>   bit smaller than the orignal scheduler weight range, the dead zones
>   on both sides are relatively small and covers wider range than the
>   nice value mappings.  This file doesn't make sense in the root
>   cgroup and isn't create on root.

s/create/&d/

Thanks!

> * "cpu.weight.nice" is added. When read, it reads back the nice value
>   which is closest to the current "cpu.weight".  When written, it sets
>   "cpu.weight" to the weight value which matches the nice value.  This
>   makes it easy to configure cgroups when they're competing against
>   threads in threaded subtrees.
> 
> * "cpu.cfs_quota_us" and "cpu.cfs_period_us" are replaced by "cpu.max"
>   which contains both quota and period.
> 
> * "cpu.rt_runtime_us" and "cpu.rt_period_us" are replaced by
>   "cpu.rt.max" which contains both runtime and period.

So we've been looking at overhauling the whole RT stuff. But sadly we've
not been able to find something that works with all the legacy
constraints (like RT tasks having arbitrary affinities).

Lets just hope we can preserve this interface :/
> 
> v3: - Added "cpu.weight.nice" to allow using nice values when
>   configuring the weight.  The feature is requested by PeterZ.
> - Merge the patch to enable threaded support on cpu and cpuacct.

> - Dropped the bits about getting rid of cpuacct from patch
>   description as there is a pretty strong case for making cpuacct
>   an implicit controller so that basic cpu usage stats are always
>   available.

What about the whole double accounting thing? Because currently cpuacct
and cpu do a fair bit of duplication. It would be very good to get rid
of that.

> - Documentation updated accordingly.  "cpu.rt.max" section is
>   dropped for now.



Re: [PATCH 0/2] constify nf_hook_ops structures

2017-07-29 Thread Florian Westphal
Julia Lawall  wrote:
> 
> 
> On Sat, 29 Jul 2017, Florian Westphal wrote:
> 
> > Julia Lawall  wrote:
> > > The nf_hook_ops structure is only passed as the second argument to
> > > nf_register_net_hook or nf_unregister_net_hook, both of which are
> > > declared as const.  Thus the nf_hook_ops structure itself can be
> > > const.
> >
> > Right, also see
> > http://patchwork.ozlabs.org/patch/793767/
> >
> > This series misses most of them (all arrays perhaps)?
> 
> Yes, my rule doesn't look for arrays.  I guess they are all done already
> anyway?

I think so (the patch is not yet applied though).

>From a quick glance I don't see why we can't e.g. constify
nf_conntrack_l3/4_proto too. It is not going to be as simple
as just placing const everywhere, but I see no requirement for
having these writeable.


Re: [PATCH 0/2] constify nf_hook_ops structures

2017-07-29 Thread Julia Lawall


On Sat, 29 Jul 2017, Florian Westphal wrote:

> Julia Lawall  wrote:
> >
> >
> > On Sat, 29 Jul 2017, Florian Westphal wrote:
> >
> > > Julia Lawall  wrote:
> > > > The nf_hook_ops structure is only passed as the second argument to
> > > > nf_register_net_hook or nf_unregister_net_hook, both of which are
> > > > declared as const.  Thus the nf_hook_ops structure itself can be
> > > > const.
> > >
> > > Right, also see
> > > http://patchwork.ozlabs.org/patch/793767/
> > >
> > > This series misses most of them (all arrays perhaps)?
> >
> > Yes, my rule doesn't look for arrays.  I guess they are all done already
> > anyway?
>
> I think so (the patch is not yet applied though).

OK, just drop my patch then.

>
> From a quick glance I don't see why we can't e.g. constify
> nf_conntrack_l3/4_proto too. It is not going to be as simple
> as just placing const everywhere, but I see no requirement for
> having these writeable.

I will take a look.

thanks,
julia

> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


Re: [RFC PATCH v2] membarrier: expedited private command

2017-07-29 Thread Peter Zijlstra
On Sat, Jul 29, 2017 at 11:58:40AM +1000, Nicholas Piggin wrote:
> I haven't had time to read the thread and understand exactly why you need
> this extra barrier, I'll do it next week. Thanks for cc'ing us on it.

Bottom of here:

https://lkml.kernel.org/r/20170727135610.jwjfvyuacqzj5...@hirez.programming.kicks-ass.net

is probably the fastest way towards understanding the need for a barrier
after rq->curr assignment.

Any barrier after that assignment is good for us, but so far it looks
like PPC doesn't (and PPC only afaict) provide any smp_mb() after that
point.

> A smp_mb is pretty expensive on powerpc CPUs. Removing the sync from
> switch_to increased thread switch performance by 2-3%. Putting it in
> switch_mm may be a little less painful, but still we have to weigh it
> against the benefit of this new functionality. Would that be a net win
> for the average end-user? Seems unlikely.
> 
> But we also don't want to lose sys_membarrier completely. Would it be too
> painful to make  MEMBARRIER_CMD_PRIVATE_EXPEDITED return error, or make it
> fall back to a slower case if we decide not to implement it?

One ugly thing we've thought of is tagging each mm that has used
sys_membarrier() and only issue the smp_mb() for those. That way only
those tasks that actually rely on the syscall get to pay the price.


Re: [RFC] perf: Delayed userspace unwind (Was: [PATCH v3 00/10] x86: ORC unwinder)

2017-07-29 Thread Peter Zijlstra
On Fri, Jul 28, 2017 at 08:35:16PM -0700, Andy Lutomirski wrote:

> I haven't checked task_work specifically, but a bunch of the exit work
> is permitted to sleep, which is potentially useful.

Yes.

> If this becomes successful enough that we could eventually deprecate
> the old code, I wonder if copy_from_user_nmi() could go away? :)

So we still use that for things like the PEBS IP fixup for older CPUs.
That needs to read the userspace code.

Also, since all this is optional on userspace asking for the new format,
we will probably (forever) need to support userspace not asking for it.

> > +if (!work->func) {
> > +work->func = perf_callchain_work;
> > +/*
> > + * We cannot do set_notify_resume() from NMI context,
> > + * also, knowing we are already in an interrupted
> > + * context and will pass return to userspace, we can
> > + * simply set TIF_NOTIFY_RESUME.
> > + */
> > +task_work_add(current, work, false);
> > +set_tsk_thread_flag(current, TIF_NOTIFY_RESUME);
> 
> There's a more or leas unavoidable window in which this won't be
> noticed, which could plausibly confuse userspace.  It might be
> possible to figure out a way for an NMI to tell if it lands in this
> window, but it would be a bit tricky.

Correct, I have been thinking on how to do that but haven't found
anything particularly nice yet.

> Also, is the task_work code prepared to handle task_work_add during
> exit?

That is one I hadn't thought of, but basically task_work_add() will fail
if the task is too far gone. At that point we should fallback to the
'old' behaviour and simply include the information in the kernel SAMPLE
record.



[PATCH] staging: pi433: Use matching enum types calling rf69_set_packet_format

2017-07-29 Thread Elia Geretto
This patch fixes the following four warnings found using sparse:

drivers/staging/pi433/pi433_if.c:211:9: warning: mixing different enum types
drivers/staging/pi433/pi433_if.c:211:9: int enum optionOnOff  versus
drivers/staging/pi433/pi433_if.c:211:9: int enum packetFormat
drivers/staging/pi433/pi433_if.c:211:9: warning: mixing different enum types
drivers/staging/pi433/pi433_if.c:211:9: int enum optionOnOff  versus
drivers/staging/pi433/pi433_if.c:211:9: int enum packetFormat
drivers/staging/pi433/pi433_if.c:268:9: warning: mixing different enum types
drivers/staging/pi433/pi433_if.c:268:9: int enum optionOnOff  versus
drivers/staging/pi433/pi433_if.c:268:9: int enum packetFormat
drivers/staging/pi433/pi433_if.c:268:9: warning: mixing different enum types
drivers/staging/pi433/pi433_if.c:268:9: int enum optionOnOff  versus
drivers/staging/pi433/pi433_if.c:268:9: int enum packetFormat

This is done calling the rf69_set_packet_format function using the
appropriate enum for the packetFormat argument.

Signed-off-by: Elia Geretto 
---
 drivers/staging/pi433/pi433_if.c | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d9328ce5ec1d..fc2250810eed 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -208,7 +208,17 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
{
SET_CHECKED(rf69_set_fifo_fill_condition(dev->spi, always));
}
-   SET_CHECKED(rf69_set_packet_format  (dev->spi, 
rx_cfg->enable_length_byte));
+   if (rx_cfg->enable_length_byte == optionOn) {
+   int ret = rf69_set_packet_format(dev->spi, packetLengthVar);
+
+   if (ret < 0)
+   return ret;
+   } else {
+   int ret = rf69_set_packet_format(dev->spi, packetLengthFix);
+
+   if (ret < 0)
+   return ret;
+   }
SET_CHECKED(rf69_set_adressFiltering(dev->spi, 
rx_cfg->enable_address_filtering));
SET_CHECKED(rf69_set_crc_enable (dev->spi, rx_cfg->enable_crc));
 
@@ -264,8 +274,18 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct 
pi433_tx_cfg *tx_cfg)
{
SET_CHECKED(rf69_set_preamble_length(dev->spi, 0));
}
+   if (tx_cfg->enable_length_byte == optionOn) {
+   int ret = rf69_set_packet_format(dev->spi, packetLengthVar);
+
+   if (ret < 0)
+   return ret;
+   } else {
+   int ret = rf69_set_packet_format(dev->spi, packetLengthFix);
+
+   if (ret < 0)
+   return ret;
+   }
SET_CHECKED(rf69_set_sync_enable  (dev->spi, tx_cfg->enable_sync));
-   SET_CHECKED(rf69_set_packet_format(dev->spi, 
tx_cfg->enable_length_byte));
SET_CHECKED(rf69_set_crc_enable   (dev->spi, tx_cfg->enable_crc));
 
/* configure sync, if enabled */
-- 
2.13.3



Re: [PATCH v2] staging: octeon: fix line over 80 characters

2017-07-29 Thread kbuild test robot
Hi John,

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

url:
https://github.com/0day-ci/linux/commits/catalinnow-gmail-com/staging-octeon-fix-line-over-80-characters/20170728-071556
config: mips-cavium_octeon_defconfig (attached as .config)
compiler: mips64-linux-gnuabi64-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=mips 

All warnings (new ones prefixed by >>):

   drivers/staging/octeon/ethernet-rx.c: In function 'copy_segments_to_skb':
>> drivers/staging/octeon/ethernet-rx.c:173:3: warning: ISO C90 forbids mixed 
>> declarations and code [-Wdeclaration-after-statement]
  int segment_size =
  ^~~

vim +173 drivers/staging/octeon/ethernet-rx.c

   151  
   152  static void copy_segments_to_skb(cvmx_wqe_t *work, struct sk_buff *skb)
   153  {
   154  int segments = work->word2.s.bufs;
   155  union cvmx_buf_ptr segment_ptr = work->packet_ptr;
   156  int len = work->word1.len;
   157  
   158  while (segments--) {
   159  union cvmx_buf_ptr next_ptr;
   160  
   161  next_ptr = *(union cvmx_buf_ptr *)
   162  cvmx_phys_to_ptr(segment_ptr.s.addr - 8);
   163  
   164  /*
   165   * Octeon Errata PKI-100: The segment size is wrong.
   166   *
   167   * Until it is fixed, calculate the segment size based 
on
   168   * the packet pool buffer size.
   169   * When it is fixed, the following line should be 
replaced
   170   * with this one:
   171   * int segment_size = segment_ptr.s.size;
   172   */
 > 173  int segment_size =
   174  CVMX_FPA_PACKET_POOL_SIZE -
   175  (segment_ptr.s.addr -
   176   (((segment_ptr.s.addr >> 7) -
   177 segment_ptr.s.back) << 7));
   178  
   179  /* Don't copy more than what is left in the packet */
   180  if (segment_size > len)
   181  segment_size = len;
   182  
   183  /* Copy the data into the packet */
   184  skb_put_data(skb, cvmx_phys_to_ptr(segment_ptr.s.addr),
   185   segment_size);
   186  len -= segment_size;
   187  segment_ptr = next_ptr;
   188  }
   189  }
   190  

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


.config.gz
Description: application/gzip


Re: [PATCH 4/5] mtd: spi-nor: Add driver for Adaptrum Anarion QSPI controller

2017-07-29 Thread Marek Vasut
On 07/29/2017 12:07 AM, Alexandru Gagniuc wrote:
> Add support for the QSPI controller found in Adaptrum Anarion SOCs.
> This controller is designed specifically to handle SPI NOR chips, and
> the driver is modeled as such.
> 
> Because the system is emulated on an FPGA, we don't have a way to test
> all the hardware adjustemts, so only basic features are implemented at
> this time.
> 
> Signed-off-by: Alexandru Gagniuc 
> ---
>  .../devicetree/bindings/mtd/anarion-quadspi.txt|  22 +
>  drivers/mtd/spi-nor/Kconfig|   7 +
>  drivers/mtd/spi-nor/Makefile   |   1 +
>  drivers/mtd/spi-nor/anarion-quadspi.c  | 490 
> +
>  4 files changed, 520 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mtd/anarion-quadspi.txt
>  create mode 100644 drivers/mtd/spi-nor/anarion-quadspi.c
> 
> diff --git a/Documentation/devicetree/bindings/mtd/anarion-quadspi.txt 
> b/Documentation/devicetree/bindings/mtd/anarion-quadspi.txt
> new file mode 100644
> index 000..b4971e1
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mtd/anarion-quadspi.txt
> @@ -0,0 +1,22 @@
> +* Adaptrum Anarion Quad SPI controller
> +
> +Required properties:
> +- compatible : Should be "adaptrum,anarion-qspi".
> +- reg : Contains two entries, each of which is a tuple consisting of a
> + physical address and length. The first entry is the address and
> + length of the controller register set. The second entry is the
> + address and length of the memory-mapped flash. This second region is
> + the region where the controller responds to XIP requests, and may be
> + larger than the size of the attached flash.

You want to split the bindings into separate patch and CC Rob to review
them.

> +Example:
> +
> + qspi: qspi@f200f000 {
> + compatible = "adaptrum,anarion-qspi";
> + reg =   <0xf200f000 0x1000>,
> + <0x2000 0x0800>;
> +
> + flash0: w25q128fvn@0 {
> + ...
> + }
> + };
> diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
> index 293c8a4..98dc012 100644
> --- a/drivers/mtd/spi-nor/Kconfig
> +++ b/drivers/mtd/spi-nor/Kconfig
> @@ -48,6 +48,13 @@ config SPI_ATMEL_QUADSPI
> This driver does not support generic SPI. The implementation only
> supports SPI NOR.
>  
> +config SPI_ANARION_QUADSPI
> + tristate "Adaptrum Anarion Quad SPI Controller"
> + depends on OF && HAS_IOMEM
> + help
> +   Enable support for the Adaptrum Anarion Quad SPI controller.
> +   This driver does not support generic SPI. It only supports SPI NOR.

Keep the list sorted.

>  config SPI_CADENCE_QUADSPI
>   tristate "Cadence Quad SPI controller"
>   depends on OF && (ARM || COMPILE_TEST)
> diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
> index 285aab8..53635f6 100644
> --- a/drivers/mtd/spi-nor/Makefile
> +++ b/drivers/mtd/spi-nor/Makefile
> @@ -1,6 +1,7 @@
>  obj-$(CONFIG_MTD_SPI_NOR)+= spi-nor.o
>  obj-$(CONFIG_SPI_ASPEED_SMC) += aspeed-smc.o
>  obj-$(CONFIG_SPI_ATMEL_QUADSPI)  += atmel-quadspi.o
> +obj-$(CONFIG_SPI_ANARION_QUADSPI)+= anarion-quadspi.o

DTTO, N is before S and T .

>  obj-$(CONFIG_SPI_CADENCE_QUADSPI)+= cadence-quadspi.o
>  obj-$(CONFIG_SPI_FSL_QUADSPI)+= fsl-quadspi.o
>  obj-$(CONFIG_SPI_HISI_SFC)   += hisi-sfc.o
> diff --git a/drivers/mtd/spi-nor/anarion-quadspi.c 
> b/drivers/mtd/spi-nor/anarion-quadspi.c
> new file mode 100644
> index 000..d981356
> --- /dev/null
> +++ b/drivers/mtd/spi-nor/anarion-quadspi.c
> @@ -0,0 +1,490 @@
> +/*
> + * Adaptrum Anarion Quad SPI controller driver
> + *
> + * Copyright (C) 2017, Adaptrum, Inc.
> + * (Written by Alexandru Gagniuc  for Adaptrum, Inc.)
> + * Licensed under the GPLv2 or (at your option) any later version.

The GPL boilerplate should be here.

> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define ASPI_REG_CLOCK   0x00
> +#define ASPI_REG_GO  0x04
> +#define ASPI_REG_CHAIN   0x08
> +#define ASPI_REG_CMD10x0c
> +#define ASPI_REG_CMD20x10
> +#define ASPI_REG_ADDR1   0x14
> +#define ASPI_REG_ADDR2   0x18
> +#define ASPI_REG_PERF1   0x1c
> +#define ASPI_REG_PERF2   0x20
> +#define ASPI_REG_HI_Z0x24
> +#define ASPI_REG_BYTE_COUNT  0x28
> +#define ASPI_REG_DATA1   0x2c
> +#define ASPI_REG_DATA2   0x30
> +#define ASPI_REG_FINISH  0x34
> +#define ASPI_REG_XIP 0x38
> +#define ASPI_REG_FIFO_STATUS 0x3c
> +#define ASPI_REG_LAT 0x40
> +#define ASPI_REG_OUT_DELAY_0 0x44
> +#define ASPI_REG_OUT_DELAY_1  

Re: [PATCH 0/2] constify nf_hook_ops structures

2017-07-29 Thread Florian Westphal
Julia Lawall  wrote:
> On Sat, 29 Jul 2017, Florian Westphal wrote:
> > From a quick glance I don't see why we can't e.g. constify
> > nf_conntrack_l3/4_proto too. It is not going to be as simple
> > as just placing const everywhere, but I see no requirement for
> > having these writeable.
> 
> I will take a look.

Thanks.

nf_logger and nf_loginfo also look like constify candidates.

If there is a way to add "const" qualifier to pointer-to-structs
that are not modified this would good as well to have IMO, if just
for purpose of documentation.  For instance:

+++ b/net/netfilter/nf_conntrack_core.c
@@ -1177,8 +1177,8 @@ void nf_conntrack_free(struct nf_conn *ct)
 static noinline struct nf_conntrack_tuple_hash *
 init_conntrack(struct net *net, struct nf_conn *tmpl,
   const struct nf_conntrack_tuple *tuple,
-  struct nf_conntrack_l3proto *l3proto,
-  struct nf_conntrack_l4proto *l4proto,
+  const struct nf_conntrack_l3proto *l3proto,
+  const struct nf_conntrack_l4proto *l4proto,


(its only passed as arg to a function that expects
"const struct nf_conntrack_x *").

I think we have several (also non-static helpers) that
take "struct foo *" arg while they could use "const struct foo*"
instead.


Re: [RFC PATCH v2] membarrier: expedited private command

2017-07-29 Thread Nicholas Piggin
On Sat, 29 Jul 2017 11:23:33 +0200
Peter Zijlstra  wrote:

> On Sat, Jul 29, 2017 at 11:58:40AM +1000, Nicholas Piggin wrote:
> > I haven't had time to read the thread and understand exactly why you need
> > this extra barrier, I'll do it next week. Thanks for cc'ing us on it.  
> 
> Bottom of here:
> 
> https://lkml.kernel.org/r/20170727135610.jwjfvyuacqzj5...@hirez.programming.kicks-ass.net
> 
> is probably the fastest way towards understanding the need for a barrier
> after rq->curr assignment.
> 
> Any barrier after that assignment is good for us, but so far it looks
> like PPC doesn't (and PPC only afaict) provide any smp_mb() after that
> point.

Thanks, yeah that's relatively straightforward.

> > A smp_mb is pretty expensive on powerpc CPUs. Removing the sync from
> > switch_to increased thread switch performance by 2-3%. Putting it in
> > switch_mm may be a little less painful, but still we have to weigh it
> > against the benefit of this new functionality. Would that be a net win
> > for the average end-user? Seems unlikely.
> > 
> > But we also don't want to lose sys_membarrier completely. Would it be too
> > painful to make  MEMBARRIER_CMD_PRIVATE_EXPEDITED return error, or make it
> > fall back to a slower case if we decide not to implement it?  
> 
> One ugly thing we've thought of is tagging each mm that has used
> sys_membarrier() and only issue the smp_mb() for those. That way only
> those tasks that actually rely on the syscall get to pay the price.

The biggest hammer that puts everything on the syscall side I think would
be to lock each runqueue to while iterating over them, right?

That could be pretty expensive but it would be interesting to know how
bad that is for real apps... hmm, we might be able to restrict iteration
to mm_cpumask(current->mm), no? 


Re: [RFC PATCH v2] membarrier: expedited private command

2017-07-29 Thread Nicholas Piggin
On Sat, 29 Jul 2017 19:45:43 +1000
Nicholas Piggin  wrote:

> hmm, we might be able to restrict iteration
> to mm_cpumask(current->mm), no? 

Oh that's been discussed too. I'll read back over it too.


DO GET BACK IF INTERESTED!!

2017-07-29 Thread Micheal Lenn
Hello

I am Mr Micheal Lennings , an Auditor Officer, PNC bank here in U.S.A. I 
believe it is the wish of God for me to come across you now. I have been in 
search of someone with this last name  ,so when I saw you online, I was pushed 
to contact you and see how best we can assist each other. I am having an 
important business discussion I wish to share with you which I believe will 
interest you, because it is in connection with your last name and you are going 
to benefit from.

One Late jeremiah , a citizen of your country had a fixed deposit with my bank 
in 2005 for 108 calendar months, valued at US$30,000,000.00 (Thirty Million 
United State Dollars) the due date for this deposit contract was last 22nd of 
January 2015. Sadly jerry was among the death victims in the May 27 2006 
Earthquake disaster in Java, Indonesia that killed over 5,000 people. He was in 
Indonesia on a business trip and that was how he met his end. My bank 
management is yet to know about his death, I knew about it because he was my 
friend and I am his account officer. jeremiah did not mention any Next of Kin/ 
Heir when the account was opened, and he was not married and no children. Last 
week my Bank Management requested that jeremiah should give instructions on 
what to do about his funds, if to renew the contract.

I know this will happen and that is why I have been looking for a means to 
handle the situation, because if my Bank Directors happens to know that 
jeremiah is dead and do not have any Heir, they will taKe it to there personal 
purse.There is no risk involved; the transaction will be executed under a 
legitimate arrangement that will protect you from any breach of law. It is 
better that we claim the money, than allowing the Bank Directors to take it, 
they are rich already. I am not a greedy person, so I am suggesting we share 
the funds equal, 50/50% to both parties, my share will assist me to start my 
own company which has been my dream. Let me know your mind on this and please 
do treat this information as TOP SECRET. We shall go over the details once I 
receive your urgent response strictly through my personal 
Email:mike.lennni...@gmail.com

Have a nice day and God bless. Anticipating your communication.

Regards,
Mr.Micheal Lennings
Senior Audior Officer,
PNC Bank


Re: [PATCH 0/2] constify nf_hook_ops structures

2017-07-29 Thread Julia Lawall


On Sat, 29 Jul 2017, Florian Westphal wrote:

> Julia Lawall  wrote:
> > On Sat, 29 Jul 2017, Florian Westphal wrote:
> > > From a quick glance I don't see why we can't e.g. constify
> > > nf_conntrack_l3/4_proto too. It is not going to be as simple
> > > as just placing const everywhere, but I see no requirement for
> > > having these writeable.
> >
> > I will take a look.
>
> Thanks.

For the protos, the functions nf_ct_l3proto_register and
nf_ct_l4proto_register_one update the nla_size field. I don't know how
many structures reach these functions.

julia

>
> nf_logger and nf_loginfo also look like constify candidates.
>
> If there is a way to add "const" qualifier to pointer-to-structs
> that are not modified this would good as well to have IMO, if just
> for purpose of documentation.  For instance:
>
> +++ b/net/netfilter/nf_conntrack_core.c
> @@ -1177,8 +1177,8 @@ void nf_conntrack_free(struct nf_conn *ct)
>  static noinline struct nf_conntrack_tuple_hash *
>  init_conntrack(struct net *net, struct nf_conn *tmpl,
>const struct nf_conntrack_tuple *tuple,
> -  struct nf_conntrack_l3proto *l3proto,
> -  struct nf_conntrack_l4proto *l4proto,
> +  const struct nf_conntrack_l3proto *l3proto,
> +  const struct nf_conntrack_l4proto *l4proto,
>
>
> (its only passed as arg to a function that expects
> "const struct nf_conntrack_x *").
>
> I think we have several (also non-static helpers) that
> take "struct foo *" arg while they could use "const struct foo*"
> instead.
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


Re: [PATCH] x86/boot: check overlap between kernel and EFI_BOOT_SERVICES_*

2017-07-29 Thread kbuild test robot
Hi Naoya,

[auto build test ERROR on efi/next]
[also build test ERROR on v4.13-rc2 next-20170728]
[cannot apply to tip/x86/core]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Naoya-Horiguchi/x86-boot-check-overlap-between-kernel-and-EFI_BOOT_SERVICES_/20170729-170209
base:   https://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git next
config: x86_64-lkp (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   arch/x86/boot/compressed/misc.o: In function `extract_kernel':
>> misc.c:(.text+0x2cf9): undefined reference to `initialize_identity_maps'
   arch/x86/boot/compressed/misc.o: In function 
`efi_kernel_boot_services_overlap':
>> misc.c:(.init.text+0x7b): undefined reference to `add_identity_map'

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


.config.gz
Description: application/gzip


[PATCH] f2fs: add app/fs io stat

2017-07-29 Thread Chao Yu
This patch enables inner app/fs io stats and introduces below virtual fs
nodes for exposing stats info:
/sys/fs/f2fs//iostat_enable
/proc/fs/f2fs//iostat_info

Signed-off-by: Chao Yu 
---
 fs/f2fs/checkpoint.c | 34 +-
 fs/f2fs/data.c   | 35 +++
 fs/f2fs/f2fs.h   | 58 +---
 fs/f2fs/file.c   |  7 ++-
 fs/f2fs/gc.c |  3 +++
 fs/f2fs/inline.c |  1 +
 fs/f2fs/node.c   | 15 --
 fs/f2fs/segment.c| 19 +++--
 fs/f2fs/super.c  |  4 
 fs/f2fs/sysfs.c  | 35 +++
 10 files changed, 180 insertions(+), 31 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 3c84a2520796..da5b49183e09 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -230,8 +230,9 @@ void ra_meta_pages_cond(struct f2fs_sb_info *sbi, pgoff_t 
index)
ra_meta_pages(sbi, index, BIO_MAX_PAGES, META_POR, true);
 }
 
-static int f2fs_write_meta_page(struct page *page,
-   struct writeback_control *wbc)
+static int __f2fs_write_meta_page(struct page *page,
+   struct writeback_control *wbc,
+   enum iostat_type io_type)
 {
struct f2fs_sb_info *sbi = F2FS_P_SB(page);
 
@@ -244,7 +245,7 @@ static int f2fs_write_meta_page(struct page *page,
if (unlikely(f2fs_cp_error(sbi)))
goto redirty_out;
 
-   write_meta_page(sbi, page);
+   write_meta_page(sbi, page, io_type);
dec_page_count(sbi, F2FS_DIRTY_META);
 
if (wbc->for_reclaim)
@@ -263,6 +264,12 @@ static int f2fs_write_meta_page(struct page *page,
return AOP_WRITEPAGE_ACTIVATE;
 }
 
+static int f2fs_write_meta_page(struct page *page,
+   struct writeback_control *wbc)
+{
+   return __f2fs_write_meta_page(page, wbc, FS_META_IO);
+}
+
 static int f2fs_write_meta_pages(struct address_space *mapping,
struct writeback_control *wbc)
 {
@@ -283,7 +290,7 @@ static int f2fs_write_meta_pages(struct address_space 
*mapping,
 
trace_f2fs_writepages(mapping->host, wbc, META);
diff = nr_pages_to_write(sbi, META, wbc);
-   written = sync_meta_pages(sbi, META, wbc->nr_to_write);
+   written = sync_meta_pages(sbi, META, wbc->nr_to_write, FS_META_IO);
mutex_unlock(&sbi->cp_mutex);
wbc->nr_to_write = max((long)0, wbc->nr_to_write - written - diff);
return 0;
@@ -295,7 +302,7 @@ static int f2fs_write_meta_pages(struct address_space 
*mapping,
 }
 
 long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
-   long nr_to_write)
+   long nr_to_write, enum iostat_type io_type)
 {
struct address_space *mapping = META_MAPPING(sbi);
pgoff_t index = 0, end = ULONG_MAX, prev = ULONG_MAX;
@@ -346,7 +353,7 @@ long sync_meta_pages(struct f2fs_sb_info *sbi, enum 
page_type type,
if (!clear_page_dirty_for_io(page))
goto continue_unlock;
 
-   if (mapping->a_ops->writepage(page, &wbc)) {
+   if (__f2fs_write_meta_page(page, &wbc, io_type)) {
unlock_page(page);
break;
}
@@ -904,7 +911,14 @@ int sync_dirty_inodes(struct f2fs_sb_info *sbi, enum 
inode_type type)
if (inode) {
unsigned long cur_ino = inode->i_ino;
 
+   if (is_dir)
+   F2FS_I(inode)->cp_task = current;
+
filemap_fdatawrite(inode->i_mapping);
+
+   if (is_dir)
+   F2FS_I(inode)->cp_task = NULL;
+
iput(inode);
/* We need to give cpu to another writers. */
if (ino == cur_ino) {
@@ -1017,7 +1031,7 @@ static int block_operations(struct f2fs_sb_info *sbi)
 
if (get_pages(sbi, F2FS_DIRTY_NODES)) {
up_write(&sbi->node_write);
-   err = sync_node_pages(sbi, &wbc, false);
+   err = sync_node_pages(sbi, &wbc, false, FS_CP_NODE_IO);
if (err) {
up_write(&sbi->node_change);
f2fs_unlock_all(sbi);
@@ -1115,7 +1129,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct 
cp_control *cpc)
 
/* Flush all the NAT/SIT pages */
while (get_pages(sbi, F2FS_DIRTY_META)) {
-   sync_meta_pages(sbi, META, LONG_MAX);
+   sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
if (unlikely(f2fs_cp_error(sbi)))
return -EIO;
}
@@ -1194,7 +1208,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct 
cp_control *cpc)
 
/* Flush all the NAT BITS pages */

[PATCH BUGFIX] block, bfq: consider also in_service_entity to state whether an entity is active

2017-07-29 Thread Paolo Valente
Groups of BFQ queues are represented by generic entities in BFQ. When
a queue belonging to a parent entity is deactivated, the parent entity
may need to be deactivated too, in case the deactivated queue was the
only active queue for the parent entity. This deactivation may need to
be propagated upwards if the entity belongs, in its turn, to a further
higher-level entity, and so on. In particular, the upward propagation
of deactivation stops at the first parent entity that remains active
even if one of its child entities has been deactivated.

To decide whether the last non-deactivation condition holds for a
parent entity, BFQ checks whether the field next_in_service is still
not NULL for the parent entity, after the deactivation of one of its
child entity. If it is not NULL, then there are certainly other active
entities in the parent entity, and deactivations can stop.

Unfortunately, this check misses a corner case: if in_service_entity
is not NULL, then next_in_service may happen to be NULL, although the
parent entity is evidently active. This happens if: 1) the entity
pointed by in_service_entity is the only active entity in the parent
entity, and 2) according to the definition of next_in_service, the
in_service_entity cannot be considered as next_in_service. See the
comments on the definition of next_in_service for details on this
second point.

Hitting the above corner case causes crashes.

To address this issue, this commit:
1) Extends the above check on only next_in_service to controlling both
next_in_service and in_service_entity (if any of them is not NULL,
then no further deactivation is performed)
2) Improves the (important) comments on how next_in_service is defined
and updated; in particular it fixes a few rather obscure paragraphs

Reported-by: Eric Wheeler 
Reported-by: Rick Yiu 
Reported-by: Tom X Nguyen 
Signed-off-by: Paolo Valente 
Tested-by: Eric Wheeler 
Tested-by: Rick Yiu 
Tested-by: Laurentiu Nicola 
Tested-by: Tom X Nguyen 
---
 block/bfq-iosched.h |  22 ++--
 block/bfq-wf2q.c| 142 +---
 2 files changed, 95 insertions(+), 69 deletions(-)

diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
index 63e771a..859f0a8 100644
--- a/block/bfq-iosched.h
+++ b/block/bfq-iosched.h
@@ -71,17 +71,29 @@ struct bfq_service_tree {
  *
  * bfq_sched_data is the basic scheduler queue.  It supports three
  * ioprio_classes, and can be used either as a toplevel queue or as an
- * intermediate queue on a hierarchical setup.  @next_in_service
- * points to the active entity of the sched_data service trees that
- * will be scheduled next. It is used to reduce the number of steps
- * needed for each hierarchical-schedule update.
+ * intermediate queue in a hierarchical setup.
  *
  * The supported ioprio_classes are the same as in CFQ, in descending
  * priority order, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE.
  * Requests from higher priority queues are served before all the
  * requests from lower priority queues; among requests of the same
  * queue requests are served according to B-WF2Q+.
- * All the fields are protected by the queue lock of the containing bfqd.
+ *
+ * The schedule is implemented by the service trees, plus the field
+ * @next_in_service, which points to the entity on the active trees
+ * that will be served next, if 1) no changes in the schedule occurs
+ * before the current in-service entity is expired, 2) the in-service
+ * queue becomes idle when it expires, and 3) if the entity pointed by
+ * in_service_entity is not a queue, then the in-service child entity
+ * of the entity pointed by in_service_entity becomes idle on
+ * expiration. This peculiar definition allows for the following
+ * optimization, not yet exploited: while a given entity is still in
+ * service, we already know which is the best candidate for next
+ * service among the other active entitities in the same parent
+ * entity. We can then quickly compare the timestamps of the
+ * in-service entity with those of such best candidate.
+ *
+ * All fields are protected by the lock of the containing bfqd.
  */
 struct bfq_sched_data {
/* entity in service */
diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c
index 881bbe5..911aa74 100644
--- a/block/bfq-wf2q.c
+++ b/block/bfq-wf2q.c
@@ -188,21 +188,23 @@ static bool bfq_update_parent_budget(struct bfq_entity 
*next_in_service)
 
 /*
  * This function tells whether entity stops being a candidate for next
- * service, according to the following logic.
+ * service, according to the restrictive definition of the field
+ * next_in_service. In particular, this function is invoked for an
+ * entity that is about to be set in service.
  *
- * This function is invoked for an entity that is about to be set in
- * service. If such an entity is a queue, then the entity is no longer
- * a candidate for next service (i.e, a candidate entity to serve
- * after the in-service entity is expired). The function

[PATCH 0/6] net: moxa: Fix style issues

2017-07-29 Thread SZ Lin
This patch set fixs the WARNINGs found by the checkpatch.pl tool

SZ Lin (6):
  net: moxa: Remove braces from single-line body
  net: moxa: Prefer 'unsigned int' to bare use of 'unsigned'
  net: moxa: Fix comparison to NULL could be written with !
  net: moxa: Remove extra space after a cast
  net: moxa: Fix for typo in comment to function
moxart_mac_setup_desc_ring()
  net: moxa: Add spaces preferred around that '{+,-}'

 drivers/net/ethernet/moxa/moxart_ether.c | 15 +++
 drivers/net/ethernet/moxa/moxart_ether.h |  8 
 2 files changed, 11 insertions(+), 12 deletions(-)

-- 
2.13.3



[PATCH 2/6] net: moxa: Prefer 'unsigned int' to bare use of 'unsigned'

2017-07-29 Thread SZ Lin
Use 'unsigned int' instead of 'unsigned'
This warning is found using checkpatch.pl

Signed-off-by: SZ Lin 
---
 drivers/net/ethernet/moxa/moxart_ether.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 105215862949..9997e72103d5 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -288,8 +288,8 @@ static int moxart_tx_queue_space(struct net_device *ndev)
 static void moxart_tx_finished(struct net_device *ndev)
 {
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
-   unsigned tx_head = priv->tx_head;
-   unsigned tx_tail = priv->tx_tail;
+   unsigned int tx_head = priv->tx_head;
+   unsigned int tx_tail = priv->tx_tail;
 
while (tx_tail != tx_head) {
dma_unmap_single(&ndev->dev, priv->tx_mapping[tx_tail],
-- 
2.13.3



[PATCH 3/6] net: moxa: Fix comparison to NULL could be written with !

2017-07-29 Thread SZ Lin
Fixed coding style for null comparisons in moxart_ether driver
to be more consistent with the rest of the kernel coding style

Signed-off-by: SZ Lin 
---
 drivers/net/ethernet/moxa/moxart_ether.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 9997e72103d5..1d6384873393 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -494,7 +494,7 @@ static int moxart_mac_probe(struct platform_device *pdev)
priv->tx_desc_base = dma_alloc_coherent(NULL, TX_REG_DESC_SIZE *
TX_DESC_NUM, &priv->tx_base,
GFP_DMA | GFP_KERNEL);
-   if (priv->tx_desc_base == NULL) {
+   if (!priv->tx_desc_base) {
ret = -ENOMEM;
goto init_fail;
}
@@ -502,7 +502,7 @@ static int moxart_mac_probe(struct platform_device *pdev)
priv->rx_desc_base = dma_alloc_coherent(NULL, RX_REG_DESC_SIZE *
RX_DESC_NUM, &priv->rx_base,
GFP_DMA | GFP_KERNEL);
-   if (priv->rx_desc_base == NULL) {
+   if (!priv->rx_desc_base) {
ret = -ENOMEM;
goto init_fail;
}
-- 
2.13.3



[PATCH 1/6] net: moxa: Remove braces from single-line body

2017-07-29 Thread SZ Lin
Remove unnecessary braces from single-line if statement
This warning is found using checkpatch.pl

Signed-off-by: SZ Lin 
---
 drivers/net/ethernet/moxa/moxart_ether.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index c0d7d5eec7e7..105215862949 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -269,9 +269,8 @@ static int moxart_rx_poll(struct napi_struct *napi, int 
budget)
priv->rx_head = rx_head;
}
 
-   if (rx < budget) {
+   if (rx < budget)
napi_complete_done(napi, rx);
-   }
 
priv->reg_imr |= RPKT_FINISH_M;
writel(priv->reg_imr, priv->base + REG_INTERRUPT_MASK);
-- 
2.13.3



[PATCH 4/6] net: moxa: Remove extra space after a cast

2017-07-29 Thread SZ Lin
No space is necessary after a cast
This warning is found using checkpatch.pl

Signed-off-by: SZ Lin 
---
 drivers/net/ethernet/moxa/moxart_ether.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 1d6384873393..31e179a651ae 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -311,7 +311,7 @@ static void moxart_tx_finished(struct net_device *ndev)
 
 static irqreturn_t moxart_mac_interrupt(int irq, void *dev_id)
 {
-   struct net_device *ndev = (struct net_device *) dev_id;
+   struct net_device *ndev = (struct net_device *)dev_id;
struct moxart_mac_priv_t *priv = netdev_priv(ndev);
unsigned int ists = readl(priv->base + REG_INTERRUPT_STATUS);
 
-- 
2.13.3



[PATCH 6/6] net: moxa: Add spaces preferred around that '{+,-}'

2017-07-29 Thread SZ Lin
This patch fixes all checkpatch occurences of
"CHECK: spaces preferred around that '{+,-}' (ctx:VxV)"
in moxart_ether code.

Signed-off-by: SZ Lin 
---
 drivers/net/ethernet/moxa/moxart_ether.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.h 
b/drivers/net/ethernet/moxa/moxart_ether.h
index 686b8957d5cf..bee608b547d1 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.h
+++ b/drivers/net/ethernet/moxa/moxart_ether.h
@@ -55,17 +55,17 @@
 #define RX_DESC2_ADDRESS_VIRT  4
 
 #define TX_DESC_NUM64
-#define TX_DESC_NUM_MASK   (TX_DESC_NUM-1)
+#define TX_DESC_NUM_MASK   (TX_DESC_NUM - 1)
 #define TX_NEXT(N) (((N) + 1) & (TX_DESC_NUM_MASK))
 #define TX_BUF_SIZE1600
-#define TX_BUF_SIZE_MAX(TX_DESC1_BUF_SIZE_MASK+1)
+#define TX_BUF_SIZE_MAX(TX_DESC1_BUF_SIZE_MASK + 1)
 #define TX_WAKE_THRESHOLD  16
 
 #define RX_DESC_NUM64
-#define RX_DESC_NUM_MASK   (RX_DESC_NUM-1)
+#define RX_DESC_NUM_MASK   (RX_DESC_NUM - 1)
 #define RX_NEXT(N) (((N) + 1) & (RX_DESC_NUM_MASK))
 #define RX_BUF_SIZE1600
-#define RX_BUF_SIZE_MAX(RX_DESC1_BUF_SIZE_MASK+1)
+#define RX_BUF_SIZE_MAX(RX_DESC1_BUF_SIZE_MASK + 1)
 
 #define REG_INTERRUPT_STATUS   0
 #define REG_INTERRUPT_MASK 4
-- 
2.13.3



[PATCH 5/6] net: moxa: Fix for typo in comment to function moxart_mac_setup_desc_ring()

2017-07-29 Thread SZ Lin
Signed-off-by: SZ Lin 
---
 drivers/net/ethernet/moxa/moxart_ether.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c 
b/drivers/net/ethernet/moxa/moxart_ether.c
index 31e179a651ae..2e4effa9fe45 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -161,7 +161,7 @@ static void moxart_mac_setup_desc_ring(struct net_device 
*ndev)
 
priv->rx_head = 0;
 
-   /* reset the MAC controller TX/RX desciptor base address */
+   /* reset the MAC controller TX/RX descriptor base address */
writel(priv->tx_base, priv->base + REG_TXR_BASE_ADDRESS);
writel(priv->rx_base, priv->base + REG_RXR_BASE_ADDRESS);
 }
-- 
2.13.3



Re: [RFC PATCH v2] membarrier: expedited private command

2017-07-29 Thread Peter Zijlstra
On Sat, Jul 29, 2017 at 07:48:56PM +1000, Nicholas Piggin wrote:
> On Sat, 29 Jul 2017 19:45:43 +1000
> Nicholas Piggin  wrote:
> 
> > hmm, we might be able to restrict iteration
> > to mm_cpumask(current->mm), no? 
> 
> Oh that's been discussed too. I'll read back over it too.

Right, the main problem is that some architectures (arm64 for instance,
although Will is looking at it) don't use mm_cpumask() at all.

Other architectures (PPC for instance) only ever set bits.



Re: strace-4.18 test suite oopses sparc64 4.12 and 4.13-rc kernels

2017-07-29 Thread Anatoly Pugachev
On Fri, Jul 28, 2017 at 11:45 AM, Mikael Pettersson
 wrote:
> It's an rpmbuild --rebuild of Fedora's strace-4.18-1.fc24.src.rpm, but 
> according to the
> build log the following should do it:
>
> export CFLAGS='-O2 -g -pipe -Wall -Werror=format-security 
> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
> --param=ssp-buffer-size=4 -grecord-gcc-switches  -m32 -mcpu=ultrasparc'
> ./configure --build=sparcv9-unknown-linux-gnu 
> --host=sparcv9-unknown-linux-gnu --program-prefix= 
> --disable-dependency-tracking --prefix=/usr --exec-prefix=/u
> sr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc 
> --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib 
> --libexecdir=/usr/libexec --local
> statedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man 
> --infodir=/usr/share/info
> make -j2
> make -j2 -k check VERBOSE=1

cant' reproduce it here on debian sparc64 LDOM:

used git version of strace ( https://github.com/strace/strace )

strace$ make -j24 check VERBOSE=1
...

Testsuite summary for strace 4.18.0.134.805d

# TOTAL: 443
# PASS:  389
# SKIP:  40
# XFAIL: 0
# FAIL:  14
# XPASS: 0
# ERROR: 0


while in kernel logs (journalctl -k -f):

Jul 29 12:49:22 ttip kernel: mmap: remap_file_page (77341) uses
deprecated remap_file_pages() syscall. See
Documentation/vm/remap_file_pages.txt.
Jul 29 12:49:22 ttip kernel: capability: warning: `caps' uses
deprecated v2 capabilities in a way that may be insecure
Jul 29 12:49:22 ttip kernel: capability: warning: `caps' uses 32-bit
capabilities (legacy support in use)
Jul 29 12:49:22 ttip kernel: [ cut here ]
Jul 29 12:49:22 ttip kernel: WARNING: CPU: 18 PID: 78388 at
arch/sparc/kernel/sys_sparc32.c:150
compat_SyS_sparc_sigaction+0x3c/0x60
Jul 29 12:49:22 ttip kernel: Modules linked in: tcp_diag inet_diag
xfrm_user xfrm_algo nfnetlink netlink_diag xt_tcpudp xt_multiport
xt_conntrack tun iptable_filter iptable_nat nf_conntrack_ipv4
nf_defrag_ipv4 nf_nat_ipv4 xfs camellia_sparc64 des_sparc64
des_generic aes_sparc64 n2_rng md5_sparc64 rng_core flash
sha512_sparc64 sha256_sparc64 sha1_sparc64 nf_nat_pptp
nf_nat_proto_gre nf_conntrack_pptp nf_conntrack_proto_gre nf_nat
nf_conntrack libcrc32c crc32c_generic ip_tables x_tables autofs4 ext4
crc16 mbcache jbd2 crc32c_sparc64
Jul 29 12:49:22 ttip kernel: CPU: 18 PID: 78388 Comm: sigaction Not
tainted 4.13.0-rc2-00220-g0a07b238e5f4 #376
Jul 29 12:49:22 ttip kernel: Call Trace:
Jul 29 12:49:22 ttip kernel:  [0046c074] __warn+0xb4/0xe0
Jul 29 12:49:22 ttip kernel:  [0046c120] warn_slowpath_null+0x20/0x40
Jul 29 12:49:22 ttip kernel:  [0044b7bc]
compat_SyS_sparc_sigaction+0x3c/0x60
Jul 29 12:49:22 ttip kernel:  [004061d4] linux_sparc_syscall32+0x34/0x60
Jul 29 12:49:22 ttip kernel: ---[ end trace 1ad5184278304e6d ]---
Jul 29 12:49:25 ttip kernel: pc[83378]: segfault at 7974 ip
7974 (rpc 796c) sp ffdd9438 error
30001 in pc[7001+2000]


Re: [PATCH 1/1][staging-next] staging: pi433: Make functions rf69_set_dc_cut_off_frequency_intern static

2017-07-29 Thread Dan Carpenter
On Sat, Jul 29, 2017 at 11:09:23AM +0200, Marcus Wolf wrote:
> Hi Greg,
>  
> also had a very close look to this patch. Even in your reply I can't find any
> problems with line wraps or other corruptions :-/
> 

Here are the relevant lines from Greg's email:

> +++ b/drivers/staging/pi433/rf69.c
> @@ -221,7 +221,7 @@ int rf69_set_frequency(struct spi_device *spi, u32
> frequency)

The "frequency)" bit is supposed to be on the line before.

regards,
dan carpenter


Re: [PATCH 2/2] mfd: ds1374: Add Dallas/Maxim DS1374 Multi Function Device

2017-07-29 Thread Alexandre Belloni
On 17/07/2017 at 08:51:17 +0100, Lee Jones wrote:
> > +static int ds1374_probe(struct i2c_client *client,
> > +   const struct i2c_device_id *id)
> > +{
> > +   struct ds1374 *ds1374;
> > +   u32 mode;
> > +   int err;
> > +
> > +   ds1374 = devm_kzalloc(&client->dev, sizeof(struct ds1374), GFP_KERNEL);
> > +   if (!ds1374)
> > +   return -ENOMEM;
> > +
> > +   ds1374->regmap = devm_regmap_init_i2c(client, &ds1374_regmap_config);
> > +   if (IS_ERR(ds1374->regmap))
> > +   return PTR_ERR(ds1374->regmap);
> > +
> > +   if (IS_ENABLED(CONFIG_OF) && client->dev.of_node) {
> > +   err = of_property_read_u32(client->dev.of_node,
> > +  "dallas,mode", &mode);
> > +   if (err < 0) {
> > +   dev_err(&client->dev, "missing dallas,mode property\n");
> > +   return -EINVAL;
> > +   }
> > +
> > +   ds1374->remapped_reset
> > +   = of_property_read_bool(client->dev.of_node,
> > +   "dallas,remap-reset");
> > +
> > +   ds1374->mode = (enum ds1374_mode)mode;
> > +   } else if (IS_ENABLED(CONFIG_RTC_DRV_DS1374_WDT)) {
> > +   ds1374->mode = DS1374_MODE_RTC_WDT;
> > +   } else {
> > +   ds1374->mode = DS1374_MODE_RTC_ALM;
> > +   }
> 
> This is non-standard.  So if OF is enabled, you're taking the 'mode'
> from platform data (DT) and if it's not, you're relying on Kconfig.
> May I suggest that you pick platform data OR Kconfig, but not mix the
> two.
> 

I've explicitly asked for that. CONFIG_RTC_DRV_DS1374_WDT has been in
the kernel since 2014. Requiring the use of dallas,mode now would break
the functionality for people not updating their DT.

However, my suggestion was that if OF is enabled and dallas,mode is not
present, then rely on CONFIG_RTC_DRV_DS1374_WDT to set the mode.

I personally don't care too much about breaking the DT ABI but this one
can be a bit tricky to discover and I still think it can be avoided.
At least, we should silently ignore CONFIG_RTC_DRV_DS1374_WDT.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


Re: [PATCH -tip v7 1/2] irq: Make irqentry text section unconditional

2017-07-29 Thread kbuild test robot
Hi Masami,

[auto build test ERROR on tip/x86/core]
[also build test ERROR on v4.13-rc2 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Masami-Hiramatsu/irq-Make-irqentry-text-section-unconditional/20170729-170710
config: h8300-h8300h-sim_defconfig (attached as .config)
compiler: h8300-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=h8300 

All errors (new ones prefixed by >>):

   In file included from arch/h8300/kernel/process.c:45:0:
>> arch/h8300/include/asm/traps.h:36:21: error: conflicting types for '_etext'
extern char _start, _etext;
^~
   In file included from ./arch/h8300/include/generated/asm/sections.h:1:0,
from include/linux/interrupt.h:21,
from arch/h8300/kernel/process.c:38:
   include/asm-generic/sections.h:33:32: note: previous declaration of '_etext' 
was here
extern char _text[], _stext[], _etext[];
   ^~

vim +/_etext +36 arch/h8300/include/asm/traps.h

d2a5f499 Yoshinori Sato 2015-05-11  35  
d2a5f499 Yoshinori Sato 2015-05-11 @36  extern char _start, _etext;
d2a5f499 Yoshinori Sato 2015-05-11  37  #define check_kernel_text(addr) \
d2a5f499 Yoshinori Sato 2015-05-11  38  ((addr >= (unsigned 
long)(&_start)) && \
bf24eec3 Yoshinori Sato 2016-01-15  39   (addr <  (unsigned 
long)(&_etext)) && !(addr & 1))
d2a5f499 Yoshinori Sato 2015-05-11  40  

:: The code at line 36 was first introduced by commit
:: d2a5f4999f6c211adf30d9788349e13988d6f2a7 h8300: Assembly headers

:: TO: Yoshinori Sato 
:: CC: Yoshinori Sato 

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


.config.gz
Description: application/gzip


Re: [PATCH -tip v7 1/2] irq: Make irqentry text section unconditional

2017-07-29 Thread kbuild test robot
Hi Masami,

[auto build test ERROR on tip/x86/core]
[also build test ERROR on v4.13-rc2 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Masami-Hiramatsu/irq-Make-irqentry-text-section-unconditional/20170729-170710
config: xtensa-common_defconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

All errors (new ones prefixed by >>):

>> arch/xtensa/kernel/setup.c:276:13: error: conflicting types for '_end'
extern char _end;
^
   In file included from ./arch/xtensa/include/generated/asm/sections.h:1:0,
from include/linux/interrupt.h:21,
from include/linux/pci.h:31,
from arch/xtensa/include/asm/platform.h:15,
from arch/xtensa/kernel/setup.c:43:
   include/asm-generic/sections.h:39:13: note: previous declaration of '_end' 
was here
extern char _end[];
^
>> arch/xtensa/kernel/setup.c:277:13: error: conflicting types for '_stext'
extern char _stext;
^
   In file included from ./arch/xtensa/include/generated/asm/sections.h:1:0,
from include/linux/interrupt.h:21,
from include/linux/pci.h:31,
from arch/xtensa/include/asm/platform.h:15,
from arch/xtensa/kernel/setup.c:43:
   include/asm-generic/sections.h:33:22: note: previous declaration of '_stext' 
was here
extern char _text[], _stext[], _etext[];
 ^

vim +/_stext +277 arch/xtensa/kernel/setup.c

5a0015d62 Chris Zankel  2005-06-23  271  
5a0015d62 Chris Zankel  2005-06-23  272  /*
5a0015d62 Chris Zankel  2005-06-23  273   * Initialize system. Setup memory and 
reserve regions.
5a0015d62 Chris Zankel  2005-06-23  274   */
5a0015d62 Chris Zankel  2005-06-23  275  
5a0015d62 Chris Zankel  2005-06-23 @276  extern char _end;
5a0015d62 Chris Zankel  2005-06-23 @277  extern char _stext;
5a0015d62 Chris Zankel  2005-06-23  278  extern char _WindowVectors_text_start;
5a0015d62 Chris Zankel  2005-06-23  279  extern char _WindowVectors_text_end;
5a0015d62 Chris Zankel  2005-06-23  280  extern char 
_DebugInterruptVector_literal_start;
5a0015d62 Chris Zankel  2005-06-23  281  extern char 
_DebugInterruptVector_text_end;
5a0015d62 Chris Zankel  2005-06-23  282  extern char 
_KernelExceptionVector_literal_start;
5a0015d62 Chris Zankel  2005-06-23  283  extern char 
_KernelExceptionVector_text_end;
5a0015d62 Chris Zankel  2005-06-23  284  extern char 
_UserExceptionVector_literal_start;
5a0015d62 Chris Zankel  2005-06-23  285  extern char 
_UserExceptionVector_text_end;
5a0015d62 Chris Zankel  2005-06-23  286  extern char 
_DoubleExceptionVector_literal_start;
5a0015d62 Chris Zankel  2005-06-23  287  extern char 
_DoubleExceptionVector_text_end;
2d1c645cc Marc Gauthier 2013-01-05  288  #if XCHAL_EXCM_LEVEL >= 2
2d1c645cc Marc Gauthier 2013-01-05  289  extern char 
_Level2InterruptVector_text_start;
2d1c645cc Marc Gauthier 2013-01-05  290  extern char 
_Level2InterruptVector_text_end;
2d1c645cc Marc Gauthier 2013-01-05  291  #endif
2d1c645cc Marc Gauthier 2013-01-05  292  #if XCHAL_EXCM_LEVEL >= 3
2d1c645cc Marc Gauthier 2013-01-05  293  extern char 
_Level3InterruptVector_text_start;
2d1c645cc Marc Gauthier 2013-01-05  294  extern char 
_Level3InterruptVector_text_end;
2d1c645cc Marc Gauthier 2013-01-05  295  #endif
2d1c645cc Marc Gauthier 2013-01-05  296  #if XCHAL_EXCM_LEVEL >= 4
2d1c645cc Marc Gauthier 2013-01-05  297  extern char 
_Level4InterruptVector_text_start;
2d1c645cc Marc Gauthier 2013-01-05  298  extern char 
_Level4InterruptVector_text_end;
2d1c645cc Marc Gauthier 2013-01-05  299  #endif
2d1c645cc Marc Gauthier 2013-01-05  300  #if XCHAL_EXCM_LEVEL >= 5
2d1c645cc Marc Gauthier 2013-01-05  301  extern char 
_Level5InterruptVector_text_start;
2d1c645cc Marc Gauthier 2013-01-05  302  extern char 
_Level5InterruptVector_text_end;
2d1c645cc Marc Gauthier 2013-01-05  303  #endif
2d1c645cc Marc Gauthier 2013-01-05  304  #if XCHAL_EXCM_LEVEL >= 6
2d1c645cc Marc Gauthier 2013-01-05  305  extern char 
_Level6InterruptVector_text_start;
2d1c645cc Marc Gauthier 2013-01-05  306  extern char 
_Level6InterruptVector_text_end;
2d1c645cc Marc Gauthier 2013-01-05  307  #endif
ab45fb145 Max Filippov  2015-10-16  308  #ifdef CONFIG_SMP
ab45fb145 Max Filippov  2015-10-16  309  extern char 
_SecondaryResetVector_text_start;
ab45fb145 Max Filippov  2015-10-16  310  extern char 
_SecondaryResetVector_text_end;
ab45fb145 Max Filippov  2015-10-16  311  #endif
5a0015d62 Chris Zankel  2005

[PATCH] rtc: ds1374: Fix decimal permission coding issue

2017-07-29 Thread SZ Lin
Fixed ERROR: Use 4 digit octal (0777) not decimal permissions to fulfill
the current coding-style

This error was detected by checkpatch.pl

Signed-off-by: SZ Lin 
---
 drivers/rtc/rtc-ds1374.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 38a2e9e684df..7d55ad297f36 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -378,7 +378,7 @@ static struct i2c_client *save_client;
 
 static int wdt_margin = WD_TIMO;
 static unsigned long wdt_is_open;
-module_param(wdt_margin, int, 0);
+module_param(wdt_margin, int, );
 MODULE_PARM_DESC(wdt_margin, "Watchdog timeout in seconds (default 32s)");
 
 static const struct watchdog_info ds1374_wdt_info = {
-- 
2.13.3



Re: strace-4.18 test suite oopses sparc64 4.12 and 4.13-rc kernels

2017-07-29 Thread Mikael Pettersson
Anatoly Pugachev writes:
 > On Fri, Jul 28, 2017 at 11:45 AM, Mikael Pettersson
 >  wrote:
 > > It's an rpmbuild --rebuild of Fedora's strace-4.18-1.fc24.src.rpm, but 
 > > according to the
 > > build log the following should do it:
 > >
 > > export CFLAGS='-O2 -g -pipe -Wall -Werror=format-security 
 > > -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
 > > --param=ssp-buffer-size=4 -grecord-gcc-switches  -m32 -mcpu=ultrasparc'
 > > ./configure --build=sparcv9-unknown-linux-gnu 
 > > --host=sparcv9-unknown-linux-gnu --program-prefix= 
 > > --disable-dependency-tracking --prefix=/usr --exec-prefix=/u
 > > sr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc 
 > > --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib 
 > > --libexecdir=/usr/libexec --local
 > > statedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man 
 > > --infodir=/usr/share/info
 > > make -j2
 > > make -j2 -k check VERBOSE=1
 > 
 > cant' reproduce it here on debian sparc64 LDOM:

DaveM was also unable to reproduce it.

I'll be investigating a possible kernel miscompile next.


 > 
 > used git version of strace ( https://github.com/strace/strace )
 > 
 > strace$ make -j24 check VERBOSE=1
 > ...
 > 
 > Testsuite summary for strace 4.18.0.134.805d
 > 
 > # TOTAL: 443
 > # PASS:  389
 > # SKIP:  40
 > # XFAIL: 0
 > # FAIL:  14
 > # XPASS: 0
 > # ERROR: 0
 > 
 > 
 > while in kernel logs (journalctl -k -f):
 > 
 > Jul 29 12:49:22 ttip kernel: mmap: remap_file_page (77341) uses
 > deprecated remap_file_pages() syscall. See
 > Documentation/vm/remap_file_pages.txt.
 > Jul 29 12:49:22 ttip kernel: capability: warning: `caps' uses
 > deprecated v2 capabilities in a way that may be insecure
 > Jul 29 12:49:22 ttip kernel: capability: warning: `caps' uses 32-bit
 > capabilities (legacy support in use)
 > Jul 29 12:49:22 ttip kernel: [ cut here ]
 > Jul 29 12:49:22 ttip kernel: WARNING: CPU: 18 PID: 78388 at
 > arch/sparc/kernel/sys_sparc32.c:150
 > compat_SyS_sparc_sigaction+0x3c/0x60
 > Jul 29 12:49:22 ttip kernel: Modules linked in: tcp_diag inet_diag
 > xfrm_user xfrm_algo nfnetlink netlink_diag xt_tcpudp xt_multiport
 > xt_conntrack tun iptable_filter iptable_nat nf_conntrack_ipv4
 > nf_defrag_ipv4 nf_nat_ipv4 xfs camellia_sparc64 des_sparc64
 > des_generic aes_sparc64 n2_rng md5_sparc64 rng_core flash
 > sha512_sparc64 sha256_sparc64 sha1_sparc64 nf_nat_pptp
 > nf_nat_proto_gre nf_conntrack_pptp nf_conntrack_proto_gre nf_nat
 > nf_conntrack libcrc32c crc32c_generic ip_tables x_tables autofs4 ext4
 > crc16 mbcache jbd2 crc32c_sparc64
 > Jul 29 12:49:22 ttip kernel: CPU: 18 PID: 78388 Comm: sigaction Not
 > tainted 4.13.0-rc2-00220-g0a07b238e5f4 #376
 > Jul 29 12:49:22 ttip kernel: Call Trace:
 > Jul 29 12:49:22 ttip kernel:  [0046c074] __warn+0xb4/0xe0
 > Jul 29 12:49:22 ttip kernel:  [0046c120] warn_slowpath_null+0x20/0x40
 > Jul 29 12:49:22 ttip kernel:  [0044b7bc]
 > compat_SyS_sparc_sigaction+0x3c/0x60
 > Jul 29 12:49:22 ttip kernel:  [004061d4] 
 > linux_sparc_syscall32+0x34/0x60
 > Jul 29 12:49:22 ttip kernel: ---[ end trace 1ad5184278304e6d ]---
 > Jul 29 12:49:25 ttip kernel: pc[83378]: segfault at 7974 ip
 > 7974 (rpc 796c) sp ffdd9438 error
 > 30001 in pc[7001+2000]

-- 


Re: [PATCHv2] i2c: add sc18is600 driver

2017-07-29 Thread Wolfram Sang
Hi,

thanks for V2.

On Sat, Jul 01, 2017 at 05:08:31PM +0200, Sebastian Reichel wrote:
> This adds an I²C master driver for SPI -> I²C bus bridge chips.
> It currently supports NXP's SC18IS600 and SC18IS601, as well as
> Silicon Labs' CP2120. The driver was only tested on SC18IS600.

I prefer 'I2C' to "I²C' to keep things simple, but I'll leave it to you.

> +++ b/Documentation/devicetree/bindings/i2c/i2c-cp2120.txt
> @@ -0,0 +1 @@
> +Please see binding for i2c-sc18is600

I still prefer this to be dropped. There is no i2c-cp2120 driver.

> + * Datasheets:
> + *  - http://www.nxp.com/documents/data_sheet/SC18IS600.pdf
> + *  - https://www.silabs.com/documents/public/data-sheets/CP2120.pdf

Nice pointers.

> +static int sc18is600_read_write(struct sc18is600dev *s600dev,

This function used to be named '*_read_after_write' which is correct.
'*_read_write' sounds like it does the opposite!

> +static int sc18is600_xfer(struct i2c_adapter *adapter,
> +   struct i2c_msg *msgs, int num)
> +{
> + struct sc18is600dev *s600dev = adapter->algo_data;
> + int read_operations = 0;
> + bool ignore_nak = false;
> + int i, err;
> +
> + for (i = 0; i < num; i++) {
> + if (msgs[i].len > s600dev->chip->buffer_size)
> + return -EOPNOTSUPP;
> +
> + /* chip only support standard read & write */
> + if (msgs[i].flags & ~I2C_M_RD)
> + return -EOPNOTSUPP;

This will bail out on I2C_M_IGNORE_NAK which you added support for.
Didn't you test that?

> +
> + if (msgs[i].flags & I2C_M_RD)
> + read_operations++;
> + }

I'd think the for loop can completely go by populating an i2c_quirks
structure. From what I see, you'd need I2C_AQ_COMB |
I2C_AQ_COMB_WRITE_FIRST with max_comb_1st_msg_len and
max_comb_2nd_msg_len properly set. But please double check.


> +
> + reinit_completion(&s600dev->completion);
> +
> + if (num == 1) {
> + if (msgs[0].flags & I2C_M_IGNORE_NAK)
> + ignore_nak = true;

Why do you ignore NAK only for 1 message?

> +
> + if (read_operations == 1)
> + err = sc18is600_read(s600dev, &msgs[0]);
> + else
> + err = sc18is600_write(s600dev, &msgs[0]);
> + } else if (num == 2) {
> + if (read_operations == 1)
> + err = sc18is600_read_write(s600dev, &msgs[0], &msgs[1]);
> + else
> + err = sc18is600_write_write(s600dev, &msgs[0], 
> &msgs[1]);
> + } else {
> + return -EOPNOTSUPP;
> + }

With i2c_quirks, the last else-block could also go.


> + if (!err) {
> + dev_warn(&s600dev->spi->dev,
> +  "timeout waiting for irq, poll status register");

Don't log on timeouts, it is not unusual to happen on the bus.

> + s600dev->state = SC18IS600_STAT_BUSY;
> + regmap_read(s600dev->regmap, SC18IS600_REG_I2C_STAT,
> + &s600dev->state);
> + }

...

> + s600dev->spi = spi;
> + s600dev->adapter.owner = THIS_MODULE;
> + s600dev->adapter.class = I2C_CLASS_DEPRECATED;

Huh? This is a new driver, why do you need it? Hmm, maybe I could
rephrase the docs a little.

...

> + err = clk_prepare_enable(s600dev->clk);

You never disable the clock anywhere.

Regards,

   Wolfram



signature.asc
Description: PGP signature


Yes you have standing to sue GRSecurity.

2017-07-29 Thread nisus
It has come to my attention that some entities are claiming that you, 
dear Linux Hackers, (1)need to go through some foundation or get some 
permission from upon high in-order to sue the progenitors of GRSecurity 
for their violation of section 6 of the terms underwhich the linux 
kernel is distributed (version 2 of the GPL). And, furthermore, that 
(2)this foundation has no intention of bringing such a suit.


(1) is false.
(2) may very well be true.

You do have standing to sue GRSecurity for their blatant continuing 
copyright violation if GRSecurity has made a derivative work of your 
code contribution to the Linux Kernel as-long as (a)you have not 
assigned your copyrights, and (b)you are not a work-for-hire.


How do you know if you are a work for hire or if you have signed away 
your copyrights?
If you are working for a company and as your job duties you are 
programming the linux kernel, there is a good chance that you are a work 
for hire and thus the company owns said copyrights.


How do you know if you signed away your copyrights? Well if you singed a 
document transferring ownership of your copyrights for the code you 
produced at some point.


If you are not working for a company while hacking linux and you haven't 
assigned your copyrights away then YOU OWN YOUR CONTRIBUTIONS.


This means most of you hobby hackers, if GRSecurity has modified your 
code, YES YOU HAVE STANDING TO SUE.


Yes your "betters" are lying to you.
You have individual separate standing to sue.

Yes you SHOULD consult a lawyer of your own.
Yes you SHOULD consider a joint filing with other individual 
rights-holders willing to bring suit against GRSecurity for their 
blatant violation of your terms, and yes you should consider starting 
CLASS ACTION since the number of Linux Kernel Contributors seemingly 
numbers in the multitudes upon multitudes upon multitudes.


And yes, I am an attorney.
But no, I'm not looking for clients. Just correcting some false 
information that has been spreading.


And yes, GRSecurity will try to claim that the linux-kernel is a work of 
Joint ownership (so as to shield themselves via procedural law) and yes 
they will try to claim fair use (probably de minimus), and yes your 
Lawyer will have to respond to these claims. The Joint ownership claim 
will go down quickly but it will have to be responded to. De minimus 
Fair Use depends on how much code is modified and how signifigant the 
modifications are. Don't anyone but your own legal council dissuade you 
from bringing suit: Remember the statute of limitations is only a few 
years, so the clock is ticking on the CURRENT violation.


Also make sure you register your copyright of the version of the 
linux-kernel that GRSecurity is using in its violation prior to bringing 
suit. The registration must be for the specific version. Yes you can 
register after the violation has occurred, however if you have 
registered before the violation then you can also pursue recovery of 
legal fees, pursue statutory damages, etc.



( NOTE: If you would like to read on how your copyright is being 
violated by GRSecurity, Bruce Perens posted a good write-up on his 
web-page )
( 
perens.com/blog/2017/06/28/warning-grsecurity-potential-contributory-infringement-risk-for-customers/ 
  )
( There was also a discussion on the linux section of slashdot, and on 
the debian user mailing list, and on the dng devuan mailing list and on 
the openwall mailing list and the fedora legal mailing list )




Re: [PATCH] tinydrm: repaper: add CONFIG_THERMAL dependency

2017-07-29 Thread Noralf Trønnes


Den 27.07.2017 11.58, skrev Arnd Bergmann:

The new RePaper driver uses the thermal subsystem, and fails to link
when it is built-in but thermal is a loadable module:

drivers/gpu/drm/tinydrm/repaper.o: In function `repaper_probe':
repaper.c:(.text+0x540): undefined reference to `thermal_zone_get_zone_by_name'
drivers/gpu/drm/tinydrm/repaper.o: In function `repaper_fb_dirty':
repaper.c:(.text+0xff4): undefined reference to `thermal_zone_get_temp'

This adds another Kconfig dependency to prevent the broken configuration,
forcing repaper to be a module too.

Fixes: 3589211e9b03 ("drm/tinydrm: Add RePaper e-ink driver")
Signed-off-by: Arnd Bergmann 
---


Thanks for fixing this, applied to drm-misc.

Noralf.


  drivers/gpu/drm/tinydrm/Kconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/tinydrm/Kconfig b/drivers/gpu/drm/tinydrm/Kconfig
index 9596e447f877..f17c3caceab2 100644
--- a/drivers/gpu/drm/tinydrm/Kconfig
+++ b/drivers/gpu/drm/tinydrm/Kconfig
@@ -23,6 +23,7 @@ config TINYDRM_MI0283QT
  config TINYDRM_REPAPER
tristate "DRM support for Pervasive Displays RePaper panels (V231)"
depends on DRM_TINYDRM && SPI
+   depends on THERMAL || !THERMAL
help
  DRM driver for the following Pervasive Displays panels:
  1.44" TFT EPD Panel (E1144CS021)




Re: [PATCH v12 5/8] virtio-balloon: VIRTIO_BALLOON_F_SG

2017-07-29 Thread Wei Wang

On 07/29/2017 07:08 AM, Michael S. Tsirkin wrote:

On Thu, Jul 27, 2017 at 10:50:11AM +0800, Wei Wang wrote:

OK I thought this over. While we might need these new APIs in
the future, I think that at the moment, there's a way to implement
this feature that is significantly simpler. Just add each s/g
as a separate input buffer.

Should it be an output buffer?

Hypervisor overwrites these pages with zeroes. Therefore it is
writeable by device: DMA_FROM_DEVICE.

Why would the hypervisor need to zero the buffer?

The page is supplied to hypervisor and can lose the value that
is there.  That is the definition of writeable by device.


I think for the free pages, it should be clear that they will be added as
output buffer to the device, because (as we discussed) they are just hints,
and some of them may be used by the guest after the report_ API is invoked.
The device/hypervisor should not use or discard them.

For the balloon pages, I kind of agree with the existing implementation
(e.g. inside tell_host()), which uses virtqueue_add_outbuf (instead of 
_add_inbuf()).
I think inbuf should be a buffer which will be written by the device and 
read by the
driver. The cmd buffer put on the vq for the device to send commands can 
be an

inbuf, I think.





I think it may only
need to read out the info(base,size).

And then do what?



For the free pages, the info will be used to clear the corresponding "1" 
in the dirty bitmap.
For balloon pages, they will be made DONTNEED and given to other host 
processes to
use (the device won't write them, so no need to set "write" when 
virtqueue_map_desc() in

the device).





I think it should be like this:
the cmd hdr buffer: input, because the hypervisor would write it to
send a cmd to the guest
the payload buffer: output, for the hypervisor to read the info

These should be split.

We have:

1. request that hypervisor sends to guest, includes ID: input
2. synchronisation header with ID sent by guest: output
3. list of pages: input

2 and 3 must be on the same VQ. 1 can come on any VQ - reusing stats VQ
might make sense.


I would prefer to make the above item 1 come on the the free page vq,
because the existing stat_vq doesn't support the cmd hdr.
Now, I think it is also not necessary to move the existing stat_vq 
implementation to

a new implementation under the cmd hdr, because
that new support doesn't make a difference for stats, it will still use 
its stat_vq (the free

page vq will be used for reporting free pages only)

What do you think?


Best,
Wei


Re: [PATCH v3] vfio: platform: reset: Add Broadcom FlexRM reset module

2017-07-29 Thread Auger Eric
Hi Anup,
On 20/07/2017 13:17, Anup Patel wrote:
> This patch adds Broadcom FlexRM low-level reset for
> VFIO platform.
> 
> It will do the following:
> 1. Disable/Deactivate each FlexRM ring
> 2. Flush each FlexRM ring
> 
> The cleanup sequence for FlexRM rings is adapted from
> Broadcom FlexRM mailbox driver.
> 
> Signed-off-by: Anup Patel 
> Reviewed-by: Oza Oza 
> Reviewed-by: Scott Branden 
> ---
>  drivers/vfio/platform/reset/Kconfig|  9 +++
>  drivers/vfio/platform/reset/Makefile   |  1 +
>  .../vfio/platform/reset/vfio_platform_bcmflexrm.c  | 93 
> ++
>  3 files changed, 103 insertions(+)
>  create mode 100644 drivers/vfio/platform/reset/vfio_platform_bcmflexrm.c
> 
> diff --git a/drivers/vfio/platform/reset/Kconfig 
> b/drivers/vfio/platform/reset/Kconfig
> index 705..8d8d226 100644
> --- a/drivers/vfio/platform/reset/Kconfig
> +++ b/drivers/vfio/platform/reset/Kconfig
> @@ -13,3 +13,12 @@ config VFIO_PLATFORM_AMDXGBE_RESET
> Enables the VFIO platform driver to handle reset for AMD XGBE
>  
> If you don't know what to do here, say N.
> +
> +config VFIO_PLATFORM_BCMFLEXRM_RESET
> + tristate "VFIO support for Broadcom FlexRM reset"
> + depends on VFIO_PLATFORM
> + depends on ARCH_BCM_IPROC || COMPILE_TEST
depends on VFIO_PLATFORM && (ARCH_BCM_IPROC || COMPILE_TEST)?
> + help
> +   Enables the VFIO platform driver to handle reset for Broadcom FlexRM
> +
> +   If you don't know what to do here, say N.
> diff --git a/drivers/vfio/platform/reset/Makefile 
> b/drivers/vfio/platform/reset/Makefile
> index 93f4e23..8d9874b 100644
> --- a/drivers/vfio/platform/reset/Makefile
> +++ b/drivers/vfio/platform/reset/Makefile
> @@ -5,3 +5,4 @@ ccflags-y += -Idrivers/vfio/platform
>  
>  obj-$(CONFIG_VFIO_PLATFORM_CALXEDAXGMAC_RESET) += 
> vfio-platform-calxedaxgmac.o
>  obj-$(CONFIG_VFIO_PLATFORM_AMDXGBE_RESET) += vfio-platform-amdxgbe.o
> +obj-$(CONFIG_VFIO_PLATFORM_BCMFLEXRM_RESET) += vfio_platform_bcmflexrm.o
> diff --git a/drivers/vfio/platform/reset/vfio_platform_bcmflexrm.c 
> b/drivers/vfio/platform/reset/vfio_platform_bcmflexrm.c
> new file mode 100644
> index 000..a198196
> --- /dev/null
> +++ b/drivers/vfio/platform/reset/vfio_platform_bcmflexrm.c
> @@ -0,0 +1,93 @@
> +/*
> + * Copyright (C) 2017 Broadcom
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see .
> + */
> +
> +/*
> + * This driver provides reset support for Broadcom FlexRM ring manager
> + * to VFIO platform.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "vfio_platform_private.h"
> +
> +/* FlexRM configuration */
> +#define RING_REGS_SIZE   0x1
> +#define RING_VER_MAGIC   0x76303031
> +
> +/* Per-Ring register offsets */
> +#define RING_VER 0x000
> +#define RING_CONTROL 0x034
> +#define RING_FLUSH_DONE  0x038
> +
> +/* Register RING_CONTROL fields */
> +#define CONTROL_FLUSH_SHIFT  5
> +#define CONTROL_ACTIVE_SHIFT 4
not used
> +
> +/* Register RING_FLUSH_DONE fields */
> +#define FLUSH_DONE_MASK  0x1
> +
> +static void vfio_platform_bcmflexrm_shutdown(void __iomem *ring)
> +{
> + unsigned int timeout;
> +
> + /* Disable/inactivate ring */
> + writel_relaxed(0x0, ring + RING_CONTROL);
> +
> + /* Flush ring with timeout of 1s */
> + timeout = 1000;
> + writel_relaxed(BIT(CONTROL_FLUSH_SHIFT), ring + RING_CONTROL);
> + do {
> + if (readl_relaxed(ring + RING_FLUSH_DONE) & FLUSH_DONE_MASK)
> + break;
> + mdelay(1);
> + } while (timeout--);
> +
> + if (!timeout)
> + pr_warn("VFIO FlexRM shutdown timedout\n");
s/timedout/timeout

vfio_platform_bcmflexrm_shutdown may also return an error that would be
propagated to the called:
vfio_platform_release() would then emit a dev_warn + WARN_ON. your
choice - I know this is not done in amdxge reset function ;-) -.


Comparing to the drivers/mailbox/bcm-flexrm-mailbox.c flexrm_shutdown()
there is one section missing commented as "Abort all in-flight
requests". I understand there is no HW adherence of this section but I
just want to double check that after disabling 

Re: [PATCH] x86/boot: check overlap between kernel and EFI_BOOT_SERVICES_*

2017-07-29 Thread kbuild test robot
Hi Naoya,

[auto build test WARNING on efi/next]
[also build test WARNING on v4.13-rc2 next-20170728]
[cannot apply to tip/x86/core]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Naoya-Horiguchi/x86-boot-check-overlap-between-kernel-and-EFI_BOOT_SERVICES_/20170729-170209
base:   https://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git next
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)


Please review and possibly fold the followup patch.

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


[RFC PATCH] x86/boot: efi_kernel_boot_services_overlap can be static

2017-07-29 Thread kbuild test robot

Fixes: 7ebe6cf3a6da ("x86/boot: check overlap between kernel and 
EFI_BOOT_SERVICES_*")
Signed-off-by: Fengguang Wu 
---
 misc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index b23159f..981d5f3 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -172,7 +172,7 @@ void __puthex(unsigned long value)
 }
 
 #ifdef CONFIG_EFI
-bool __init
+static bool __init
 efi_kernel_boot_services_overlap(unsigned long start, unsigned long size)
 {
int i;


Yes you have standing to sue GRSecurity

2017-07-29 Thread nisus
It has come to my attention that some entities are claiming that you, 
dear Linux Hackers, (1)need to go through some foundation or get some 
permission from upon high in-order to sue the progenitors of GRSecurity 
for their violation of section 6 of the terms underwhich the linux 
kernel is distributed (version 2 of the GPL). And, furthermore, that 
(2)this foundation has no intention of bringing such a suit.


(1) is false.
(2) may very well be true.

You do have standing to sue GRSecurity for their blatant continuing 
copyright violation if GRSecurity has made a derivative work of your 
code contribution to the Linux Kernel as-long as (a)you have not 
assigned your copyrights, and (b)you are not a work-for-hire.


How do you know if you are a work for hire or if you have signed away 
your copyrights?
If you are working for a company and as your job duties you are 
programming the linux kernel, there is a good chance that you are a work 
for hire and thus the company owns said copyrights.


How do you know if you signed away your copyrights? Well if you singed a 
document transferring ownership of your copyrights for the code you 
produced at some point.


If you are not working for a company while hacking linux and you haven't 
assigned your copyrights away then YOU OWN YOUR CONTRIBUTIONS.


This means most of you hobby hackers, if GRSecurity has modified your 
code, YES YOU HAVE STANDING TO SUE.


Yes your "betters" are lying to you.
You have individual separate standing to sue.

Yes you SHOULD consult a lawyer of your own.
Yes you SHOULD consider a joint filing with other individual 
rights-holders willing to bring suit against GRSecurity for their 
blatant violation of your terms, and yes you should consider starting 
CLASS ACTION since the number of Linux Kernel Contributors seemingly 
numbers in the multitudes upon multitudes upon multitudes.


And yes, I am an attorney.
But no, I'm not looking for clients. Just correcting some false 
information that has been spreading.


And yes, GRSecurity will try to claim that the linux-kernel is a work of 
Joint ownership (so as to shield themselves via procedural law) and yes 
they will try to claim fair use (probably de minimus), and yes your 
Lawyer will have to respond to these claims. The Joint ownership claim 
will go down quickly but it will have to be responded to. De minimus 
Fair Use depends on how much code is modified and how signifigant the 
modifications are. Don't let anyone but your own legal council dissuade 
you from bringing suit: Remember the statute of limitations is only a 
few years, so the clock is ticking on the CURRENT violation.


Also make sure you register your copyright of the version of the 
linux-kernel that GRSecurity is using in its violation prior to bringing 
suit. The registration must be for the specific version. Yes you can 
register after the violation has occurred, however if you have 
registered before the violation then you can also pursue recovery of 
legal fees, pursue statutory damages, etc.



( NOTE: If you would like to read on how your copyright is being 
violated by GRSecurity, Bruce Perens posted a good write-up on his 
web-page )
( 
perens.com/blog/2017/06/28/warning-grsecurity-potential-contributory-infringement-risk-for-customers/ 
  )
( There was also a discussion on the linux section of slashdot, and on 
the debian user mailing list, and on the dng devuan mailing list and on 
the openwall mailing list and the fedora legal mailing list )




[PATCH] f2fs: provide f2fs_balance_fs to __write_data_page for dentry pages

2017-07-29 Thread Yunlong Song
f2fs_balance_fs of dentry pages is skipped in __write_data_page due to deadlock
of gc_mutex in write_checkpoint flow. This patch enables f2fs_balance_fs for
normal dentry page writeback to ensure there are always enough free segments.

Reported-by: Chao Yu 
Signed-off-by: Yunlong Song 
---
 fs/f2fs/checkpoint.c |  2 +-
 fs/f2fs/data.c   | 67 +---
 fs/f2fs/f2fs.h   |  1 +
 3 files changed, 61 insertions(+), 9 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 3c84a25..2882878 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -904,7 +904,7 @@ int sync_dirty_inodes(struct f2fs_sb_info *sbi, enum 
inode_type type)
if (inode) {
unsigned long cur_ino = inode->i_ino;
 
-   filemap_fdatawrite(inode->i_mapping);
+   f2fs_filemap_fdatawrite(inode->i_mapping, is_dir);
iput(inode);
/* We need to give cpu to another writers. */
if (ino == cur_ino) {
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index aefc2a5..ed7efa5 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1475,7 +1475,7 @@ int do_write_data_page(struct f2fs_io_info *fio)
 }
 
 static int __write_data_page(struct page *page, bool *submitted,
-   struct writeback_control *wbc)
+   struct writeback_control *wbc, bool do_balance)
 {
struct inode *inode = page->mapping->host;
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
@@ -1578,7 +1578,7 @@ static int __write_data_page(struct page *page, bool 
*submitted,
}
 
unlock_page(page);
-   if (!S_ISDIR(inode->i_mode))
+   if (do_balance)
f2fs_balance_fs(sbi, need_balance_fs);
 
if (unlikely(f2fs_cp_error(sbi))) {
@@ -1602,7 +1602,7 @@ static int __write_data_page(struct page *page, bool 
*submitted,
 static int f2fs_write_data_page(struct page *page,
struct writeback_control *wbc)
 {
-   return __write_data_page(page, NULL, wbc);
+   return __write_data_page(page, NULL, wbc, true);
 }
 
 /*
@@ -1611,7 +1611,7 @@ static int f2fs_write_data_page(struct page *page,
  * warm/hot data page.
  */
 static int f2fs_write_cache_pages(struct address_space *mapping,
-   struct writeback_control *wbc)
+   struct writeback_control *wbc, bool 
do_balance)
 {
int ret = 0;
int done = 0;
@@ -1701,7 +1701,7 @@ static int f2fs_write_cache_pages(struct address_space 
*mapping,
if (!clear_page_dirty_for_io(page))
goto continue_unlock;
 
-   ret = __write_data_page(page, &submitted, wbc);
+   ret = __write_data_page(page, &submitted, wbc, 
do_balance);
if (unlikely(ret)) {
/*
 * keep nr_to_write, since vfs uses this to
@@ -1756,8 +1756,8 @@ static int f2fs_write_cache_pages(struct address_space 
*mapping,
return ret;
 }
 
-static int f2fs_write_data_pages(struct address_space *mapping,
-   struct writeback_control *wbc)
+static int _f2fs_write_data_pages(struct address_space *mapping,
+   struct writeback_control *wbc, bool do_balance)
 {
struct inode *inode = mapping->host;
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
@@ -1794,7 +1794,7 @@ static int f2fs_write_data_pages(struct address_space 
*mapping,
goto skip_write;
 
blk_start_plug(&plug);
-   ret = f2fs_write_cache_pages(mapping, wbc);
+   ret = f2fs_write_cache_pages(mapping, wbc, do_balance);
blk_finish_plug(&plug);
 
if (wbc->sync_mode == WB_SYNC_ALL)
@@ -1813,6 +1813,57 @@ static int f2fs_write_data_pages(struct address_space 
*mapping,
return 0;
 }
 
+static int f2fs_write_data_pages(struct address_space *mapping,
+   struct writeback_control *wbc)
+{
+   return  _f2fs_write_data_pages(mapping, wbc, true);
+}
+
+/*
+ * This function was copied from do_writepages from mm/page-writeback.c.
+ * The major change is changing writepages to _f2fs_write_data_pages.
+ */
+static int f2fs_do_writepages(struct address_space *mapping,
+   struct writeback_control *wbc, bool is_dir)
+{
+   int ret;
+
+   if (wbc->nr_to_write <= 0)
+   return 0;
+   while (1) {
+   ret = _f2fs_write_data_pages(mapping, wbc, !is_dir);
+   if ((ret != -ENOMEM) || (wbc->sync_mode != WB_SYNC_ALL))
+   break;
+   cond_resched();
+   congestion_wait(BLK_RW_ASYNC, HZ/50);
+   }
+   return ret;
+}
+
+/*
+ * This function was copied from __filemap_fdatawrite_range from
+ * mm/filemap.c. The major change is changing do_

Re: [PATCH v2] f2fs: provide f2fs_balance_fs to __write_node_page

2017-07-29 Thread Yunlong Song

Hi, Jay,
Not sure yet, whether it is just the case or not, at least we 
strengthen f2fs_balance_fs in some
corner cases. And maybe there are still some corner cases which we have 
not considered yet. See
my new patch "provide f2fs_balance_fs to __write_data_page for dentry 
pages", which is reported

by Chao. This is another corner case.

On 2017/7/29 0:20, Jaegeuk Kim wrote:

Hi Yunlong,

On 07/27, Yunlong Song wrote:

v1->v2, fix some dead lock problems under some heavy load test

So, does this patch resolve the previous GC problem?

Thanks,


On 2017/7/27 20:11, Yunlong Song wrote:

Let node writeback also do f2fs_balance_fs to ensure there are always enough 
free
segments.

Signed-off-by: Yunlong Song 
---
   fs/f2fs/checkpoint.c |  2 +-
   fs/f2fs/f2fs.h   |  2 +-
   fs/f2fs/node.c   | 14 --
   3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 5b876f6..3c84a25 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -1017,7 +1017,7 @@ static int block_operations(struct f2fs_sb_info *sbi)
if (get_pages(sbi, F2FS_DIRTY_NODES)) {
up_write(&sbi->node_write);
-   err = sync_node_pages(sbi, &wbc);
+   err = sync_node_pages(sbi, &wbc, false);
if (err) {
up_write(&sbi->node_change);
f2fs_unlock_all(sbi);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 94a88b2..f69051b 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -2293,7 +2293,7 @@ struct page *new_node_page(struct dnode_of_data *dn,
   void move_node_page(struct page *node_page, int gc_type);
   int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
struct writeback_control *wbc, bool atomic);
-int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc);
+int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc, 
bool need);
   void build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount);
   bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid);
   void alloc_nid_done(struct f2fs_sb_info *sbi, nid_t nid);
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index d53fe62..210ec25 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1326,7 +1326,7 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info 
*sbi, nid_t ino)
   }
   static int __write_node_page(struct page *page, bool atomic, bool *submitted,
-   struct writeback_control *wbc)
+   struct writeback_control *wbc, bool need)
   {
struct f2fs_sb_info *sbi = F2FS_P_SB(page);
nid_t nid;
@@ -1387,6 +1387,8 @@ static int __write_node_page(struct page *page, bool 
atomic, bool *submitted,
}
unlock_page(page);
+   if (need)
+   f2fs_balance_fs(sbi, false);
if (unlikely(f2fs_cp_error(sbi))) {
f2fs_submit_merged_write(sbi, NODE);
@@ -1405,7 +1407,7 @@ static int __write_node_page(struct page *page, bool 
atomic, bool *submitted,
   static int f2fs_write_node_page(struct page *page,
struct writeback_control *wbc)
   {
-   return __write_node_page(page, false, NULL, wbc);
+   return __write_node_page(page, false, NULL, wbc, false);
   }
   int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
@@ -1493,7 +1495,7 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct 
inode *inode,
ret = __write_node_page(page, atomic &&
page == last_page,
-   &submitted, wbc);
+   &submitted, wbc, true);
if (ret) {
unlock_page(page);
f2fs_put_page(last_page, 0);
@@ -1530,7 +1532,7 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct 
inode *inode,
return ret ? -EIO: 0;
   }
-int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc)
+int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc, 
bool need)
   {
pgoff_t index, end;
struct pagevec pvec;
@@ -1608,7 +1610,7 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct 
writeback_control *wbc)
set_fsync_mark(page, 0);
set_dentry_mark(page, 0);
-   ret = __write_node_page(page, false, &submitted, wbc);
+   ret = __write_node_page(page, false, &submitted, wbc, 
need);
if (ret)
unlock_page(page);
else if (submitted)
@@ -1697,7 +1699,7 @@ static int f2fs_write_node_pages(struct address_space 
*mapping,
diff = nr_pages_to_write(sbi, NODE, wbc);
wbc->sync_mode = WB_SYNC_NONE;
blk_start_plug(&plug);
-   sync_node_pa

Re: [PATCH v2] f2fs: provide f2fs_balance_fs to __write_node_page

2017-07-29 Thread Yunlong Song

Hi Chao,
Nice suggestion, I have sent out a new patch to implement it.

On 2017/7/29 8:19, Chao Yu wrote:

Hi Yunlong,

On 2017/7/27 20:13, Yunlong Song wrote:

v1->v2, fix some dead lock problems under some heavy load test

On 2017/7/27 20:11, Yunlong Song wrote:

Let node writeback also do f2fs_balance_fs to ensure there are always enough 
free
segments.

Could we cover __write_data_page of directory inode with this logic?

Thanks,


Signed-off-by: Yunlong Song 
---
   fs/f2fs/checkpoint.c |  2 +-
   fs/f2fs/f2fs.h   |  2 +-
   fs/f2fs/node.c   | 14 --
   3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 5b876f6..3c84a25 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -1017,7 +1017,7 @@ static int block_operations(struct f2fs_sb_info *sbi)
   
   	if (get_pages(sbi, F2FS_DIRTY_NODES)) {

up_write(&sbi->node_write);
-   err = sync_node_pages(sbi, &wbc);
+   err = sync_node_pages(sbi, &wbc, false);
if (err) {
up_write(&sbi->node_change);
f2fs_unlock_all(sbi);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 94a88b2..f69051b 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -2293,7 +2293,7 @@ struct page *new_node_page(struct dnode_of_data *dn,
   void move_node_page(struct page *node_page, int gc_type);
   int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
struct writeback_control *wbc, bool atomic);
-int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc);
+int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc, 
bool need);
   void build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount);
   bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid);
   void alloc_nid_done(struct f2fs_sb_info *sbi, nid_t nid);
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index d53fe62..210ec25 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1326,7 +1326,7 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info 
*sbi, nid_t ino)
   }
   
   static int __write_node_page(struct page *page, bool atomic, bool *submitted,

-   struct writeback_control *wbc)
+   struct writeback_control *wbc, bool need)
   {
struct f2fs_sb_info *sbi = F2FS_P_SB(page);
nid_t nid;
@@ -1387,6 +1387,8 @@ static int __write_node_page(struct page *page, bool 
atomic, bool *submitted,
}
   
   	unlock_page(page);

+   if (need)
+   f2fs_balance_fs(sbi, false);
   
   	if (unlikely(f2fs_cp_error(sbi))) {

f2fs_submit_merged_write(sbi, NODE);
@@ -1405,7 +1407,7 @@ static int __write_node_page(struct page *page, bool 
atomic, bool *submitted,
   static int f2fs_write_node_page(struct page *page,
struct writeback_control *wbc)
   {
-   return __write_node_page(page, false, NULL, wbc);
+   return __write_node_page(page, false, NULL, wbc, false);
   }
   
   int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,

@@ -1493,7 +1495,7 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct 
inode *inode,
   
   			ret = __write_node_page(page, atomic &&

page == last_page,
-   &submitted, wbc);
+   &submitted, wbc, true);
if (ret) {
unlock_page(page);
f2fs_put_page(last_page, 0);
@@ -1530,7 +1532,7 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct 
inode *inode,
return ret ? -EIO: 0;
   }
   
-int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc)

+int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc, 
bool need)
   {
pgoff_t index, end;
struct pagevec pvec;
@@ -1608,7 +1610,7 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct 
writeback_control *wbc)
set_fsync_mark(page, 0);
set_dentry_mark(page, 0);
   
-			ret = __write_node_page(page, false, &submitted, wbc);

+   ret = __write_node_page(page, false, &submitted, wbc, 
need);
if (ret)
unlock_page(page);
else if (submitted)
@@ -1697,7 +1699,7 @@ static int f2fs_write_node_pages(struct address_space 
*mapping,
diff = nr_pages_to_write(sbi, NODE, wbc);
wbc->sync_mode = WB_SYNC_NONE;
blk_start_plug(&plug);
-   sync_node_pages(sbi, wbc);
+   sync_node_pages(sbi, wbc, true);
blk_finish_plug(&plug);
wbc->nr_to_write = max((long)0, wbc->nr_to_write - diff);
return 0;


.



--
Thanks,
Yunlong Song




Re: [PATCH v5 1/2] platform: Add driver for RAVE Supervisory Processor

2017-07-29 Thread kbuild test robot
Hi Andrey,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.13-rc2 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Andrey-Smirnov/ZII-RAVE-platform-driver/20170729-210238
config: blackfin-allyesconfig (attached as .config)
compiler: bfin-uclinux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=blackfin 

All errors (new ones prefixed by >>):

   drivers/platform/rave/rave-sp.c: In function 'csum_ccitt':
   drivers/platform/rave/rave-sp.c:458:25: error: implicit declaration of 
function 'crc_ccitt_false' [-Werror=implicit-function-declaration]
 const u16 calculated = crc_ccitt_false(0x, buf, size);
^~~
   drivers/platform/rave/rave-sp.c: In function 'rave_sp_write':
>> drivers/platform/rave/rave-sp.c:495:11: error: 'ENOME' undeclared (first use 
>> in this function)
  return -ENOME;
  ^
   drivers/platform/rave/rave-sp.c:495:11: note: each undeclared identifier is 
reported only once for each function it appears in
   cc1: some warnings being treated as errors

vim +/ENOME +495 drivers/platform/rave/rave-sp.c

   455  
   456  static void csum_ccitt(const u8 *buf, size_t size, u8 *crc)
   457  {
 > 458  const u16 calculated = crc_ccitt_false(0x, buf, size);
   459  
   460  /*
   461   * While the rest of the wire protocol is little-endian,
   462   * CCITT-16 CRC in RDU2 device is sent out in big-endian order.
   463   */
   464  put_unaligned_be16(calculated, crc);
   465  }
   466  
   467  static void *stuff(unsigned char *dest, const unsigned char *src, 
size_t n)
   468  {
   469  while (n--) {
   470  const unsigned char byte = *src++;
   471  
   472  switch (byte) {
   473  case RAVE_SP_STX:
   474  case RAVE_SP_ETX:
   475  case RAVE_SP_DLE:
   476  *dest++ = RAVE_SP_DLE;
   477  /* FALLTHROUGH */
   478  default:
   479  *dest++ = byte;
   480  }
   481  }
   482  
   483  return dest;
   484  }
   485  
   486  static int rave_sp_write(struct rave_sp *sp, const u8 *data, u8 
data_size)
   487  {
   488  const size_t checksum_length = sp->variant->checksum->length;
   489  unsigned char frame[RAVE_SP_TX_BUFFER_SIZE];
   490  unsigned char crc[RAVE_SP_CHECKSUM_SIZE];
   491  unsigned char *dest = frame;
   492  size_t length;
   493  
   494  if (WARN_ON(checksum_length > sizeof(crc)))
 > 495  return -ENOME;
   496  
   497  if (WARN_ON(data_size > sizeof(frame)))
   498  return -ENOMEM;
   499  
   500  sp->variant->checksum->subroutine(data, data_size, crc);
   501  
   502  *dest++ = RAVE_SP_STX;
   503  dest = stuff(dest, data, data_size);
   504  dest = stuff(dest, crc, checksum_length);
   505  *dest++ = RAVE_SP_ETX;
   506  
   507  length = dest - frame;
   508  
   509  print_hex_dump(KERN_DEBUG, "rave-sp tx: ", DUMP_PREFIX_NONE,
   510 16, 1, frame, length, false);
   511  
   512  return serdev_device_write(sp->serdev, frame, length, HZ);
   513  }
   514  

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


.config.gz
Description: application/gzip


Re: [PATCH 3/3] mm/sched: memdelay: memory health interface for systems and workloads

2017-07-29 Thread kbuild test robot
Hi Johannes,

[auto build test ERROR on v4.12]
[cannot apply to linus/master linux/master v4.13-rc2 v4.13-rc1 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Johannes-Weiner/sched-loadavg-consolidate-LOAD_INT-LOAD_FRAC-macros/20170729-191658
config: arm-sunxi_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   In file included from include/linux/spinlock_types.h:13:0,
from include/linux/memdelay.h:4,
from kernel/sched/memdelay.c:10:
>> arch/arm/include/asm/spinlock_types.h:12:3: error: unknown type name 'u32'
  u32 slock;
  ^~~
>> arch/arm/include/asm/spinlock_types.h:18:4: error: unknown type name 'u16'
   u16 owner;
   ^~~
   arch/arm/include/asm/spinlock_types.h:19:4: error: unknown type name 'u16'
   u16 next;
   ^~~
   arch/arm/include/asm/spinlock_types.h:28:2: error: unknown type name 'u32'
 u32 lock;
 ^~~

vim +/u32 +12 arch/arm/include/asm/spinlock_types.h

546c2896 arch/arm/include/asm/spinlock_types.h Will Deacon 2012-07-06   9  
fb1c8f93 include/asm-arm/spinlock_types.h  Ingo Molnar 2005-09-10  10  
typedef struct {
546c2896 arch/arm/include/asm/spinlock_types.h Will Deacon 2012-07-06  11   
union {
546c2896 arch/arm/include/asm/spinlock_types.h Will Deacon 2012-07-06 @12   
u32 slock;
546c2896 arch/arm/include/asm/spinlock_types.h Will Deacon 2012-07-06  13   
struct __raw_tickets {
546c2896 arch/arm/include/asm/spinlock_types.h Will Deacon 2012-07-06  14  
#ifdef __ARMEB__
546c2896 arch/arm/include/asm/spinlock_types.h Will Deacon 2012-07-06  15   
u16 next;
546c2896 arch/arm/include/asm/spinlock_types.h Will Deacon 2012-07-06  16   
u16 owner;
546c2896 arch/arm/include/asm/spinlock_types.h Will Deacon 2012-07-06  17  
#else
546c2896 arch/arm/include/asm/spinlock_types.h Will Deacon 2012-07-06 @18   
u16 owner;
546c2896 arch/arm/include/asm/spinlock_types.h Will Deacon 2012-07-06  19   
u16 next;
546c2896 arch/arm/include/asm/spinlock_types.h Will Deacon 2012-07-06  20  
#endif
546c2896 arch/arm/include/asm/spinlock_types.h Will Deacon 2012-07-06  21   
} tickets;
546c2896 arch/arm/include/asm/spinlock_types.h Will Deacon 2012-07-06  22   
};
445c8951 arch/arm/include/asm/spinlock_types.h Thomas Gleixner 2009-12-02  23  
} arch_spinlock_t;
fb1c8f93 include/asm-arm/spinlock_types.h  Ingo Molnar 2005-09-10  24  

:: The code at line 12 was first introduced by commit
:: 546c2896a42202dbc7d02f7c6ec9948ac1bf511b ARM: 7446/1: spinlock: use 
ticket algorithm for ARMv6+ locking implementation

:: TO: Will Deacon 
:: CC: Russell King 

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


.config.gz
Description: application/gzip


Re: [PATCH 1/1] usb: xhci: Add debugfs interface for xHCI driver

2017-07-29 Thread Greg KH
On Sat, Jul 29, 2017 at 04:18:03PM +0800, Lu Baolu wrote:
> +static void xhci_debugfs_create_files(struct xhci_hcd *xhci,
> +   struct xhci_file_map *files,
> +   size_t nentries, void *data,
> +   struct dentry *parent,
> +   const struct file_operations *fops)
> +{
> + int i;
> + struct dentry   *file;
> +
> + for (i = 0; i < nentries; i++) {
> + file = debugfs_create_file(files[i].name, 0444,
> +parent, data, fops);
> + if (IS_ERR_OR_NULL(file))
> + break;

There's no need to ever check the return value of a debugfs_ function,
there's nothing you can do here, just keep calling it :)

And you will not get an error, you will only get NULL if there is an
error, as the only error you would get is if debugfs was not enabled.

> +static struct dentry *xhci_debugfs_create_ring_dir(struct xhci_hcd *xhci,
> +struct xhci_ring *ring,
> +const char *name,
> +struct dentry *parent)
> +{
> + struct dentry   *dir;
> +
> + dir = debugfs_create_dir(name, parent);
> + if (IS_ERR_OR_NULL(dir))
> + return NULL;

Same here.  Just keep going, you don't care about the return value, but
you can use it safely no matter what.


Same for other places in this patch as well.

thanks,

greg k-h


Re: [PATCH] Staging: pi433: fix some warnings detected using sparse

2017-07-29 Thread kbuild test robot
Hi Elia,

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on next-20170728]
[cannot apply to v4.13-rc2]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Elia-Geretto/Staging-pi433-fix-some-warnings-detected-using-sparse/20170729-205713
config: blackfin-allyesconfig (attached as .config)
compiler: bfin-uclinux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=blackfin 

All errors (new ones prefixed by >>):

   drivers/staging//pi433/pi433_if.c: In function 'rf69_set_rx_cfg':
>> drivers/staging//pi433/pi433_if.c:213:2: error: 'else' without a previous 
>> 'if'
 else
 ^~~~
   drivers/staging//pi433/pi433_if.c: In function 'rf69_set_tx_cfg':
   drivers/staging//pi433/pi433_if.c:272:2: error: 'else' without a previous 
'if'
 else
 ^~~~

vim +213 drivers/staging//pi433/pi433_if.c

   181  
   182  static int
   183  rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg)
   184  {
   185  int payload_length;
   186  
   187  /* receiver config */
   188  SET_CHECKED(rf69_set_frequency  (dev->spi, rx_cfg->frequency));
   189  SET_CHECKED(rf69_set_bit_rate   (dev->spi, rx_cfg->bit_rate));
   190  SET_CHECKED(rf69_set_modulation (dev->spi, rx_cfg->modulation));
   191  SET_CHECKED(rf69_set_antenna_impedance   (dev->spi, 
rx_cfg->antenna_impedance));
   192  SET_CHECKED(rf69_set_rssi_threshold  (dev->spi, 
rx_cfg->rssi_threshold));
   193  SET_CHECKED(rf69_set_ook_threshold_dec   (dev->spi, 
rx_cfg->thresholdDecrement));
   194  SET_CHECKED(rf69_set_bandwidth   (dev->spi, 
rx_cfg->bw_mantisse, rx_cfg->bw_exponent));
   195  SET_CHECKED(rf69_set_bandwidth_during_afc(dev->spi, 
rx_cfg->bw_mantisse, rx_cfg->bw_exponent));
   196  SET_CHECKED(rf69_set_dagc(dev->spi, 
rx_cfg->dagc));
   197  
   198  dev->rx_bytes_to_drop = rx_cfg->bytes_to_drop;
   199  
   200  /* packet config */
   201  /* enable */
   202  SET_CHECKED(rf69_set_sync_enable(dev->spi, 
rx_cfg->enable_sync));
   203  if (rx_cfg->enable_sync == optionOn)
   204  {
   205  SET_CHECKED(rf69_set_fifo_fill_condition(dev->spi, 
afterSyncInterrupt));
   206  }
   207  else
   208  {
   209  SET_CHECKED(rf69_set_fifo_fill_condition(dev->spi, 
always));
   210  }
   211  if (rx_cfg->enable_length_byte == optionOn)
   212  SET_CHECKED(rf69_set_packet_format(dev->spi, 
packetLengthVar));
 > 213  else
   214  SET_CHECKED(rf69_set_packet_format(dev->spi, 
packetLengthFix));
   215  SET_CHECKED(rf69_set_adressFiltering(dev->spi, 
rx_cfg->enable_address_filtering));
   216  SET_CHECKED(rf69_set_crc_enable (dev->spi, 
rx_cfg->enable_crc));
   217  
   218  /* lengths */
   219  SET_CHECKED(rf69_set_sync_size(dev->spi, rx_cfg->sync_length));
   220  if (rx_cfg->enable_length_byte == optionOn)
   221  {
   222  SET_CHECKED(rf69_set_payload_length(dev->spi, 0xff));
   223  }
   224  else if (rx_cfg->fixed_message_length != 0)
   225  {
   226  payload_length = rx_cfg->fixed_message_length;
   227  if (rx_cfg->enable_length_byte  == optionOn) 
payload_length++;
   228  if (rx_cfg->enable_address_filtering != filteringOff) 
payload_length++;
   229  SET_CHECKED(rf69_set_payload_length(dev->spi, 
payload_length));
   230  }
   231  else
   232  {
   233  SET_CHECKED(rf69_set_payload_length(dev->spi, 0));
   234  }
   235  
   236  /* values */
   237  if (rx_cfg->enable_sync == optionOn)
   238  {
   239  SET_CHECKED(rf69_set_sync_values(dev->spi, 
rx_cfg->sync_pattern));
   240  }
   241  if (rx_cfg->enable_address_filtering != filteringOff)
   242  {
   243  SET_CHECKED(rf69_set_node_address (dev->spi, 
rx_cfg->node_address));
   244  SET_CHECKED(rf69_set_broadcast_address(dev->spi, 
rx_cfg->broadcast_address));
   245  }
   246  
   247  return 0;
   248  }
   249  

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


.config.gz
Description: application/gzip


[PATCHv3] uapi libc compat: add fallback for unsupported libcs

2017-07-29 Thread Felix Janda
libc-compat.h aims to prevent symbol collisions between uapi and libc
headers for each supported libc. This requires continuous coordination
between them.

The goal of this commit is to improve the situation for libcs (such as
musl) which are not yet supported and/or do not wish to be explicitly
supported, while not affecting supported libcs. More precisely, with
this commit, unsupported libcs can request the suppression of any
specific uapi definition by defining the correspondings _UAPI_DEF_*
macro as 0. This can fix symbol collisions for them, as long as the
libc headers are included before the uapi headers. Inclusion in the
other order is outside the scope of this commit.

All infrastructure in order to enable this fallback for unsupported
libcs is already in place, except that libc-compat.h unconditionally
defines all _UAPI_DEF_* macros to 1 for all unsupported libcs so that
any previous definitions are ignored. In order to fix this, this commit
merely makes these definitions conditional.

This commit together with the musl libc commit

http://git.musl-libc.org/cgit/musl/commit/?id=04983f2272382af92eb8f8838964ff944fbb8258

fixes for example the following compiler errors when  is
included after musl's :

./linux/in6.h:32:8: error: redefinition of 'struct in6_addr'
./linux/in6.h:49:8: error: redefinition of 'struct sockaddr_in6'
./linux/in6.h:59:8: error: redefinition of 'struct ipv6_mreq'

Signed-off-by: Felix Janda 
---
v3: Fix typos, add a comment to the file and use #ifndef.
v2: The only change to the previous version is the commit title and
message.
---
 include/uapi/linux/libc-compat.h | 55 +++-
 1 file changed, 54 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index 44b8a6bd5fe1..65db6b26d790 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -167,46 +167,99 @@
 
 /* If we did not see any headers from any supported C libraries,
  * or we are being included in the kernel, then define everything
- * that we need. */
+ * that we need. Check for previous __UAPI_* definitions to give
+ * unsupported C libraries a way to opt out of any kernel definition. */
 #else /* !defined(__GLIBC__) */
 
 /* Definitions for if.h */
+#ifndef __UAPI_DEF_IF_IFCONF
 #define __UAPI_DEF_IF_IFCONF 1
+#endif
+#ifndef __UAPI_DEF_IF_IFMAP
 #define __UAPI_DEF_IF_IFMAP 1
+#endif
+#ifndef __UAPI_DEF_IF_IFNAMSIZ
 #define __UAPI_DEF_IF_IFNAMSIZ 1
+#endif
+#ifndef __UAPI_DEF_IF_IFREQ
 #define __UAPI_DEF_IF_IFREQ 1
+#endif
 /* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */
+#ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS
 #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1
+#endif
 /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
+#ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
 #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
+#endif
 
 /* Definitions for in.h */
+#ifndef __UAPI_DEF_IN_ADDR
 #define __UAPI_DEF_IN_ADDR 1
+#endif
+#ifndef __UAPI_DEF_IN_IPPROTO
 #define __UAPI_DEF_IN_IPPROTO  1
+#endif
+#ifndef __UAPI_DEF_IN_PKTINFO
 #define __UAPI_DEF_IN_PKTINFO  1
+#endif
+#ifndef __UAPI_DEF_IP_MREQ
 #define __UAPI_DEF_IP_MREQ 1
+#endif
+#ifndef __UAPI_DEF_SOCKADDR_IN
 #define __UAPI_DEF_SOCKADDR_IN 1
+#endif
+#ifndef __UAPI_DEF_IN_CLASS
 #define __UAPI_DEF_IN_CLASS1
+#endif
 
 /* Definitions for in6.h */
+#ifndef __UAPI_DEF_IN6_ADDR
 #define __UAPI_DEF_IN6_ADDR1
+#endif
+#ifndef __UAPI_DEF_IN6_ADDR_ALT
 #define __UAPI_DEF_IN6_ADDR_ALT1
+#endif
+#ifndef __UAPI_DEF_SOCKADDR_IN6
 #define __UAPI_DEF_SOCKADDR_IN61
+#endif
+#ifndef __UAPI_DEF_IPV6_MREQ
 #define __UAPI_DEF_IPV6_MREQ   1
+#endif
+#ifndef __UAPI_DEF_IPPROTO_V6
 #define __UAPI_DEF_IPPROTO_V6  1
+#endif
+#ifndef __UAPI_DEF_IPV6_OPTIONS
 #define __UAPI_DEF_IPV6_OPTIONS1
+#endif
+#ifndef __UAPI_DEF_IN6_PKTINFO
 #define __UAPI_DEF_IN6_PKTINFO 1
+#endif
+#ifndef __UAPI_DEF_IP6_MTUINFO
 #define __UAPI_DEF_IP6_MTUINFO 1
+#endif
 
 /* Definitions for ipx.h */
+#ifndef __UAPI_DEF_SOCKADDR_IPX
 #define __UAPI_DEF_SOCKADDR_IPX1
+#endif
+#ifndef __UAPI_DEF_IPX_ROUTE_DEFINITION
 #define __UAPI_DEF_IPX_ROUTE_DEFINITION1
+#endif
+#ifndef __UAPI_DEF_IPX_INTERFACE_DEFINITION
 #define __UAPI_DEF_IPX_INTERFACE_DEFINITION1
+#endif
+#ifndef __UAPI_DEF_IPX_CONFIG_DATA
 #define __UAPI_DEF_IPX_CONFIG_DATA 1
+#endif
+#ifndef __UAPI_DEF_IPX_ROUTE_DEF
 #define __UAPI_DEF_IPX_ROUTE_DEF   1
+#endif
 
 /* Definitions for xattr.h */
+#ifndef __UAPI_DEF_XATTR
 #define __UAPI_DEF_XATTR   1
+#endif
 
 #endif /* __GLIBC__ */
 
-- 
2.13.0



[PATCH v3 02/12] ASoC: sun4i-i2s: Add clkdiv offsets to quirks

2017-07-29 Thread codekipper
From: Marcus Cooper 

The BCLKDIV and MCLKDIV found on newer SoCs start from an offset of 1.
Add the functionality to adjust the division values according to the
needs to the device being used.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index d7ee7a443e4e..1d538de4e4d0 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -94,9 +94,13 @@
  * struct sun4i_i2s_quirks - Differences between SoC variants.
  *
  * @has_reset: SoC needs reset deasserted.
+ * @mclk_offset: Value by which mclkdiv needs to be adjusted.
+ * @bclk_offset: Value by which bclkdiv needs to be adjusted.
  */
 struct sun4i_i2s_quirks {
boolhas_reset;
+   unsigned intmclk_offset;
+   unsigned intbclk_offset;
 };
 
 struct sun4i_i2s {
@@ -149,7 +153,7 @@ static int sun4i_i2s_get_bclk_div(struct sun4i_i2s *i2s,
const struct sun4i_i2s_clk_div *bdiv = &sun4i_i2s_bclk_div[i];
 
if (bdiv->div == div)
-   return bdiv->val;
+   return bdiv->val + i2s->variant->bclk_offset;
}
 
return -EINVAL;
@@ -167,7 +171,7 @@ static int sun4i_i2s_get_mclk_div(struct sun4i_i2s *i2s,
const struct sun4i_i2s_clk_div *mdiv = &sun4i_i2s_mclk_div[i];
 
if (mdiv->div == div)
-   return mdiv->val;
+   return mdiv->val + i2s->variant->mclk_offset;
}
 
return -EINVAL;
-- 
2.13.3



[PATCH v3 00/12] ASoC: Add I2S support for Allwinner H3 SoCs

2017-07-29 Thread codekipper
From: Marcus Cooper 

Hi All,
please find attached a series of patches to bring i2s support to the
Allwinner H3 SoC. This has been tested with the following setups:

A20 Olimex EVB connected to a pcm5102
Orange Pi 2 connected to a uda1380
Orange Pi 2 hdmi audio playback
Pine 64 connected to the audio DAC board

To get i2s working some additional patches are required which will be
delivered later. For now they have been pushed here

https://github.com/codekipper/linux-sunxi/commits/sunxi-audio-h3

I don't own a A33 device which uses the i2s block for the audio codec
so if someone could test against that it would be much appreciated.

I'm also wondering if there is a preferred way of setting the lrclk
size in the dts?..currently it is set to the sample width but for example
the pcm5102a wants it to be 32 bits whatever the sample rate.

Thanks in advance,
CK

---

v3 changes compared to v2 are:
- initial changes to prepare driver for newer SoCs has been broken down
  into smaller patches
- reduce use of regmap fields to where just needed.
- clkdiv expansion will be delivered later.
- defines for H3 variant segregated.
- fixed regmap config issue with SUN8I_I2S_FIFO_TX_REG.


v2 changes compared to v1 are:
 - massive refactoring to remove duplicate code making use of regmap_fields.
 - extending the clock divisors.
 - removed code that should be delivered when we support 20/24bits

---

Marcus Cooper (12):
  ASoC: sun4i-i2s: Extend quirks scope
  ASoC: sun4i-i2s: Add clkdiv offsets to quirks
  ASoC: sun4i-i2s: Add regmap config to quirks
  ASoC: sun4i-i2s: Add TX FIFO offset to quirks
  ASoC: sun4i-i2s: Add regmap fields for channels
  ASoC: sun4i-i2s: Add changes for wss and sr
  ASoC: sun4i-i2s: bclk and lrclk polarity tidyup
  ASoC: sun4i-i2s: Add mclk enable regmap field
  ASoC: sun4i-i2s: Add regmap field to set format
  ASoC: sun4i-i2s: Check for slave select bit
  ASoC: sun4i-i2s: Update global enable with bitmask
  ASoC: sun4i-i2s: Add support for H3

 .../devicetree/bindings/sound/sun4i-i2s.txt|   2 +
 sound/soc/sunxi/sun4i-i2s.c| 460 ++---
 2 files changed, 398 insertions(+), 64 deletions(-)

-- 
2.13.3



[PATCH v3 09/12] ASoC: sun4i-i2s: Add regmap field to set format

2017-07-29 Thread codekipper
From: Marcus Cooper 

On the newer SoCs the bits to configure the operational mode are
located in a different register. Add a regmap field so that this
location can be configured.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 6d8d2c4a675b..9e060d1b73d5 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -106,6 +106,7 @@
  * @field_fmt_set_sr: regmap field to set sample resolution.
  * @field_fmt_set_bclk_polarity: regmap field to set clk polarity.
  * @field_fmt_set_lrclk_polarity: regmap field to set frame polarity.
+ * @field_fmt_set_mode: regmap field to set the operational mode.
  * @field_txchanmap: location of the tx channel mapping register.
  * @field_rxchanmap: location of the rx channel mapping register.
  * @field_txchansel: location of the tx channel select bit fields.
@@ -125,6 +126,7 @@ struct sun4i_i2s_quirks {
struct reg_fieldfield_fmt_set_sr;
struct reg_fieldfield_fmt_set_bclk_polarity;
struct reg_fieldfield_fmt_set_lrclk_polarity;
+   struct reg_fieldfield_fmt_set_mode;
struct reg_fieldfield_txchanmap;
struct reg_fieldfield_rxchanmap;
struct reg_fieldfield_txchansel;
@@ -148,6 +150,7 @@ struct sun4i_i2s {
struct regmap_field *field_fmt_set_sr;
struct regmap_field *field_fmt_set_bclk_polarity;
struct regmap_field *field_fmt_set_lrclk_polarity;
+   struct regmap_field *field_fmt_set_mode;
struct regmap_field *field_txchanmap;
struct regmap_field *field_rxchanmap;
struct regmap_field *field_txchansel;
@@ -362,9 +365,7 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, 
unsigned int fmt)
return -EINVAL;
}
 
-   regmap_update_bits(i2s->regmap, SUN4I_I2S_FMT0_REG,
-  SUN4I_I2S_FMT0_FMT_MASK,
-  val);
+   regmap_field_write(i2s->field_fmt_set_mode, val);
 
/* DAI clock polarity */
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
@@ -721,6 +722,7 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = 
{
.field_fmt_set_sr   = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5),
.field_fmt_set_bclk_polarity = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6),
.field_fmt_set_lrclk_polarity = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7),
+   .field_fmt_set_mode = REG_FIELD(SUN4I_I2S_FMT0_REG, 0, 1),
.field_txchanmap= REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31),
.field_rxchanmap= REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31),
.field_txchansel= REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2),
@@ -738,6 +740,7 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = 
{
.field_fmt_set_sr   = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5),
.field_fmt_set_bclk_polarity = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6),
.field_fmt_set_lrclk_polarity = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7),
+   .field_fmt_set_mode = REG_FIELD(SUN4I_I2S_FMT0_REG, 0, 1),
.field_txchanmap= REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31),
.field_rxchanmap= REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31),
.field_txchansel= REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2),
@@ -770,6 +773,12 @@ static int sun4i_i2s_init_regmap_fields(struct device 
*dev, struct sun4i_i2s *i2
if (IS_ERR(i2s->field_fmt_set_lrclk_polarity))
return PTR_ERR(i2s->field_fmt_set_lrclk_polarity);
 
+   i2s->field_fmt_set_mode =
+   devm_regmap_field_alloc(dev, i2s->regmap,
+   i2s->variant->field_fmt_set_mode);
+   if (IS_ERR(i2s->field_fmt_set_mode))
+   return PTR_ERR(i2s->field_fmt_set_mode);
+
i2s->field_clkdiv_mclk_en =
devm_regmap_field_alloc(dev, i2s->regmap,
i2s->variant->field_clkdiv_mclk_en);
-- 
2.13.3



[PATCH v3 10/12] ASoC: sun4i-i2s: Check for slave select bit

2017-07-29 Thread codekipper
From: Marcus Cooper 

The newer SoCs do not have this setting. Instead they set the pin
direction. Add a check to see if the bit is valid and if so set
it accordingly.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 38 ++
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 9e060d1b73d5..1c4d763e3a8e 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -96,6 +96,7 @@
  * struct sun4i_i2s_quirks - Differences between SoC variants.
  *
  * @has_reset: SoC needs reset deasserted.
+ * @has_slave_select_bit: SoC has a bit to enable slave mode.
  * @reg_offset_txdata: offset of the tx fifo.
  * @sun4i_i2s_regmap: regmap config to use.
  * @mclk_offset: Value by which mclkdiv needs to be adjusted.
@@ -114,6 +115,7 @@
  */
 struct sun4i_i2s_quirks {
boolhas_reset;
+   boolhas_slave_select_bit;
unsigned intreg_offset_txdata;  /* TX FIFO */
const struct regmap_config  *sun4i_i2s_regmap;
unsigned intmclk_offset;
@@ -391,30 +393,32 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, 
unsigned int fmt)
regmap_field_write(i2s->field_fmt_set_bclk_polarity, bclk_polarity);
regmap_field_write(i2s->field_fmt_set_lrclk_polarity, lrclk_polarity);
 
-   /* DAI clock master masks */
-   switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
-   case SND_SOC_DAIFMT_CBS_CFS:
-   /* BCLK and LRCLK master */
-   val = SUN4I_I2S_CTRL_MODE_MASTER;
-   break;
-   case SND_SOC_DAIFMT_CBM_CFM:
-   /* BCLK and LRCLK slave */
-   val = SUN4I_I2S_CTRL_MODE_SLAVE;
-   break;
-   default:
-   return -EINVAL;
+   if (i2s->variant->has_slave_select_bit) {
+   /* DAI clock master masks */
+   switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+   case SND_SOC_DAIFMT_CBS_CFS:
+   /* BCLK and LRCLK master */
+   val = SUN4I_I2S_CTRL_MODE_MASTER;
+   break;
+   case SND_SOC_DAIFMT_CBM_CFM:
+   /* BCLK and LRCLK slave */
+   val = SUN4I_I2S_CTRL_MODE_SLAVE;
+   break;
+   default:
+   return -EINVAL;
+   }
+   regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
+  SUN4I_I2S_CTRL_MODE_MASK,
+  val);
}
 
-   regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
-  SUN4I_I2S_CTRL_MODE_MASK,
-  val);
-
/* Set significant bits in our FIFOs */
regmap_update_bits(i2s->regmap, SUN4I_I2S_FIFO_CTRL_REG,
   SUN4I_I2S_FIFO_CTRL_TX_MODE_MASK |
   SUN4I_I2S_FIFO_CTRL_RX_MODE_MASK,
   SUN4I_I2S_FIFO_CTRL_TX_MODE(1) |
   SUN4I_I2S_FIFO_CTRL_RX_MODE(1));
+
return 0;
 }
 
@@ -715,6 +719,7 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = 
{
.has_reset  = false,
.reg_offset_txdata  = SUN4I_I2S_FIFO_TX_REG,
.sun4i_i2s_regmap   = &sun4i_i2s_regmap_config,
+   .has_slave_select_bit   = true,
.field_clkdiv_mclk_en   = REG_FIELD(SUN4I_I2S_CLK_DIV_REG,
SUN4I_I2S_CLK_DIV_MCLK_EN,
SUN4I_I2S_CLK_DIV_MCLK_EN),
@@ -733,6 +738,7 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = 
{
.has_reset  = true,
.reg_offset_txdata  = SUN4I_I2S_FIFO_TX_REG,
.sun4i_i2s_regmap   = &sun4i_i2s_regmap_config,
+   .has_slave_select_bit   = true,
.field_clkdiv_mclk_en   = REG_FIELD(SUN4I_I2S_CLK_DIV_REG,
SUN4I_I2S_CLK_DIV_MCLK_EN,
SUN4I_I2S_CLK_DIV_MCLK_EN),
-- 
2.13.3



[PATCH v3 07/12] ASoC: sun4i-i2s: bclk and lrclk polarity tidyup

2017-07-29 Thread codekipper
From: Marcus Cooper 

On newer SoCs the bit fields for the blck and lrclk polarity are in
a different locations. Use regmap fields to set the polarity bits
as intended.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 45 -
 1 file changed, 32 insertions(+), 13 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 171df99a267e..90daa974bd27 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -50,6 +50,8 @@
 #define SUN4I_I2S_FMT0_FMT_RIGHT_J (2 << 0)
 #define SUN4I_I2S_FMT0_FMT_LEFT_J  (1 << 0)
 #define SUN4I_I2S_FMT0_FMT_I2S (0 << 0)
+#define SUN4I_I2S_FMT0_POLARITY_INVERTED   (1)
+#define SUN4I_I2S_FMT0_POLARITY_NORMAL (0)
 
 #define SUN4I_I2S_FMT1_REG 0x08
 #define SUN4I_I2S_FIFO_TX_REG  0x0c
@@ -101,6 +103,8 @@
  * @fmt_offset: Value by which wss and sr needs to be adjusted.
  * @field_fmt_set_wss: regmap field to set word select size.
  * @field_fmt_set_sr: regmap field to set sample resolution.
+ * @field_fmt_set_bclk_polarity: regmap field to set clk polarity.
+ * @field_fmt_set_lrclk_polarity: regmap field to set frame polarity.
  * @field_txchanmap: location of the tx channel mapping register.
  * @field_rxchanmap: location of the rx channel mapping register.
  * @field_txchansel: location of the tx channel select bit fields.
@@ -117,6 +121,8 @@ struct sun4i_i2s_quirks {
/* Register fields for i2s */
struct reg_fieldfield_fmt_set_wss;
struct reg_fieldfield_fmt_set_sr;
+   struct reg_fieldfield_fmt_set_bclk_polarity;
+   struct reg_fieldfield_fmt_set_lrclk_polarity;
struct reg_fieldfield_txchanmap;
struct reg_fieldfield_rxchanmap;
struct reg_fieldfield_txchansel;
@@ -137,6 +143,8 @@ struct sun4i_i2s {
/* Register fields for i2s */
struct regmap_field *field_fmt_set_wss;
struct regmap_field *field_fmt_set_sr;
+   struct regmap_field *field_fmt_set_bclk_polarity;
+   struct regmap_field *field_fmt_set_lrclk_polarity;
struct regmap_field *field_txchanmap;
struct regmap_field *field_rxchanmap;
struct regmap_field *field_txchansel;
@@ -332,6 +340,8 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, 
unsigned int fmt)
 {
struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
u32 val;
+   u32 bclk_polarity = SUN4I_I2S_FMT0_POLARITY_NORMAL;
+   u32 lrclk_polarity = SUN4I_I2S_FMT0_POLARITY_NORMAL;
 
/* DAI Mode */
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
@@ -356,32 +366,25 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, 
unsigned int fmt)
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
case SND_SOC_DAIFMT_IB_IF:
/* Invert both clocks */
-   val = SUN4I_I2S_FMT0_BCLK_POLARITY_INVERTED |
-   SUN4I_I2S_FMT0_LRCLK_POLARITY_INVERTED;
+   bclk_polarity = SUN4I_I2S_FMT0_POLARITY_INVERTED;
+   lrclk_polarity = SUN4I_I2S_FMT0_POLARITY_INVERTED;
break;
case SND_SOC_DAIFMT_IB_NF:
/* Invert bit clock */
-   val = SUN4I_I2S_FMT0_BCLK_POLARITY_INVERTED |
-   SUN4I_I2S_FMT0_LRCLK_POLARITY_NORMAL;
+   bclk_polarity = SUN4I_I2S_FMT0_POLARITY_INVERTED;
break;
case SND_SOC_DAIFMT_NB_IF:
/* Invert frame clock */
-   val = SUN4I_I2S_FMT0_LRCLK_POLARITY_INVERTED |
-   SUN4I_I2S_FMT0_BCLK_POLARITY_NORMAL;
+   lrclk_polarity = SUN4I_I2S_FMT0_POLARITY_INVERTED;
break;
case SND_SOC_DAIFMT_NB_NF:
-   /* Nothing to do for both normal cases */
-   val = SUN4I_I2S_FMT0_BCLK_POLARITY_NORMAL |
-   SUN4I_I2S_FMT0_LRCLK_POLARITY_NORMAL;
break;
default:
return -EINVAL;
}
 
-   regmap_update_bits(i2s->regmap, SUN4I_I2S_FMT0_REG,
-  SUN4I_I2S_FMT0_BCLK_POLARITY_MASK |
-  SUN4I_I2S_FMT0_LRCLK_POLARITY_MASK,
-  val);
+   regmap_field_write(i2s->field_fmt_set_bclk_polarity, bclk_polarity);
+   regmap_field_write(i2s->field_fmt_set_lrclk_polarity, lrclk_polarity);
 
/* DAI clock master masks */
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -709,6 +712,8 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = 
{
.sun4i_i2s_regmap   = &sun4i_i2s_regmap_config,
.field_fmt_set_wss  = REG_FIELD(SUN4I_I2S_FMT0_REG, 2, 3),
.field_fmt_set_sr   = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5),
+   .field_fmt_set_bclk_polarity = RE

[PATCH v3 12/12] ASoC: sun4i-i2s: Add support for H3

2017-07-29 Thread codekipper
From: Marcus Cooper 

The sun8i-h3 introduces a lot of changes to the i2s block such
as different register locations, extended clock division and
more operational modes. As we have to consider the earlier
implementation then these changes need to be isolated.

Signed-off-by: Marcus Cooper 
---
 .../devicetree/bindings/sound/sun4i-i2s.txt|   2 +
 sound/soc/sunxi/sun4i-i2s.c| 173 +
 2 files changed, 175 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/sun4i-i2s.txt 
b/Documentation/devicetree/bindings/sound/sun4i-i2s.txt
index ee21da865771..fc5da6080759 100644
--- a/Documentation/devicetree/bindings/sound/sun4i-i2s.txt
+++ b/Documentation/devicetree/bindings/sound/sun4i-i2s.txt
@@ -8,6 +8,7 @@ Required properties:
 - compatible: should be one of the following:
- "allwinner,sun4i-a10-i2s"
- "allwinner,sun6i-a31-i2s"
+   - "allwinner,sun8i-h3-i2s"
 - reg: physical base address of the controller and length of memory mapped
   region.
 - interrupts: should contain the I2S interrupt.
@@ -22,6 +23,7 @@ Required properties:
 
 Required properties for the following compatibles:
- "allwinner,sun6i-a31-i2s"
+   - "allwinner,sun8i-h3-i2s"
 - resets: phandle to the reset line for this codec
 
 Example:
diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index d8bcd3d9c2b6..87dfb5017c25 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -92,11 +92,43 @@
 #define SUN4I_I2S_RX_CHAN_SEL_REG  0x38
 #define SUN4I_I2S_RX_CHAN_MAP_REG  0x3c
 
+/* Defines required for sun8i-h3 support */
+#define SUN8I_I2S_CTRL_BCLK_OUTBIT(18)
+#define SUN8I_I2S_CTRL_LRCK_OUTBIT(17)
+
+#define SUN8I_I2S_FMT0_LRCK_PERIOD_MASKGENMASK(17, 8)
+#define SUN8I_I2S_FMT0_LRCK_PERIOD(period) (period << 8)
+
+#define SUN8I_I2S_INT_STA_REG  0x0c
+#define SUN8I_I2S_FIFO_TX_REG  0x20
+
+#define SUN8I_I2S_CLK_DIV_MCLK_EN  8
+
+#define SUN8I_I2S_CHAN_CFG_REG 0x30
+#define SUN8I_I2S_CHAN_CFG_RX_SLOT_NUM_MASKGENMASK(6, 4)
+#define SUN8I_I2S_CHAN_CFG_RX_SLOT_NUM(chan)   (chan - 1)
+#define SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM_MASKGENMASK(2, 0)
+#define SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM(chan)   (chan - 1)
+
+#define SUN8I_I2S_TX_CHAN_MAP_REG  0x44
+#define SUN8I_I2S_TX_CHAN_SEL_REG  0x34
+#define SUN8I_I2S_TX_CHAN_OFFSET_MASK  GENMASK(13,11)
+#define SUN8I_I2S_TX_CHAN_OFFSET(offset)   (offset << 12)
+#define SUN8I_I2S_TX_CHAN_EN_MASK  GENMASK(11, 4)
+#define SUN8I_I2S_TX_CHAN_EN(num_chan) (((1 << num_chan) - 1) << 4)
+
+#define SUN8I_I2S_RX_CHAN_SEL_REG  0x54
+#define SUN8I_I2S_RX_CHAN_MAP_REG  0x58
+
 /**
  * struct sun4i_i2s_quirks - Differences between SoC variants.
  *
  * @has_reset: SoC needs reset deasserted.
  * @has_slave_select_bit: SoC has a bit to enable slave mode.
+ * @has_fmt_set_lrck_period: SoC requires lrclk period to be set.
+ * @has_chcfg: tx and rx slot number need to be set.
+ * @has_chsel_tx_chen: requires lrclk period to be set.
+ * @has_chsel_offset: requires lrclk period to be set.
  * @reg_offset_txdata: offset of the tx fifo.
  * @sun4i_i2s_regmap: regmap config to use.
  * @mclk_offset: Value by which mclkdiv needs to be adjusted.
@@ -116,6 +148,10 @@
 struct sun4i_i2s_quirks {
boolhas_reset;
boolhas_slave_select_bit;
+   boolhas_fmt_set_lrck_period;
+   boolhas_chcfg;
+   boolhas_chsel_tx_chen;
+   boolhas_chsel_offset;
unsigned intreg_offset_txdata;  /* TX FIFO */
const struct regmap_config  *sun4i_i2s_regmap;
unsigned intmclk_offset;
@@ -291,6 +327,12 @@ static int sun4i_i2s_set_clk_rate(struct sun4i_i2s *i2s,
 
regmap_field_write(i2s->field_clkdiv_mclk_en, 1);
 
+   /* Set sync period */
+   if (i2s->variant->has_fmt_set_lrck_period)
+   regmap_update_bits(i2s->regmap, SUN4I_I2S_FMT0_REG,
+  SUN8I_I2S_FMT0_LRCK_PERIOD_MASK,
+  SUN8I_I2S_FMT0_LRCK_PERIOD(0x1f));
+
return 0;
 }
 
@@ -305,6 +347,15 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream 
*substream,
if (params_channels(params) != 2)
return -EINVAL;
 
+   if (i2s->variant->has_chcfg) {
+   regmap_update_bits(i2s->regmap, SUN8I_I2S_CHAN_CFG_REG,
+  SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM_MASK,
+  
SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM(params_channels(params)));
+   regmap_update_bits(i2s->regmap, SUN8I_I2S_CHAN_CFG_REG,
+  SUN8I_I2S_CHAN_CFG_RX_SLOT_NUM_MASK,
+   

[PATCH v3 11/12] ASoC: sun4i-i2s: Update global enable with bitmask

2017-07-29 Thread codekipper
From: Marcus Cooper 

The default value of the config register is different on newer
SoCs and therefore enabling/disabling with a register write
will clear bits used to set the direction of the clock and frame
pins.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 1c4d763e3a8e..d8bcd3d9c2b6 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -527,8 +527,8 @@ static int sun4i_i2s_startup(struct snd_pcm_substream 
*substream,
struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
 
/* Enable the whole hardware block */
-   regmap_write(i2s->regmap, SUN4I_I2S_CTRL_REG,
-SUN4I_I2S_CTRL_GL_EN);
+   regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
+  SUN4I_I2S_CTRL_GL_EN, SUN4I_I2S_CTRL_GL_EN);
 
/* Enable the first output line */
regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
@@ -551,7 +551,8 @@ static void sun4i_i2s_shutdown(struct snd_pcm_substream 
*substream,
   SUN4I_I2S_CTRL_SDO_EN_MASK, 0);
 
/* Disable the whole hardware block */
-   regmap_write(i2s->regmap, SUN4I_I2S_CTRL_REG, 0);
+   regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
+  SUN4I_I2S_CTRL_GL_EN, 0);
 }
 
 static int sun4i_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id,
-- 
2.13.3



[PATCH v3 06/12] ASoC: sun4i-i2s: Add changes for wss and sr

2017-07-29 Thread codekipper
From: Marcus Cooper 

On newer SoCs the location of the slot width select and sample
resolution are different and also there is a bigger range of
support.

For the current supported rates then an offset is required.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 31 ---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 120f797a38e8..171df99a267e 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -98,6 +98,9 @@
  * @sun4i_i2s_regmap: regmap config to use.
  * @mclk_offset: Value by which mclkdiv needs to be adjusted.
  * @bclk_offset: Value by which bclkdiv needs to be adjusted.
+ * @fmt_offset: Value by which wss and sr needs to be adjusted.
+ * @field_fmt_set_wss: regmap field to set word select size.
+ * @field_fmt_set_sr: regmap field to set sample resolution.
  * @field_txchanmap: location of the tx channel mapping register.
  * @field_rxchanmap: location of the rx channel mapping register.
  * @field_txchansel: location of the tx channel select bit fields.
@@ -109,8 +112,11 @@ struct sun4i_i2s_quirks {
const struct regmap_config  *sun4i_i2s_regmap;
unsigned intmclk_offset;
unsigned intbclk_offset;
+   unsigned intfmt_offset;
 
/* Register fields for i2s */
+   struct reg_fieldfield_fmt_set_wss;
+   struct reg_fieldfield_fmt_set_sr;
struct reg_fieldfield_txchanmap;
struct reg_fieldfield_rxchanmap;
struct reg_fieldfield_txchansel;
@@ -129,6 +135,8 @@ struct sun4i_i2s {
struct snd_dmaengine_dai_dma_data   playback_dma_data;
 
/* Register fields for i2s */
+   struct regmap_field *field_fmt_set_wss;
+   struct regmap_field *field_fmt_set_sr;
struct regmap_field *field_txchanmap;
struct regmap_field *field_rxchanmap;
struct regmap_field *field_txchansel;
@@ -311,9 +319,10 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream 
*substream,
return -EINVAL;
}
 
-   regmap_update_bits(i2s->regmap, SUN4I_I2S_FMT0_REG,
-  SUN4I_I2S_FMT0_WSS_MASK | SUN4I_I2S_FMT0_SR_MASK,
-  SUN4I_I2S_FMT0_WSS(wss) | SUN4I_I2S_FMT0_SR(sr));
+   regmap_field_write(i2s->field_fmt_set_wss,
+  wss + i2s->variant->fmt_offset);
+   regmap_field_write(i2s->field_fmt_set_sr,
+  sr + i2s->variant->fmt_offset);
 
return sun4i_i2s_set_clk_rate(i2s, params_rate(params),
  params_width(params));
@@ -698,6 +707,8 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = 
{
.has_reset  = false,
.reg_offset_txdata  = SUN4I_I2S_FIFO_TX_REG,
.sun4i_i2s_regmap   = &sun4i_i2s_regmap_config,
+   .field_fmt_set_wss  = REG_FIELD(SUN4I_I2S_FMT0_REG, 2, 3),
+   .field_fmt_set_sr   = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5),
.field_txchanmap= REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31),
.field_rxchanmap= REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31),
.field_txchansel= REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2),
@@ -708,6 +719,8 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = 
{
.has_reset  = true,
.reg_offset_txdata  = SUN4I_I2S_FIFO_TX_REG,
.sun4i_i2s_regmap   = &sun4i_i2s_regmap_config,
+   .field_fmt_set_wss  = REG_FIELD(SUN4I_I2S_FMT0_REG, 2, 3),
+   .field_fmt_set_sr   = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5),
.field_txchanmap= REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31),
.field_rxchanmap= REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31),
.field_txchansel= REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2),
@@ -716,6 +729,18 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks 
= {
 
 static int sun4i_i2s_init_regmap_fields(struct device *dev, struct sun4i_i2s 
*i2s)
 {
+   i2s->field_fmt_set_wss =
+   devm_regmap_field_alloc(dev, i2s->regmap,
+   i2s->variant->field_fmt_set_wss);
+   if (IS_ERR(i2s->field_fmt_set_wss))
+   return PTR_ERR(i2s->field_fmt_set_wss);
+
+   i2s->field_fmt_set_sr =
+   devm_regmap_field_alloc(dev, i2s->regmap,
+   i2s->variant->field_fmt_set_sr);
+   if (IS_ERR(i2s->field_fmt_set_sr))
+   return PTR_ERR(i2s->field_fmt_set_sr);
+
i2s->field_txchanmap =
devm_regmap_field_alloc(dev, i2s->regmap,
i2s->variant->field_txchanmap);
-- 
2.13.3



[PATCH v3 08/12] ASoC: sun4i-i2s: Add mclk enable regmap field

2017-07-29 Thread codekipper
From: Marcus Cooper 

The location of the mclk output enable bit is different on newer
SoCs. Use a regmap field to enable it.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 22 +++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 90daa974bd27..6d8d2c4a675b 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -74,7 +74,7 @@
 #define SUN4I_I2S_INT_STA_REG  0x20
 
 #define SUN4I_I2S_CLK_DIV_REG  0x24
-#define SUN4I_I2S_CLK_DIV_MCLK_EN  BIT(7)
+#define SUN4I_I2S_CLK_DIV_MCLK_EN  7
 #define SUN4I_I2S_CLK_DIV_BCLK_MASKGENMASK(6, 4)
 #define SUN4I_I2S_CLK_DIV_BCLK(bclk)   ((bclk) << 4)
 #define SUN4I_I2S_CLK_DIV_MCLK_MASKGENMASK(3, 0)
@@ -101,6 +101,7 @@
  * @mclk_offset: Value by which mclkdiv needs to be adjusted.
  * @bclk_offset: Value by which bclkdiv needs to be adjusted.
  * @fmt_offset: Value by which wss and sr needs to be adjusted.
+ * @field_clkdiv_mclk_en: regmap field to enable mclk output.
  * @field_fmt_set_wss: regmap field to set word select size.
  * @field_fmt_set_sr: regmap field to set sample resolution.
  * @field_fmt_set_bclk_polarity: regmap field to set clk polarity.
@@ -119,6 +120,7 @@ struct sun4i_i2s_quirks {
unsigned intfmt_offset;
 
/* Register fields for i2s */
+   struct reg_fieldfield_clkdiv_mclk_en;
struct reg_fieldfield_fmt_set_wss;
struct reg_fieldfield_fmt_set_sr;
struct reg_fieldfield_fmt_set_bclk_polarity;
@@ -141,6 +143,7 @@ struct sun4i_i2s {
struct snd_dmaengine_dai_dma_data   playback_dma_data;
 
/* Register fields for i2s */
+   struct regmap_field *field_clkdiv_mclk_en;
struct regmap_field *field_fmt_set_wss;
struct regmap_field *field_fmt_set_sr;
struct regmap_field *field_fmt_set_bclk_polarity;
@@ -279,8 +282,9 @@ static int sun4i_i2s_set_clk_rate(struct sun4i_i2s *i2s,
 
regmap_write(i2s->regmap, SUN4I_I2S_CLK_DIV_REG,
 SUN4I_I2S_CLK_DIV_BCLK(bclk_div) |
-SUN4I_I2S_CLK_DIV_MCLK(mclk_div) |
-SUN4I_I2S_CLK_DIV_MCLK_EN);
+SUN4I_I2S_CLK_DIV_MCLK(mclk_div));
+
+   regmap_field_write(i2s->field_clkdiv_mclk_en, 1);
 
return 0;
 }
@@ -710,6 +714,9 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = 
{
.has_reset  = false,
.reg_offset_txdata  = SUN4I_I2S_FIFO_TX_REG,
.sun4i_i2s_regmap   = &sun4i_i2s_regmap_config,
+   .field_clkdiv_mclk_en   = REG_FIELD(SUN4I_I2S_CLK_DIV_REG,
+   SUN4I_I2S_CLK_DIV_MCLK_EN,
+   SUN4I_I2S_CLK_DIV_MCLK_EN),
.field_fmt_set_wss  = REG_FIELD(SUN4I_I2S_FMT0_REG, 2, 3),
.field_fmt_set_sr   = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5),
.field_fmt_set_bclk_polarity = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6),
@@ -724,6 +731,9 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = 
{
.has_reset  = true,
.reg_offset_txdata  = SUN4I_I2S_FIFO_TX_REG,
.sun4i_i2s_regmap   = &sun4i_i2s_regmap_config,
+   .field_clkdiv_mclk_en   = REG_FIELD(SUN4I_I2S_CLK_DIV_REG,
+   SUN4I_I2S_CLK_DIV_MCLK_EN,
+   SUN4I_I2S_CLK_DIV_MCLK_EN),
.field_fmt_set_wss  = REG_FIELD(SUN4I_I2S_FMT0_REG, 2, 3),
.field_fmt_set_sr   = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5),
.field_fmt_set_bclk_polarity = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6),
@@ -760,6 +770,12 @@ static int sun4i_i2s_init_regmap_fields(struct device 
*dev, struct sun4i_i2s *i2
if (IS_ERR(i2s->field_fmt_set_lrclk_polarity))
return PTR_ERR(i2s->field_fmt_set_lrclk_polarity);
 
+   i2s->field_clkdiv_mclk_en =
+   devm_regmap_field_alloc(dev, i2s->regmap,
+   i2s->variant->field_clkdiv_mclk_en);
+   if (IS_ERR(i2s->field_clkdiv_mclk_en))
+   return PTR_ERR(i2s->field_clkdiv_mclk_en);
+
i2s->field_txchanmap =
devm_regmap_field_alloc(dev, i2s->regmap,
i2s->variant->field_txchanmap);
-- 
2.13.3



[PATCH v3 05/12] ASoC: sun4i-i2s: Add regmap fields for channels

2017-07-29 Thread codekipper
From: Marcus Cooper 

On the original i2s block the channel mapping and selection were
configured for stereo audio by default: This is not the case with
the newer SoCs and they are also located at different offsets.

To support the newer SoC then regmap fields have been added to the
quirks and these are initialised to their correct settings during
probing.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 80 -
 1 file changed, 72 insertions(+), 8 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 2a25df22c2f8..120f797a38e8 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -82,7 +82,7 @@
 #define SUN4I_I2S_TX_CNT_REG   0x2c
 
 #define SUN4I_I2S_TX_CHAN_SEL_REG  0x30
-#define SUN4I_I2S_TX_CHAN_SEL(num_chan)(((num_chan) - 1) << 0)
+#define SUN4I_I2S_CHAN_SEL(num_chan)   (((num_chan) - 1) << 0)
 
 #define SUN4I_I2S_TX_CHAN_MAP_REG  0x34
 #define SUN4I_I2S_TX_CHAN_MAP(chan, sample)((sample) << (chan << 2))
@@ -98,6 +98,10 @@
  * @sun4i_i2s_regmap: regmap config to use.
  * @mclk_offset: Value by which mclkdiv needs to be adjusted.
  * @bclk_offset: Value by which bclkdiv needs to be adjusted.
+ * @field_txchanmap: location of the tx channel mapping register.
+ * @field_rxchanmap: location of the rx channel mapping register.
+ * @field_txchansel: location of the tx channel select bit fields.
+ * @field_rxchansel: location of the rx channel select bit fields.
  */
 struct sun4i_i2s_quirks {
boolhas_reset;
@@ -105,6 +109,12 @@ struct sun4i_i2s_quirks {
const struct regmap_config  *sun4i_i2s_regmap;
unsigned intmclk_offset;
unsigned intbclk_offset;
+
+   /* Register fields for i2s */
+   struct reg_fieldfield_txchanmap;
+   struct reg_fieldfield_rxchanmap;
+   struct reg_fieldfield_txchansel;
+   struct reg_fieldfield_rxchansel;
 };
 
 struct sun4i_i2s {
@@ -118,6 +128,12 @@ struct sun4i_i2s {
struct snd_dmaengine_dai_dma_data   capture_dma_data;
struct snd_dmaengine_dai_dma_data   playback_dma_data;
 
+   /* Register fields for i2s */
+   struct regmap_field *field_txchanmap;
+   struct regmap_field *field_rxchanmap;
+   struct regmap_field *field_txchansel;
+   struct regmap_field *field_rxchansel;
+
const struct sun4i_i2s_quirks   *variant;
 };
 
@@ -264,6 +280,18 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream 
*substream,
if (params_channels(params) != 2)
return -EINVAL;
 
+   /* Map the channels for playback and capture */
+   regmap_field_write(i2s->field_txchanmap, 0x76543210);
+   regmap_field_write(i2s->field_rxchanmap, 0x3210);
+
+   /* Configure the channels */
+   regmap_field_write(i2s->field_txchansel,
+  SUN4I_I2S_CHAN_SEL(params_channels(params)));
+
+   regmap_field_write(i2s->field_rxchansel,
+  SUN4I_I2S_CHAN_SEL(params_channels(params)));
+
+
switch (params_physical_width(params)) {
case 16:
width = DMA_SLAVE_BUSWIDTH_2_BYTES;
@@ -486,13 +514,6 @@ static int sun4i_i2s_startup(struct snd_pcm_substream 
*substream,
   SUN4I_I2S_CTRL_SDO_EN_MASK,
   SUN4I_I2S_CTRL_SDO_EN(0));
 
-   /* Enable the first two channels */
-   regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_SEL_REG,
-SUN4I_I2S_TX_CHAN_SEL(2));
-
-   /* Map them to the two first samples coming in */
-   regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_MAP_REG,
-SUN4I_I2S_TX_CHAN_MAP(0, 0) | SUN4I_I2S_TX_CHAN_MAP(1, 1));
 
return clk_prepare_enable(i2s->mod_clk);
 }
@@ -677,14 +698,51 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks 
= {
.has_reset  = false,
.reg_offset_txdata  = SUN4I_I2S_FIFO_TX_REG,
.sun4i_i2s_regmap   = &sun4i_i2s_regmap_config,
+   .field_txchanmap= REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31),
+   .field_rxchanmap= REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31),
+   .field_txchansel= REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2),
+   .field_rxchansel= REG_FIELD(SUN4I_I2S_RX_CHAN_SEL_REG, 0, 2),
 };
 
 static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = {
.has_reset  = true,
.reg_offset_txdata  = SUN4I_I2S_FIFO_TX_REG,
.sun4i_i2s_regmap   = &sun4i_i2s_regmap_config,
+   .field_txchanmap= REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31),
+   .field_rxchanmap= REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31),
+   .field_txchansel= REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2),
+   .fie

[PATCH v3 04/12] ASoC: sun4i-i2s: Add TX FIFO offset to quirks

2017-07-29 Thread codekipper
From: Marcus Cooper 

It has been seen that the newer SoCs have a different TX FIFO
address. Add this to the quirks structure.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 73e991f5a81e..2a25df22c2f8 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -94,12 +94,14 @@
  * struct sun4i_i2s_quirks - Differences between SoC variants.
  *
  * @has_reset: SoC needs reset deasserted.
+ * @reg_offset_txdata: offset of the tx fifo.
  * @sun4i_i2s_regmap: regmap config to use.
  * @mclk_offset: Value by which mclkdiv needs to be adjusted.
  * @bclk_offset: Value by which bclkdiv needs to be adjusted.
  */
 struct sun4i_i2s_quirks {
boolhas_reset;
+   unsigned intreg_offset_txdata;  /* TX FIFO */
const struct regmap_config  *sun4i_i2s_regmap;
unsigned intmclk_offset;
unsigned intbclk_offset;
@@ -673,11 +675,13 @@ static int sun4i_i2s_runtime_suspend(struct device *dev)
 
 static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = {
.has_reset  = false,
+   .reg_offset_txdata  = SUN4I_I2S_FIFO_TX_REG,
.sun4i_i2s_regmap   = &sun4i_i2s_regmap_config,
 };
 
 static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = {
.has_reset  = true,
+   .reg_offset_txdata  = SUN4I_I2S_FIFO_TX_REG,
.sun4i_i2s_regmap   = &sun4i_i2s_regmap_config,
 };
 
@@ -746,7 +750,8 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
}
}
 
-   i2s->playback_dma_data.addr = res->start + SUN4I_I2S_FIFO_TX_REG;
+   i2s->playback_dma_data.addr = res->start +
+   i2s->variant->reg_offset_txdata;
i2s->playback_dma_data.maxburst = 8;
 
i2s->capture_dma_data.addr = res->start + SUN4I_I2S_FIFO_RX_REG;
-- 
2.13.3



[PATCH v3 03/12] ASoC: sun4i-i2s: Add regmap config to quirks

2017-07-29 Thread codekipper
From: Marcus Cooper 

The newer SoCs have a larger range than the original SoC that this
driver was developed for. By adding the regmap config to the quirks
then the driver can initialise the managed register map correctly.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 1d538de4e4d0..73e991f5a81e 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -94,11 +94,13 @@
  * struct sun4i_i2s_quirks - Differences between SoC variants.
  *
  * @has_reset: SoC needs reset deasserted.
+ * @sun4i_i2s_regmap: regmap config to use.
  * @mclk_offset: Value by which mclkdiv needs to be adjusted.
  * @bclk_offset: Value by which bclkdiv needs to be adjusted.
  */
 struct sun4i_i2s_quirks {
boolhas_reset;
+   const struct regmap_config  *sun4i_i2s_regmap;
unsigned intmclk_offset;
unsigned intbclk_offset;
 };
@@ -670,11 +672,13 @@ static int sun4i_i2s_runtime_suspend(struct device *dev)
 }
 
 static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = {
-   .has_reset  = false,
+   .has_reset  = false,
+   .sun4i_i2s_regmap   = &sun4i_i2s_regmap_config,
 };
 
 static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = {
-   .has_reset  = true,
+   .has_reset  = true,
+   .sun4i_i2s_regmap   = &sun4i_i2s_regmap_config,
 };
 
 static int sun4i_i2s_probe(struct platform_device *pdev)
@@ -713,7 +717,7 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
}
 
i2s->regmap = devm_regmap_init_mmio(&pdev->dev, regs,
-   &sun4i_i2s_regmap_config);
+   i2s->variant->sun4i_i2s_regmap);
if (IS_ERR(i2s->regmap)) {
dev_err(&pdev->dev, "Regmap initialisation failed\n");
return PTR_ERR(i2s->regmap);
-- 
2.13.3



[PATCH v3 01/12] ASoC: sun4i-i2s: Extend quirks scope

2017-07-29 Thread codekipper
From: Marcus Cooper 

In preparation for the changes required to support newer SoCs then
quirks has been moved and also added to the device structure.

Signed-off-by: Marcus Cooper 
---
 sound/soc/sunxi/sun4i-i2s.c | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 62b307b0c846..d7ee7a443e4e 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -90,6 +90,15 @@
 #define SUN4I_I2S_RX_CHAN_SEL_REG  0x38
 #define SUN4I_I2S_RX_CHAN_MAP_REG  0x3c
 
+/**
+ * struct sun4i_i2s_quirks - Differences between SoC variants.
+ *
+ * @has_reset: SoC needs reset deasserted.
+ */
+struct sun4i_i2s_quirks {
+   boolhas_reset;
+};
+
 struct sun4i_i2s {
struct clk  *bus_clk;
struct clk  *mod_clk;
@@ -100,6 +109,8 @@ struct sun4i_i2s {
 
struct snd_dmaengine_dai_dma_data   capture_dma_data;
struct snd_dmaengine_dai_dma_data   playback_dma_data;
+
+   const struct sun4i_i2s_quirks   *variant;
 };
 
 struct sun4i_i2s_clk_div {
@@ -654,10 +665,6 @@ static int sun4i_i2s_runtime_suspend(struct device *dev)
return 0;
 }
 
-struct sun4i_i2s_quirks {
-   bool has_reset;
-};
-
 static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = {
.has_reset  = false,
 };
@@ -669,7 +676,6 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = 
{
 static int sun4i_i2s_probe(struct platform_device *pdev)
 {
struct sun4i_i2s *i2s;
-   const struct sun4i_i2s_quirks *quirks;
struct resource *res;
void __iomem *regs;
int irq, ret;
@@ -690,8 +696,8 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
return irq;
}
 
-   quirks = of_device_get_match_data(&pdev->dev);
-   if (!quirks) {
+   i2s->variant = of_device_get_match_data(&pdev->dev);
+   if (!i2s->variant) {
dev_err(&pdev->dev, "Failed to determine the quirks to use\n");
return -ENODEV;
}
@@ -715,7 +721,7 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
return PTR_ERR(i2s->mod_clk);
}
 
-   if (quirks->has_reset) {
+   if (i2s->variant->has_reset) {
i2s->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
if (IS_ERR(i2s->rst)) {
dev_err(&pdev->dev, "Failed to get reset control\n");
-- 
2.13.3



Re: [PATCH] kselftest: exec: make exec test output conform to TAP13

2017-07-29 Thread Paul Elder
On 07/27/2017 01:58 AM, Shuah Khan wrote:
> Hi Paul,
> 
> Please see comments below:
> 
> On 07/25/2017 11:12 AM, Paul Elder wrote:
>> Convert exec test output to TAP13 format, using the ksft framework.
>>
>> Signed-off-by: Paul Elder 
>> ---
>>
>> Depends on Shuah Khan's patch: "[PATCH 2/3] selftests: kselftest framework: 
>> add API to return pass/fail/* counts" 
>> (https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.spinics.net%2Flists%2Flinux-kselftest%2Fmsg01964.html&data=01%7C01%7Cpaul.elder%40pitt.edu%7C0709e3fc974f4ccf6fcb08d4d4478c78%7C9ef9f489e0a04eeb87cc3a526112fd0d%7C1&sdata=G3AQ%2FJRvrD0AXNupCNBbi4Ne9%2FAbYBZxZ3GryWev%2FN4%3D&reserved=0)
>>
>>  tools/testing/selftests/exec/execveat.c | 148 
>> +---
>>  1 file changed, 81 insertions(+), 67 deletions(-)
>>
>> diff --git a/tools/testing/selftests/exec/execveat.c 
>> b/tools/testing/selftests/exec/execveat.c
>> index 8d5d1d2ee7c1..dc94c0661459 100644
>> --- a/tools/testing/selftests/exec/execveat.c
>> +++ b/tools/testing/selftests/exec/execveat.c
>> @@ -20,6 +20,8 @@
>>  #include 
>>  #include 
>>  
>> +#include "../kselftest.h"
>> +
>>  static char longpath[2 * PATH_MAX] = "";
>>  static char *envp[] = { "IN_TEST=yes", NULL, NULL };
>>  static char *argv[] = { "execveat", "99", NULL };
>> @@ -41,23 +43,26 @@ static int _check_execveat_fail(int fd, const char 
>> *path, int flags,
>>  int expected_errno, const char *errno_str)
>>  {
>>  int rc;
>> +char msg[512];
> 
> You need a line between declarations and code.
Okay.
> 
>> +snprintf(msg, 512, "Check failure of execveat(%d, '%s', %d) with 
>> %s...\n",
>> +fd, path?:"(null)", flags, errno_str);
> 
> Is there is a need to use snprinf() here? ksft_test_result_fail() does 
> suppoort
> var args now. Also, please use sizeof(msg) instead of 512.
As you have noted later, it is to populate the static msg to be printed on both
failure and success.

>>  
>>  errno = 0;
>> -printf("Check failure of execveat(%d, '%s', %d) with %s... ",
>> -fd, path?:"(null)", flags, errno_str);
>>  rc = execveat_(fd, path, argv, envp, flags);
>>  
>>  if (rc > 0) {
>> -printf("[FAIL] (unexpected success from execveat(2))\n");
>> +ksft_test_result_fail(msg);
>> +ksft_print_msg("unexpected success from execveat(2)\n");
> 
> I think one single message to indicate the test result is desirable as
> opposed to two messages.
The ksft_test_result_fail(msg) prints the test name and increments the
fail counter, then the ksft_print_msg() gives information regarding the
failure.
> 
>>  return 1;
>>  }
>>  if (errno != expected_errno) {
>> -printf("[FAIL] (expected errno %d (%s) not %d (%s)\n",
>> +ksft_test_result_fail(msg);
>> +ksft_print_msg("expected errno %d (%s) not %d (%s)\n",
>>  expected_errno, strerror(expected_errno),
>>  errno, strerror(errno));
> 
> Same as above.
> 
>>  return 1;
>>  }
>> -printf("[OK]\n");
>> +ksft_test_result_pass(msg);
>>  return 0;
>>  }
>>  
>> @@ -68,43 +73,48 @@ static int check_execveat_invoked_rc(int fd, const char 
>> *path, int flags,
>>  int rc;
>>  pid_t child;
>>  int pathlen = path ? strlen(path) : 0;
>> +char msg[512];
>>  
>>  if (pathlen > 40)
>> -printf("Check success of execveat(%d, '%.20s...%s', %d)... ",
>> +snprintf(msg, 512, "Check success of execveat(%d, '%.20s...%s', 
>> %d)...\n",
>>  fd, path, (path + pathlen - 20), flags);
>>  else
>> -printf("Check success of execveat(%d, '%s', %d)... ",
>> +snprintf(msg, 512, "Check success of execveat(%d, '%s', 
>> %d)...\n",
>>  fd, path?:"(null)", flags);
> 
> Is there is a need to use snprinf() here? ksft_test_result_fail() does 
> suppoort
> var args now. Also, please use sizeof(msg) instead of 512.
> 
>>  child = fork();
>>  if (child < 0) {
>> -printf("[FAIL] (fork() failed)\n");
>> +ksft_test_result_fail(msg);
>> +ksft_print_msg("fork() failed\n");
>>  return 1;
>>  }
>>  if (child == 0) {
>>  /* Child: do execveat(). */
>>  rc = execveat_(fd, path, argv, envp, flags);
>> -printf("[FAIL]: execveat() failed, rc=%d errno=%d (%s)\n",
>> +ksft_exit_fail_msg("execveat() failed, rc=%d errno=%d (%s)\n",
>>  rc, errno, strerror(errno));
>>  exit(1);  /* should not reach here */
>>  }
>>  /* Parent: wait for & check child's exit status. */
>>  rc = waitpid(child, &status, 0);
>>  if (rc != child) {
>> -printf("[FAIL] (waitpid(%d,...) returned %d)\n", child, rc);
>> +ksft_test_result_fail(msg);
>> +ksft_print_msg("waitpid(%d,...) returned %d\n", child, r

Re: [PATCH 1/5] of: Add vendor prefix for Adaptrum, Inc.

2017-07-29 Thread Andreas Färber
Hi Alexandru,

Am 29.07.2017 um 00:07 schrieb Alexandru Gagniuc:
> Signed-off-by: Alexandru Gagniuc 
> ---
>  Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
>  1 file changed, 1 insertion(+)

Not sure why I'm CC'ed here, but it looks sane, so

Reviewed-by: Andreas Färber 

If this patch gets respun, please add a sentence about your company to
the commit message. I also think "dt-bindings:" is a more common prefix?

Cheers,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)


Re: wake_wide mechanism clarification

2017-07-29 Thread Mike Galbraith
On Sat, 2017-07-29 at 01:01 -0700, Joel Fernandes wrote:
> Hi Mike,
> 
> I have take spent some time understanding the email thread and
> previous discussions. Unfortunately the second condition we are
> checking for in the wake_wide still didn't make sense to me (mentioned
> below) :-(
> 
> On Fri, Jun 30, 2017 at 10:02 AM, Mike Galbraith
>  wrote:
> > On Fri, 2017-06-30 at 10:28 -0400, Josef Bacik wrote:
> >> On Thu, Jun 29, 2017 at 08:04:59PM -0700, Joel Fernandes wrote:
> >>
> >> > That makes sense that we multiply slave's flips by a factor because
> >> > its low, but I still didn't get why the factor is chosen to be
> >> > llc_size instead of something else for the multiplication with slave
> >> > (slave * factor).
> >
> >> Yeah I don't know why llc_size was chosen...
> >
> > static void update_top_cache_domain(int cpu)
> > {
> > struct sched_domain_shared *sds = NULL;
> > struct sched_domain *sd;
> > int id = cpu;
> > int size = 1;
> >
> > sd = highest_flag_domain(cpu, SD_SHARE_PKG_RESOURCES);
> > if (sd) {
> > id = cpumask_first(sched_domain_span(sd));
> > size = cpumask_weight(sched_domain_span(sd));
> > sds = sd->shared;
> > }
> >
> > rcu_assign_pointer(per_cpu(sd_llc, cpu), sd);
> > per_cpu(sd_llc_size, cpu) = size;
> >
> > The goal of wake wide was to approximate when pulling would be a futile
> > consolidation effort and counterproductive to scaling.  'course with
> > ever increasing socket size, any 1:N waker is ever more likely to run
> > out of CPU for its one and only self (slamming into scaling wall)
> > before it needing to turn its minions loose to conquer the world.
> 
> Actually the original question was why do we have the second condition
> as "master < slave * factor", instead of "master < factor". that's
> what didn't make sense to me. Why don't we return 0 from wake_wide if
> master < factor ?
> 
> Infact, as the factor is set to the llc_size, I think the condition
> that makes sense to me is:
> 
> if ((master + slave) < llc_size)
>   return 0;

That says to me turn affine wakeups off for nearly everything.

> In other words, if the master flips and the slave flips are totally
> higher than the llc_size, then we are most likely waking up too many
> tasks as affine and should then switch to wide to prevent overloading.

The heuristic is mostly about the ratio of flip counts.

> Digging further into the original patch from Michael Wang (I also CC'd
> him), this was the code (before you had changed it to master/slave):
> 
> wakee->nr_wakee_switch > factor &&
> waker->nr_wakee_switch > (factor * wakee->nr_wakee_switch)

Yeah, it was originally unidirectional.

> To explain the second condition above, Michael Wang said the following in [1]
> 
> "Furthermore, if waker also has a high 'nr_wakee_switch', imply that multiple
> tasks rely on it, then waker's higher latency will damage all of them, pull
> wakee seems to be a bad deal."

Yes, "Furthermore". To detect 1:N, Michael chose llc_size as his N.  Is
the one flipping partners at least N/s, and the other about N times as
often?  If so, the two may be part of a too big to wisely pull 1:N.

If you have a better idea, by all means, pull it out.  Nobody is
attached to wake_wide(), in fact, I suspect Peter hates it.  I'm not
fond of it either, it having obvious holes.  The only thing it has
going for it is simplicity.  Bend it up, replace it, fire away.
  
> Again I didn't follow why the second condition couldn't just be:
> waker->nr_wakee_switch > factor, or, (waker->nr_wakee_switch +
> wakee->nr_wakee_switch) > factor, based on the above explanation from
> Micheal Wang that I quoted.
> and why he's instead doing the whole multiplication thing there that I
> was talking about earlier: "factor * wakee->nr_wakee_switch".
> 
> Rephrasing my question in another way, why are we talking the ratio of
> master/slave instead of the sum when comparing if its > factor? I am
> surely missing something here.

Because the heuristic tries to not demolish 1:1 buddies.  Big partner
flip delta means the pair are unlikely to be a communicating pair,
perhaps at high frequency where misses hurt like hell.

> Just taking an example:
> 
> Say we have llc_size = 3, we have 3 masters M1, M2 and M3. M1 has 8
> slaves, M2 has 4 slaves and M3 has 4 slaves. Only 1 slave is common
> between all 3 masters. Also to make it a bit more interesting, let s8
> wake up some random task T0. A diagram to show the master/slave
> relation ships could look like:

I don't need the artwork, as soon as you describe a squid orgie in a
bucket with no adult supervision, I can visualize what happens: the
load balancer tries to make pedantically perfect load numbers, caring
not one whit about any of the relationships in either text or graphic
description, stirs bucket vigorously, making squid soup.

IMHO, placement optimization of that is a job for a human, the
scheduler a

Re: [RESEND PATCH 2/6] ipc: mqueue: Replace timespec with timespec64

2017-07-29 Thread Richard Guy Briggs
On 2017-07-28 11:52, Deepa Dinamani wrote:
> struct timespec is not y2038 safe. Replace
> all uses of timespec by y2038 safe struct timespec64.
> 
> Even though timespec is used here to represent timeouts,
> replace these with timespec64 so that it facilitates
> in verification by creating a y2038 safe kernel image
> that is free of timespec.
> 
> The syscall interfaces themselves are not changed as part
> of the patch. They will be part of a different series.
> 
> Signed-off-by: Deepa Dinamani 
> Cc: Paul Moore 
> Cc: Richard Guy Briggs 

Looks reasonable to me.
Reviewed-by: Richard Guy Briggs 

> ---
>  include/linux/audit.h |  6 +++---
>  ipc/mqueue.c  | 28 ++--
>  kernel/audit.h|  2 +-
>  kernel/auditsc.c  | 12 ++--
>  4 files changed, 24 insertions(+), 24 deletions(-)
> 
> diff --git a/include/linux/audit.h b/include/linux/audit.h
> index 2150bdccfbab..74d4d4e8e3db 100644
> --- a/include/linux/audit.h
> +++ b/include/linux/audit.h
> @@ -351,7 +351,7 @@ extern int __audit_socketcall(int nargs, unsigned long 
> *args);
>  extern int __audit_sockaddr(int len, void *addr);
>  extern void __audit_fd_pair(int fd1, int fd2);
>  extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr);
> -extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int 
> msg_prio, const struct timespec *abs_timeout);
> +extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int 
> msg_prio, const struct timespec64 *abs_timeout);
>  extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent 
> *notification);
>  extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
>  extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
> @@ -412,7 +412,7 @@ static inline void audit_mq_open(int oflag, umode_t mode, 
> struct mq_attr *attr)
>   if (unlikely(!audit_dummy_context()))
>   __audit_mq_open(oflag, mode, attr);
>  }
> -static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned 
> int msg_prio, const struct timespec *abs_timeout)
> +static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned 
> int msg_prio, const struct timespec64 *abs_timeout)
>  {
>   if (unlikely(!audit_dummy_context()))
>   __audit_mq_sendrecv(mqdes, msg_len, msg_prio, abs_timeout);
> @@ -549,7 +549,7 @@ static inline void audit_mq_open(int oflag, umode_t mode, 
> struct mq_attr *attr)
>  { }
>  static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len,
>unsigned int msg_prio,
> -  const struct timespec *abs_timeout)
> +  const struct timespec64 *abs_timeout)
>  { }
>  static inline void audit_mq_notify(mqd_t mqdes,
>  const struct sigevent *notification)
> diff --git a/ipc/mqueue.c b/ipc/mqueue.c
> index c9ff943f19ab..5be1346a9167 100644
> --- a/ipc/mqueue.c
> +++ b/ipc/mqueue.c
> @@ -668,11 +668,11 @@ static void __do_notify(struct mqueue_inode_info *info)
>  }
>  
>  static int prepare_timeout(const struct timespec __user *u_abs_timeout,
> -struct timespec *ts)
> +struct timespec64 *ts)
>  {
> - if (copy_from_user(ts, u_abs_timeout, sizeof(struct timespec)))
> + if (get_timespec64(ts, u_abs_timeout))
>   return -EFAULT;
> - if (!timespec_valid(ts))
> + if (!timespec64_valid(ts))
>   return -EINVAL;
>   return 0;
>  }
> @@ -962,7 +962,7 @@ static inline void pipelined_receive(struct wake_q_head 
> *wake_q,
>  
>  static int do_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr,
>   size_t msg_len, unsigned int msg_prio,
> - struct timespec *ts)
> + struct timespec64 *ts)
>  {
>   struct fd f;
>   struct inode *inode;
> @@ -979,7 +979,7 @@ static int do_mq_timedsend(mqd_t mqdes, const char __user 
> *u_msg_ptr,
>   return -EINVAL;
>  
>   if (ts) {
> - expires = timespec_to_ktime(*ts);
> + expires = timespec64_to_ktime(*ts);
>   timeout = &expires;
>   }
>  
> @@ -1080,7 +1080,7 @@ static int do_mq_timedsend(mqd_t mqdes, const char 
> __user *u_msg_ptr,
>  
>  static int do_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr,
>   size_t msg_len, unsigned int __user *u_msg_prio,
> - struct timespec *ts)
> + struct timespec64 *ts)
>  {
>   ssize_t ret;
>   struct msg_msg *msg_ptr;
> @@ -1092,7 +1092,7 @@ static int do_mq_timedreceive(mqd_t mqdes, char __user 
> *u_msg_ptr,
>   struct posix_msg_tree_node *new_leaf = NULL;
>  
>   if (ts) {
> - expires = timespec_to_ktime(*ts);
> + expires = timespec64_to_ktime(*ts);
>   timeout = &expires;
>   }
>  
> @@ -1184,7 +1184,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char 
> __user *, u_msg_ptr,
> 

Re: Yes you have standing to sue GRSecurity

2017-07-29 Thread Paul G. Allen
I have not contributed to the kernel for some time (I have been
working on some stuff, but nothing that's been contributed), so I
don't know if any of my code would be infringed (or if it's even in
the latest kernels).

My work was on AGP and VIA drivers, so I am wondering if GRSecurity's
patches affect that code?

Thanks,

PGA

On Sat, Jul 29, 2017 at 7:06 AM,   wrote:
> It has come to my attention that some entities are claiming that you, dear
> Linux Hackers, (1)need to go through some foundation or get some permission
> from upon high in-order to sue the progenitors of GRSecurity for their
> violation of section 6 of the terms underwhich the linux kernel is
> distributed (version 2 of the GPL). And, furthermore, that (2)this
> foundation has no intention of bringing such a suit.
>
> (1) is false.
> (2) may very well be true.
>
> You do have standing to sue GRSecurity for their blatant continuing
> copyright violation if GRSecurity has made a derivative work of your code
> contribution to the Linux Kernel as-long as (a)you have not assigned your
> copyrights, and (b)you are not a work-for-hire.
>
> How do you know if you are a work for hire or if you have signed away your
> copyrights?
> If you are working for a company and as your job duties you are programming
> the linux kernel, there is a good chance that you are a work for hire and
> thus the company owns said copyrights.
>
> How do you know if you signed away your copyrights? Well if you singed a
> document transferring ownership of your copyrights for the code you produced
> at some point.
>
> If you are not working for a company while hacking linux and you haven't
> assigned your copyrights away then YOU OWN YOUR CONTRIBUTIONS.
>
> This means most of you hobby hackers, if GRSecurity has modified your code,
> YES YOU HAVE STANDING TO SUE.
>
> Yes your "betters" are lying to you.
> You have individual separate standing to sue.
>
> Yes you SHOULD consult a lawyer of your own.
> Yes you SHOULD consider a joint filing with other individual rights-holders
> willing to bring suit against GRSecurity for their blatant violation of your
> terms, and yes you should consider starting CLASS ACTION since the number of
> Linux Kernel Contributors seemingly numbers in the multitudes upon
> multitudes upon multitudes.
>
> And yes, I am an attorney.
> But no, I'm not looking for clients. Just correcting some false information
> that has been spreading.
>
> And yes, GRSecurity will try to claim that the linux-kernel is a work of
> Joint ownership (so as to shield themselves via procedural law) and yes they
> will try to claim fair use (probably de minimus), and yes your Lawyer will
> have to respond to these claims. The Joint ownership claim will go down
> quickly but it will have to be responded to. De minimus Fair Use depends on
> how much code is modified and how signifigant the modifications are. Don't
> let anyone but your own legal council dissuade you from bringing suit:
> Remember the statute of limitations is only a few years, so the clock is
> ticking on the CURRENT violation.
>
> Also make sure you register your copyright of the version of the
> linux-kernel that GRSecurity is using in its violation prior to bringing
> suit. The registration must be for the specific version. Yes you can
> register after the violation has occurred, however if you have registered
> before the violation then you can also pursue recovery of legal fees, pursue
> statutory damages, etc.
>
>
> ( NOTE: If you would like to read on how your copyright is being violated by
> GRSecurity, Bruce Perens posted a good write-up on his web-page )
> (
> perens.com/blog/2017/06/28/warning-grsecurity-potential-contributory-infringement-risk-for-customers/
> )
> ( There was also a discussion on the linux section of slashdot, and on the
> debian user mailing list, and on the dng devuan mailing list and on the
> openwall mailing list and the fedora legal mailing list )
>



-- 
Paul G. Allen, BSIT/SE
Owner, Sr. Engineer
Random Logic Consulting
www.randomlogic.com


blk-mq breaks suspend even with runtime PM patch

2017-07-29 Thread Oleksandr Natalenko
Hello Jens, Christoph.

Unfortunately, even with "block: disable runtime-pm for blk-mq" patch applied 
blk-mq breaks suspend to RAM for me. It is reproducible on my laptop as well 
as in a VM.

I use complex disk layout involving MD, LUKS and LVM, and managed to get these 
warnings from VM via serial console when suspend fails:

===
[  245.516573] INFO: task kworker/0:1:49 blocked for more than 120 seconds.
[  245.520025]   Not tainted 4.12.0-pf4 #1
[  245.521836] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables 
this message.
[  245.525612] kworker/0:1 D049  2 0x
[  245.527515] Workqueue: events vmstat_shepherd
[  245.528685] Call Trace:
[  245.529296]  __schedule+0x459/0xe40
[  245.530115]  ? kvm_clock_read+0x25/0x40
[  245.531003]  ? ktime_get+0x40/0xa0
[  245.531819]  schedule+0x3d/0xb0
[  245.532542]  ? schedule+0x3d/0xb0
[  245.533299]  schedule_preempt_disabled+0x15/0x20
[  245.534367]  __mutex_lock.isra.5+0x295/0x530
[  245.535351]  __mutex_lock_slowpath+0x13/0x20
[  245.536362]  ? __mutex_lock_slowpath+0x13/0x20
[  245.537334]  mutex_lock+0x25/0x30
[  245.538118]  get_online_cpus.part.14+0x15/0x30
[  245.539588]  get_online_cpus+0x20/0x30
[  245.540560]  vmstat_shepherd+0x21/0xc0
[  245.541538]  process_one_work+0x1de/0x430
[  245.542364]  worker_thread+0x47/0x3f0
[  245.543042]  kthread+0x125/0x140
[  245.543649]  ? process_one_work+0x430/0x430
[  245.544417]  ? kthread_create_on_node+0x70/0x70
[  245.545737]  ret_from_fork+0x25/0x30
[  245.546490] INFO: task md0_raid10:459 blocked for more than 120 seconds.
[  245.547668]   Not tainted 4.12.0-pf4 #1
[  245.548769] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables 
this message.
[  245.550133] md0_raid10  D0   459  2 0x
[  245.551092] Call Trace:
[  245.551539]  __schedule+0x459/0xe40
[  245.552163]  schedule+0x3d/0xb0
[  245.552728]  ? schedule+0x3d/0xb0
[  245.553344]  md_super_wait+0x6e/0xa0 [md_mod]
[  245.554118]  ? wake_bit_function+0x60/0x60
[  245.554854]  md_update_sb.part.60+0x3df/0x840 [md_mod]
[  245.555771]  md_check_recovery+0x215/0x4b0 [md_mod]
[  245.556732]  raid10d+0x62/0x13c0 [raid10]
[  245.557456]  ? schedule+0x3d/0xb0
[  245.558169]  ? schedule+0x3d/0xb0
[  245.558803]  ? schedule_timeout+0x21f/0x330
[  245.559593]  md_thread+0x120/0x160 [md_mod]
[  245.560380]  ? md_thread+0x120/0x160 [md_mod]
[  245.561202]  ? wake_bit_function+0x60/0x60
[  245.561975]  kthread+0x125/0x140
[  245.562601]  ? find_pers+0x70/0x70 [md_mod]
[  245.563394]  ? kthread_create_on_node+0x70/0x70
[  245.564516]  ret_from_fork+0x25/0x30
[  245.565669] INFO: task dmcrypt_write:487 blocked for more than 120 seconds.
[  245.567151]   Not tainted 4.12.0-pf4 #1
[  245.567946] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables 
this message.
[  245.569390] dmcrypt_write   D0   487  2 0x
[  245.570352] Call Trace:
[  245.570801]  __schedule+0x459/0xe40
[  245.571601]  ? preempt_schedule_common+0x1f/0x30
[  245.572421]  ? ___preempt_schedule+0x16/0x18
[  245.573168]  schedule+0x3d/0xb0
[  245.573733]  ? schedule+0x3d/0xb0
[  245.574378]  md_write_start+0xe3/0x270 [md_mod]
[  245.575180]  ? wake_bit_function+0x60/0x60
[  245.575915]  raid10_make_request+0x3f/0x140 [raid10]
[  245.576827]  md_make_request+0xa9/0x2a0 [md_mod]
[  245.577659]  generic_make_request+0x11e/0x2f0
[  245.578464]  dmcrypt_write+0x22d/0x250 [dm_crypt]
[  245.579288]  ? dmcrypt_write+0x22d/0x250 [dm_crypt]
[  245.580183]  ? wake_up_process+0x20/0x20
[  245.580875]  kthread+0x125/0x140
[  245.581455]  ? kthread+0x125/0x140
[  245.582064]  ? crypt_iv_essiv_dtr+0x70/0x70 [dm_crypt]
[  245.582971]  ? kthread_create_on_node+0x70/0x70
[  245.583772]  ret_from_fork+0x25/0x30
[  245.584424] INFO: task btrfs-transacti:553 blocked for more than 120 
seconds.
[  245.585830]   Not tainted 4.12.0-pf4 #1
[  245.586596] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables 
this message.
[  245.587947] btrfs-transacti D0   553  2 0x
[  245.588922] Call Trace:
[  245.589377]  __schedule+0x459/0xe40
[  245.590062]  ? btrfs_submit_bio_hook+0x8c/0x180 [btrfs]
[  245.590976]  schedule+0x3d/0xb0
[  245.591538]  ? schedule+0x3d/0xb0
[  245.592175]  io_schedule+0x16/0x40
[  245.592794]  wait_on_page_bit_common+0xe3/0x180
[  245.593589]  ? page_cache_tree_insert+0xc0/0xc0
[  245.594387]  __filemap_fdatawait_range+0x12a/0x1a0
[  245.595229]  filemap_fdatawait_range+0x14/0x30
[  245.596033]  btrfs_wait_ordered_range+0x6b/0x110 [btrfs]
[  245.596998]  ? _raw_spin_unlock+0x10/0x30
[  245.597735]  __btrfs_wait_cache_io+0x45/0x1c0 [btrfs]
[  245.599091]  btrfs_wait_cache_io+0x2c/0x30 [btrfs]
[  245.600789]  btrfs_write_dirty_block_groups+0x206/0x390 [btrfs]
[  245.602068]  commit_cowonly_roots+0x221/0x2c0 [btrfs]
[  245.602981]  btrfs_commit_transaction+0x3c4/0x900 [btrfs]
[  245.603940]  transaction_kthread+0x190/0x1c0 [btrfs]
[  245.604806]  kthread+0x125/0x140
[  245.605398]  ? btrfs_clean

[PATCH] net-next: stmmac: dwmac-sun8i: fix of_table.cocci warnings

2017-07-29 Thread Julia Lawall
Make sure (of/i2c/platform)_device_id tables are NULL terminated

Generated by: scripts/coccinelle/misc/of_table.cocci

Fixes: d5dbe1976d52 ("net-next: stmmac: dwmac-sun8i: choose internal PHY via 
compatible")
CC: Corentin Labbe 
Signed-off-by: Fengguang Wu 
---

url:
https://github.com/0day-ci/linux/commits/Corentin-Labbe/dt-bindings-net-add-compatible-for-internal-sun8i-h3-sun8i-v3s-PHYs/20170729-174950
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next

 dwmac-sun8i.c |1 +
 1 file changed, 1 insertion(+)

--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -892,6 +892,7 @@ static int sun8i_dwmac_probe(struct plat
static const struct of_device_id internal_phys[] = {
{ .compatible = "allwinner,sun8i-h3-ephy" },
{ .compatible = "allwinner,sun8i-v3s-ephy" },
+   {},
};

ret = stmmac_get_platform_resources(pdev, &stmmac_res);


MikeeUSA warning (Re: Yes you have standing to sue GRSecurity.)

2017-07-29 Thread Adam Borowski
Note that this is quite clearly yet another of MikeeUSA's sockpuppets.  And
you guys really don't want to be caught in another of his troll threads.

Yeah, GRsecurity is a problem, but don't let our dear Mikee milk it.


-- 
⢀⣴⠾⠻⢶⣦⠀ What Would Jesus Do, MUD/MMORPG edition:
⣾⠁⢰⠒⠀⣿⡁ • multiplay with an admin char to benefit your mortal
⢿⡄⠘⠷⠚⠋⠀ • abuse item cloning bugs (the five fishes + two breads affair)
⠈⠳⣄ • use glitches to walk on water


Re: [PATCH v2 02/10] drivers/hwmon/occ: Add command transport method for P8 and P9

2017-07-29 Thread kbuild test robot
Hi Edward,

[auto build test ERROR on hwmon/hwmon-next]
[also build test ERROR on v4.13-rc2 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Eddie-James/drivers-hwmon-Add-On-Chip-Controller-OCC-hwmon-driver/20170729-233004
base:   
https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git 
hwmon-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

>> drivers/hwmon/occ/p8_i2c.c:14:23: fatal error: linux/occ.h: No such file or 
>> directory
#include 
  ^
   compilation terminated.

vim +14 drivers/hwmon/occ/p8_i2c.c

  > 14  #include 
15  #include 
16  #include 
17  

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


.config.gz
Description: application/gzip


[PATCH] md: replace seq_release_private with seq_release

2017-07-29 Thread Cihangir Akturk
Since commit f15146380d28 ("fs: seq_file - add event counter to simplify
poll() support"), md.c code has been no longer used the private field of
the struct seq_file, but seq_release_private() has been continued to be
used to release the allocated seq_file. This seems to have been
forgotten. So convert it to use seq_release() instead of
seq_release_private().

Signed-off-by: Cihangir Akturk 
---
 drivers/md/md.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 8cdca029..6174360 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7836,7 +7836,7 @@ static const struct file_operations md_seq_fops = {
.open   = md_seq_open,
.read   = seq_read,
.llseek = seq_lseek,
-   .release= seq_release_private,
+   .release= seq_release,
.poll   = mdstat_poll,
 };
 
-- 
2.7.4



  1   2   >