[PATCH] irq: fix comment typo on irq_thread_check_affinity

2013-04-02 Thread Kefeng Wang
The CONFIG CPU_MASK_OFFSTACK mentioned should be CPUMASK_OFFSTACK,
and fix a misspelling.

Signed-off-by: Kefeng Wang 
---
 kernel/irq/manage.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index fa17855..78c6d0f 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -727,7 +727,7 @@ out_unlock:
 
 #ifdef CONFIG_SMP
 /*
- * Check whether we need to chasnge the affinity of the interrupt thread.
+ * Check whether we need to change the affinity of the interrupt thread.
  */
 static void
 irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
@@ -750,7 +750,7 @@ irq_thread_check_affinity(struct irq_desc *desc, struct 
irqaction *action)
raw_spin_lock_irq(&desc->lock);
/*
 * This code is triggered unconditionally. Check the affinity
-* mask pointer. For CPU_MASK_OFFSTACK=n this is optimized out.
+* mask pointer. For CPUMASK_OFFSTACK=n this is optimized out.
 */
if (desc->irq_data.affinity)
cpumask_copy(mask, desc->irq_data.affinity);
-- 
1.6.0.2


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/7] irq: fix checkpatch error

2013-06-06 Thread Kefeng Wang
ERROR: space required before the open parenthesis '('
WARNING: Prefer pr_warn(... to pr_warning(...
Just fix above 2 issue.

Signed-off-by: Kefeng Wang 
---
 kernel/irq/irqdomain.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 5a83dde..fd47f33 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -419,7 +419,7 @@ static void irq_domain_disassociate_many(struct irq_domain 
*domain,
irq_data->hwirq = 0;
 
/* Clear reverse map */
-   switch(domain->revmap_type) {
+   switch (domain->revmap_type) {
case IRQ_DOMAIN_MAP_LINEAR:
if (hwirq < domain->revmap_data.linear.size)
domain->revmap_data.linear.revmap[hwirq] = 0;
@@ -570,7 +570,7 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
if (domain == NULL)
domain = irq_default_domain;
if (domain == NULL) {
-   pr_warning("irq_create_mapping called for"
+   pr_warn("irq_create_mapping called for"
   " NULL domain, hwirq=%lx\n", hwirq);
WARN_ON(1);
return 0;
@@ -672,7 +672,7 @@ unsigned int irq_create_of_mapping(struct device_node 
*controller,
if (intsize > 0)
return intspec[0];
 #endif
-   pr_warning("no irq domain found for %s !\n",
+   pr_warn("no irq domain found for %s !\n",
   of_node_full_name(controller));
return 0;
}
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 7/7] irq: fix all checkpatch errors and warnings

2013-06-06 Thread Kefeng Wang
Fix following issue, and use pr_foo().
WARNING: line over 80 characters
ERROR: spaces required around that '>=' (ctx:WxV)

Signed-off-by: Kefeng Wang 
---
 kernel/irq/irqdesc.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 192a302..9ba01f5 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -7,6 +7,9 @@
  * Detailed information is available in Documentation/DocBook/genericirq
  *
  */
+
+#define pr_fmt(fmt)  "NR_IRQS: " fmt
+
 #include 
 #include 
 #include 
@@ -219,7 +222,7 @@ int __init early_irq_init(void)
 
/* Let arch update nr_irqs and return the nr of preallocated irqs */
initcnt = arch_probe_nr_irqs();
-   printk(KERN_INFO "NR_IRQS:%d nr_irqs:%d %d\n", NR_IRQS, nr_irqs, 
initcnt);
+   pr_info("%d nr_irqs:%d %d\n", NR_IRQS, nr_irqs, initcnt);
 
if (WARN_ON(nr_irqs > IRQ_BITMAP_BITS))
nr_irqs = IRQ_BITMAP_BITS;
@@ -255,7 +258,7 @@ int __init early_irq_init(void)
 
init_irq_default_affinity();
 
-   printk(KERN_INFO "NR_IRQS:%d\n", NR_IRQS);
+   pr_info("%d\n", NR_IRQS);
 
desc = irq_desc;
count = ARRAY_SIZE(irq_desc);
@@ -369,7 +372,7 @@ __irq_alloc_descs(int irq, unsigned int from, unsigned int 
cnt, int node,
start = bitmap_find_next_zero_area(allocated_irqs, IRQ_BITMAP_BITS,
   from, cnt, 0);
ret = -EEXIST;
-   if (irq >=0 && start != irq)
+   if (irq >= 0 && start != irq)
goto err;
 
if (start + cnt > nr_irqs) {
@@ -404,7 +407,8 @@ int irq_reserve_irqs(unsigned int from, unsigned int cnt)
return -EINVAL;
 
mutex_lock(&sparse_irq_lock);
-   start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 
0);
+   start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs,
+   from, cnt, 0);
if (start == from)
bitmap_set(allocated_irqs, start, cnt);
else
@@ -465,7 +469,8 @@ int irq_set_percpu_devid(unsigned int irq)
if (desc->percpu_enabled)
return -EINVAL;
 
-   desc->percpu_enabled = kzalloc(sizeof(*desc->percpu_enabled), 
GFP_KERNEL);
+   desc->percpu_enabled = kzalloc(sizeof(*desc->percpu_enabled),
+   GFP_KERNEL);
 
if (!desc->percpu_enabled)
return -ENOMEM;
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/7] irq: fix all checkpatch errors and warnings

2013-06-06 Thread Kefeng Wang
Fixes following errors and warnings:
WARNING: line over 80 characters
ERROR: spaces required around that '=' (ctx:WxV)
WARNING: Avoid unnecessary line continuations
WARNING: Prefer pr_warn(... to pr_warning(...
WARNING: suspect code indent for conditional statements (8, 12)

Signed-off-by: Kefeng Wang 
---
 kernel/irq/manage.c | 31 +++
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index fa17855..0d6446e 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -211,7 +211,8 @@ int irq_set_affinity(unsigned int irq, const struct cpumask 
*mask)
 int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
 {
unsigned long flags;
-   struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 
IRQ_GET_DESC_CHECK_GLOBAL);
+   struct irq_desc *desc = irq_get_desc_lock(irq, &flags,
+   IRQ_GET_DESC_CHECK_GLOBAL);
 
if (!desc)
return -EINVAL;
@@ -372,7 +373,8 @@ void __disable_irq(struct irq_desc *desc, unsigned int irq, 
bool suspend)
 static int __disable_irq_nosync(unsigned int irq)
 {
unsigned long flags;
-   struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, 
IRQ_GET_DESC_CHECK_GLOBAL);
+   struct irq_desc *desc = irq_get_desc_buslock(irq, &flags,
+   IRQ_GET_DESC_CHECK_GLOBAL);
 
if (!desc)
return -EINVAL;
@@ -464,7 +466,8 @@ void __enable_irq(struct irq_desc *desc, unsigned int irq, 
bool resume)
 void enable_irq(unsigned int irq)
 {
unsigned long flags;
-   struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, 
IRQ_GET_DESC_CHECK_GLOBAL);
+   struct irq_desc *desc = irq_get_desc_buslock(irq, &flags,
+   IRQ_GET_DESC_CHECK_GLOBAL);
 
if (!desc)
return;
@@ -507,7 +510,8 @@ static int set_irq_wake_real(unsigned int irq, unsigned int 
on)
 int irq_set_irq_wake(unsigned int irq, unsigned int on)
 {
unsigned long flags;
-   struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, 
IRQ_GET_DESC_CHECK_GLOBAL);
+   struct irq_desc *desc = irq_get_desc_buslock(irq, &flags,
+   IRQ_GET_DESC_CHECK_GLOBAL);
int ret = 0;
 
if (!desc)
@@ -557,7 +561,7 @@ int can_request_irq(unsigned int irq, unsigned long 
irqflags)
if (irq_settings_can_request(desc)) {
if (desc->action)
if (irqflags & desc->action->flags & IRQF_SHARED)
-   canrequest =1;
+   canrequest = 1;
}
irq_put_desc_unlock(desc, flags);
return canrequest;
@@ -1102,7 +1106,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, 
struct irqaction *new)
goto out_mask;
}
 
-   desc->istate &= ~(IRQS_AUTODETECT | IRQS_SPURIOUS_DISABLED | \
+   desc->istate &= ~(IRQS_AUTODETECT | IRQS_SPURIOUS_DISABLED |
  IRQS_ONESHOT | IRQS_WAITING);
irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS);
 
@@ -1135,7 +1139,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, 
struct irqaction *new)
 
if (nmsk != omsk)
/* hope the handler works with current  trigger mode */
-   pr_warning("irq %d uses trigger mode %u; requested 
%u\n",
+   pr_warn("irq %d uses trigger mode %u; requested %u\n",
   irq, nmsk, omsk);
}
 
@@ -1314,7 +1318,7 @@ void remove_irq(unsigned int irq, struct irqaction *act)
struct irq_desc *desc = irq_to_desc(irq);
 
if (desc && !WARN_ON(irq_settings_is_per_cpu_devid(desc)))
-   __free_irq(irq, act->dev_id);
+   __free_irq(irq, act->dev_id);
 }
 EXPORT_SYMBOL_GPL(remove_irq);
 
@@ -1504,7 +1508,8 @@ void enable_percpu_irq(unsigned int irq, unsigned int 
type)
 {
unsigned int cpu = smp_processor_id();
unsigned long flags;
-   struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 
IRQ_GET_DESC_CHECK_PERCPU);
+   struct irq_desc *desc = irq_get_desc_lock(irq, &flags,
+   IRQ_GET_DESC_CHECK_PERCPU);
 
if (!desc)
return;
@@ -1531,7 +1536,8 @@ void disable_percpu_irq(unsigned int irq)
 {
unsigned int cpu = smp_processor_id();
unsigned long flags;
-   struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 
IRQ_GET_DESC_CHECK_PERCPU);
+   struct irq_desc *desc = irq_get_desc_lock(irq, &flags,
+   IRQ_GET_DESC_CHECK_PERCPU);
 
if (!desc)
return;
@@ -1544,7 +1550,8 @

[PATCH 1/7] irq: fix checkpatch warnings

2013-06-06 Thread Kefeng Wang
Fixes line over 80 characters warnings.

Signed-off-by: Kefeng Wang 
---
 kernel/irq/chip.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index cbd97ce..f19865a 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -56,7 +56,8 @@ EXPORT_SYMBOL(irq_set_chip);
 int irq_set_irq_type(unsigned int irq, unsigned int type)
 {
unsigned long flags;
-   struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, 
IRQ_GET_DESC_CHECK_GLOBAL);
+   struct irq_desc *desc = irq_get_desc_buslock(irq, &flags,
+   IRQ_GET_DESC_CHECK_GLOBAL);
int ret = 0;
 
if (!desc)
@@ -101,7 +102,8 @@ int irq_set_msi_desc_off(unsigned int irq_base, unsigned 
int irq_offset,
 struct msi_desc *entry)
 {
unsigned long flags;
-   struct irq_desc *desc = irq_get_desc_lock(irq_base + irq_offset, 
&flags, IRQ_GET_DESC_CHECK_GLOBAL);
+   struct irq_desc *desc = irq_get_desc_lock(irq_base + irq_offset, &flags,
+   IRQ_GET_DESC_CHECK_GLOBAL);
 
if (!desc)
return -EINVAL;
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/7] irq: fix checkpatch errors and warnings

2013-06-06 Thread Kefeng Wang
Fix all the checkpath errors in kernel/irq dir, and some warnings
also fixed.

Kefeng Wang (7):
  irq: fix checkpatch warnings
  irq: fix checkpatch error
  irq: fix checkpatch error
  irq: fix all checkpatch errors and warnings
  irq: fix all checkpatch errors and warnings
  irq: fix checkpatch warnings
  irq: fix all checkpatch errors and warnings

 kernel/irq/chip.c  |  6 --
 kernel/irq/handle.c|  7 ---
 kernel/irq/irqdesc.c   | 15 ++-
 kernel/irq/irqdomain.c |  6 +++---
 kernel/irq/manage.c| 31 +++
 kernel/irq/proc.c  | 11 ++-
 kernel/irq/spurious.c  | 33 -
 7 files changed, 62 insertions(+), 47 deletions(-)

-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND] irq: fix typos around irq_thread_check_affinity

2013-06-06 Thread Kefeng Wang
The CONFIG CPU_MASK_OFFSTACK mentioned should be CPUMASK_OFFSTACK,
and fix a misspelling, chasnge -> change.

Signed-off-by: Kefeng Wang 
---
 kernel/irq/manage.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index fa17855..78c6d0f 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -727,7 +727,7 @@ out_unlock:
 
 #ifdef CONFIG_SMP
 /*
- * Check whether we need to chasnge the affinity of the interrupt thread.
+ * Check whether we need to change the affinity of the interrupt thread.
  */
 static void
 irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
@@ -750,7 +750,7 @@ irq_thread_check_affinity(struct irq_desc *desc, struct 
irqaction *action)
raw_spin_lock_irq(&desc->lock);
/*
 * This code is triggered unconditionally. Check the affinity
-* mask pointer. For CPU_MASK_OFFSTACK=n this is optimized out.
+* mask pointer. For CPUMASK_OFFSTACK=n this is optimized out.
 */
if (desc->irq_data.affinity)
cpumask_copy(mask, desc->irq_data.affinity);
-- 
1.8.2.2


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/7] irq: fix checkpatch warnings

2013-06-06 Thread Kefeng Wang
Fix line over and code indent warning, and use pr_foo().

Signed-off-by: Kefeng Wang 
---
 kernel/irq/spurious.c | 33 -
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
index 7b5f012..84cf547 100644
--- a/kernel/irq/spurious.c
+++ b/kernel/irq/spurious.c
@@ -68,7 +68,8 @@ static int try_one_irq(int irq, struct irq_desc *desc, bool 
force)
raw_spin_lock(&desc->lock);
 
/* PER_CPU and nested thread interrupts are never polled */
-   if (irq_settings_is_per_cpu(desc) || 
irq_settings_is_nested_thread(desc))
+   if (irq_settings_is_per_cpu(desc) ||
+   irq_settings_is_nested_thread(desc))
goto out;
 
/*
@@ -123,7 +124,7 @@ static int misrouted_irq(int irq)
 
for_each_irq_desc(i, desc) {
if (!i)
-continue;
+   continue;
 
if (i == irq)   /* Already tried */
continue;
@@ -150,7 +151,7 @@ static void poll_spurious_irqs(unsigned long dummy)
unsigned int state;
 
if (!i)
-continue;
+   continue;
 
/* Racy but it doesn't matter */
state = desc->istate;
@@ -191,14 +192,14 @@ __report_bad_irq(unsigned int irq, struct irq_desc *desc,
unsigned long flags;
 
if (bad_action_ret(action_ret)) {
-   printk(KERN_ERR "irq event %d: bogus return value %x\n",
+   pr_err("irq event %d: bogus return value %x\n",
irq, action_ret);
} else {
-   printk(KERN_ERR "irq %d: nobody cared (try booting with "
+   pr_err("irq %d: nobody cared (try booting with "
"the \"irqpoll\" option)\n", irq);
}
dump_stack();
-   printk(KERN_ERR "handlers:\n");
+   pr_err("handlers:\n");
 
/*
 * We need to take desc->lock here. note_interrupt() is called
@@ -209,11 +210,11 @@ __report_bad_irq(unsigned int irq, struct irq_desc *desc,
raw_spin_lock_irqsave(&desc->lock, flags);
action = desc->action;
while (action) {
-   printk(KERN_ERR "[<%p>] %pf", action->handler, action->handler);
+   pr_err("[<%p>] %pf", action->handler, action->handler);
if (action->thread_fn)
-   printk(KERN_CONT " threaded [<%p>] %pf",
+   pr_cont(" threaded [<%p>] %pf",
action->thread_fn, action->thread_fn);
-   printk(KERN_CONT "\n");
+   pr_cont("\n");
action = action->next;
}
raw_spin_unlock_irqrestore(&desc->lock, flags);
@@ -313,7 +314,7 @@ void note_interrupt(unsigned int irq, struct irq_desc *desc,
/*
 * Now kill the IRQ
 */
-   printk(KERN_EMERG "Disabling IRQ #%d\n", irq);
+   pr_emerg("Disabling IRQ #%d\n", irq);
desc->istate |= IRQS_SPURIOUS_DISABLED;
desc->depth++;
irq_disable(desc);
@@ -329,7 +330,7 @@ bool noirqdebug __read_mostly;
 int noirqdebug_setup(char *str)
 {
noirqdebug = 1;
-   printk(KERN_INFO "IRQ lockup detection disabled\n");
+   pr_info("IRQ lockup detection disabled\n");
 
return 1;
 }
@@ -341,8 +342,8 @@ MODULE_PARM_DESC(noirqdebug, "Disable irq lockup detection 
when true");
 static int __init irqfixup_setup(char *str)
 {
irqfixup = 1;
-   printk(KERN_WARNING "Misrouted IRQ fixup support enabled.\n");
-   printk(KERN_WARNING "This may impact system performance.\n");
+   pr_warn("Misrouted IRQ fixup support enabled.\n");
+   pr_warn("This may impact system performance.\n");
 
return 1;
 }
@@ -353,10 +354,8 @@ module_param(irqfixup, int, 0644);
 static int __init irqpoll_setup(char *str)
 {
irqfixup = 2;
-   printk(KERN_WARNING "Misrouted IRQ fixup and polling support "
-   "enabled\n");
-   printk(KERN_WARNING "This may significantly impact system "
-   "performance\n");
+   pr_warn("Misrouted IRQ fixup and polling support enabled\n");
+   pr_warn("This may significantly impact system performance\n");
return 1;
 }
 
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/7] irq: fix all checkpatch errors and warnings

2013-06-06 Thread Kefeng Wang
Fix following errors and warnings:
WARNING: space prohibited before semicolon
ERROR: space prohibited before open square bracket '['
WARNING: line over 80 characters

Signed-off-by: Kefeng Wang 
---
 kernel/irq/proc.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 19ed5c4..291e383 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -276,7 +276,7 @@ static int name_unique(unsigned int irq, struct irqaction 
*new_action)
int ret = 1;
 
raw_spin_lock_irqsave(&desc->lock, flags);
-   for (action = desc->action ; action; action = action->next) {
+   for (action = desc->action; action; action = action->next) {
if ((action != new_action) && action->name &&
!strcmp(new_action->name, action->name)) {
ret = 0;
@@ -289,7 +289,7 @@ static int name_unique(unsigned int irq, struct irqaction 
*new_action)
 
 void register_handler_proc(unsigned int irq, struct irqaction *action)
 {
-   char name [MAX_NAMELEN];
+   char name[MAX_NAMELEN];
struct irq_desc *desc = irq_to_desc(irq);
 
if (!desc->dir || action->dir || !action->name ||
@@ -309,7 +309,7 @@ void register_handler_proc(unsigned int irq, struct 
irqaction *action)
 
 void register_irq_proc(unsigned int irq, struct irq_desc *desc)
 {
-   char name [MAX_NAMELEN];
+   char name[MAX_NAMELEN];
 
if (!root_irq_dir || (desc->irq_data.chip == &no_irq_chip) || desc->dir)
return;
@@ -345,7 +345,7 @@ void register_irq_proc(unsigned int irq, struct irq_desc 
*desc)
 
 void unregister_irq_proc(unsigned int irq, struct irq_desc *desc)
 {
-   char name [MAX_NAMELEN];
+   char name[MAX_NAMELEN];
 
if (!root_irq_dir || !desc->dir)
return;
@@ -463,7 +463,8 @@ int show_interrupts(struct seq_file *p, void *v)
seq_printf(p, " %8s", "None");
}
 #ifdef CONFIG_GENERIC_IRQ_SHOW_LEVEL
-   seq_printf(p, " %-8s", irqd_is_level_type(&desc->irq_data) ? "Level" : 
"Edge");
+   seq_printf(p, " %-8s",
+   irqd_is_level_type(&desc->irq_data) ? "Level" : "Edge");
 #endif
if (desc->name)
seq_printf(p, "-%-8s", desc->name);
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/7] irq: fix checkpatch error

2013-06-06 Thread Kefeng Wang
Change printk(KERN_WARNING ... to pr_warn(...
Fix ERROR: space required after that ',' (ctx:VxV)

Signed-off-by: Kefeng Wang 
---
 kernel/irq/handle.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 131ca17..07a1c15 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -47,7 +47,7 @@ static void warn_no_thread(unsigned int irq, struct irqaction 
*action)
if (test_and_set_bit(IRQTF_WARNED, &action->thread_flags))
return;
 
-   printk(KERN_WARNING "IRQ %d device %s returned IRQ_WAKE_THREAD "
+   pr_warn("IRQ %d device %s returned IRQ_WAKE_THREAD "
   "but no thread function available.", irq, action->name);
 }
 
@@ -142,8 +142,9 @@ handle_irq_event_percpu(struct irq_desc *desc, struct 
irqaction *action)
res = action->handler(irq, action->dev_id);
trace_irq_handler_exit(irq, action, res);
 
-   if (WARN_ONCE(!irqs_disabled(),"irq %u handler %pF enabled 
interrupts\n",
- irq, action->handler))
+   if (WARN_ONCE(!irqs_disabled(),
+   "irq %u handler %pF enabled interrupts\n",
+   irq, action->handler))
local_irq_disable();
 
switch (res) {
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/5] scsi: sun: use module_platform_driver() and platform_{set,get}_drvdata

2013-05-30 Thread Kefeng Wang
Use helper macro and wrapper functions to simpily code. Meanwhile,
remove unnecessary drvdata set to null due to commint 0998d0631
(device-core: Ensure drvdata = NULL when no driver is bound).

Signed-off-by: Kefeng Wang 
---
 drivers/scsi/sun_esp.c | 19 +++
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/sun_esp.c b/drivers/scsi/sun_esp.c
index f2e6845..b7361a6 100644
--- a/drivers/scsi/sun_esp.c
+++ b/drivers/scsi/sun_esp.c
@@ -538,7 +538,7 @@ static int esp_sbus_probe_one(struct platform_device *op,
dma_write32(val & ~DMA_RST_SCSI, DMA_CSR);
}
 
-   dev_set_drvdata(&op->dev, esp);
+   platform_set_drvdata(op, esp);
 
err = scsi_esp_register(esp, &op->dev);
if (err)
@@ -585,7 +585,7 @@ static int esp_sbus_probe(struct platform_device *op)
 
 static int esp_sbus_remove(struct platform_device *op)
 {
-   struct esp *esp = dev_get_drvdata(&op->dev);
+   struct esp *esp = platform_get_drvdata(op);
struct platform_device *dma_of = esp->dma;
unsigned int irq = esp->host->irq;
bool is_hme;
@@ -611,8 +611,6 @@ static int esp_sbus_remove(struct platform_device *op)
 
scsi_host_put(esp->host);
 
-   dev_set_drvdata(&op->dev, NULL);
-
return 0;
 }
 
@@ -640,20 +638,9 @@ static struct platform_driver esp_sbus_driver = {
.remove = esp_sbus_remove,
 };
 
-static int __init sunesp_init(void)
-{
-   return platform_driver_register(&esp_sbus_driver);
-}
-
-static void __exit sunesp_exit(void)
-{
-   platform_driver_unregister(&esp_sbus_driver);
-}
+module_platform_driver(esp_sbus_driver);
 
 MODULE_DESCRIPTION("Sun ESP SCSI driver");
 MODULE_AUTHOR("David S. Miller (da...@davemloft.net)");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
-
-module_init(sunesp_init);
-module_exit(sunesp_exit);
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/5] scsi: jazz: use module_platform_driver() and platform_{set,get}_drvdata

2013-05-30 Thread Kefeng Wang
Use helper macro and wrapper functions to simpily code.

Signed-off-by: Kefeng Wang 
---
 drivers/scsi/jazz_esp.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/jazz_esp.c b/drivers/scsi/jazz_esp.c
index 69efbf1..08fa257 100644
--- a/drivers/scsi/jazz_esp.c
+++ b/drivers/scsi/jazz_esp.c
@@ -180,7 +180,7 @@ static int esp_jazz_probe(struct platform_device *dev)
esp->scsi_id_mask = (1 << esp->scsi_id);
esp->cfreq = 4000;
 
-   dev_set_drvdata(&dev->dev, esp);
+   platform_set_drvdata(dev, esp);
 
err = scsi_esp_register(esp, &dev->dev);
if (err)
@@ -203,7 +203,7 @@ fail:
 
 static int esp_jazz_remove(struct platform_device *dev)
 {
-   struct esp *esp = dev_get_drvdata(&dev->dev);
+   struct esp *esp = platform_get_drvdata(dev);
unsigned int irq = esp->host->irq;
 
scsi_esp_unregister(esp);
@@ -230,20 +230,9 @@ static struct platform_driver esp_jazz_driver = {
},
 };
 
-static int __init jazz_esp_init(void)
-{
-   return platform_driver_register(&esp_jazz_driver);
-}
-
-static void __exit jazz_esp_exit(void)
-{
-   platform_driver_unregister(&esp_jazz_driver);
-}
+module_platform_driver(esp_jazz_driver);
 
 MODULE_DESCRIPTION("JAZZ ESP SCSI driver");
 MODULE_AUTHOR("Thomas Bogendoerfer (tsbog...@alpha.franken.de)");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
-
-module_init(jazz_esp_init);
-module_exit(jazz_esp_exit);
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/5] scsi: sni: use module_platform_driver() and platform_{set,get}_drvdata

2013-05-30 Thread Kefeng Wang
Use helper macro and wrapper functions to simpily code.

Signed-off-by: Kefeng Wang 
---
 drivers/scsi/sni_53c710.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/sni_53c710.c b/drivers/scsi/sni_53c710.c
index 52d54e7..eff84c4 100644
--- a/drivers/scsi/sni_53c710.c
+++ b/drivers/scsi/sni_53c710.c
@@ -104,7 +104,7 @@ static int snirm710_probe(struct platform_device *dev)
goto out_put_host;
}
 
-   dev_set_drvdata(&dev->dev, host);
+   platform_set_drvdata(dev, host);
scsi_scan_host(host);
 
return 0;
@@ -119,7 +119,7 @@ static int snirm710_probe(struct platform_device *dev)
 
 static int __exit snirm710_driver_remove(struct platform_device *dev)
 {
-   struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
+   struct Scsi_Host *host = platform_get_drvdata(dev);
struct NCR_700_Host_Parameters *hostdata =
(struct NCR_700_Host_Parameters *)host->hostdata[0];
 
@@ -141,15 +141,4 @@ static struct platform_driver snirm710_driver = {
},
 };
 
-static int __init snirm710_init(void)
-{
-   return platform_driver_register(&snirm710_driver);
-}
-
-static void __exit snirm710_exit(void)
-{
-   platform_driver_unregister(&snirm710_driver);
-}
-
-module_init(snirm710_init);
-module_exit(snirm710_exit);
+module_platform_driver(snirm710_driver);
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5] scsi: qlogicpti: use module_platform_driver() and platform_{set,get}_drvdata

2013-05-30 Thread Kefeng Wang
Use helper macro and wrapper functions to simpily code.

Signed-off-by: Kefeng Wang 
---
 drivers/scsi/qlogicpti.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index 6d48d30..1349374 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -1367,7 +1367,7 @@ static int qpti_sbus_probe(struct platform_device *op)
goto fail_unmap_queues;
}
 
-   dev_set_drvdata(&op->dev, qpti);
+   platform_set_drvdata(op, qpti);
 
qpti_chain_add(qpti);
 
@@ -1404,7 +1404,7 @@ fail_unlink:
 
 static int qpti_sbus_remove(struct platform_device *op)
 {
-   struct qlogicpti *qpti = dev_get_drvdata(&op->dev);
+   struct qlogicpti *qpti = platform_get_drvdata(&op->dev);
 
qpti_chain_del(qpti);
 
@@ -1462,21 +1462,10 @@ static struct platform_driver qpti_sbus_driver = {
.remove = qpti_sbus_remove,
 };
 
-static int __init qpti_init(void)
-{
-   return platform_driver_register(&qpti_sbus_driver);
-}
-
-static void __exit qpti_exit(void)
-{
-   platform_driver_unregister(&qpti_sbus_driver);
-}
+module_platform_driver(qpti_sbus_driver);
 
 MODULE_DESCRIPTION("QlogicISP SBUS driver");
 MODULE_AUTHOR("David S. Miller (da...@davemloft.net)");
 MODULE_LICENSE("GPL");
 MODULE_VERSION("2.1");
 MODULE_FIRMWARE("qlogic/isp1000.bin");
-
-module_init(qpti_init);
-module_exit(qpti_exit);
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/5] scsi: sun3x: use module_platform_driver() and platform_{set,get}_drvdata

2013-05-30 Thread Kefeng Wang
Use helper macro and wrapper functions to simpily code.

Signed-off-by: Kefeng Wang 
---
 drivers/scsi/sun3x_esp.c | 16 +++-
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c
index 534eb96..4c9a2b4 100644
--- a/drivers/scsi/sun3x_esp.c
+++ b/drivers/scsi/sun3x_esp.c
@@ -244,7 +244,7 @@ static int esp_sun3x_probe(struct platform_device *dev)
esp->scsi_id_mask = (1 << esp->scsi_id);
esp->cfreq = 2000;
 
-   dev_set_drvdata(&dev->dev, esp);
+   platform_set_drvdata(dev, esp);
 
err = scsi_esp_register(esp, &dev->dev);
if (err)
@@ -270,7 +270,7 @@ fail:
 
 static int esp_sun3x_remove(struct platform_device *dev)
 {
-   struct esp *esp = dev_get_drvdata(&dev->dev);
+   struct esp *esp = platform_get_drvdata(dev);
unsigned int irq = esp->host->irq;
u32 val;
 
@@ -299,21 +299,11 @@ static struct platform_driver esp_sun3x_driver = {
},
 };
 
-static int __init sun3x_esp_init(void)
-{
-   return platform_driver_register(&esp_sun3x_driver);
-}
-
-static void __exit sun3x_esp_exit(void)
-{
-   platform_driver_unregister(&esp_sun3x_driver);
-}
+module_platform_driver(esp_sun3x_driver);
 
 MODULE_DESCRIPTION("Sun3x ESP SCSI driver");
 MODULE_AUTHOR("Thomas Bogendoerfer (tsbog...@alpha.franken.de)");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
 
-module_init(sun3x_esp_init);
-module_exit(sun3x_esp_exit);
 MODULE_ALIAS("platform:sun3x_esp");
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/5] scsi: use platform helper macro and wrapper functions

2013-05-30 Thread Kefeng Wang
use module_platform_driver() and paltform{set,get}_drvdata to simpily code,
and patch 2/5 delete unnecessery drvdate set to null.

Kefeng Wang (5):
  scsi: jazz: use module_platform_driver() and
platform_{set,get}_drvdata
  scsi: sun: use module_platform_driver() and platform_{set,get}_drvdata
  scsi: qlogicpti: use module_platform_driver() and
platform_{set,get}_drvdata
  scsi: sun3x: use module_platform_driver() and
platform_{set,get}_drvdata
  scsi: sni: use module_platform_driver() and platform_{set,get}_drvdata

 drivers/scsi/jazz_esp.c   | 17 +++--
 drivers/scsi/qlogicpti.c  | 17 +++--
 drivers/scsi/sni_53c710.c | 17 +++--
 drivers/scsi/sun3x_esp.c  | 16 +++-
 drivers/scsi/sun_esp.c| 19 +++
 5 files changed, 15 insertions(+), 71 deletions(-)

-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 0/5] scsi: use platform helper macro and wrapper functions

2013-05-30 Thread Kefeng Wang
On 2013-05-30 22:38, James Bottomley wrote:
> There doesn't seem to be much point to these patches since either idiom
> is fine and easily understood.  We also try to touch the ancient drivers
> as little as possible since it can be months before anyone actually
> tries them out and notices that something got broken, so the rule for
> them is obvious bug fixes only.
> 
> James

hi James,
Thanks for remind, I got it.



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 0/7] irq: fix checkpatch errors and warnings

2013-06-07 Thread Kefeng Wang
On 2013-06-08 6:24, Joe Perches wrote:
> On Fri, 2013-06-07 at 22:42 +0200, Thomas Gleixner wrote:
>> On Thu, 6 Jun 2013, Kefeng Wang wrote:
>>
>>> Fix all the checkpath errors in kernel/irq dir, and some warnings
>>> also fixed.
>>
>> Sorry, I'm not really interested in this kind of patches. To be
>> honest, it would be way more exciting if you had taught checkpatch to
>> actually fix the missing space after the comma.
> 
> Yup.  Kefeng, if you want to take that up,
> I'd be happy to help/guide you.
> 
>> Aside of that your mechanical fixups are mostly making the code worse
>> to read. Just a few examples:
>>
>> --- linux-2.6.orig/kernel/irq/chip.c
> []
>> struct irq_desc *desc = irq_get_desc_buslock(irq, &flags,
>>  
>> IRQ_GET_DESC_CHECK_GLOBAL);
>>
>> Aligning the first arguments of the first and the second line makes it
>> way simpler to read.
> 
> or maybe use
> 
>   struct irq_desc *desc =
>   irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
> 
> and satisfy 80 cols too.
> 
> Existing uses that exceed the 80 column text limit shouldn't
> be changed without making other useful changes at the same
> time.  Make 80 column changes as part of a larger patch set,
> 
>> --- linux-2.6.orig/kernel/irq/handle.c
> []
>> @@ -47,7 +47,7 @@ static void warn_no_thread(unsigned int 
> 
>> -   printk(KERN_WARNING "IRQ %d device %s returned IRQ_WAKE_THREAD "
>> +   pr_warn("IRQ %d device %s returned IRQ_WAKE_THREAD "
>>"but no thread function available.", irq, action->name);
> 
> It'd be useful to add a terminating \n though to avoid
> interleaving by other thread pr_cont/naked printks.
> 
>> The checkpatch warning is to prevent new code to use the old style
>> printk format, but it's not intended to force that on existing code.
> 
> Yup, and checkpatch will never be a perfect tool.
> 
>> Please sit down and read and understand the code and try to find real
>> issues which cannot be detected and solved by scripts and
>> tools. That's what's kernel hacking is about. You are not becoming a
>> kernel developer by running tools and blindly fixing the complaints of
>> the tools. You have to understand the code and you have to learn to
>> judge the output of tools.
> 
> Quite right.
> 
> Maybe add something like it to SubmittingPatches in
> Section 2 ala:
> 
> 5) "Don't be a checkpatch monkey - How not to write patches"
> 

hi Thomas and Joe, thank very much for your reply and remind,
I will pay more attention to study kernel, like your said,
read more code and be an good kernel developer.

thanks,
kefeng


> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
> .
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] video: remove unused variable dev

2013-07-27 Thread Kefeng Wang
Due to commit: e21d2170f [video: remove unnecessary platform_set_drvdata()],
variable dev is unused, so remove it.

Signed-off-by: Kefeng Wang 
---
 drivers/video/vga16fb.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/video/vga16fb.c b/drivers/video/vga16fb.c
index 830ded4..2827333 100644
--- a/drivers/video/vga16fb.c
+++ b/drivers/video/vga16fb.c
@@ -1265,7 +1265,6 @@ static void vga16fb_imageblit(struct fb_info *info, const 
struct fb_image *image
 
 static void vga16fb_destroy(struct fb_info *info)
 {
-   struct platform_device *dev = container_of(info->device, struct 
platform_device, dev);
iounmap(info->screen_base);
fb_dealloc_cmap(&info->cmap);
/* XXX unshare VGA regions */
-- 
1.8.2.2


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] video: remove unused variable dev

2013-07-28 Thread Kefeng Wang
On 07/29 8:52, Jingoo Han wrote:
> On Saturday, July 27, 2013 7:05 PM, Kefeng Wang wrote:
>>
>> Due to commit: e21d2170f [video: remove unnecessary platform_set_drvdata()],
>> variable dev is unused, so remove it.
>>
>> Signed-off-by: Kefeng Wang 
>> ---
>>  drivers/video/vga16fb.c | 1 -
>>  1 file changed, 1 deletion(-)
> 
> CC'ed Luis Henriques.
> 
> 
> Hi Kefeng Wang,
> 
> The same patch was submitted by Luis Henriques 2 weeks ago.
> Also, the patch was already applied by Tomi Valkeinen.
> 
> Best regards,
> Jingoo Han
> 

Thanks for your reply, I got it, so ignore it.

>>
>> diff --git a/drivers/video/vga16fb.c b/drivers/video/vga16fb.c
>> index 830ded4..2827333 100644
>> --- a/drivers/video/vga16fb.c
>> +++ b/drivers/video/vga16fb.c
>> @@ -1265,7 +1265,6 @@ static void vga16fb_imageblit(struct fb_info *info, 
>> const struct fb_image *image
>>
>>  static void vga16fb_destroy(struct fb_info *info)
>>  {
>> -struct platform_device *dev = container_of(info->device, struct 
>> platform_device, dev);
>>  iounmap(info->screen_base);
>>  fb_dealloc_cmap(&info->cmap);
>>  /* XXX unshare VGA regions */
>> --
>> 1.8.2.2
> 
> 
> 
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] sparc:remove unused declaration smp_boot_cpus()

2013-03-27 Thread Kefeng Wang
smp_boot_cpus() was replaced smp_prepare_cpus() long ago, and it no
longer needed, so delete it.

Signed-off-by: Kefeng Wang 
---
 arch/sparc/include/asm/smp_32.h |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/arch/sparc/include/asm/smp_32.h b/arch/sparc/include/asm/smp_32.h
index b73da3c..68503d3 100644
--- a/arch/sparc/include/asm/smp_32.h
+++ b/arch/sparc/include/asm/smp_32.h
@@ -46,7 +46,6 @@ void sun4m_init_smp(void);
 void sun4d_init_smp(void);

 void smp_callin(void);
-void smp_boot_cpus(void);
 void smp_store_cpu_info(int);

 void smp_resched_interrupt(void);
-- 
1.6.0.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] sparc:cleanup unused code in smp_32.h

2013-03-30 Thread Kefeng Wang
After genirq and generic clockevent support at sparc32,
smp4m_irq_rotate(), prof_multiplier() and prof_counter()
are no longer used and should be removed.

Find more info from commit 6baa9b20 & 62f08283.

Signed-off-by: Kefeng Wang 
---
 arch/sparc/include/asm/smp_32.h |4 
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/arch/sparc/include/asm/smp_32.h b/arch/sparc/include/asm/smp_32.h
index 68503d3..3c8917f 100644
--- a/arch/sparc/include/asm/smp_32.h
+++ b/arch/sparc/include/asm/smp_32.h
@@ -36,7 +36,6 @@ typedef void (*smpfunc_t)(unsigned long, unsigned long, 
unsigned long,
   unsigned long, unsigned long);

 void cpu_panic(void);
-extern void smp4m_irq_rotate(int cpu);

 /*
  * General functions that each host system must provide.
@@ -106,9 +105,6 @@ extern int hard_smp_processor_id(void);

 #define raw_smp_processor_id() (current_thread_info()->cpu)

-#define prof_multiplier(__cpu) cpu_data(__cpu).multiplier
-#define prof_counter(__cpu)cpu_data(__cpu).counter
-
 void smp_setup_cpu_possible_map(void);

 #endif /* !(__ASSEMBLY__) */
-- 
1.6.0.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/5] Documentation: arm64: Add Hisilicon Hip07 D05 dts binding

2016-09-24 Thread Kefeng Wang
This patch adds documentation for the devicetree bindings used by
the DT files of Hisilicon Hip07 D05 board.

Signed-off-by: Kefeng Wang 
---
 Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt 
b/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
index 3f81575..7df79a7 100644
--- a/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
+++ b/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
@@ -28,6 +28,10 @@ HiP06 D03 Board
 Required root node properties:
- compatible = "hisilicon,hip06-d03";
 
+HiP07 D05 Board
+Required root node properties:
+   - compatible = "hisilicon,hip07-d05";
+
 Hisilicon system controller
 
 Required properties:
-- 
1.7.12.4



[PATCH 0/5] arm64: dts: hisilicon: Hip06 fix and support Hip07 D05 board

2016-09-24 Thread Kefeng Wang
1) DTs
- Fix Hip06 ehci/ohci interrupt pin number.
- Add initial support for Hip07 D05 board.

2) PL011
- The sbsa uart is used on Hip07 SoC, the interrupt is connected to mbigen,
  but the uart probe(arch_init) is earlier than mbigen(module_init), so
  don't complain on -EPROBE_DEFER when no irq.
- Add earlycon support for SBSA UART.

Kefeng Wang (5):
  arm64: dts: hip06: Correct hardware pin number of usb node
  Documentation: arm64: Add Hisilicon Hip07 D05 dts binding
  arm64: dts: hisilicon: Add initial dts for Hip07 D05 board
  tty: amba-pl011: Don't complain on -EPROBE_DEFER when no irq
  tty: amba-pl011: Add earlycon support for SBSA UART

 .../bindings/arm/hisilicon/hisilicon.txt   |4 +
 arch/arm64/boot/dts/hisilicon/Makefile |1 +
 arch/arm64/boot/dts/hisilicon/hip06.dtsi   |4 +-
 arch/arm64/boot/dts/hisilicon/hip07-d05.dts|   66 ++
 arch/arm64/boot/dts/hisilicon/hip07.dtsi   | 1059 
 drivers/tty/serial/amba-pl011.c|4 +-
 6 files changed, 1135 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm64/boot/dts/hisilicon/hip07-d05.dts
 create mode 100644 arch/arm64/boot/dts/hisilicon/hip07.dtsi

-- 
1.7.12.4



[PATCH 1/5] arm64: dts: hip06: Correct hardware pin number of usb node

2016-09-24 Thread Kefeng Wang
The ohci/ehci hardware pin number should be 640/641, correct them.

Fixes: commit aa8d3e74f54d ("arm64: dts: Add initial dts for Hisilicon Hip06 
D03 board")
Signed-off-by: Kefeng Wang 
---
 arch/arm64/boot/dts/hisilicon/hip06.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/hisilicon/hip06.dtsi 
b/arch/arm64/boot/dts/hisilicon/hip06.dtsi
index 66b1bbf..be76f7d 100644
--- a/arch/arm64/boot/dts/hisilicon/hip06.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hip06.dtsi
@@ -322,7 +322,7 @@
compatible = "generic-ohci";
reg = <0x0 0xa703 0x0 0x1>;
interrupt-parent = <&mbigen_usb>;
-   interrupts = <64 4>;
+   interrupts = <640 4>;
dma-coherent;
status = "disabled";
};
@@ -331,7 +331,7 @@
compatible = "generic-ehci";
reg = <0x0 0xa702 0x0 0x1>;
interrupt-parent = <&mbigen_usb>;
-   interrupts = <65 4>;
+   interrupts = <641 4>;
dma-coherent;
status = "disabled";
};
-- 
1.7.12.4



[PATCH 3/5] arm64: dts: hisilicon: Add initial dts for Hip07 D05 board

2016-09-24 Thread Kefeng Wang
Adding initial dt file for Hip07 D05 board, it is with dual socket
and each socket has two SCCLs(supper cpu cluster), one SCCL contains
four clusters and each cluster has quard Cortex-A72.

Since each SCCL has their own DDR controller, it could be treated as
a separate numa node. Thus, there are four numa nodes(one node with
sixteen core) on Hip07 SoC.

Signed-off-by: Kefeng Wang 
---
 arch/arm64/boot/dts/hisilicon/Makefile  |1 +
 arch/arm64/boot/dts/hisilicon/hip07-d05.dts |   66 ++
 arch/arm64/boot/dts/hisilicon/hip07.dtsi| 1059 +++
 3 files changed, 1126 insertions(+)
 create mode 100644 arch/arm64/boot/dts/hisilicon/hip07-d05.dts
 create mode 100644 arch/arm64/boot/dts/hisilicon/hip07.dtsi

diff --git a/arch/arm64/boot/dts/hisilicon/Makefile 
b/arch/arm64/boot/dts/hisilicon/Makefile
index d5f43a0..c8b8f80 100644
--- a/arch/arm64/boot/dts/hisilicon/Makefile
+++ b/arch/arm64/boot/dts/hisilicon/Makefile
@@ -1,6 +1,7 @@
 dtb-$(CONFIG_ARCH_HISI) += hi6220-hikey.dtb
 dtb-$(CONFIG_ARCH_HISI) += hip05-d02.dtb
 dtb-$(CONFIG_ARCH_HISI) += hip06-d03.dtb
+dtb-$(CONFIG_ARCH_HISI) += hip07-d05.dtb
 
 always := $(dtb-y)
 subdir-y   := $(dts-dirs)
diff --git a/arch/arm64/boot/dts/hisilicon/hip07-d05.dts 
b/arch/arm64/boot/dts/hisilicon/hip07-d05.dts
new file mode 100644
index 000..e058442
--- /dev/null
+++ b/arch/arm64/boot/dts/hisilicon/hip07-d05.dts
@@ -0,0 +1,66 @@
+/**
+ * dts file for Hisilicon D05 Development Board
+ *
+ * Copyright (C) 2016 Hisilicon Ltd.
+ *
+ * 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
+ * publishhed by the Free Software Foundation.
+ *
+ */
+
+/dts-v1/;
+
+#include "hip07.dtsi"
+
+/ {
+   model = "Hisilicon Hip07 D05 Development Board";
+   compatible = "hisilicon,hip07-d05";
+
+   /* the mem node will be updated by UEFI. */
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x 0x0 0x4000>;
+   numa-node-id = <0>;
+   };
+
+   distance-map {
+   compatible = "numa-distance-map-v1";
+   distance-matrix = <0 0 10>,
+ <0 1 15>,
+ <0 2 20>,
+ <0 3 25>,
+ <1 0 15>,
+ <1 1 10>,
+ <1 2 25>,
+ <1 3 30>,
+ <2 0 20>,
+ <2 1 25>,
+ <2 2 10>,
+ <2 3 15>,
+ <3 0 25>,
+ <3 1 30>,
+ <3 2 15>,
+ <3 3 10>;
+   };
+
+   aliases {
+   serial0 = &uart0;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+};
+
+&uart0 {
+   status = "ok";
+};
+
+&usb_ohci {
+   status = "ok";
+};
+
+&usb_ehci {
+   status = "ok";
+};
diff --git a/arch/arm64/boot/dts/hisilicon/hip07.dtsi 
b/arch/arm64/boot/dts/hisilicon/hip07.dtsi
new file mode 100644
index 000..5144eb1
--- /dev/null
+++ b/arch/arm64/boot/dts/hisilicon/hip07.dtsi
@@ -0,0 +1,1059 @@
+/**
+ * dts file for Hisilicon D05 Development Board
+ *
+ * Copyright (C) 2016 Hisilicon Ltd.
+ *
+ * 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
+ * publishhed by the Free Software Foundation.
+ *
+ */
+
+#include 
+
+/ {
+   compatible = "hisilicon,hip07-d05";
+   interrupt-parent = <&gic>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu-map {
+   cluster0 {
+   core0 {
+   cpu = <&cpu0>;
+   };
+   core1 {
+   cpu = <&cpu1>;
+   };
+   core2 {
+   cpu = <&cpu2>;
+   };
+   core3 {
+   cpu = <&cpu3>;
+   };
+   };
+
+ 

[PATCH 5/5] tty: amba-pl011: Add earlycon support for SBSA UART

2016-09-24 Thread Kefeng Wang
Declare an OF early console for SBSA UART so that the early console device
can be specified via the "stdout-path" property in device-tree.

Cc: Russell King 
Cc: Greg Kroah-Hartman 
Signed-off-by: Kefeng Wang 
---
 drivers/tty/serial/amba-pl011.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 7d9b291..3688d3b 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2330,6 +2330,7 @@ static int __init pl011_early_console_setup(struct 
earlycon_device *device,
return 0;
 }
 OF_EARLYCON_DECLARE(pl011, "arm,pl011", pl011_early_console_setup);
+OF_EARLYCON_DECLARE(pl011, "arm,sbsa-uart", pl011_early_console_setup);
 
 #else
 #define AMBA_CONSOLE   NULL
-- 
1.7.12.4



[PATCH 4/5] tty: amba-pl011: Don't complain on -EPROBE_DEFER when no irq

2016-09-24 Thread Kefeng Wang
Don't complain on -EPROBE_DEFER when attempting to get the irq.
the driver probe will be retried later.

Cc: Russell King 
Cc: Greg Kroah-Hartman 
Signed-off-by: Kefeng Wang 
---
 drivers/tty/serial/amba-pl011.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 8a9e213..7d9b291 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2555,7 +2555,8 @@ static int sbsa_uart_probe(struct platform_device *pdev)
 
ret = platform_get_irq(pdev, 0);
if (ret < 0) {
-   dev_err(&pdev->dev, "cannot obtain irq\n");
+   if (ret != -EPROBE_DEFER)
+   dev_err(&pdev->dev, "cannot obtain irq\n");
return ret;
}
uap->port.irq   = ret;
-- 
1.7.12.4



Re: [PATCH 5/5] tty: amba-pl011: Add earlycon support for SBSA UART

2016-09-27 Thread Kefeng Wang


On 2016/9/27 18:57, Greg Kroah-Hartman wrote:
> On Sat, Sep 24, 2016 at 05:14:25PM +0800, Kefeng Wang wrote:
>> Declare an OF early console for SBSA UART so that the early console device
>> can be specified via the "stdout-path" property in device-tree.
>>
>> Cc: Russell King 
>> Cc: Greg Kroah-Hartman 
>> Signed-off-by: Kefeng Wang 
>> ---
>>  drivers/tty/serial/amba-pl011.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/tty/serial/amba-pl011.c 
>> b/drivers/tty/serial/amba-pl011.c
>> index 7d9b291..3688d3b 100644
>> --- a/drivers/tty/serial/amba-pl011.c
>> +++ b/drivers/tty/serial/amba-pl011.c
>> @@ -2330,6 +2330,7 @@ static int __init pl011_early_console_setup(struct 
>> earlycon_device *device,
>>  return 0;
>>  }
>>  OF_EARLYCON_DECLARE(pl011, "arm,pl011", pl011_early_console_setup);
>> +OF_EARLYCON_DECLARE(pl011, "arm,sbsa-uart", pl011_early_console_setup);
> 
> Why do you need another option for the same thing?


It is used to support earlycon(without option) for sbsa-uart in bootargs.

chosen {
stdout-path = "serial0:115200n8";
bootargs = "earlycon"
};

uart0: uart@602b {
compatible = "arm,sbsa-uart";
reg = <0x0 0x602b 0x0 0x1000>;
...
};

We setup a unique struct with compatible name by OF_EARLYCON_DECLARE,
#define OF_EARLYCON_DECLARE(_name, compat, fn)  \
static const struct earlycon_id __UNIQUE_ID(__earlycon_##_name) \
 __used __section(__earlycon_table) \
= { .name = __stringify(_name), \
.compatible = compat,   \
.setup = fn  }

if without this patch(see drivers/of/fdt.c),

early_init_dt_scan_chosen_serial()
 - for (match = __earlycon_table; match < __earlycon_table_end; match++)
  -- if (fdt_node_check_compatible(fdt, offset, match->compatible))
countinue;
  -- of_setup_earlycon(match, offset, options); // will never touch here.

Thanks,
Kefeng

> 
> confused,
> 
> greg k-h
> 
> .
> 



Re: [PATCH] net: hns: declare function as static

2016-09-06 Thread Kefeng Wang


On 2016/9/7 7:20, David Miller wrote:
> From: Kefeng Wang 
> Date: Tue, 6 Sep 2016 19:53:11 +0800
> 
>> Declare function as static to kill warning about missing-prototypes.
>>
>> Cc: Yisen Zhuang 
>> Cc: Kejian Yan 
>> Signed-off-by: Kefeng Wang 
>  ...
>> @@ -73,7 +73,7 @@ static struct ring_pair_cb *hns_ae_get_ring_pair(struct 
>> hnae_queue *q)
>>  return container_of(q, struct ring_pair_cb, q);
>>  }
>>  
>> -struct hnae_handle *hns_ae_get_handle(struct hnae_ae_dev *dev,
>> +static struct hnae_handle *hns_ae_get_handle(struct hnae_ae_dev *dev,
>>u32 port_id)
> 
> You have to adjust the indentation of the arguments on the following lines
> if you change where the openning parenthesis is.  They must start exactly
> at the column folling that openning parenthesis.

Hi David,

Talked with Yisen, please ignore it for now, will resend it after some hns/roce 
functional changes.

Thanks,
Kefeng



> 
> 
> .
> 



[PATCH v4 1/2] serial: 8250_dw: make dw8250_set_termios as default set_termios callback

2016-08-30 Thread Kefeng Wang
Make dw8250_set_termios() handle all cases of dw8250_data->clk properly,
then we can safely use dw8250_set_termios() as the default set_termios
callback instead of serial8250_do_set_termios(), so do it.

Signed-off-by: Kefeng Wang 
---
 drivers/tty/serial/8250/8250_dw.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_dw.c 
b/drivers/tty/serial/8250/8250_dw.c
index 5c0c123..adecece 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -235,7 +235,7 @@ static void dw8250_set_termios(struct uart_port *p, struct 
ktermios *termios,
unsigned int rate;
int ret;
 
-   if (IS_ERR(d->clk) || !old)
+   if (IS_ERR_OR_NULL(d->clk) || !old)
goto out;
 
clk_disable_unprepare(d->clk);
@@ -308,13 +308,11 @@ static void dw8250_quirks(struct uart_port *p, struct 
dw8250_data *data)
p->serial_in = dw8250_serial_in32;
data->uart_16550_compatible = true;
}
-   p->set_termios = dw8250_set_termios;
}
 
/* Platforms with iDMA */
if (platform_get_resource_byname(to_platform_device(p->dev),
 IORESOURCE_MEM, "lpss_priv")) {
-   p->set_termios = dw8250_set_termios;
data->dma.rx_param = p->dev->parent;
data->dma.tx_param = p->dev->parent;
data->dma.fn = dw8250_idma_filter;
@@ -391,6 +389,7 @@ static int dw8250_probe(struct platform_device *pdev)
p->iotype   = UPIO_MEM;
p->serial_in= dw8250_serial_in;
p->serial_out   = dw8250_serial_out;
+   p->set_termios  = dw8250_set_termios;
 
p->membase = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
if (!p->membase)
-- 
1.7.12.4



[PATCH] serial: 8250_dw: Use an unified new dev variable in probe

2016-08-30 Thread Kefeng Wang
Use an unified new dev variable instead of &pdev->dev and p->dev
in probe function.

Signed-off-by: Kefeng Wang 
---
 drivers/tty/serial/8250/8250_dw.c | 45 ---
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_dw.c 
b/drivers/tty/serial/8250/8250_dw.c
index 3478c2c..225d797 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -363,18 +363,19 @@ static int dw8250_probe(struct platform_device *pdev)
struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
int irq = platform_get_irq(pdev, 0);
struct uart_port *p = &uart.port;
+   struct device *dev = &pdev->dev;
struct dw8250_data *data;
int err;
u32 val;
 
if (!regs) {
-   dev_err(&pdev->dev, "no registers defined\n");
+   dev_err(dev, "no registers defined\n");
return -EINVAL;
}
 
if (irq < 0) {
if (irq != -EPROBE_DEFER)
-   dev_err(&pdev->dev, "cannot get irq\n");
+   dev_err(dev, "cannot get irq\n");
return irq;
}
 
@@ -385,17 +386,17 @@ static int dw8250_probe(struct platform_device *pdev)
p->pm   = dw8250_do_pm;
p->type = PORT_8250;
p->flags= UPF_SHARE_IRQ | UPF_FIXED_PORT;
-   p->dev  = &pdev->dev;
+   p->dev  = dev;
p->iotype   = UPIO_MEM;
p->serial_in= dw8250_serial_in;
p->serial_out   = dw8250_serial_out;
p->set_termios  = dw8250_set_termios;
 
-   p->membase = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
+   p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
if (!p->membase)
return -ENOMEM;
 
-   data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+   data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
 
@@ -403,57 +404,57 @@ static int dw8250_probe(struct platform_device *pdev)
data->usr_reg = DW_UART_USR;
p->private_data = data;
 
-   data->uart_16550_compatible = device_property_read_bool(p->dev,
+   data->uart_16550_compatible = device_property_read_bool(dev,
"snps,uart-16550-compatible");
 
-   err = device_property_read_u32(p->dev, "reg-shift", &val);
+   err = device_property_read_u32(dev, "reg-shift", &val);
if (!err)
p->regshift = val;
 
-   err = device_property_read_u32(p->dev, "reg-io-width", &val);
+   err = device_property_read_u32(dev, "reg-io-width", &val);
if (!err && val == 4) {
p->iotype = UPIO_MEM32;
p->serial_in = dw8250_serial_in32;
p->serial_out = dw8250_serial_out32;
}
 
-   if (device_property_read_bool(p->dev, "dcd-override")) {
+   if (device_property_read_bool(dev, "dcd-override")) {
/* Always report DCD as active */
data->msr_mask_on |= UART_MSR_DCD;
data->msr_mask_off |= UART_MSR_DDCD;
}
 
-   if (device_property_read_bool(p->dev, "dsr-override")) {
+   if (device_property_read_bool(dev, "dsr-override")) {
/* Always report DSR as active */
data->msr_mask_on |= UART_MSR_DSR;
data->msr_mask_off |= UART_MSR_DDSR;
}
 
-   if (device_property_read_bool(p->dev, "cts-override")) {
+   if (device_property_read_bool(dev, "cts-override")) {
/* Always report CTS as active */
data->msr_mask_on |= UART_MSR_CTS;
data->msr_mask_off |= UART_MSR_DCTS;
}
 
-   if (device_property_read_bool(p->dev, "ri-override")) {
+   if (device_property_read_bool(dev, "ri-override")) {
/* Always report Ring indicator as inactive */
data->msr_mask_off |= UART_MSR_RI;
data->msr_mask_off |= UART_MSR_TERI;
}
 
/* Always ask for fixed clock rate from a property. */
-   device_property_read_u32(p->dev, "clock-frequency", &p->uartclk);
+   device_property_read_u32(dev, "clock-frequency", &p->uartclk);
 
/* If there is separate baudclk, get the rate from it. */
-   data->clk = devm_clk_get(&pdev->dev, "baudclk");
+   data->clk = devm_clk_get(dev, "baudclk");
if (IS_ERR(data->clk) && PTR_ERR(data-

[PATCH v4 2/2] serial: 8250_dw: add ACPI support for uart on Hisilicon Hip05 SoC

2016-08-30 Thread Kefeng Wang
Add ACPI identifier for UART on Hisilicon Hip05 SoC, be careful that
it is not 16550 compatible, and "reg-io-width" and "reg-shift" need
be set properly by _DSD method in DSDT.

Signed-off-by: Kefeng Wang 
---
 drivers/tty/serial/8250/8250_dw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/serial/8250/8250_dw.c 
b/drivers/tty/serial/8250/8250_dw.c
index adecece..3478c2c 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -623,6 +623,7 @@ static const struct acpi_device_id dw8250_acpi_match[] = {
{ "APMC0D08", 0},
{ "AMD0020", 0 },
{ "AMDI0020", 0 },
+   { "HISI0031", 0 },
{ },
 };
 MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match);
-- 
1.7.12.4



[PATCH v4 0/2] serial: 8250_dw: Add ACPI support for uart on Hisilicon Hip05 SoC

2016-08-30 Thread Kefeng Wang
Handle all cases of dw8250_data->clk properly in dw8250_set_termios(), then
make it as the default set_termios callback for 8250 dw uart.

After that, add ACPI support for uart on Hisilicon Hip05 SoC, be careful that
it is not 16500 compatible, and with Heikki's patchset[1], we safely only add
ACPI identifier, due to the ACPI quirks in dw8250_quirks() only for "APMC0D08".

Change since v3:
- The new dev var patch is sent separately.
- Address the comment from Andy, and repost patches based on Heikki Krogerus's 
patchset[1]
  "[PATCHv2 0/3] serial: dw8250: ACPI tuning"  

Change since v2:
- Add a new patch to use new var dev in probe
- Use built-in device properties to set device parameters for existing device 
probed by acpi,
  suggested by Andy Shevchenko


Change since v1:
- Use acpi_match_device() instead of acpi_dev_found(), limit the check to the 
device
  being probed and not a global search for whole DSDT (pointed by 
graeme.greg...@linaro.org)

[1] http://www.spinics.net/lists/linux-acpi/msg68519.html

Kefeng Wang (2):
  serial: 8250_dw: make dw8250_set_termios as default set_termios
callback
  serial: 8250_dw: add ACPI support for uart on Hisilicon Hip05 SoC

 drivers/tty/serial/8250/8250_dw.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
1.7.12.4



[PATCH] serial: 8250_dw: Use an unified new dev variable in probe

2016-08-31 Thread Kefeng Wang
Use an unified new dev variable instead of &pdev->dev and p->dev
in probe function.

Signed-off-by: Kefeng Wang 
---
 drivers/tty/serial/8250/8250_dw.c | 45 ---
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_dw.c 
b/drivers/tty/serial/8250/8250_dw.c
index 3478c2c..225d797 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -363,18 +363,19 @@ static int dw8250_probe(struct platform_device *pdev)
struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
int irq = platform_get_irq(pdev, 0);
struct uart_port *p = &uart.port;
+   struct device *dev = &pdev->dev;
struct dw8250_data *data;
int err;
u32 val;
 
if (!regs) {
-   dev_err(&pdev->dev, "no registers defined\n");
+   dev_err(dev, "no registers defined\n");
return -EINVAL;
}
 
if (irq < 0) {
if (irq != -EPROBE_DEFER)
-   dev_err(&pdev->dev, "cannot get irq\n");
+   dev_err(dev, "cannot get irq\n");
return irq;
}
 
@@ -385,17 +386,17 @@ static int dw8250_probe(struct platform_device *pdev)
p->pm   = dw8250_do_pm;
p->type = PORT_8250;
p->flags= UPF_SHARE_IRQ | UPF_FIXED_PORT;
-   p->dev  = &pdev->dev;
+   p->dev  = dev;
p->iotype   = UPIO_MEM;
p->serial_in= dw8250_serial_in;
p->serial_out   = dw8250_serial_out;
p->set_termios  = dw8250_set_termios;
 
-   p->membase = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
+   p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
if (!p->membase)
return -ENOMEM;
 
-   data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+   data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
 
@@ -403,57 +404,57 @@ static int dw8250_probe(struct platform_device *pdev)
data->usr_reg = DW_UART_USR;
p->private_data = data;
 
-   data->uart_16550_compatible = device_property_read_bool(p->dev,
+   data->uart_16550_compatible = device_property_read_bool(dev,
"snps,uart-16550-compatible");
 
-   err = device_property_read_u32(p->dev, "reg-shift", &val);
+   err = device_property_read_u32(dev, "reg-shift", &val);
if (!err)
p->regshift = val;
 
-   err = device_property_read_u32(p->dev, "reg-io-width", &val);
+   err = device_property_read_u32(dev, "reg-io-width", &val);
if (!err && val == 4) {
p->iotype = UPIO_MEM32;
p->serial_in = dw8250_serial_in32;
p->serial_out = dw8250_serial_out32;
}
 
-   if (device_property_read_bool(p->dev, "dcd-override")) {
+   if (device_property_read_bool(dev, "dcd-override")) {
/* Always report DCD as active */
data->msr_mask_on |= UART_MSR_DCD;
data->msr_mask_off |= UART_MSR_DDCD;
}
 
-   if (device_property_read_bool(p->dev, "dsr-override")) {
+   if (device_property_read_bool(dev, "dsr-override")) {
/* Always report DSR as active */
data->msr_mask_on |= UART_MSR_DSR;
data->msr_mask_off |= UART_MSR_DDSR;
}
 
-   if (device_property_read_bool(p->dev, "cts-override")) {
+   if (device_property_read_bool(dev, "cts-override")) {
/* Always report CTS as active */
data->msr_mask_on |= UART_MSR_CTS;
data->msr_mask_off |= UART_MSR_DCTS;
}
 
-   if (device_property_read_bool(p->dev, "ri-override")) {
+   if (device_property_read_bool(dev, "ri-override")) {
/* Always report Ring indicator as inactive */
data->msr_mask_off |= UART_MSR_RI;
data->msr_mask_off |= UART_MSR_TERI;
}
 
/* Always ask for fixed clock rate from a property. */
-   device_property_read_u32(p->dev, "clock-frequency", &p->uartclk);
+   device_property_read_u32(dev, "clock-frequency", &p->uartclk);
 
/* If there is separate baudclk, get the rate from it. */
-   data->clk = devm_clk_get(&pdev->dev, "baudclk");
+   data->clk = devm_clk_get(dev, "baudclk");
if (IS_ERR(data->clk) && PTR_ERR(data-

Re: [PATCH] serial: 8250_dw: Use an unified new dev variable in probe

2016-08-31 Thread Kefeng Wang
Sorry, please ignore, send wrong patch.

On 2016/9/1 9:34, Kefeng Wang wrote:
> Use an unified new dev variable instead of &pdev->dev and p->dev
> in probe function.
> 
> Signed-off-by: Kefeng Wang 
> ---
>  drivers/tty/serial/8250/8250_dw.c | 45 
> ---
>  1 file changed, 23 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_dw.c 
> b/drivers/tty/serial/8250/8250_dw.c
> index 3478c2c..225d797 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
> @@ -363,18 +363,19 @@ static int dw8250_probe(struct platform_device *pdev)
>   struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>   int irq = platform_get_irq(pdev, 0);
>   struct uart_port *p = &uart.port;
> + struct device *dev = &pdev->dev;
>   struct dw8250_data *data;
>   int err;
>   u32 val;
>  
>   if (!regs) {
> - dev_err(&pdev->dev, "no registers defined\n");
> + dev_err(dev, "no registers defined\n");
>   return -EINVAL;
>   }
>  
>   if (irq < 0) {
>   if (irq != -EPROBE_DEFER)
> - dev_err(&pdev->dev, "cannot get irq\n");
> + dev_err(dev, "cannot get irq\n");
>   return irq;
>   }
>  
> @@ -385,17 +386,17 @@ static int dw8250_probe(struct platform_device *pdev)
>   p->pm   = dw8250_do_pm;
>   p->type = PORT_8250;
>   p->flags= UPF_SHARE_IRQ | UPF_FIXED_PORT;
> - p->dev  = &pdev->dev;
> + p->dev  = dev;
>   p->iotype   = UPIO_MEM;
>   p->serial_in= dw8250_serial_in;
>   p->serial_out   = dw8250_serial_out;
>   p->set_termios  = dw8250_set_termios;
>  
> - p->membase = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
> + p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
>   if (!p->membase)
>   return -ENOMEM;
>  
> - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
> + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
>   if (!data)
>   return -ENOMEM;
>  
> @@ -403,57 +404,57 @@ static int dw8250_probe(struct platform_device *pdev)
>   data->usr_reg = DW_UART_USR;
>   p->private_data = data;
>  
> - data->uart_16550_compatible = device_property_read_bool(p->dev,
> + data->uart_16550_compatible = device_property_read_bool(dev,
>   "snps,uart-16550-compatible");
>  
> - err = device_property_read_u32(p->dev, "reg-shift", &val);
> + err = device_property_read_u32(dev, "reg-shift", &val);
>   if (!err)
>   p->regshift = val;
>  
> - err = device_property_read_u32(p->dev, "reg-io-width", &val);
> + err = device_property_read_u32(dev, "reg-io-width", &val);
>   if (!err && val == 4) {
>   p->iotype = UPIO_MEM32;
>   p->serial_in = dw8250_serial_in32;
>   p->serial_out = dw8250_serial_out32;
>   }
>  
> - if (device_property_read_bool(p->dev, "dcd-override")) {
> + if (device_property_read_bool(dev, "dcd-override")) {
>   /* Always report DCD as active */
>   data->msr_mask_on |= UART_MSR_DCD;
>   data->msr_mask_off |= UART_MSR_DDCD;
>   }
>  
> - if (device_property_read_bool(p->dev, "dsr-override")) {
> + if (device_property_read_bool(dev, "dsr-override")) {
>   /* Always report DSR as active */
>   data->msr_mask_on |= UART_MSR_DSR;
>   data->msr_mask_off |= UART_MSR_DDSR;
>   }
>  
> - if (device_property_read_bool(p->dev, "cts-override")) {
> + if (device_property_read_bool(dev, "cts-override")) {
>   /* Always report CTS as active */
>   data->msr_mask_on |= UART_MSR_CTS;
>   data->msr_mask_off |= UART_MSR_DCTS;
>   }
>  
> - if (device_property_read_bool(p->dev, "ri-override")) {
> + if (device_property_read_bool(dev, "ri-override")) {
>   /* Always report Ring indicator as inactive */
>   data->msr_mask_off |= UART_MSR_RI;
>   data->msr_mask_off |= UART_MSR_TERI;
>   }
>  
>   /* Always ask for fi

[PATCH v2] serial: 8250_dw: Use an unified new dev variable in probe

2016-08-31 Thread Kefeng Wang
Use an unified new dev variable instead of &pdev->dev and p->dev
in probe function.

Reviewed-by: Heikki Krogerus 
Signed-off-by: Kefeng Wang 
---

Hi Greg, updated, based on tty-testing branch :)

v1->v2:
1) Add Heikki's reviewed-by
2) Rebase on tty-testing branch of 
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git

 drivers/tty/serial/8250/8250_dw.c | 45 ---
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_dw.c 
b/drivers/tty/serial/8250/8250_dw.c
index b022f5a..47e6d08 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -360,18 +360,19 @@ static int dw8250_probe(struct platform_device *pdev)
struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
int irq = platform_get_irq(pdev, 0);
struct uart_port *p = &uart.port;
+   struct device *dev = &pdev->dev;
struct dw8250_data *data;
int err;
u32 val;
 
if (!regs) {
-   dev_err(&pdev->dev, "no registers defined\n");
+   dev_err(dev, "no registers defined\n");
return -EINVAL;
}
 
if (irq < 0) {
if (irq != -EPROBE_DEFER)
-   dev_err(&pdev->dev, "cannot get irq\n");
+   dev_err(dev, "cannot get irq\n");
return irq;
}
 
@@ -382,16 +383,16 @@ static int dw8250_probe(struct platform_device *pdev)
p->pm   = dw8250_do_pm;
p->type = PORT_8250;
p->flags= UPF_SHARE_IRQ | UPF_FIXED_PORT;
-   p->dev  = &pdev->dev;
+   p->dev  = dev;
p->iotype   = UPIO_MEM;
p->serial_in= dw8250_serial_in;
p->serial_out   = dw8250_serial_out;
 
-   p->membase = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
+   p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
if (!p->membase)
return -ENOMEM;
 
-   data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+   data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
 
@@ -399,57 +400,57 @@ static int dw8250_probe(struct platform_device *pdev)
data->usr_reg = DW_UART_USR;
p->private_data = data;
 
-   data->uart_16550_compatible = device_property_read_bool(p->dev,
+   data->uart_16550_compatible = device_property_read_bool(dev,
"snps,uart-16550-compatible");
 
-   err = device_property_read_u32(p->dev, "reg-shift", &val);
+   err = device_property_read_u32(dev, "reg-shift", &val);
if (!err)
p->regshift = val;
 
-   err = device_property_read_u32(p->dev, "reg-io-width", &val);
+   err = device_property_read_u32(dev, "reg-io-width", &val);
if (!err && val == 4) {
p->iotype = UPIO_MEM32;
p->serial_in = dw8250_serial_in32;
p->serial_out = dw8250_serial_out32;
}
 
-   if (device_property_read_bool(p->dev, "dcd-override")) {
+   if (device_property_read_bool(dev, "dcd-override")) {
/* Always report DCD as active */
data->msr_mask_on |= UART_MSR_DCD;
data->msr_mask_off |= UART_MSR_DDCD;
}
 
-   if (device_property_read_bool(p->dev, "dsr-override")) {
+   if (device_property_read_bool(dev, "dsr-override")) {
/* Always report DSR as active */
data->msr_mask_on |= UART_MSR_DSR;
data->msr_mask_off |= UART_MSR_DDSR;
}
 
-   if (device_property_read_bool(p->dev, "cts-override")) {
+   if (device_property_read_bool(dev, "cts-override")) {
/* Always report CTS as active */
data->msr_mask_on |= UART_MSR_CTS;
data->msr_mask_off |= UART_MSR_DCTS;
}
 
-   if (device_property_read_bool(p->dev, "ri-override")) {
+   if (device_property_read_bool(dev, "ri-override")) {
/* Always report Ring indicator as inactive */
data->msr_mask_off |= UART_MSR_RI;
data->msr_mask_off |= UART_MSR_TERI;
}
 
/* Always ask for fixed clock rate from a property. */
-   device_property_read_u32(p->dev, "clock-frequency", &p->uartclk);
+   device_property_read_u32(dev, "clock-frequency", &p->uartclk);
 
/* If there is separate baudclk, get the rate from it. */
-   data->clk = d

Re: [PATCH v3 3/3] serial: 8250_dw: add ACPI support for uart on Hisilicon Hip05 soc

2016-08-07 Thread Kefeng Wang
+ kernel malilist

Hi Andriy and all, any comments, thanks.

On 2016/7/15 19:01, Kefeng Wang wrote:
> Use built-in device properties to set device parameters for the
> existing device probed by acpi.
> 
> Add ACPI identifier for UART on Hisilicon Hip05 soc, be careful
> that it is not 16550 compatibal, so we need set "reg-io-width"
> and "reg-shift" by _DSD method in DSDT.
> 
> Signed-off-by: Kefeng Wang 
> ---
>  drivers/tty/serial/8250/8250_dw.c | 23 +--
>  1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_dw.c 
> b/drivers/tty/serial/8250/8250_dw.c
> index d6934310..5ab9cfe 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
> @@ -297,12 +297,6 @@ static void dw8250_quirks(struct uart_port *p, struct 
> dw8250_data *data)
>   p->serial_in = dw8250_serial_in32be;
>   p->serial_out = dw8250_serial_out32be;
>   }
> - } else if (has_acpi_companion(p->dev)) {
> - p->iotype = UPIO_MEM32;
> - p->regshift = 2;
> - p->serial_in = dw8250_serial_in32;
> - /* So far none of there implement the Busy Functionality */
> - data->uart_16550_compatible = true;
>   }
>  
>   /* Platforms with iDMA */
> @@ -352,6 +346,19 @@ static void dw8250_setup_port(struct uart_port *p)
>   up->capabilities |= UART_CAP_AFE;
>  }
>  
> +static struct property_entry dw8250_properties[] = {
> + PROPERTY_ENTRY_U32("reg-io-width", 4),
> + PROPERTY_ENTRY_U32("reg-shift", 2),
> + PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"),
> + { },
> +};
> +
> +/* non 16550 compatible id list*/
> +static const struct acpi_device_id non_16550_ids[] = {
> + { "HISI0031", 0 },
> + { },
> +};
> +
>  static int dw8250_probe(struct platform_device *pdev)
>  {
>   struct uart_8250_port uart = {};
> @@ -395,6 +402,9 @@ static int dw8250_probe(struct platform_device *pdev)
>   if (!data)
>   return -ENOMEM;
>  
> + if (has_acpi_companion(dev) && !acpi_match_device(non_16550_ids, dev))
> + platform_device_add_properties(pdev, dw8250_properties);
> +
>   data->dma.fn = dw8250_fallback_dma_filter;
>   data->usr_reg = DW_UART_USR;
>   p->private_data = data;
> @@ -619,6 +629,7 @@ static const struct acpi_device_id dw8250_acpi_match[] = {
>   { "APMC0D08", 0},
>   { "AMD0020", 0 },
>   { "AMDI0020", 0 },
> + { "HISI0031", 0 },
>   { },
>  };
>  MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match);
> 



[PATCH] serial: 8250_dw: Check the data->pclk when get apb_pclk

2016-08-24 Thread Kefeng Wang
It should check the data->pclk, not data->clk when get apb_pclk.

Fixes: c8ed99d4f6a8("serial: 8250_dw: Add support for deferred probing")
Signed-off-by: Kefeng Wang 
---
 drivers/tty/serial/8250/8250_dw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_dw.c 
b/drivers/tty/serial/8250/8250_dw.c
index e199696..b022f5a 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -462,7 +462,7 @@ static int dw8250_probe(struct platform_device *pdev)
}
 
data->pclk = devm_clk_get(&pdev->dev, "apb_pclk");
-   if (IS_ERR(data->clk) && PTR_ERR(data->clk) == -EPROBE_DEFER) {
+   if (IS_ERR(data->pclk) && PTR_ERR(data->pclk) == -EPROBE_DEFER) {
err = -EPROBE_DEFER;
goto err_clk;
}
-- 
2.6.0.GIT



Re: [PATCH v3 3/3] serial: 8250_dw: add ACPI support for uart on Hisilicon Hip05 soc

2016-08-24 Thread Kefeng Wang


On 2016/8/22 22:05, Heikki Krogerus wrote:
> Hi,
> 
> On Mon, Aug 22, 2016 at 02:24:14PM +0300, Andy Shevchenko wrote:
>> On Fri, 2016-07-15 at 19:01 +0800, Kefeng Wang wrote:
>>> Use built-in device properties to set device parameters for the
>>> existing device probed by acpi.
>>
>> acpi -> ACPI
>>
>>>
>>> Add ACPI identifier for UART on Hisilicon Hip05 soc, be careful
>>
>> soc -> SoC
>>
>>> that it is not 16550 compatibal, so we need set "reg-io-width"
>>
>> compatibal -> compatible

Will fix.

>>
>>> and "reg-shift" by _DSD method in DSDT.
>>>
>>> Signed-off-by: Kefeng Wang 
>>> ---
>>>  drivers/tty/serial/8250/8250_dw.c | 23 +--
>>>  1 file changed, 17 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/tty/serial/8250/8250_dw.c
>>> b/drivers/tty/serial/8250/8250_dw.c
>>> index d6934310..5ab9cfe 100644
>>> --- a/drivers/tty/serial/8250/8250_dw.c
>>> +++ b/drivers/tty/serial/8250/8250_dw.c
>>> @@ -297,12 +297,6 @@ static void dw8250_quirks(struct uart_port *p,
>>> struct dw8250_data *data)
>>> p->serial_in = dw8250_serial_in32be;
>>> p->serial_out = dw8250_serial_out32be;
>>> }
>>> -   } else if (has_acpi_companion(p->dev)) {
>>> -   p->iotype = UPIO_MEM32;
>>> -   p->regshift = 2;
>>> -   p->serial_in = dw8250_serial_in32;
>>> -   /* So far none of there implement the Busy
>>> Functionality */
>>> -   data->uart_16550_compatible = true;
>>> }
>>>  
>>> /* Platforms with iDMA */
>>> @@ -352,6 +346,19 @@ static void dw8250_setup_port(struct uart_port
>>> *p)
>>> up->capabilities |= UART_CAP_AFE;
>>>  }
>>>  
>>> +static struct property_entry dw8250_properties[] = {
>>> +   PROPERTY_ENTRY_U32("reg-io-width", 4),
>>> +   PROPERTY_ENTRY_U32("reg-shift", 2),
>>> +   PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"),
>>> +   { },
>>> +};
>>> +
>>> +/* non 16550 compatible id list*/
>>
>> non 16550 -> Non-16550
>> Space before */
>>
>>> +static const struct acpi_device_id non_16550_ids[] = {
>>> +   { "HISI0031", 0 },
>>> +   { },
>>> +};
>>> +
>>>  static int dw8250_probe(struct platform_device *pdev)
>>>  {
>>> struct uart_8250_port uart = {};
>>> @@ -395,6 +402,9 @@ static int dw8250_probe(struct platform_device
>>> *pdev)
>>> if (!data)
>>> return -ENOMEM;
>>>  
>>> +   if (has_acpi_companion(dev) &&
>>> !acpi_match_device(non_16550_ids, dev))
>>
>>
>>> +   platform_device_add_properties(pdev,
>>> dw8250_properties);
>>
>> What if we probe device which has already properties assigned?
>>
>> Heikki, are you good with such trick?
> 
> No this is not the way to do this. As we talked, we need to add the
> properties in the mfd drivers when they exist and not in the driver
> itself. Only if there is no mfd driver that creates the actual
> platform device for dw8250 and when also the ACPI tables don't provide
> the properties, we identify the board in dw8250_quirks and handle it
> separately. Right now there is only one such board.
> 
> I'll prepare the patches for that right now. This series can then be
> made on top of those.
> 

OK, will base on your patchset.

Thanks Andy and Heikki for your comments.

Kefeng


> 
> Thanks,
> 



[PATCH] mtd: nand: convert to unified device property interface

2017-08-16 Thread Kefeng Wang
Changing from of_* to device_* interface, then we can also extract
the properties from ACPI tables as well as from DT.

Signed-off-by: Kefeng Wang 
---

- APCI will be supported in hisi504_nand.c, and it will use nand_scan_ident().

 drivers/mtd/nand/nand_base.c | 54 ++--
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index c6c18b8..27a0947 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -46,7 +46,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 static int nand_get_device(struct mtd_info *mtd, int new_state);
 
@@ -4209,12 +4209,12 @@ static int nand_detect(struct nand_chip *chip, struct 
nand_flash_dev *type)
[NAND_ECC_ON_DIE]   = "on-die",
 };
 
-static int of_get_nand_ecc_mode(struct device_node *np)
+static int device_get_nand_ecc_mode(struct device *dev)
 {
const char *pm;
int err, i;
 
-   err = of_property_read_string(np, "nand-ecc-mode", &pm);
+   err = device_property_read_string(dev, "nand-ecc-mode", &pm);
if (err < 0)
return err;
 
@@ -4238,12 +4238,12 @@ static int of_get_nand_ecc_mode(struct device_node *np)
[NAND_ECC_BCH]  = "bch",
 };
 
-static int of_get_nand_ecc_algo(struct device_node *np)
+static int device_get_nand_ecc_algo(struct device *dev)
 {
const char *pm;
int err, i;
 
-   err = of_property_read_string(np, "nand-ecc-algo", &pm);
+   err = device_property_read_string(dev, "nand-ecc-algo", &pm);
if (!err) {
for (i = NAND_ECC_HAMMING; i < ARRAY_SIZE(nand_ecc_algos); i++)
if (!strcasecmp(pm, nand_ecc_algos[i]))
@@ -4255,7 +4255,7 @@ static int of_get_nand_ecc_algo(struct device_node *np)
 * For backward compatibility we also read "nand-ecc-mode" checking
 * for some obsoleted values that were specifying ECC algorithm.
 */
-   err = of_property_read_string(np, "nand-ecc-mode", &pm);
+   err = device_property_read_string(dev, "nand-ecc-mode", &pm);
if (err < 0)
return err;
 
@@ -4267,29 +4267,29 @@ static int of_get_nand_ecc_algo(struct device_node *np)
return -ENODEV;
 }
 
-static int of_get_nand_ecc_step_size(struct device_node *np)
+static int device_get_nand_ecc_step_size(struct device *dev)
 {
int ret;
u32 val;
 
-   ret = of_property_read_u32(np, "nand-ecc-step-size", &val);
+   ret = device_property_read_u32(dev, "nand-ecc-step-size", &val);
return ret ? ret : val;
 }
 
-static int of_get_nand_ecc_strength(struct device_node *np)
+static int device_get_nand_ecc_strength(struct device *dev)
 {
int ret;
u32 val;
 
-   ret = of_property_read_u32(np, "nand-ecc-strength", &val);
+   ret = device_property_read_u32(dev, "nand-ecc-strength", &val);
return ret ? ret : val;
 }
 
-static int of_get_nand_bus_width(struct device_node *np)
+static int device_get_nand_bus_width(struct device *dev)
 {
u32 val;
 
-   if (of_property_read_u32(np, "nand-bus-width", &val))
+   if (device_property_read_u32(dev, "nand-bus-width", &val))
return 8;
 
switch (val) {
@@ -4301,29 +4301,28 @@ static int of_get_nand_bus_width(struct device_node *np)
}
 }
 
-static bool of_get_nand_on_flash_bbt(struct device_node *np)
+static bool device_get_nand_on_flash_bbt(struct device *dev)
 {
-   return of_property_read_bool(np, "nand-on-flash-bbt");
+   return device_property_read_bool(dev, "nand-on-flash-bbt");
 }
 
-static int nand_dt_init(struct nand_chip *chip)
+static int nand_chip_init(struct nand_chip *chip, struct device *dev)
 {
-   struct device_node *dn = nand_get_flash_node(chip);
int ecc_mode, ecc_algo, ecc_strength, ecc_step;
 
-   if (!dn)
+   if (!dev)
return 0;
 
-   if (of_get_nand_bus_width(dn) == 16)
+   if (device_get_nand_bus_width(dev) == 16)
chip->options |= NAND_BUSWIDTH_16;
 
-   if (of_get_nand_on_flash_bbt(dn))
+   if (device_get_nand_on_flash_bbt(dev))
chip->bbt_options |= NAND_BBT_USE_FLASH;
 
-   ecc_mode = of_get_nand_ecc_mode(dn);
-   ecc_algo = of_get_nand_ecc_algo(dn);
-   ecc_strength = of_get_nand_ecc_strength(dn);
-   ecc_step = of_get_nand_ecc_step_size(dn);
+   ecc_mode = device_get_nand_ecc_mode(dev);
+   ecc_algo = device_get_nand_ecc_algo(dev);
+   ecc_strength = device_get_nand_ecc_strength(dev);
+   ecc_step = device_get_nand_ecc_step_size(dev);
 
if (ecc_mode >= 0)
chip->ecc.mode = ecc_mode;
@@ -4337,7 +43

Re: [PATCH] mtd: nand: convert to unified device property interface

2017-08-17 Thread Kefeng Wang


On 2017/8/18 5:55, Boris Brezillon wrote:
> Le Wed, 16 Aug 2017 15:29:05 +0800,
> Kefeng Wang  a écrit :
>
>> Changing from of_* to device_* interface, then we can also extract
>> the properties from ACPI tables as well as from DT.
>>
>> Signed-off-by: Kefeng Wang 
>> ---
>>
>> - APCI will be supported in hisi504_nand.c, and it will use 
>> nand_scan_ident().
>>
>>  drivers/mtd/nand/nand_base.c | 54 
>> ++--
>>  1 file changed, 27 insertions(+), 27 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
>> index c6c18b8..27a0947 100644
>> --- a/drivers/mtd/nand/nand_base.c
>> +++ b/drivers/mtd/nand/nand_base.c
>> @@ -46,7 +46,7 @@
>>  #include 
>>  #include 
>>  #include 
>> -#include 
>> +#include 
>>  
>>  static int nand_get_device(struct mtd_info *mtd, int new_state);
>>  
>> @@ -4209,12 +4209,12 @@ static int nand_detect(struct nand_chip *chip, 
>> struct nand_flash_dev *type)
>>  [NAND_ECC_ON_DIE]   = "on-die",
>>  };
>>  
>> -static int of_get_nand_ecc_mode(struct device_node *np)
>> +static int device_get_nand_ecc_mode(struct device *dev)
>>  {
>>  const char *pm;
>>  int err, i;
>>  
>> -err = of_property_read_string(np, "nand-ecc-mode", &pm);
>> +err = device_property_read_string(dev, "nand-ecc-mode", &pm);
>>  if (err < 0)
>>  return err;
>>  
>> @@ -4238,12 +4238,12 @@ static int of_get_nand_ecc_mode(struct device_node 
>> *np)
>>  [NAND_ECC_BCH]  = "bch",
>>  };
>>  
>> -static int of_get_nand_ecc_algo(struct device_node *np)
>> +static int device_get_nand_ecc_algo(struct device *dev)
>>  {
>>  const char *pm;
>>  int err, i;
>>  
>> -err = of_property_read_string(np, "nand-ecc-algo", &pm);
>> +err = device_property_read_string(dev, "nand-ecc-algo", &pm);
>>  if (!err) {
>>  for (i = NAND_ECC_HAMMING; i < ARRAY_SIZE(nand_ecc_algos); i++)
>>  if (!strcasecmp(pm, nand_ecc_algos[i]))
>> @@ -4255,7 +4255,7 @@ static int of_get_nand_ecc_algo(struct device_node *np)
>>   * For backward compatibility we also read "nand-ecc-mode" checking
>>   * for some obsoleted values that were specifying ECC algorithm.
>>   */
>> -err = of_property_read_string(np, "nand-ecc-mode", &pm);
>> +err = device_property_read_string(dev, "nand-ecc-mode", &pm);
>>  if (err < 0)
>>  return err;
>>  
>> @@ -4267,29 +4267,29 @@ static int of_get_nand_ecc_algo(struct device_node 
>> *np)
>>  return -ENODEV;
>>  }
>>  
>> -static int of_get_nand_ecc_step_size(struct device_node *np)
>> +static int device_get_nand_ecc_step_size(struct device *dev)
>>  {
>>  int ret;
>>  u32 val;
>>  
>> -ret = of_property_read_u32(np, "nand-ecc-step-size", &val);
>> +ret = device_property_read_u32(dev, "nand-ecc-step-size", &val);
>>  return ret ? ret : val;
>>  }
>>  
>> -static int of_get_nand_ecc_strength(struct device_node *np)
>> +static int device_get_nand_ecc_strength(struct device *dev)
>>  {
>>  int ret;
>>  u32 val;
>>  
>> -ret = of_property_read_u32(np, "nand-ecc-strength", &val);
>> +ret = device_property_read_u32(dev, "nand-ecc-strength", &val);
>>  return ret ? ret : val;
>>  }
>>  
>> -static int of_get_nand_bus_width(struct device_node *np)
>> +static int device_get_nand_bus_width(struct device *dev)
>>  {
>>  u32 val;
>>  
>> -if (of_property_read_u32(np, "nand-bus-width", &val))
>> +if (device_property_read_u32(dev, "nand-bus-width", &val))
>>  return 8;
>>  
>>  switch (val) {
>> @@ -4301,29 +4301,28 @@ static int of_get_nand_bus_width(struct device_node 
>> *np)
>>  }
>>  }
>>  
>> -static bool of_get_nand_on_flash_bbt(struct device_node *np)
>> +static bool device_get_nand_on_flash_bbt(struct device *dev)
> Not sure I like the device prefix, for the same reason I don't like
> nand_chip_init(). How about fw_ or fwnode_?
OK.
>
>>  {
>> -return of_property_read_bool(np, "nand-on-flash-bbt");
>> +return device_property_

[PATCH resend] scsi: fc: drop residual tsk_mgmt_response and it_nexus_response

2017-06-20 Thread Kefeng Wang
After commit 556e26a70b64 ("scsi: remove tsk_mgmt_response and
it_nexus_response transport methods"), the target driver support
was removed totally. Drop the residua.

Signed-off-by: Kefeng Wang 
---
 include/scsi/scsi_transport_fc.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index 6e208bb..e308cd5 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -658,10 +658,6 @@ struct fc_function_template {
int (*vport_disable)(struct fc_vport *, bool);
int (*vport_delete)(struct fc_vport *);
 
-   /* target-mode drivers' functions */
-   int (* tsk_mgmt_response)(struct Scsi_Host *, u64, u64, int);
-   int (* it_nexus_response)(struct Scsi_Host *, u64, int);
-
/* bsg support */
int (*bsg_request)(struct bsg_job *);
int (*bsg_timeout)(struct bsg_job *);
-- 
1.7.12.4



[PATCH] genirq: drop outdated comment in irqdesc.h

2015-09-01 Thread Kefeng Wang
All __do_IRQ are removed after commit 1c77ff22f(genirq: Remove __do_IRQ),
update comment accordingly.

Signed-off-by: Kefeng Wang 
---
 include/linux/irqdesc.h |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
index fcea4e4..8659278 100644
--- a/include/linux/irqdesc.h
+++ b/include/linux/irqdesc.h
@@ -138,8 +138,7 @@ static inline struct msi_desc *irq_desc_get_msi_desc(struct 
irq_desc *desc)
 /*
  * Architectures call this to let the generic IRQ layer
  * handle an interrupt. If the descriptor is attached to an
- * irqchip-style controller then we call the ->handle_irq() handler,
- * and it calls __do_IRQ() if it's attached to an irqtype-style controller.
+ * irqchip-style controller then we call the ->handle_irq() handler.
  */
 static inline void generic_handle_irq_desc(unsigned int irq, struct irq_desc 
*desc)
 {
-- 
1.7.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] net: bridge: Fix jump_label config

2021-02-24 Thread Kefeng Wang
HAVE_JUMP_LABLE is removed by commit e9666d10a567 ("jump_label: move
'asm goto' support test to Kconfig"), use CONFIG_JUMP_LABLE instead
of HAVE_JUMP_LABLE.

Fixes: 971502d77faa ("bridge: netfilter: unroll NF_HOOK helper in bridge input 
path")
Signed-off-by: Kefeng Wang 
---
 net/bridge/br_input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 85d9dae2..065b6cfba40f 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -207,7 +207,7 @@ static int nf_hook_bridge_pre(struct sk_buff *skb, struct 
sk_buff **pskb)
int ret;
 
net = dev_net(skb->dev);
-#ifdef HAVE_JUMP_LABEL
+#ifdef CONFIG_JUMP_LABEL
if 
(!static_key_false(&nf_hooks_needed[NFPROTO_BRIDGE][NF_BR_PRE_ROUTING]))
goto frame_finish;
 #endif
-- 
2.26.2



Re: [PATCH] net: bridge: Fix jump_label config

2021-02-24 Thread Kefeng Wang



On 2021/2/25 2:54, Jakub Kicinski wrote:

On Wed, 24 Feb 2021 23:38:03 +0800 Kefeng Wang wrote:

HAVE_JUMP_LABLE is removed by commit e9666d10a567 ("jump_label: move
'asm goto' support test to Kconfig"), use CONFIG_JUMP_LABLE instead
of HAVE_JUMP_LABLE.

Fixes: 971502d77faa ("bridge: netfilter: unroll NF_HOOK helper in bridge input 
path")
Signed-off-by: Kefeng Wang 

You need to CC the authors of the commit you're blaming. Please make
use of scripts/get_maintainers.pl and repost.


Yes, I use get_maintainers.pl, but only add maintainers to the list, 
thanks for your reminder,


cc the author Florian now.



[PATCH -next] RISCV: Add some depends for NUMA

2021-02-03 Thread Kefeng Wang
The numa feature is useless for riscv32 platform(MAXPHYSMEM_1GB if 32bit),
and it should depends on SMP feature, this also fix the build error,

  riscv64-buildroot-linux-gnu-ld: mm/page_alloc.o: in function `.L0 ':
  page_alloc.c:(.text+0x4808): undefined reference to `node_reclaim_distance'

Fixes: 4f0e8eef772e ("riscv: Add numa support for riscv64 platform")
Signed-off-by: Kefeng Wang 
---
 arch/riscv/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 22fa17898d29..ac7f5801bd82 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -312,6 +312,8 @@ endchoice
 # Common NUMA Features
 config NUMA
bool "NUMA Memory Allocation and Scheduler Support"
+   depends on SMP
+   depends on 64BIT
select GENERIC_ARCH_NUMA
select OF_NUMA
select ARCH_SUPPORTS_NUMA_BALANCING
-- 
2.26.2



Re: [PATCH -next] RISCV: Add some depends for NUMA

2021-02-04 Thread Kefeng Wang



On 2021/2/4 3:59, Atish Patra wrote:

On Wed, Feb 3, 2021 at 6:20 AM Kefeng Wang  wrote:

The numa feature is useless for riscv32 platform(MAXPHYSMEM_1GB if 32bit),
and it should depends on SMP feature, this also fix the build error,

   riscv64-buildroot-linux-gnu-ld: mm/page_alloc.o: in function `.L0 ':
   page_alloc.c:(.text+0x4808): undefined reference to `node_reclaim_distance'


Thanks for the fix. The commit text is a bit ambiguous. The
compilation issue error is due to SMP.
RV32 dependency is just another fix  as NUMA is not very useful for RV32.


Yes, the two depends fix different issue,the lack of SMP leads to the 
compilation issue,  another


depend is to remove support on RV32.

Thanks for your review, if necessary, I could resend with changelog 
updated.



Reviewed-by: Atish Patra 


Re: [PATCH -next] RISCV: Add some depends for NUMA

2021-02-04 Thread Kefeng Wang



On 2021/2/5 14:58, Palmer Dabbelt wrote:
On Wed, 03 Feb 2021 06:23:43 PST (-0800), wangkefeng.w...@huawei.com 
wrote:
The numa feature is useless for riscv32 platform(MAXPHYSMEM_1GB if 
32bit),


I'm not convinced of that.  There's no reason NUMA shouldn't work on 
32-bit, it

doesn't depend on having a large amount of memory just having non-uniform
memory.  I could buy the argument that build a 32-bit NUMA system 
would be
wacky, but IIUC it works now and I don't see any reason to throw that 
away.


I think the RV32 won't benefit from NUMA, there's no too much memory 
support on RV32,


and it may increase the Image size,  so I decided to drop support for RV32.




and it should depends on SMP feature, this also fix the build error,


I can buy that CONFIG_NUMA doesn't really make sense without 
CONFIG_SMP, as
there's not a whole lot to do, but I also don't see any reason from 
disallowing
users from picking it.  arm64 allows !SMP && NUMA, and I don't see any 
reason

it wouldn't work just as well for us.


ARM64 won' support !SMP after following patch, and for most 
architecture,  the NUMA feature


depends or select SMP feature.


commit 4b3dc9679cf779339d9049800803dfc3c83433d1
Author: Will Deacon 
Date:   Fri May 29 18:28:44 2015 +0100

    arm64: force CONFIG_SMP=y and remove redundant #ifdefs






  riscv64-buildroot-linux-gnu-ld: mm/page_alloc.o: in function `.L0 ':
  page_alloc.c:(.text+0x4808): undefined reference to 
`node_reclaim_distance'


The only instance of node_reclaim_distance I see in mm/page_alloc.c is 
already
guarded with CONFIG_NUMA, but the definition of node_reclaim_distance 
isn't.
I'll send out some patches to add the guard which might make sorting 
this out

earlier, but I don't see it fixing any failures.





Re: [PATCH] net: bridge: Fix jump_label config

2021-02-25 Thread Kefeng Wang



On 2021/2/26 5:22, Cong Wang wrote:

On Wed, Feb 24, 2021 at 8:03 AM Kefeng Wang  wrote:

HAVE_JUMP_LABLE is removed by commit e9666d10a567 ("jump_label: move
'asm goto' support test to Kconfig"), use CONFIG_JUMP_LABLE instead
of HAVE_JUMP_LABLE.

Fixes: 971502d77faa ("bridge: netfilter: unroll NF_HOOK helper in bridge input 
path")
Signed-off-by: Kefeng Wang 

Hmm, why do we have to use a macro here? static_key_false() is defined
in both cases, CONFIG_JUMP_LABEL=y or CONFIG_JUMP_LABEL=n.


It seems that all nf_hooks_needed related are using the macro,

see net/netfilter/core.c and include/linux/netfilter.h,

  #ifdef CONFIG_JUMP_LABEL
  struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
EXPORT_SYMBOL(nf_hooks_needed);
#endif

  nf_static_key_inc()/nf_static_key_dec()




Thanks.



Re: [PATCH] RISC-V: Make NUMA depend on SMP

2021-02-26 Thread Kefeng Wang



On 2021/2/27 4:25, Palmer Dabbelt wrote:

From: Palmer Dabbelt 

In theory these are orthogonal, but in practice all NUMA systems are
SMP.  NUMA && !SMP doesn't build, everyone else is coupling them, and I
don't really see any value in supporting that configuration.

Fixes: 4f0e8eef772e ("riscv: Add numa support for riscv64 platform")
Suggested-by: Andrew Morton 
Suggested-by: Atish Patra 
Signed-off-by: Palmer Dabbelt 


Reported-and-Tested-by:  Kefeng Wang 



---
This is on fixes.
---
  arch/riscv/Kconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index a998babc1237..85d626b8ce5e 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -314,6 +314,7 @@ endchoice
  # Common NUMA Features
  config NUMA
bool "NUMA Memory Allocation and Scheduler Support"
+   depends on SMP
select GENERIC_ARCH_NUMA
select OF_NUMA
select ARCH_SUPPORTS_NUMA_BALANCING


Re: [PATCH] net: bridge: Fix jump_label config

2021-02-26 Thread Kefeng Wang



On 2021/2/27 4:19, Cong Wang wrote:

On Thu, Feb 25, 2021 at 5:39 PM Kefeng Wang  wrote:


On 2021/2/26 5:22, Cong Wang wrote:

On Wed, Feb 24, 2021 at 8:03 AM Kefeng Wang  wrote:

HAVE_JUMP_LABLE is removed by commit e9666d10a567 ("jump_label: move
'asm goto' support test to Kconfig"), use CONFIG_JUMP_LABLE instead
of HAVE_JUMP_LABLE.

Fixes: 971502d77faa ("bridge: netfilter: unroll NF_HOOK helper in bridge input 
path")
Signed-off-by: Kefeng Wang 

Hmm, why do we have to use a macro here? static_key_false() is defined
in both cases, CONFIG_JUMP_LABEL=y or CONFIG_JUMP_LABEL=n.

It seems that all nf_hooks_needed related are using the macro,

see net/netfilter/core.c and include/linux/netfilter.h,

#ifdef CONFIG_JUMP_LABEL
struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
EXPORT_SYMBOL(nf_hooks_needed);
#endif

nf_static_key_inc()/nf_static_key_dec()

Same question: why? Clearly struct static_key is defined in both cases:


Ok,  I mean that I don't change the original logic, but that's no need 
this macro actually,


it could be built with or without CONFIG_JUMP_LABEL, only increased the 
size a little bit.





#else
struct static_key {
 atomic_t enabled;
};
#endif  /* CONFIG_JUMP_LABEL */

Thanks.



Re: [PATCH 09/10] timer-riscv: Fix undefined riscv_time_val

2020-05-19 Thread Kefeng Wang



On 2020/5/19 4:23, Daniel Lezcano wrote:

Hi Kefeng,

On 18/05/2020 17:40, Kefeng Wang wrote:

On 2020/5/18 22:09, Daniel Lezcano wrote:

On 13/05/2020 23:14, Palmer Dabbelt wrote:

On Sun, 10 May 2020 19:20:00 PDT (-0700), wangkefeng.w...@huawei.com
wrote:

ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
   drivers/clocksource/timer-riscv.c | 1 +
   1 file changed, 1 insertion(+)

diff --git a/drivers/clocksource/timer-riscv.c
b/drivers/clocksource/timer-riscv.c
index c4f15c4068c0..071b8c144027 100644
--- a/drivers/clocksource/timer-riscv.c
+++ b/drivers/clocksource/timer-riscv.c
@@ -19,6 +19,7 @@

   u64 __iomem *riscv_time_cmp;
   u64 __iomem *riscv_time_val;
+EXPORT_SYMBOL(riscv_time_val);

   static inline void mmio_set_timer(u64 val)
   {

Reviewed-by: Palmer Dabbelt 
Acked-by: Palmer Dabbelt 

Adding the clocksource maintainers.  Let me know if you want this
through my
tree, I'm assuming you want it through your tree.

How can we end up by an export symbol here ?!

Hi Danile,

s/Danile/Daniel/

Sorry for typing error.



Found this build error when CONFIG_RISCV_M_MODE=y and CONFIG_RISCV_SBI
is not,

see patch "4f9bbcefa142 riscv: add support for MMIO access to the timer
registers"

Thanks for the pointer.

The question still remains, how do we end up with this EXPORT_SYMBOL?

There is something wrong if the fix is an EXPORT_SYMBOL for a global
variable.


Not very clear, there are some global variable( eg, acpi_disabled, 
memstart_addr in arm64,) is exported by EXPORT_SYMBOL,  do you mean that 
export riscv_time_val is wrong way?












Re: [PATCH 09/10] timer-riscv: Fix undefined riscv_time_val

2020-05-19 Thread Kefeng Wang



On 2020/5/20 9:14, Anup Patel wrote:

On Tue, May 19, 2020 at 7:21 PM Daniel Lezcano
 wrote:

On 19/05/2020 14:39, Kefeng Wang wrote:

On 2020/5/19 4:23, Daniel Lezcano wrote:

Hi Kefeng,

On 18/05/2020 17:40, Kefeng Wang wrote:

On 2020/5/18 22:09, Daniel Lezcano wrote:

On 13/05/2020 23:14, Palmer Dabbelt wrote:

On Sun, 10 May 2020 19:20:00 PDT (-0700), wangkefeng.w...@huawei.com
wrote:

ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!

Reported-by: Hulk Robot 
Signed-off-by: Kefeng Wang 
---
drivers/clocksource/timer-riscv.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/clocksource/timer-riscv.c
b/drivers/clocksource/timer-riscv.c
index c4f15c4068c0..071b8c144027 100644
--- a/drivers/clocksource/timer-riscv.c
+++ b/drivers/clocksource/timer-riscv.c
@@ -19,6 +19,7 @@

u64 __iomem *riscv_time_cmp;
u64 __iomem *riscv_time_val;
+EXPORT_SYMBOL(riscv_time_val);

static inline void mmio_set_timer(u64 val)
{

Reviewed-by: Palmer Dabbelt 
Acked-by: Palmer Dabbelt 

Adding the clocksource maintainers.  Let me know if you want this
through my
tree, I'm assuming you want it through your tree.

How can we end up by an export symbol here ?!

Hi Danile,

s/Danile/Daniel/

Sorry for typing error.

Found this build error when CONFIG_RISCV_M_MODE=y and CONFIG_RISCV_SBI
is not,

see patch "4f9bbcefa142 riscv: add support for MMIO access to the timer
registers"

Thanks for the pointer.

The question still remains, how do we end up with this EXPORT_SYMBOL?

There is something wrong if the fix is an EXPORT_SYMBOL for a global
variable.

Not very clear, there are some global variable( eg, acpi_disabled,
memstart_addr in arm64,) is exported by EXPORT_SYMBOL,  do you mean that
export riscv_time_val is wrong way?

I do not maintain acpi neither arm64.mm.

AFAICT, riscv_time_val is globally declared in
drivers/clocksource/timer-riscv.c

The driver does not use this variable at all. Then there is a readl on
it in the header file arch/riscv/include/asm/timex.h

And finally it is initialized in arch/riscv/kernel/clint.c

Same thing for riscv_time_cmp.

The correct fix is to initialize the variables in the place where they
belong to (drivers/clocksource/timer-riscv.c), create a function to read
their content and export-symbol-gpl the function.


ok, it's better.  thanks for your explanation.



I agree with Daniel. Exporting riscv_time_val is a temporary fix.


yes.  it's only for build,  let's wait for Anup's patch.



The problem is timer-riscv.c is pretty convoluted right now. It is
implementing two different clocksources and clockevents in one-place.

I think we need two separate drivers for RISC-V world.

1. timer-riscv: This for regular S-mode kernel with MMU. The clocksource
will use TIME CSR and the clockevent device will use SBI calls.

2. timer-clint: This for M-mode kernel without MMU (or NoMMU kernel).
The clocksource will use MMIO counter for clocksource and the
clockevent device will use MMIO compare registers.

I will send a patch to have a separate timer-clint driver under
drivers/clocksource. (@Daniel, I hope you will be fine with this?)
Regards,
Anup



--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

.





[PATCH] initramfs: Provide a common initrd reserve function

2021-01-13 Thread Kefeng Wang
The arm and riscv have same logic to check and reserve
the memory of initrd, let's provide a common function
to reduce duplicated code.

Signed-off-by: Kefeng Wang 
---
PS: 
- Other architecture may use this function too, eg, csky,
  could guoren check it? thanks.

 arch/arm/mm/init.c | 43 +-
 arch/riscv/mm/init.c   | 53 +-
 include/linux/initrd.h |  6 +
 init/initramfs.c   | 45 +++
 4 files changed, 53 insertions(+), 94 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..a29e14cd626c 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -153,47 +153,6 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, 
phys_addr_t align)
return phys;
 }
 
-static void __init arm_initrd_init(void)
-{
-#ifdef CONFIG_BLK_DEV_INITRD
-   phys_addr_t start;
-   unsigned long size;
-
-   initrd_start = initrd_end = 0;
-
-   if (!phys_initrd_size)
-   return;
-
-   /*
-* Round the memory region to page boundaries as per free_initrd_mem()
-* This allows us to detect whether the pages overlapping the initrd
-* are in use, but more importantly, reserves the entire set of pages
-* as we don't want these pages allocated for other purposes.
-*/
-   start = round_down(phys_initrd_start, PAGE_SIZE);
-   size = phys_initrd_size + (phys_initrd_start - start);
-   size = round_up(size, PAGE_SIZE);
-
-   if (!memblock_is_region_memory(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region - 
disabling initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   if (memblock_is_region_reserved(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory region 
- disabling initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   memblock_reserve(start, size);
-
-   /* Now convert initrd to virtual addresses */
-   initrd_start = __phys_to_virt(phys_initrd_start);
-   initrd_end = initrd_start + phys_initrd_size;
-#endif
-}
-
 #ifdef CONFIG_CPU_ICACHE_MISMATCH_WORKAROUND
 void check_cpu_icache_size(int cpuid)
 {
@@ -215,7 +174,7 @@ void __init arm_memblock_init(const struct machine_desc 
*mdesc)
/* Register the kernel text, kernel data and initrd with memblock. */
memblock_reserve(__pa(KERNEL_START), KERNEL_END - KERNEL_START);
 
-   arm_initrd_init();
+   reserve_initrd_mem();
 
arm_mm_memblock_reserve();
 
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index da53902ef0fc..93cba0d3f43f 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -105,55 +105,6 @@ void __init mem_init(void)
print_vm_layout();
 }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static void __init setup_initrd(void)
-{
-   phys_addr_t start;
-   unsigned long size;
-
-   /* Ignore the virtul address computed during device tree parsing */
-   initrd_start = initrd_end = 0;
-
-   if (!phys_initrd_size)
-   return;
-   /*
-* Round the memory region to page boundaries as per free_initrd_mem()
-* This allows us to detect whether the pages overlapping the initrd
-* are in use, but more importantly, reserves the entire set of pages
-* as we don't want these pages allocated for other purposes.
-*/
-   start = round_down(phys_initrd_start, PAGE_SIZE);
-   size = phys_initrd_size + (phys_initrd_start - start);
-   size = round_up(size, PAGE_SIZE);
-
-   if (!memblock_is_region_memory(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region",
-  (u64)start, size);
-   goto disable;
-   }
-
-   if (memblock_is_region_reserved(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory 
region\n",
-  (u64)start, size);
-   goto disable;
-   }
-
-   memblock_reserve(start, size);
-   /* Now convert initrd to virtual addresses */
-   initrd_start = (unsigned long)__va(phys_initrd_start);
-   initrd_end = initrd_start + phys_initrd_size;
-   initrd_below_start_ok = 1;
-
-   pr_info("Initial ramdisk at: 0x%p (%lu bytes)\n",
-   (void *)(initrd_start), size);
-   return;
-disable:
-   pr_cont(" - disabling initrd\n");
-   initrd_start = 0;
-   initrd_end = 0;
-}
-#endif /* CONFIG_BLK_DEV_INITRD */
-
 void __init setup_bootmem(void)
 {
phys_addr_t mem_start = 0;
@@ -198,9 +149,7 @@ void __init setup_bootmem(void)
dma32_phys_limit = min(4UL * SZ_1G, (unsigned 
long)PFN_PHYS(max_low_pfn));
set_max_mapnr(max_low_pfn);
 
-#ifdef CONFIG_BLK_DEV_INITRD
-   set

[PATCH v2] initramfs: Provide a common initrd reserve function

2021-01-13 Thread Kefeng Wang
The ARM and riscv have same logic to check and reserve
the memory of initrd, let's provide a common function to
reduce duplicated code.

Add __LINUX_INITRD_H define in initrd.h to prevent build error
(found by kernel test robot ) from the multiple
inclusion of same header file multiple time.

Signed-off-by: Kefeng Wang 
---
v2: fix build err

 arch/arm/mm/init.c | 43 +-
 arch/riscv/mm/init.c   | 53 +-
 include/linux/initrd.h | 11 +
 init/initramfs.c   | 45 +++
 4 files changed, 58 insertions(+), 94 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..a29e14cd626c 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -153,47 +153,6 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, 
phys_addr_t align)
return phys;
 }
 
-static void __init arm_initrd_init(void)
-{
-#ifdef CONFIG_BLK_DEV_INITRD
-   phys_addr_t start;
-   unsigned long size;
-
-   initrd_start = initrd_end = 0;
-
-   if (!phys_initrd_size)
-   return;
-
-   /*
-* Round the memory region to page boundaries as per free_initrd_mem()
-* This allows us to detect whether the pages overlapping the initrd
-* are in use, but more importantly, reserves the entire set of pages
-* as we don't want these pages allocated for other purposes.
-*/
-   start = round_down(phys_initrd_start, PAGE_SIZE);
-   size = phys_initrd_size + (phys_initrd_start - start);
-   size = round_up(size, PAGE_SIZE);
-
-   if (!memblock_is_region_memory(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region - 
disabling initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   if (memblock_is_region_reserved(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory region 
- disabling initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   memblock_reserve(start, size);
-
-   /* Now convert initrd to virtual addresses */
-   initrd_start = __phys_to_virt(phys_initrd_start);
-   initrd_end = initrd_start + phys_initrd_size;
-#endif
-}
-
 #ifdef CONFIG_CPU_ICACHE_MISMATCH_WORKAROUND
 void check_cpu_icache_size(int cpuid)
 {
@@ -215,7 +174,7 @@ void __init arm_memblock_init(const struct machine_desc 
*mdesc)
/* Register the kernel text, kernel data and initrd with memblock. */
memblock_reserve(__pa(KERNEL_START), KERNEL_END - KERNEL_START);
 
-   arm_initrd_init();
+   reserve_initrd_mem();
 
arm_mm_memblock_reserve();
 
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index da53902ef0fc..93cba0d3f43f 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -105,55 +105,6 @@ void __init mem_init(void)
print_vm_layout();
 }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static void __init setup_initrd(void)
-{
-   phys_addr_t start;
-   unsigned long size;
-
-   /* Ignore the virtul address computed during device tree parsing */
-   initrd_start = initrd_end = 0;
-
-   if (!phys_initrd_size)
-   return;
-   /*
-* Round the memory region to page boundaries as per free_initrd_mem()
-* This allows us to detect whether the pages overlapping the initrd
-* are in use, but more importantly, reserves the entire set of pages
-* as we don't want these pages allocated for other purposes.
-*/
-   start = round_down(phys_initrd_start, PAGE_SIZE);
-   size = phys_initrd_size + (phys_initrd_start - start);
-   size = round_up(size, PAGE_SIZE);
-
-   if (!memblock_is_region_memory(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region",
-  (u64)start, size);
-   goto disable;
-   }
-
-   if (memblock_is_region_reserved(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory 
region\n",
-  (u64)start, size);
-   goto disable;
-   }
-
-   memblock_reserve(start, size);
-   /* Now convert initrd to virtual addresses */
-   initrd_start = (unsigned long)__va(phys_initrd_start);
-   initrd_end = initrd_start + phys_initrd_size;
-   initrd_below_start_ok = 1;
-
-   pr_info("Initial ramdisk at: 0x%p (%lu bytes)\n",
-   (void *)(initrd_start), size);
-   return;
-disable:
-   pr_cont(" - disabling initrd\n");
-   initrd_start = 0;
-   initrd_end = 0;
-}
-#endif /* CONFIG_BLK_DEV_INITRD */
-
 void __init setup_bootmem(void)
 {
phys_addr_t mem_start = 0;
@@ -198,9 +149,7 @@ void __init setup_bootmem(void)
dma32_phys_limit = min(4UL * SZ_1G, (unsigned 
long)PFN_PHYS(max_low

[PATCH v3 1/4] initrd: Add the preprocessor guard in initrd.h

2021-01-14 Thread Kefeng Wang
Add the preprocessor guard in initrd.h to prevent possible
build error from the multiple inclusion of same header file
multiple time.

Signed-off-by: Kefeng Wang 
---
 include/linux/initrd.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/linux/initrd.h b/include/linux/initrd.h
index 8db6f8c8030b..fc30ac30e10e 100644
--- a/include/linux/initrd.h
+++ b/include/linux/initrd.h
@@ -1,5 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 
+#ifndef __LINUX_INITRD_H
+#define __LINUX_INITRD_H
+
 #define INITRD_MINOR 250 /* shouldn't collide with /dev/ram* too soon ... */
 
 /* starting block # of image */
@@ -24,3 +27,5 @@ extern char __initramfs_start[];
 extern unsigned long __initramfs_size;
 
 void console_on_rootfs(void);
+
+#endif /* __LINUX_INITRD_H */
-- 
2.26.2



[PATCH v3 0/4] initrd: Use unified initrd reserve function in ARM/RISCV

2021-01-14 Thread Kefeng Wang
Use the same implementation of initrd reserve to avoid duplication.

v3:
- split into four patches, suggested-by Palmer Dabbelt
v2:
- fix build error found by kernel test robot

Kefeng Wang (4):
  initrd: Add the preprocessor guard in initrd.h
  initramfs: Provide a common initrd reserve function
  ARM: Covert to reserve_initrd_mem()
  riscv: Covert to reserve_initrd_mem()

 arch/arm/mm/init.c | 43 +
 arch/riscv/mm/init.c   | 54 +-
 include/linux/initrd.h | 11 +
 init/initramfs.c   | 45 +++
 4 files changed, 58 insertions(+), 95 deletions(-)

-- 
2.26.2



[PATCH v3 2/4] initramfs: Provide a common initrd reserve function

2021-01-14 Thread Kefeng Wang
Some architectures(eg, ARM and riscv) have similar logic to
check and reserve the memory of initrd, let's provide a common
function reserve_initrd_mem() to reduce duplicated code.

Signed-off-by: Kefeng Wang 
---
 include/linux/initrd.h |  6 ++
 init/initramfs.c   | 45 ++
 2 files changed, 51 insertions(+)

diff --git a/include/linux/initrd.h b/include/linux/initrd.h
index fc30ac30e10e..85c15717af34 100644
--- a/include/linux/initrd.h
+++ b/include/linux/initrd.h
@@ -18,6 +18,12 @@ extern int initrd_below_start_ok;
 extern unsigned long initrd_start, initrd_end;
 extern void free_initrd_mem(unsigned long, unsigned long);
 
+#ifdef CONFIG_BLK_DEV_INITRD
+extern void __init reserve_initrd_mem(void);
+#else
+static inline void __init reserve_initrd_mem(void) {}
+#endif
+
 extern phys_addr_t phys_initrd_start;
 extern unsigned long phys_initrd_size;
 
diff --git a/init/initramfs.c b/init/initramfs.c
index 55b74d7e5260..f75c89e9d602 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -535,6 +535,51 @@ extern unsigned long __initramfs_size;
 #include 
 #include 
 
+void __init reserve_initrd_mem(void)
+{
+   phys_addr_t start;
+   unsigned long size;
+
+   /* Ignore the virtul address computed during device tree parsing */
+   initrd_start = initrd_end = 0;
+
+   if (!phys_initrd_size)
+   return;
+   /*
+* Round the memory region to page boundaries as per free_initrd_mem()
+* This allows us to detect whether the pages overlapping the initrd
+* are in use, but more importantly, reserves the entire set of pages
+* as we don't want these pages allocated for other purposes.
+*/
+   start = round_down(phys_initrd_start, PAGE_SIZE);
+   size = phys_initrd_size + (phys_initrd_start - start);
+   size = round_up(size, PAGE_SIZE);
+
+   if (!memblock_is_region_memory(start, size)) {
+   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region",
+  (u64)start, size);
+   goto disable;
+   }
+
+   if (memblock_is_region_reserved(start, size)) {
+   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory 
region\n",
+  (u64)start, size);
+   goto disable;
+   }
+
+   memblock_reserve(start, size);
+   /* Now convert initrd to virtual addresses */
+   initrd_start = (unsigned long)__va(phys_initrd_start);
+   initrd_end = initrd_start + phys_initrd_size;
+   initrd_below_start_ok = 1;
+
+   return;
+disable:
+   pr_cont(" - disabling initrd\n");
+   initrd_start = 0;
+   initrd_end = 0;
+}
+
 void __weak __init free_initrd_mem(unsigned long start, unsigned long end)
 {
 #ifdef CONFIG_ARCH_KEEP_MEMBLOCK
-- 
2.26.2



[PATCH v3 4/4] riscv: Covert to reserve_initrd_mem()

2021-01-14 Thread Kefeng Wang
Covert to the generic reserve_initrd_mem() function.

Signed-off-by: Kefeng Wang 
---
 arch/riscv/mm/init.c | 54 +---
 1 file changed, 1 insertion(+), 53 deletions(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index bf5379135e39..1eaae54c8ea1 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -105,55 +105,6 @@ void __init mem_init(void)
print_vm_layout();
 }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static void __init setup_initrd(void)
-{
-   phys_addr_t start;
-   unsigned long size;
-
-   /* Ignore the virtul address computed during device tree parsing */
-   initrd_start = initrd_end = 0;
-
-   if (!phys_initrd_size)
-   return;
-   /*
-* Round the memory region to page boundaries as per free_initrd_mem()
-* This allows us to detect whether the pages overlapping the initrd
-* are in use, but more importantly, reserves the entire set of pages
-* as we don't want these pages allocated for other purposes.
-*/
-   start = round_down(phys_initrd_start, PAGE_SIZE);
-   size = phys_initrd_size + (phys_initrd_start - start);
-   size = round_up(size, PAGE_SIZE);
-
-   if (!memblock_is_region_memory(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region",
-  (u64)start, size);
-   goto disable;
-   }
-
-   if (memblock_is_region_reserved(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory 
region\n",
-  (u64)start, size);
-   goto disable;
-   }
-
-   memblock_reserve(start, size);
-   /* Now convert initrd to virtual addresses */
-   initrd_start = (unsigned long)__va(phys_initrd_start);
-   initrd_end = initrd_start + phys_initrd_size;
-   initrd_below_start_ok = 1;
-
-   pr_info("Initial ramdisk at: 0x%p (%lu bytes)\n",
-   (void *)(initrd_start), size);
-   return;
-disable:
-   pr_cont(" - disabling initrd\n");
-   initrd_start = 0;
-   initrd_end = 0;
-}
-#endif /* CONFIG_BLK_DEV_INITRD */
-
 void __init setup_bootmem(void)
 {
phys_addr_t mem_start = 0;
@@ -186,10 +137,7 @@ void __init setup_bootmem(void)
dma32_phys_limit = min(4UL * SZ_1G, (unsigned 
long)PFN_PHYS(max_low_pfn));
set_max_mapnr(max_low_pfn);
 
-#ifdef CONFIG_BLK_DEV_INITRD
-   setup_initrd();
-#endif /* CONFIG_BLK_DEV_INITRD */
-
+   reserve_initrd_mem();
/*
 * Avoid using early_init_fdt_reserve_self() since __pa() does
 * not work for DTB pointers that are fixmap addresses
-- 
2.26.2



[PATCH v3 3/4] ARM: Covert to reserve_initrd_mem()

2021-01-14 Thread Kefeng Wang
Covert to the generic reserve_initrd_mem() function.

Signed-off-by: Kefeng Wang 
---
 arch/arm/mm/init.c | 43 +--
 1 file changed, 1 insertion(+), 42 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..a29e14cd626c 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -153,47 +153,6 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, 
phys_addr_t align)
return phys;
 }
 
-static void __init arm_initrd_init(void)
-{
-#ifdef CONFIG_BLK_DEV_INITRD
-   phys_addr_t start;
-   unsigned long size;
-
-   initrd_start = initrd_end = 0;
-
-   if (!phys_initrd_size)
-   return;
-
-   /*
-* Round the memory region to page boundaries as per free_initrd_mem()
-* This allows us to detect whether the pages overlapping the initrd
-* are in use, but more importantly, reserves the entire set of pages
-* as we don't want these pages allocated for other purposes.
-*/
-   start = round_down(phys_initrd_start, PAGE_SIZE);
-   size = phys_initrd_size + (phys_initrd_start - start);
-   size = round_up(size, PAGE_SIZE);
-
-   if (!memblock_is_region_memory(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region - 
disabling initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   if (memblock_is_region_reserved(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory region 
- disabling initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   memblock_reserve(start, size);
-
-   /* Now convert initrd to virtual addresses */
-   initrd_start = __phys_to_virt(phys_initrd_start);
-   initrd_end = initrd_start + phys_initrd_size;
-#endif
-}
-
 #ifdef CONFIG_CPU_ICACHE_MISMATCH_WORKAROUND
 void check_cpu_icache_size(int cpuid)
 {
@@ -215,7 +174,7 @@ void __init arm_memblock_init(const struct machine_desc 
*mdesc)
/* Register the kernel text, kernel data and initrd with memblock. */
memblock_reserve(__pa(KERNEL_START), KERNEL_END - KERNEL_START);
 
-   arm_initrd_init();
+   reserve_initrd_mem();
 
arm_mm_memblock_reserve();
 
-- 
2.26.2



Re: [PATCH v2] initramfs: Provide a common initrd reserve function

2021-01-14 Thread Kefeng Wang



On 2021/1/15 10:33, Palmer Dabbelt wrote:
On Wed, 13 Jan 2021 18:33:58 PST (-0800), wangkefeng.w...@huawei.com 
wrote:

The ARM and riscv have same logic to check and reserve
the memory of initrd, let's provide a common function to
reduce duplicated code.

Add __LINUX_INITRD_H define in initrd.h to prevent build error
(found by kernel test robot ) from the multiple
inclusion of same header file multiple time.


This is doing a bunch of different things:

* Fixing the lack of a preprocessor guard in initrd.h
* Adding some generic code.
* Converting two architectures over to that generic code.

It needs to be split into four patches.  I'm happy to take them via 
the RISC-V tree (with an Ack from for the arch/arm/ stuff), but not 
all together.


It looks like csky copied this as well, they at least have exactly the 
same message.


Send v3, according to the suggestion,thanks.



[PATCH -next] sched/fair: Move update_nohz_stats() under CONFIG_NO_HZ_COMMON

2021-03-30 Thread Kefeng Wang
update_nohz_stats() only call _nohz_idle_balance() under CONFIG_NO_HZ_COMMON.

Signed-off-by: Kefeng Wang 
---
 kernel/sched/fair.c | 40 ++--
 1 file changed, 18 insertions(+), 22 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 6d73bdbb2d40..2a20ada83cbb 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8395,28 +8395,6 @@ group_type group_classify(unsigned int imbalance_pct,
return group_has_spare;
 }
 
-static bool update_nohz_stats(struct rq *rq)
-{
-#ifdef CONFIG_NO_HZ_COMMON
-   unsigned int cpu = rq->cpu;
-
-   if (!rq->has_blocked_load)
-   return false;
-
-   if (!cpumask_test_cpu(cpu, nohz.idle_cpus_mask))
-   return false;
-
-   if (!time_after(jiffies, READ_ONCE(rq->last_blocked_load_update_tick)))
-   return true;
-
-   update_blocked_averages(cpu);
-
-   return rq->has_blocked_load;
-#else
-   return false;
-#endif
-}
-
 /**
  * update_sg_lb_stats - Update sched_group's statistics for load balancing.
  * @env: The load balancing environment.
@@ -10380,6 +10358,24 @@ void nohz_balance_enter_idle(int cpu)
WRITE_ONCE(nohz.has_blocked, 1);
 }
 
+static bool update_nohz_stats(struct rq *rq)
+{
+   unsigned int cpu = rq->cpu;
+
+   if (!rq->has_blocked_load)
+   return false;
+
+   if (!cpumask_test_cpu(cpu, nohz.idle_cpus_mask))
+   return false;
+
+   if (!time_after(jiffies, READ_ONCE(rq->last_blocked_load_update_tick)))
+   return true;
+
+   update_blocked_averages(cpu);
+
+   return rq->has_blocked_load;
+}
+
 /*
  * Internal function that runs load balance for all idle cpus. The load balance
  * can be a simple update of blocked load or a complete load balance with
-- 
2.26.2



Re: [PATCH -next] sched/fair: Move update_nohz_stats() under CONFIG_NO_HZ_COMMON

2021-03-30 Thread Kefeng Wang



On 2021/3/30 20:22, Vincent Guittot wrote:

On Tue, 30 Mar 2021 at 14:06, Kefeng Wang  wrote:

update_nohz_stats() only call _nohz_idle_balance() under CONFIG_NO_HZ_COMMON.

a similar patch has already been sent and reviewed :
20210329144029.29200-1-yuehaib...@huawei.com

ok please ignore it.



Re: [PATCH v2] mm: Move mem_init_print_info() into mm_init()

2021-03-30 Thread Kefeng Wang

Hi Andrew, kindly ping

On 2021/3/17 9:52, Kefeng Wang wrote:

mem_init_print_info() is called in mem_init() on each architecture,
and pass NULL argument, so using void argument and move it into mm_init().

Acked-by: Dave Hansen 
Signed-off-by: Kefeng Wang 
---
v2:
- Cleanup 'str' line suggested by Christophe and ACK

  arch/alpha/mm/init.c |  1 -
  arch/arc/mm/init.c   |  1 -
  arch/arm/mm/init.c   |  2 --
  arch/arm64/mm/init.c |  2 --
  arch/csky/mm/init.c  |  1 -
  arch/h8300/mm/init.c |  2 --
  arch/hexagon/mm/init.c   |  1 -
  arch/ia64/mm/init.c  |  1 -
  arch/m68k/mm/init.c  |  1 -
  arch/microblaze/mm/init.c|  1 -
  arch/mips/loongson64/numa.c  |  1 -
  arch/mips/mm/init.c  |  1 -
  arch/mips/sgi-ip27/ip27-memory.c |  1 -
  arch/nds32/mm/init.c |  1 -
  arch/nios2/mm/init.c |  1 -
  arch/openrisc/mm/init.c  |  2 --
  arch/parisc/mm/init.c|  2 --
  arch/powerpc/mm/mem.c|  1 -
  arch/riscv/mm/init.c |  1 -
  arch/s390/mm/init.c  |  2 --
  arch/sh/mm/init.c|  1 -
  arch/sparc/mm/init_32.c  |  2 --
  arch/sparc/mm/init_64.c  |  1 -
  arch/um/kernel/mem.c |  1 -
  arch/x86/mm/init_32.c|  2 --
  arch/x86/mm/init_64.c|  2 --
  arch/xtensa/mm/init.c|  1 -
  include/linux/mm.h   |  2 +-
  init/main.c  |  1 +
  mm/page_alloc.c  | 10 +-
  30 files changed, 7 insertions(+), 42 deletions(-)

diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index 3c42b3147fd6..a97650a618f1 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -282,5 +282,4 @@ mem_init(void)
set_max_mapnr(max_low_pfn);
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
  }
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index ce07e697916c..33832e36bdb7 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -194,7 +194,6 @@ void __init mem_init(void)
  {
memblock_free_all();
highmem_init();
-   mem_init_print_info(NULL);
  }
  
  #ifdef CONFIG_HIGHMEM

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..7022b7b5c400 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -316,8 +316,6 @@ void __init mem_init(void)
  
  	free_highpages();
  
-	mem_init_print_info(NULL);

-
/*
 * Check boundaries twice: Some fundamental inconsistencies can
 * be detected at build time already.
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 3685e12aba9b..e8f29a0bb2f1 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -491,8 +491,6 @@ void __init mem_init(void)
/* this will put all unused low memory onto the freelists */
memblock_free_all();
  
-	mem_init_print_info(NULL);

-
/*
 * Check boundaries twice: Some fundamental inconsistencies can be
 * detected at build time already.
diff --git a/arch/csky/mm/init.c b/arch/csky/mm/init.c
index 894050a8ce09..bf2004aa811a 100644
--- a/arch/csky/mm/init.c
+++ b/arch/csky/mm/init.c
@@ -107,7 +107,6 @@ void __init mem_init(void)
free_highmem_page(page);
}
  #endif
-   mem_init_print_info(NULL);
  }
  
  void free_initmem(void)

diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 1f3b345d68b9..f7bf4693e3b2 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -98,6 +98,4 @@ void __init mem_init(void)
  
  	/* this will put all low memory onto the freelists */

memblock_free_all();
-
-   mem_init_print_info(NULL);
  }
diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c
index f2e6c868e477..f01e91e10d95 100644
--- a/arch/hexagon/mm/init.c
+++ b/arch/hexagon/mm/init.c
@@ -55,7 +55,6 @@ void __init mem_init(void)
  {
/*  No idea where this is actually declared.  Seems to evade LXR.  */
memblock_free_all();
-   mem_init_print_info(NULL);
  
  	/*

 *  To-Do:  someone somewhere should wipe out the bootmem map
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 16d0d7d22657..83280e2df807 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -659,7 +659,6 @@ mem_init (void)
set_max_mapnr(max_low_pfn);
high_memory = __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
  
  	/*

 * For fsyscall entrpoints with no light-weight handler, use the 
ordinary
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 14c1e541451c..1759ab875d47 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -153,5 +153,4 @@ void __init mem_init(void)
/* this will put all memory onto the freelists */
memblock_free_all();
init_poin

Re: [PATCH v6] RISC-V: enable XIP

2021-03-31 Thread Kefeng Wang
Hi,some error when enable XIP_KERNEL config,ARCH_HAS_STRICT_KERNEL_RWX 
should disable when enable XIP_KERNEL,


but there

riscv64-linux-ld: section .data LMA [0080,008cd37f] 
overlaps section .rodata LMA [00706bc0,0085dd67]
riscv64-linux-ld: section .pci_fixup LMA 
[0085dd68,00861397] overlaps section .data LMA 
[0080,008cd37f]

riscv64-linux-ld: arch/riscv/mm/init.o: in function `.L138':
init.c:(.text+0x232): undefined reference to `__init_text_begin'
riscv64-linux-ld: arch/riscv/mm/init.o: in function 
`protect_kernel_text_data':

init.c:(.text+0x23a): undefined reference to `__init_data_begin'
riscv64-linux-ld: init.c:(.text+0x28c): undefined reference to 
`__init_text_begin'
riscv64-linux-ld: init.c:(.text+0x2a0): undefined reference to 
`__init_data_begin'


On 2021/3/22 8:12, Vitaly Wool wrote:

Introduce XIP (eXecute In Place) support for RISC-V platforms.
It allows code to be executed directly from non-volatile storage
directly addressable by the CPU, such as QSPI NOR flash which can
be found on many RISC-V platforms. This makes way for significant
optimization of RAM footprint. The XIP kernel is not compressed
since it has to run directly from flash, so it will occupy more
space on the non-volatile storage. The physical flash address used
to link the kernel object files and for storing it has to be known
at compile time and is represented by a Kconfig option.

XIP on RISC-V will for the time being only work on MMU-enabled
kernels.

Signed-off-by: Vitaly Wool 

---

Changes in v2:
- dedicated macro for XIP address fixup when MMU is not enabled yet
   o both for 32-bit and 64-bit RISC-V
- SP is explicitly set to a safe place in RAM before __copy_data call
- removed redundant alignment requirements in vmlinux-xip.lds.S
- changed long -> uintptr_t typecast in __XIP_FIXUP macro.
Changes in v3:
- rebased against latest for-next
- XIP address fixup macro now takes an argument
- SMP related fixes
Changes in v4:
- rebased against the current for-next
- less #ifdef's in C/ASM code
- dedicated XIP_FIXUP_OFFSET assembler macro in head.S
- C-specific definitions moved into #ifndef __ASSEMBLY__
- Fixed multi-core boot
Changes in v5:
- fixed build error for non-XIP kernels
Changes in v6:
- XIP_PHYS_RAM_BASE config option renamed to PHYS_RAM_BASE
- added PHYS_RAM_BASE_FIXED config flag to allow usage of
   PHYS_RAM_BASE in non-XIP configurations if needed
- XIP_FIXUP macro rewritten with a tempoarary variable to avoid side
   effects
- fixed crash for non-XIP kernels that don't use built-in DTB

  arch/riscv/Kconfig  |  49 ++-
  arch/riscv/Makefile |   8 +-
  arch/riscv/boot/Makefile|  13 +++
  arch/riscv/include/asm/pgtable.h|  65 --
  arch/riscv/kernel/cpu_ops_sbi.c |  11 ++-
  arch/riscv/kernel/head.S|  49 ++-
  arch/riscv/kernel/head.h|   3 +
  arch/riscv/kernel/setup.c   |   8 +-
  arch/riscv/kernel/vmlinux-xip.lds.S | 132 
  arch/riscv/kernel/vmlinux.lds.S |   6 ++
  arch/riscv/mm/init.c| 100 +++--
  11 files changed, 426 insertions(+), 18 deletions(-)
  create mode 100644 arch/riscv/kernel/vmlinux-xip.lds.S

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 8ea60a0a19ae..bd6f82240c34 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -441,7 +441,7 @@ config EFI_STUB
  
  config EFI

bool "UEFI runtime support"
-   depends on OF
+   depends on OF && !XIP_KERNEL
select LIBFDT
select UCS2_STRING
select EFI_PARAMS_FROM_FDT
@@ -465,11 +465,56 @@ config STACKPROTECTOR_PER_TASK
def_bool y
depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS
  
+config PHYS_RAM_BASE_FIXED

+   bool "Explicitly specified physical RAM address"
+   default n
+
+config PHYS_RAM_BASE
+   hex "Platform Physical RAM address"
+   depends on PHYS_RAM_BASE_FIXED
+   default "0x8000"
+   help
+ This is the physical address of RAM in the system. It has to be
+ explicitly specified to run early relocations of read-write data
+ from flash to RAM.
+
+config XIP_KERNEL
+   bool "Kernel Execute-In-Place from ROM"
+   depends on MMU
+   select PHYS_RAM_BASE_FIXED
+   help
+ Execute-In-Place allows the kernel to run from non-volatile storage
+ directly addressable by the CPU, such as NOR flash. This saves RAM
+ space since the text section of the kernel is not loaded from flash
+ to RAM.  Read-write sections, such as the data section and stack,
+ are still copied to RAM.  The XIP kernel is not compressed since
+ it has to run directly from flash, so it will take more space to
+ store it.  The flash address used to link the kernel object files,
+ and for storing it, is configuration dependent. Theref

[PATCH] mm: Move mem_init_print_info() into mm_init()

2021-03-16 Thread Kefeng Wang
mem_init_print_info() is called in mem_init() on each architecture,
and pass NULL argument, cleanup it by using void argument and move
it into mm_init().

Signed-off-by: Kefeng Wang 
---
 arch/alpha/mm/init.c | 1 -
 arch/arc/mm/init.c   | 1 -
 arch/arm/mm/init.c   | 2 --
 arch/arm64/mm/init.c | 2 --
 arch/csky/mm/init.c  | 1 -
 arch/h8300/mm/init.c | 2 --
 arch/hexagon/mm/init.c   | 1 -
 arch/ia64/mm/init.c  | 1 -
 arch/m68k/mm/init.c  | 1 -
 arch/microblaze/mm/init.c| 1 -
 arch/mips/loongson64/numa.c  | 1 -
 arch/mips/mm/init.c  | 1 -
 arch/mips/sgi-ip27/ip27-memory.c | 1 -
 arch/nds32/mm/init.c | 1 -
 arch/nios2/mm/init.c | 1 -
 arch/openrisc/mm/init.c  | 2 --
 arch/parisc/mm/init.c| 2 --
 arch/powerpc/mm/mem.c| 1 -
 arch/riscv/mm/init.c | 1 -
 arch/s390/mm/init.c  | 2 --
 arch/sh/mm/init.c| 1 -
 arch/sparc/mm/init_32.c  | 2 --
 arch/sparc/mm/init_64.c  | 1 -
 arch/um/kernel/mem.c | 1 -
 arch/x86/mm/init_32.c| 2 --
 arch/x86/mm/init_64.c| 2 --
 arch/xtensa/mm/init.c| 1 -
 include/linux/mm.h   | 2 +-
 init/main.c  | 1 +
 mm/page_alloc.c  | 2 +-
 30 files changed, 3 insertions(+), 38 deletions(-)

diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index 3c42b3147fd6..a97650a618f1 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -282,5 +282,4 @@ mem_init(void)
set_max_mapnr(max_low_pfn);
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
 }
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index ce07e697916c..33832e36bdb7 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -194,7 +194,6 @@ void __init mem_init(void)
 {
memblock_free_all();
highmem_init();
-   mem_init_print_info(NULL);
 }
 
 #ifdef CONFIG_HIGHMEM
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..7022b7b5c400 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -316,8 +316,6 @@ void __init mem_init(void)
 
free_highpages();
 
-   mem_init_print_info(NULL);
-
/*
 * Check boundaries twice: Some fundamental inconsistencies can
 * be detected at build time already.
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 3685e12aba9b..e8f29a0bb2f1 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -491,8 +491,6 @@ void __init mem_init(void)
/* this will put all unused low memory onto the freelists */
memblock_free_all();
 
-   mem_init_print_info(NULL);
-
/*
 * Check boundaries twice: Some fundamental inconsistencies can be
 * detected at build time already.
diff --git a/arch/csky/mm/init.c b/arch/csky/mm/init.c
index 894050a8ce09..bf2004aa811a 100644
--- a/arch/csky/mm/init.c
+++ b/arch/csky/mm/init.c
@@ -107,7 +107,6 @@ void __init mem_init(void)
free_highmem_page(page);
}
 #endif
-   mem_init_print_info(NULL);
 }
 
 void free_initmem(void)
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 1f3b345d68b9..f7bf4693e3b2 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -98,6 +98,4 @@ void __init mem_init(void)
 
/* this will put all low memory onto the freelists */
memblock_free_all();
-
-   mem_init_print_info(NULL);
 }
diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c
index f2e6c868e477..f01e91e10d95 100644
--- a/arch/hexagon/mm/init.c
+++ b/arch/hexagon/mm/init.c
@@ -55,7 +55,6 @@ void __init mem_init(void)
 {
/*  No idea where this is actually declared.  Seems to evade LXR.  */
memblock_free_all();
-   mem_init_print_info(NULL);
 
/*
 *  To-Do:  someone somewhere should wipe out the bootmem map
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 16d0d7d22657..83280e2df807 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -659,7 +659,6 @@ mem_init (void)
set_max_mapnr(max_low_pfn);
high_memory = __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
 
/*
 * For fsyscall entrpoints with no light-weight handler, use the 
ordinary
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 14c1e541451c..1759ab875d47 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -153,5 +153,4 @@ void __init mem_init(void)
/* this will put all memory onto the freelists */
memblock_free_all();
init_pointer_tables();
-   mem_init_print_info(NULL);
 }
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 05cf1fb3f5ff..ab55c70380a5 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm

Re: [PATCH] mm: Move mem_init_print_info() into mm_init()

2021-03-16 Thread Kefeng Wang



On 2021/3/16 22:47, Christophe Leroy wrote:



Le 16/03/2021 à 15:26, Kefeng Wang a écrit :

mem_init_print_info() is called in mem_init() on each architecture,
and pass NULL argument, cleanup it by using void argument and move
it into mm_init().

Signed-off-by: Kefeng Wang 
---
  arch/alpha/mm/init.c | 1 -
  arch/arc/mm/init.c   | 1 -
  arch/arm/mm/init.c   | 2 --
  arch/arm64/mm/init.c | 2 --
  arch/csky/mm/init.c  | 1 -
  arch/h8300/mm/init.c | 2 --
  arch/hexagon/mm/init.c   | 1 -
  arch/ia64/mm/init.c  | 1 -
  arch/m68k/mm/init.c  | 1 -
  arch/microblaze/mm/init.c    | 1 -
  arch/mips/loongson64/numa.c  | 1 -
  arch/mips/mm/init.c  | 1 -
  arch/mips/sgi-ip27/ip27-memory.c | 1 -
  arch/nds32/mm/init.c | 1 -
  arch/nios2/mm/init.c | 1 -
  arch/openrisc/mm/init.c  | 2 --
  arch/parisc/mm/init.c    | 2 --
  arch/powerpc/mm/mem.c    | 1 -
  arch/riscv/mm/init.c | 1 -
  arch/s390/mm/init.c  | 2 --
  arch/sh/mm/init.c    | 1 -
  arch/sparc/mm/init_32.c  | 2 --
  arch/sparc/mm/init_64.c  | 1 -
  arch/um/kernel/mem.c | 1 -
  arch/x86/mm/init_32.c    | 2 --
  arch/x86/mm/init_64.c    | 2 --
  arch/xtensa/mm/init.c    | 1 -
  include/linux/mm.h   | 2 +-
  init/main.c  | 1 +
  mm/page_alloc.c  | 2 +-
  30 files changed, 3 insertions(+), 38 deletions(-)




diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 55d938297ce6..e4a6bf69c806 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7728,7 +7728,7 @@ unsigned long free_reserved_area(void *start, 
void *end, int poison, const char

  return pages;
  }
  -void __init mem_init_print_info(const char *str)
+void __init mem_init_print_info(void)
  {
  unsigned long physpages, codesize, datasize, rosize, bss_size;
  unsigned long init_code_size, init_data_size;



And what about the 'str' in the last line of the function ?

pr_info("Memory: %luK/%luK available (%luK kernel code, %luK 
rwdata, %luK rodata, %luK init, %luK bss, %luK reserved, %luK 
cma-reserved"

#ifdef    CONFIG_HIGHMEM
    ", %luK highmem"
#endif
    "%s%s)\n",
    nr_free_pages() << (PAGE_SHIFT - 10),
    physpages << (PAGE_SHIFT - 10),
    codesize >> 10, datasize >> 10, rosize >> 10,
    (init_data_size + init_code_size) >> 10, bss_size >> 10,
    (physpages - totalram_pages() - totalcma_pages) << (PAGE_SHIFT 
- 10),

    totalcma_pages << (PAGE_SHIFT - 10),
#ifdef    CONFIG_HIGHMEM
    totalhigh_pages() << (PAGE_SHIFT - 10),
#endif
    str ? ", " : "", str ? str : "");


oh,   I send a bad version,firstly I want to split two patches, one for 
function move, one for function change.


sorry, please ignore it, thanks for your remind.




Christophe
.



[PATCH RESEND] mm: Move mem_init_print_info() into mm_init()

2021-03-16 Thread Kefeng Wang
mem_init_print_info() is called in mem_init() on each architecture,
and pass NULL argument, so using void argument and move it into mm_init().

Signed-off-by: Kefeng Wang 
---

Resend with 'str' line cleanup, and only test on ARM64 qemu.

 arch/alpha/mm/init.c | 1 -
 arch/arc/mm/init.c   | 1 -
 arch/arm/mm/init.c   | 2 --
 arch/arm64/mm/init.c | 2 --
 arch/csky/mm/init.c  | 1 -
 arch/h8300/mm/init.c | 2 --
 arch/hexagon/mm/init.c   | 1 -
 arch/ia64/mm/init.c  | 1 -
 arch/m68k/mm/init.c  | 1 -
 arch/microblaze/mm/init.c| 1 -
 arch/mips/loongson64/numa.c  | 1 -
 arch/mips/mm/init.c  | 1 -
 arch/mips/sgi-ip27/ip27-memory.c | 1 -
 arch/nds32/mm/init.c | 1 -
 arch/nios2/mm/init.c | 1 -
 arch/openrisc/mm/init.c  | 2 --
 arch/parisc/mm/init.c| 2 --
 arch/powerpc/mm/mem.c| 1 -
 arch/riscv/mm/init.c | 1 -
 arch/s390/mm/init.c  | 2 --
 arch/sh/mm/init.c| 1 -
 arch/sparc/mm/init_32.c  | 2 --
 arch/sparc/mm/init_64.c  | 1 -
 arch/um/kernel/mem.c | 1 -
 arch/x86/mm/init_32.c| 2 --
 arch/x86/mm/init_64.c| 2 --
 arch/xtensa/mm/init.c| 1 -
 include/linux/mm.h   | 2 +-
 init/main.c  | 1 +
 mm/page_alloc.c  | 6 +++---
 30 files changed, 5 insertions(+), 40 deletions(-)

diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index 3c42b3147fd6..a97650a618f1 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -282,5 +282,4 @@ mem_init(void)
set_max_mapnr(max_low_pfn);
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
 }
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index ce07e697916c..33832e36bdb7 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -194,7 +194,6 @@ void __init mem_init(void)
 {
memblock_free_all();
highmem_init();
-   mem_init_print_info(NULL);
 }
 
 #ifdef CONFIG_HIGHMEM
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..7022b7b5c400 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -316,8 +316,6 @@ void __init mem_init(void)
 
free_highpages();
 
-   mem_init_print_info(NULL);
-
/*
 * Check boundaries twice: Some fundamental inconsistencies can
 * be detected at build time already.
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 3685e12aba9b..e8f29a0bb2f1 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -491,8 +491,6 @@ void __init mem_init(void)
/* this will put all unused low memory onto the freelists */
memblock_free_all();
 
-   mem_init_print_info(NULL);
-
/*
 * Check boundaries twice: Some fundamental inconsistencies can be
 * detected at build time already.
diff --git a/arch/csky/mm/init.c b/arch/csky/mm/init.c
index 894050a8ce09..bf2004aa811a 100644
--- a/arch/csky/mm/init.c
+++ b/arch/csky/mm/init.c
@@ -107,7 +107,6 @@ void __init mem_init(void)
free_highmem_page(page);
}
 #endif
-   mem_init_print_info(NULL);
 }
 
 void free_initmem(void)
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 1f3b345d68b9..f7bf4693e3b2 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -98,6 +98,4 @@ void __init mem_init(void)
 
/* this will put all low memory onto the freelists */
memblock_free_all();
-
-   mem_init_print_info(NULL);
 }
diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c
index f2e6c868e477..f01e91e10d95 100644
--- a/arch/hexagon/mm/init.c
+++ b/arch/hexagon/mm/init.c
@@ -55,7 +55,6 @@ void __init mem_init(void)
 {
/*  No idea where this is actually declared.  Seems to evade LXR.  */
memblock_free_all();
-   mem_init_print_info(NULL);
 
/*
 *  To-Do:  someone somewhere should wipe out the bootmem map
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 16d0d7d22657..83280e2df807 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -659,7 +659,6 @@ mem_init (void)
set_max_mapnr(max_low_pfn);
high_memory = __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
 
/*
 * For fsyscall entrpoints with no light-weight handler, use the 
ordinary
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 14c1e541451c..1759ab875d47 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -153,5 +153,4 @@ void __init mem_init(void)
/* this will put all memory onto the freelists */
memblock_free_all();
init_pointer_tables();
-   mem_init_print_info(NULL);
 }
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 05cf1fb3f5ff..ab55c70380a5 10

Re: [PATCH] net: bridge: Fix jump_label config

2021-03-16 Thread Kefeng Wang



On 2021/2/27 4:19, Cong Wang wrote:

On Thu, Feb 25, 2021 at 5:39 PM Kefeng Wang  wrote:


On 2021/2/26 5:22, Cong Wang wrote:

On Wed, Feb 24, 2021 at 8:03 AM Kefeng Wang  wrote:

HAVE_JUMP_LABLE is removed by commit e9666d10a567 ("jump_label: move
'asm goto' support test to Kconfig"), use CONFIG_JUMP_LABLE instead
of HAVE_JUMP_LABLE.

Fixes: 971502d77faa ("bridge: netfilter: unroll NF_HOOK helper in bridge input 
path")
Signed-off-by: Kefeng Wang 

Hmm, why do we have to use a macro here? static_key_false() is defined
in both cases, CONFIG_JUMP_LABEL=y or CONFIG_JUMP_LABEL=n.

It seems that all nf_hooks_needed related are using the macro,

see net/netfilter/core.c and include/linux/netfilter.h,

#ifdef CONFIG_JUMP_LABEL
struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
EXPORT_SYMBOL(nf_hooks_needed);
#endif

nf_static_key_inc()/nf_static_key_dec()

Same question: why? Clearly struct static_key is defined in both cases:


Hi Cong,  the nf_hooks_needed is wrapped up by this macro, so this place 
should use it,


or we will meet the build issue,  thanks.

../net/bridge/br_input.c: In function ‘nf_hook_bridge_pre’:
../net/bridge/br_input.c:211:25: error: ‘nf_hooks_needed’ undeclared 
(first use in this function)
  211 |  if 
(!static_key_false(&nf_hooks_needed[NFPROTO_BRIDGE][NF_BR_PRE_ROUTING]))





#else
struct static_key {
 atomic_t enabled;
};
#endif  /* CONFIG_JUMP_LABEL */

Thanks.



[PATCH v2] mm: Move mem_init_print_info() into mm_init()

2021-03-16 Thread Kefeng Wang
mem_init_print_info() is called in mem_init() on each architecture,
and pass NULL argument, so using void argument and move it into mm_init().

Acked-by: Dave Hansen 
Signed-off-by: Kefeng Wang 
---
v2:
- Cleanup 'str' line suggested by Christophe and ACK

 arch/alpha/mm/init.c |  1 -
 arch/arc/mm/init.c   |  1 -
 arch/arm/mm/init.c   |  2 --
 arch/arm64/mm/init.c |  2 --
 arch/csky/mm/init.c  |  1 -
 arch/h8300/mm/init.c |  2 --
 arch/hexagon/mm/init.c   |  1 -
 arch/ia64/mm/init.c  |  1 -
 arch/m68k/mm/init.c  |  1 -
 arch/microblaze/mm/init.c|  1 -
 arch/mips/loongson64/numa.c  |  1 -
 arch/mips/mm/init.c  |  1 -
 arch/mips/sgi-ip27/ip27-memory.c |  1 -
 arch/nds32/mm/init.c |  1 -
 arch/nios2/mm/init.c |  1 -
 arch/openrisc/mm/init.c  |  2 --
 arch/parisc/mm/init.c|  2 --
 arch/powerpc/mm/mem.c|  1 -
 arch/riscv/mm/init.c |  1 -
 arch/s390/mm/init.c  |  2 --
 arch/sh/mm/init.c|  1 -
 arch/sparc/mm/init_32.c  |  2 --
 arch/sparc/mm/init_64.c  |  1 -
 arch/um/kernel/mem.c |  1 -
 arch/x86/mm/init_32.c|  2 --
 arch/x86/mm/init_64.c|  2 --
 arch/xtensa/mm/init.c|  1 -
 include/linux/mm.h   |  2 +-
 init/main.c  |  1 +
 mm/page_alloc.c  | 10 +-
 30 files changed, 7 insertions(+), 42 deletions(-)

diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index 3c42b3147fd6..a97650a618f1 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -282,5 +282,4 @@ mem_init(void)
set_max_mapnr(max_low_pfn);
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
 }
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index ce07e697916c..33832e36bdb7 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -194,7 +194,6 @@ void __init mem_init(void)
 {
memblock_free_all();
highmem_init();
-   mem_init_print_info(NULL);
 }
 
 #ifdef CONFIG_HIGHMEM
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..7022b7b5c400 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -316,8 +316,6 @@ void __init mem_init(void)
 
free_highpages();
 
-   mem_init_print_info(NULL);
-
/*
 * Check boundaries twice: Some fundamental inconsistencies can
 * be detected at build time already.
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 3685e12aba9b..e8f29a0bb2f1 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -491,8 +491,6 @@ void __init mem_init(void)
/* this will put all unused low memory onto the freelists */
memblock_free_all();
 
-   mem_init_print_info(NULL);
-
/*
 * Check boundaries twice: Some fundamental inconsistencies can be
 * detected at build time already.
diff --git a/arch/csky/mm/init.c b/arch/csky/mm/init.c
index 894050a8ce09..bf2004aa811a 100644
--- a/arch/csky/mm/init.c
+++ b/arch/csky/mm/init.c
@@ -107,7 +107,6 @@ void __init mem_init(void)
free_highmem_page(page);
}
 #endif
-   mem_init_print_info(NULL);
 }
 
 void free_initmem(void)
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 1f3b345d68b9..f7bf4693e3b2 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -98,6 +98,4 @@ void __init mem_init(void)
 
/* this will put all low memory onto the freelists */
memblock_free_all();
-
-   mem_init_print_info(NULL);
 }
diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c
index f2e6c868e477..f01e91e10d95 100644
--- a/arch/hexagon/mm/init.c
+++ b/arch/hexagon/mm/init.c
@@ -55,7 +55,6 @@ void __init mem_init(void)
 {
/*  No idea where this is actually declared.  Seems to evade LXR.  */
memblock_free_all();
-   mem_init_print_info(NULL);
 
/*
 *  To-Do:  someone somewhere should wipe out the bootmem map
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 16d0d7d22657..83280e2df807 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -659,7 +659,6 @@ mem_init (void)
set_max_mapnr(max_low_pfn);
high_memory = __va(max_low_pfn * PAGE_SIZE);
memblock_free_all();
-   mem_init_print_info(NULL);
 
/*
 * For fsyscall entrpoints with no light-weight handler, use the 
ordinary
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 14c1e541451c..1759ab875d47 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -153,5 +153,4 @@ void __init mem_init(void)
/* this will put all memory onto the freelists */
memblock_free_all();
init_pointer_tables();
-   mem_init_print_info(NULL);
 }
diff --git a/arch/microblaze/mm/init.c b/arch/mic

Re: [PATCH] mm: Move mem_init_print_info() into mm_init()

2021-03-16 Thread Kefeng Wang

please use v2, sorry for the wrong version.

On 2021/3/17 2:01, kernel test robot wrote:

Hi Kefeng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/x86/mm]
[also build test ERROR on linus/master v5.12-rc3 next-20210316]
[cannot apply to hnaz-linux-mm/master sparc/master sparc-next/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Kefeng-Wang/mm-Move-mem_init_print_info-into-mm_init/20210316-222501
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
a500fc918f7b8dc3dff2e6c74f3e73e856c18248
config: riscv-randconfig-r031-20210316 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 
50c7504a93fdb90c26870db8c8ea7add895c7725)
reproduce (this is a W=1 build):
 wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
 chmod +x ~/bin/make.cross
 # install riscv cross compiling tool for clang build
 # apt-get install binutils-riscv64-linux-gnu
 # 
https://github.com/0day-ci/linux/commit/0b2c07917fb7f9f87f0e2ecac3a3985155778856
 git remote add linux-review https://github.com/0day-ci/linux
 git fetch --no-tags linux-review 
Kefeng-Wang/mm-Move-mem_init_print_info-into-mm_init/20210316-222501
 git checkout 0b2c07917fb7f9f87f0e2ecac3a3985155778856
 # save the attached .config to linux build tree
 COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv

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

All errors (new ones prefixed by >>):

mm/page_alloc.c:3600:15: warning: no previous prototype for function 
'should_fail_alloc_page' [-Wmissing-prototypes]
noinline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
  ^
mm/page_alloc.c:3600:10: note: declare 'static' if the function is not 
intended to be used outside of this translation unit
noinline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
 ^
 static

mm/page_alloc.c:7744:3: error: use of undeclared identifier 'str'

str ? ", " : "", str ? str : "");
^
mm/page_alloc.c:7744:20: error: use of undeclared identifier 'str'
str ? ", " : "", str ? str : "");
 ^
mm/page_alloc.c:7744:26: error: use of undeclared identifier 'str'
str ? ", " : "", str ? str : "");
   ^
1 warning and 3 errors generated.


vim +/str +7744 mm/page_alloc.c

7ee3d4e8cd5605 Jiang Liu   2013-07-03  7729
756a025f000919 Joe Perches 2016-03-17  7730 pr_info("Memory: %luK/%luK available 
(%luK kernel code, %luK rwdata, %luK rodata, %luK init, %luK bss, %luK reserved, %luK 
cma-reserved"
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7731  #ifdef CONFIG_HIGHMEM
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7732 ", %luK highmem"
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7733  #endif
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7734 "%s%s)\n",
756a025f000919 Joe Perches 2016-03-17  7735 nr_free_pages() << 
(PAGE_SHIFT - 10),
756a025f000919 Joe Perches 2016-03-17  7736 physpages << 
(PAGE_SHIFT - 10),
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7737 codesize >> 10, datasize >> 
10, rosize >> 10,
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7738 (init_data_size + init_code_size) 
>> 10, bss_size >> 10,
ca79b0c211af63 Arun KS 2018-12-28  7739 (physpages - totalram_pages() 
- totalcma_pages) << (PAGE_SHIFT - 10),
e48322abb061d7 Pintu Kumar 2014-12-18  7740 totalcma_pages << 
(PAGE_SHIFT - 10),
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7741  #ifdef CONFIG_HIGHMEM
ca79b0c211af63 Arun KS 2018-12-28  7742 totalhigh_pages() << 
(PAGE_SHIFT - 10),
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7743  #endif
7ee3d4e8cd5605 Jiang Liu   2013-07-03 @7744 str ? ", " : "", str ? str : 
"");
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7745  }
7ee3d4e8cd5605 Jiang Liu   2013-07-03  7746

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


[PATCH] mm: Move HOLES_IN_ZONE into mm

2021-04-17 Thread Kefeng Wang
commit a55749639dc1 ("ia64: drop marked broken DISCONTIGMEM and 
VIRTUAL_MEM_MAP")
drop VIRTUAL_MEM_MAP, so there is no need HOLES_IN_ZONE on ia64.

Also move HOLES_IN_ZONE into mm/Kconfig, select it if architecture needs
this feature.

Signed-off-by: Kefeng Wang 
---
 arch/arm64/Kconfig | 4 +---
 arch/ia64/Kconfig  | 3 ---
 arch/mips/Kconfig  | 3 ---
 mm/Kconfig | 3 +++
 4 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index f0b17d758912..3c5a53e0db91 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -202,6 +202,7 @@ config ARM64
select HAVE_KPROBES
select HAVE_KRETPROBES
select HAVE_GENERIC_VDSO
+   select HOLES_IN_ZONE
select IOMMU_DMA if IOMMU_SUPPORT
select IRQ_DOMAIN
select IRQ_FORCED_THREADING
@@ -1053,9 +1054,6 @@ config NEED_PER_CPU_EMBED_FIRST_CHUNK
def_bool y
depends on NUMA
 
-config HOLES_IN_ZONE
-   def_bool y
-
 source "kernel/Kconfig.hz"
 
 config ARCH_SPARSEMEM_ENABLE
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 279252e3e0f7..36499e99102d 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -308,9 +308,6 @@ config NODES_SHIFT
  MAX_NUMNODES will be 2^(This value).
  If in doubt, use the default.
 
-config HOLES_IN_ZONE
-   bool
-
 config HAVE_ARCH_NODEDATA_EXTENSION
def_bool y
depends on NUMA
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 7a174ea61ca5..c6d522fbd67d 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1233,9 +1233,6 @@ config HAVE_PLAT_MEMCPY
 config ISA_DMA_API
bool
 
-config HOLES_IN_ZONE
-   bool
-
 config SYS_SUPPORTS_RELOCATABLE
bool
help
diff --git a/mm/Kconfig b/mm/Kconfig
index a8a367c30053..afc57cbf1cea 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -128,6 +128,9 @@ config HAVE_FAST_GUP
depends on MMU
bool
 
+config HOLES_IN_ZONE
+   bool
+
 # Don't discard allocated memory used to track "memory" and "reserved" 
memblocks
 # after early boot, so it can still be used to test for validity of memory.
 # Also, memblocks are updated with memory hot(un)plug.
-- 
2.26.2



Re: [PATCH v2] mm: Move mem_init_print_info() into mm_init()

2021-03-16 Thread Kefeng Wang



On 2021/3/17 13:48, Christophe Leroy wrote:



Le 17/03/2021 à 02:52, Kefeng Wang a écrit :

mem_init_print_info() is called in mem_init() on each architecture,
and pass NULL argument, so using void argument and move it into 
mm_init().


Acked-by: Dave Hansen 
Signed-off-by: Kefeng Wang 
---
v2:
- Cleanup 'str' line suggested by Christophe and ACK

  arch/alpha/mm/init.c |  1 -
  arch/arc/mm/init.c   |  1 -
  arch/arm/mm/init.c   |  2 --
  arch/arm64/mm/init.c |  2 --
  arch/csky/mm/init.c  |  1 -
  arch/h8300/mm/init.c |  2 --
  arch/hexagon/mm/init.c   |  1 -
  arch/ia64/mm/init.c  |  1 -
  arch/m68k/mm/init.c  |  1 -
  arch/microblaze/mm/init.c    |  1 -
  arch/mips/loongson64/numa.c  |  1 -
  arch/mips/mm/init.c  |  1 -
  arch/mips/sgi-ip27/ip27-memory.c |  1 -
  arch/nds32/mm/init.c |  1 -
  arch/nios2/mm/init.c |  1 -
  arch/openrisc/mm/init.c  |  2 --
  arch/parisc/mm/init.c    |  2 --
  arch/powerpc/mm/mem.c    |  1 -
  arch/riscv/mm/init.c |  1 -
  arch/s390/mm/init.c  |  2 --
  arch/sh/mm/init.c    |  1 -
  arch/sparc/mm/init_32.c  |  2 --
  arch/sparc/mm/init_64.c  |  1 -
  arch/um/kernel/mem.c |  1 -
  arch/x86/mm/init_32.c    |  2 --
  arch/x86/mm/init_64.c    |  2 --
  arch/xtensa/mm/init.c    |  1 -
  include/linux/mm.h   |  2 +-
  init/main.c  |  1 +
  mm/page_alloc.c  | 10 +-
  30 files changed, 7 insertions(+), 42 deletions(-)




diff --git a/include/linux/mm.h b/include/linux/mm.h
index 89314651dd62..c2e0b3495c5a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2373,7 +2373,7 @@ extern unsigned long free_reserved_area(void 
*start, void *end,

  int poison, const char *s);
    extern void adjust_managed_page_count(struct page *page, long 
count);

-extern void mem_init_print_info(const char *str);
+extern void mem_init_print_info(void);


Sorry I didn't see that in previous patch.

'extern' keyword is pointless for function prototypes and is 
deprecated, you should remove it.


That said,

Reviewed-by: Christophe Leroy  # focussed on 
powerpc
Thanks, let's wait for more feedback from other architectures, if 
necessary,  will send a new one.


    extern void reserve_bootmem_region(phys_addr_t start, phys_addr_t 
end);

.



Re: [PATCH v2] mm: Move mem_init_print_info() into mm_init()

2021-03-17 Thread Kefeng Wang



On 2021/3/18 2:48, Dave Hansen wrote:

On 3/16/21 6:52 PM, Kefeng Wang wrote:

mem_init_print_info() is called in mem_init() on each architecture,
and pass NULL argument, so using void argument and move it into mm_init().

Acked-by: Dave Hansen 

It's not a big deal but you might want to say something like:

Acked-by: Dave Hansen  # x86 bits

Just to make it clear that I didn't look at the alpha bits at all. :)

Get it, will be careful, thanks.

.



Re: [syzbot] KASAN: slab-out-of-bounds Read in riscv_intc_irq

2021-03-18 Thread Kefeng Wang



On 2021/3/14 18:47, Dmitry Vyukov wrote:

On Sun, Mar 14, 2021 at 11:14 AM syzbot
 wrote:

Hello,

syzbot found the following issue on:

HEAD commit:0d7588ab riscv: process: Fix no prototype for arch_dup_tas..
git tree:   git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git 
fixes
console output: https://syzkaller.appspot.com/x/log.txt?x=15a35756d0
kernel config:  https://syzkaller.appspot.com/x/.config?x=81c0b708b31626cc
dashboard link: https://syzkaller.appspot.com/bug?extid=005654dd9b8f26bd4c07
userspace arch: riscv64

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

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

==
BUG: KASAN: slab-out-of-bounds in riscv_intc_irq+0x24/0xcc 
drivers/irqchip/irq-riscv-intc.c:24
Read of size 8 at addr ffe00c963bd0 by task kworker/1:1/4388

CPU: 1 PID: 4388 Comm: kworker/1:1 Not tainted 
5.12.0-rc2-syzkaller-00467-g0d7588ab9ef9 #0
Hardware name: riscv-virtio,qemu (DT)
Workqueue: events nsim_dev_trap_report_work
Call Trace:
[] walk_stackframe+0x0/0x23c arch/riscv/kernel/traps.c:201

Allocated by task 76347056:
(stack is not available)

Last potentially related work creation:

There seems to be some issue with riscv stack unwinder.
This does not have stacks.


Hi, could you test with the following  patch about the no stack 
issue(from v5.11-rc4), I made a mistake when do some cleanup...


https://lore.kernel.org/linux-riscv/ce5b3533-b75d-c31c-4319-9d29769bb...@huawei.com/T/#t


"BUG: unable to handle kernel access to user memory in schedule_tail"
does not have proper stacks:
https://syzkaller.appspot.com/bug?id=9de8c24d24004fd5e482555f5ad8314da2fb1cee

I also found 2 riscv reports in "KASAN: use-after-free Read in
idr_for_each (2)":
https://syzkaller.appspot.com/bug?id=7f84dfc3902878befc22e52eb5c7298d0ad70cf3

both don't have any stacks:

==
BUG: KASAN: use-after-free in radix_tree_next_slot
include/linux/radix-tree.h:422 [inline]
BUG: KASAN: use-after-free in idr_for_each+0xf4/0x160 lib/idr.c:202
Read of size 8 at addr ffe010c00878 by task syz-executor.1/4828

CPU: 0 PID: 4828 Comm: syz-executor.1 Not tainted
5.12.0-rc2-syzkaller-00467-g0d7588ab9ef9 #0
Hardware name: riscv-virtio,qemu (DT)
Call Trace:
[] walk_stackframe+0x0/0x23c arch/riscv/kernel/traps.c:201

Allocated by task 4828:
(stack is not available)

Freed by task 4473:
(stack is not available)



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

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

___
linux-riscv mailing list
linux-ri...@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
.



Re: [syzbot] KASAN: slab-out-of-bounds Read in riscv_intc_irq

2021-03-18 Thread Kefeng Wang



On 2021/3/18 22:11, Dmitry Vyukov wrote:

On Thu, Mar 18, 2021 at 1:21 PM Kefeng Wang  wrote:

On 2021/3/14 18:47, Dmitry Vyukov wrote:

On Sun, Mar 14, 2021 at 11:14 AM syzbot
 wrote:

Hello,

syzbot found the following issue on:

HEAD commit:0d7588ab riscv: process: Fix no prototype for arch_dup_tas..
git tree:   git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git 
fixes
console output: https://syzkaller.appspot.com/x/log.txt?x=15a35756d0
kernel config:  https://syzkaller.appspot.com/x/.config?x=81c0b708b31626cc
dashboard link: https://syzkaller.appspot.com/bug?extid=005654dd9b8f26bd4c07
userspace arch: riscv64

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

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

==
BUG: KASAN: slab-out-of-bounds in riscv_intc_irq+0x24/0xcc 
drivers/irqchip/irq-riscv-intc.c:24
Read of size 8 at addr ffe00c963bd0 by task kworker/1:1/4388

CPU: 1 PID: 4388 Comm: kworker/1:1 Not tainted 
5.12.0-rc2-syzkaller-00467-g0d7588ab9ef9 #0
Hardware name: riscv-virtio,qemu (DT)
Workqueue: events nsim_dev_trap_report_work
Call Trace:
[] walk_stackframe+0x0/0x23c arch/riscv/kernel/traps.c:201

Allocated by task 76347056:
(stack is not available)

Last potentially related work creation:

There seems to be some issue with riscv stack unwinder.
This does not have stacks.

Hi, could you test with the following  patch about the no stack
issue(from v5.11-rc4), I made a mistake when do some cleanup...

https://lore.kernel.org/linux-riscv/ce5b3533-b75d-c31c-4319-9d29769bb...@huawei.com/T/#t

Hi Kefeng,

Please see:
http://bit.do/syzbot#no-custom-patches

Is a unit-test for this possible? Fuzzing is not a replacement for unit testing.


ok, I mean that the issue about stack unwinder which may cause by my 
previous patch,


if some one want the stack back, it could try the bugfix.


.



Re: [PATCH] drivers: clocksource: timer-riscv: Depend on the SBI

2020-11-25 Thread Kefeng Wang

Hi Palmer,  I send a same patch and have been acked from you : )

https://patchwork.kernel.org/project/linux-riscv/patch/20201028131230.72907-1-wangkefeng.w...@huawei.com/

On 2020/11/26 3:58, Palmer Dabbelt wrote:

From: Palmer Dabbelt 

Fundamentally this is an SBI timer driver, so it cannot be enabled without
support for the RISC-V SBI.

Fixes: d5be89a8d118 ("RISC-V: Resurrect the MMIO timer implementation for M-mode 
systems")
Signed-off-by: Palmer Dabbelt 
---
  drivers/clocksource/Kconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 68b087bff59c..3eeaf0efba8f 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -655,6 +655,7 @@ config ATCPIT100_TIMER
  config RISCV_TIMER
bool "Timer for the RISC-V platform" if COMPILE_TEST
depends on GENERIC_SCHED_CLOCK && RISCV
+   depends on RISCV_SBI
select TIMER_PROBE
select TIMER_OF
help


Re: [PATCH] printk: finalize records with trailing newlines

2020-11-26 Thread Kefeng Wang



On 2020/11/26 19:48, John Ogness wrote:

Any record with a trailing newline (LOG_NEWLINE flag) cannot
be continued because the newline has been stripped and will
not be visible if the message is appended. This was already
handled correctly when committing in log_output() but was
not handled correctly when committing in log_store().

Fixes: f5f022e53b87 ("printk: reimplement log_cont using record extension")
Signed-off-by: John Ogness 
---
  This is an important bugfix for continuous messages and should
  be part of the 5.10 release.

  If not applied, newlines will vanish when concatenating
  continuous with trailing newlines.

Thanks for you quick fix.

Reported-and-tested-by:  Kefeng Wang 


  kernel/printk/printk.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index fe64a49344bf..bc1e3b5a97bd 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -528,8 +528,8 @@ static int log_store(u32 caller_id, int facility, int level,
if (dev_info)
memcpy(&r.info->dev_info, dev_info, sizeof(r.info->dev_info));
  
-	/* insert message */

-   if ((flags & LOG_CONT) || !(flags & LOG_NEWLINE))
+   /* A message without a trailing newline can be continued. */
+   if (!(flags & LOG_NEWLINE))
prb_commit(&e);
else
prb_final_commit(&e);


Re: [PATCH v3 0/4] initrd: Use unified initrd reserve function in ARM/RISCV

2021-01-21 Thread Kefeng Wang



On 2021/1/18 17:17, Russell King - ARM Linux admin wrote:

On Mon, Jan 18, 2021 at 09:01:40AM +0800, Kefeng Wang wrote:

On 2021/1/17 18:09, Russell King - ARM Linux admin wrote:

On Sun, Jan 17, 2021 at 12:57:55PM +0800, Kefeng Wang wrote:

Correct Russell's mail address (from li...@armlinux.org.uk to
rmk+ker...@armlinux.org.uk, should update the MAINTAINERS)

No. MAINTAINERS is correct.

I got following message,  so I check mail of your recent patches, and send a
new one.

Please ignore it, there may be some other problems.

"*Delivery has failed to these recipients or groups:*

li...@armlinux.org.uk <mailto:li...@armlinux.org.uk>
A communication failure occurred during the delivery of this message. Please
to resend the message later. If the problem continues, contact your
helpdesk."

That is a most unhelpful bounce message - I suppose it's designed for
non-technical people to ensure that the problem can't be resolved.

>From what I can see from my end, every attempt involving your email
address last week (wangkefeng.w...@huawei.com) has been successful, so
I suspect the problem is not at my end.


ok,thank you for letting me know that the email has been received,

any comment about the ARM part in the patchset  ;)



In any case, all @armlinux.org.uk addresses hit the same server, so
if there's a "communication failure" for the domain, it would affect
all local-parts equally.



Re: drivers/scsi/myrs.c:2449:13: sparse: sparse: incorrect type in assignment (different base types)

2021-01-15 Thread Kefeng Wang



On 2021/1/15 16:50, kernel test robot wrote:

Hi Kefeng,

First bad commit (maybe != root cause):


Hi, the commit in patchset[1], which make riscv random build happier, 
won't lead to the following problem.


I think the driver should fix the sparse error.


[1] https://lkml.org/lkml/2020/5/10/456



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   5ee88057889bbca5f5bb96031b62b3756b33e164
commit: ed1ed4c0da5447c5e322481ce2ef9f03336c6ffb riscv: mmiowb: Fix implicit 
declaration of function 'smp_processor_id'
date:   8 months ago
config: riscv-randconfig-s032-20210115 (attached as .config)
compiler: riscv32-linux-gcc (GCC) 9.3.0
reproduce:
 wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
 chmod +x ~/bin/make.cross
 # apt-get install sparse
 # sparse version: v0.6.3-208-g46a52ca4-dirty
 # 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed1ed4c0da5447c5e322481ce2ef9f03336c6ffb
 git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
 git fetch --no-tags linus master
 git checkout ed1ed4c0da5447c5e322481ce2ef9f03336c6ffb
 # save the attached .config to linux build tree
 COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=riscv

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


"sparse warnings: (new ones prefixed by >>)"
drivers/scsi/myrs.c:1532:5: sparse: sparse: symbol 'myrs_host_reset' was 
not declared. Should it be static?
drivers/scsi/myrs.c:1922:27: sparse: sparse: symbol 'myrs_template' was not 
declared. Should it be static?
drivers/scsi/myrs.c:2036:31: sparse: sparse: symbol 'myrs_raid_functions' 
was not declared. Should it be static?
drivers/scsi/myrs.c:2046:6: sparse: sparse: symbol 'myrs_flush_cache' was 
not declared. Should it be static?
drivers/scsi/myrs.c:2275:34: sparse: sparse: incorrect type in argument 1 
(different address spaces) @@ expected void [noderef]  *base @@ 
got struct myrs_hba *cs @@
drivers/scsi/myrs.c:2275:34: sparse: expected void [noderef]  
*base
drivers/scsi/myrs.c:2275:34: sparse: got struct myrs_hba *cs
drivers/scsi/myrs.c:2434:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2502:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2427:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2502:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2413:9: sparse: sparse: cast from restricted __le32

drivers/scsi/myrs.c:2449:13: sparse: sparse: incorrect type in assignment 
(different base types) @@ expected restricted __le32 [usertype] val @@ 
got unsigned int [assigned] [usertype] __v @@

drivers/scsi/myrs.c:2449:13: sparse: expected restricted __le32 
[usertype] val
drivers/scsi/myrs.c:2449:13: sparse: got unsigned int [assigned] 
[usertype] __v
drivers/scsi/myrs.c:2549:13: sparse: sparse: incorrect type in assignment 
(different base types) @@ expected restricted __le32 [usertype] val @@ 
got unsigned int [assigned] [usertype] __v @@
drivers/scsi/myrs.c:2549:13: sparse: expected restricted __le32 
[usertype] val
drivers/scsi/myrs.c:2549:13: sparse: got unsigned int [assigned] 
[usertype] __v
drivers/scsi/myrs.c:2552:18: sparse: sparse: restricted __le32 degrades to 
integer
drivers/scsi/myrs.c:2427:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2495:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2472:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2441:13: sparse: sparse: incorrect type in assignment 
(different base types) @@ expected restricted __le32 [usertype] val @@ 
got unsigned int [assigned] [usertype] __v @@
drivers/scsi/myrs.c:2441:13: sparse: expected restricted __le32 
[usertype] val
drivers/scsi/myrs.c:2441:13: sparse: got unsigned int [assigned] 
[usertype] __v
drivers/scsi/myrs.c:2406:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2479:13: sparse: sparse: incorrect type in assignment 
(different base types) @@ expected restricted __le32 [usertype] val @@ 
got unsigned int [assigned] [usertype] __v @@
drivers/scsi/myrs.c:2479:13: sparse: expected restricted __le32 
[usertype] val
drivers/scsi/myrs.c:2479:13: sparse: got unsigned int [assigned] 
[usertype] __v
drivers/scsi/myrs.c:2457:9: sparse: sparse: cast from restricted __le32
drivers/scsi/myrs.c:2413:9: sparse: sparse: cast from restricted __le32
--
drivers/isdn/hardware/mISDN/avmfritz.c:175:9: sparse: sparse: cast removes 
address space '' of expression
drivers/isdn/hardware/mISDN/avmfritz.c:175:9: sparse: sparse

Re: [PATCH v3 3/4] ARM: Covert to reserve_initrd_mem()

2021-01-16 Thread Kefeng Wang

update Russell's mail address.


On 2021/1/15 13:46, Kefeng Wang wrote:

Covert to the generic reserve_initrd_mem() function.

Signed-off-by: Kefeng Wang 
---
  arch/arm/mm/init.c | 43 +--
  1 file changed, 1 insertion(+), 42 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a2561b229..a29e14cd626c 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -153,47 +153,6 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, 
phys_addr_t align)
return phys;
  }
  
-static void __init arm_initrd_init(void)

-{
-#ifdef CONFIG_BLK_DEV_INITRD
-   phys_addr_t start;
-   unsigned long size;
-
-   initrd_start = initrd_end = 0;
-
-   if (!phys_initrd_size)
-   return;
-
-   /*
-* Round the memory region to page boundaries as per free_initrd_mem()
-* This allows us to detect whether the pages overlapping the initrd
-* are in use, but more importantly, reserves the entire set of pages
-* as we don't want these pages allocated for other purposes.
-*/
-   start = round_down(phys_initrd_start, PAGE_SIZE);
-   size = phys_initrd_size + (phys_initrd_start - start);
-   size = round_up(size, PAGE_SIZE);
-
-   if (!memblock_is_region_memory(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region - disabling 
initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   if (memblock_is_region_reserved(start, size)) {
-   pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory region - 
disabling initrd\n",
-  (u64)start, size);
-   return;
-   }
-
-   memblock_reserve(start, size);
-
-   /* Now convert initrd to virtual addresses */
-   initrd_start = __phys_to_virt(phys_initrd_start);
-   initrd_end = initrd_start + phys_initrd_size;
-#endif
-}
-
  #ifdef CONFIG_CPU_ICACHE_MISMATCH_WORKAROUND
  void check_cpu_icache_size(int cpuid)
  {
@@ -215,7 +174,7 @@ void __init arm_memblock_init(const struct machine_desc 
*mdesc)
/* Register the kernel text, kernel data and initrd with memblock. */
memblock_reserve(__pa(KERNEL_START), KERNEL_END - KERNEL_START);
  
-	arm_initrd_init();

+   reserve_initrd_mem();
  
  	arm_mm_memblock_reserve();
  


Re: [PATCH v3 0/4] initrd: Use unified initrd reserve function in ARM/RISCV

2021-01-16 Thread Kefeng Wang
Correct Russell's mail address (from li...@armlinux.org.uk to 
rmk+ker...@armlinux.org.uk, should update the MAINTAINERS)


On 2021/1/15 13:46, Kefeng Wang wrote:

Use the same implementation of initrd reserve to avoid duplication.

v3:
- split into four patches, suggested-by Palmer Dabbelt
v2:
- fix build error found by kernel test robot

Kefeng Wang (4):
   initrd: Add the preprocessor guard in initrd.h
   initramfs: Provide a common initrd reserve function
   ARM: Covert to reserve_initrd_mem()
   riscv: Covert to reserve_initrd_mem()

  arch/arm/mm/init.c | 43 +
  arch/riscv/mm/init.c   | 54 +-
  include/linux/initrd.h | 11 +
  init/initramfs.c   | 45 +++
  4 files changed, 58 insertions(+), 95 deletions(-)



Re: linux-next: manual merge of the akpm-current tree with the risc-v tree

2020-12-16 Thread Kefeng Wang



On 2020/12/17 9:26, Stephen Rothwell wrote:

Hi all,

On Fri, 27 Nov 2020 18:34:41 +1100 Stephen Rothwell  
wrote:

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

   arch/riscv/Kconfig

between commit:

   5cb0080f1bfd ("riscv: Enable ARCH_STACKWALK")

from the risc-v tree and commit:

   46b9b00649f6 ("arch, mm: restore dependency of __kernel_map_pages() on 
DEBUG_PAGEALLOC")

from the akpm-current tree.

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


diff --cc arch/riscv/Kconfig
index 8a2a0523a9a3,9283c6f9ae2a..
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@@ -14,7 -14,7 +14,8 @@@ config RISC
def_bool y
select ARCH_CLOCKSOURCE_INIT
select ARCH_SUPPORTS_ATOMIC_RMW
  + select ARCH_STACKWALK
+   select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU
select ARCH_HAS_BINFMT_FLAT
select ARCH_HAS_DEBUG_VM_PGTABLE
select ARCH_HAS_DEBUG_VIRTUAL if MMU

This is now a conflict between the risc-v tree and Linus' tree.


Could it be fixed in alphabetical order when merging riscv tree?







Re: [PATCH] riscv/stacktrace: fix stackframe without ra on the top

2020-11-27 Thread Kefeng Wang



On 2020/11/27 16:45, Chen Huang wrote:

When a function doesn't have a callee, then it will not push ra
into the stack, such as lkdtm_BUG() function:

addisp,sp,-16
sd  s0,8(sp)
addis0,sp,16
ebreak

Then we use pt_regs as a parameter to walk_stackframe(), for the
struct stackframe use {fp,ra} to get information from stack, it
will get the wrong value. And the call trace will be:

[] lkdtm_BUG+0x6/0x8
---[ end trace 18da3fbdf08e25d5 ]---

It should be that:
[] lkdtm_BUG+0x6/0x8
[] lkdtm_do_action+0x14/0x1c
[] direct_entry+0xc0/0x10a
[] full_proxy_write+0x42/0x6a
[] vfs_write+0x7e/0x214
[] ksys_write+0x98/0xc0
[] sys_write+0xe/0x16
[] ret_from_syscall+0x0/0x2
---[ end trace 61917f3d9a9fadcd ]---

Signed-off-by: Chen Huang 
---
  arch/riscv/kernel/stacktrace.c | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
index 595342910c3f..d1d4c18335c4 100644
--- a/arch/riscv/kernel/stacktrace.c
+++ b/arch/riscv/kernel/stacktrace.c
@@ -57,7 +57,14 @@ void notrace walk_stackframe(struct task_struct *task, 
struct pt_regs *regs,
/* Unwind stack frame */
frame = (struct stackframe *)fp - 1;
sp = fp;
-   fp = frame->fp;
+   if (regs && (frame->fp & 0x7) && (pc == regs->epc)) {
+   fp = frame->ra;
+   pc = regs->ra;
+   continue;
+   } else {
+   fp = frame->fp;
+   }
+
pc = ftrace_graph_ret_addr(current, NULL, frame->ra,
   (unsigned long *)(fp - 8));


Better to move above code into else branch


}


Re: [PATCH 02/18] net: use wrapper functions of net_ratelimit() to simplify code

2013-10-15 Thread Kefeng Wang
Thanks for your reply.

On 10/16 0:24, Joe Perches wrote:
> On Tue, 2013-10-15 at 19:44 +0800, Kefeng Wang wrote:
>> Wrapper functions net_ratelimited_function() and net_XXX_ratelimited()
>> are called to simplify code.
> []
>> diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
> []
>> @@ -465,10 +465,8 @@ void br_fdb_update(struct net_bridge *br, struct 
>> net_bridge_port *source,
>>  if (likely(fdb)) {
>>  /* attempt to update an entry for a local interface */
>>  if (unlikely(fdb->is_local)) {
>> -if (net_ratelimit())
>> -br_warn(br, "received packet on %s with "
>> -"own address as source address\n",
>> -source->dev->name);
>> +net_ratelimited_function(br_warn, br, "received packet 
>> on %s "
>> +"with own address as source address\n", 
>> source->dev->name);
> 
> Hello Kefeng.
> 
> When these types of lines are changed, please coalesce the
> fragmented format pieces into a single string.
> 
> It makes grep a bit easier and 80 columns limits don't
> apply to formats.

Got it, I will coalesce them, but 80 columns limits will be
broken.

> I think using net_ratelimited_function is not particularly
> clarifying here.
> 
> Maybe net_ratelimited_function should be removed instead
> of its use sites expanded.
> 
> Perhaps adding macros like #define br_warn_ratelimited()
> would be better.

yes, I found dev_emerg_ratelimited already exists. I should
use them and will add some similar mcaros.

> This comment applies to the whole series.
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
> .
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 14/18] net: usb: use wrapper functions of net_ratelimit() to simplify code

2013-10-15 Thread Kefeng Wang
Thanks for you reply.
On 10/16 3:06, Sergei Shtylyov wrote:
> Hello.
> 
> On 10/15/2013 03:45 PM, Kefeng Wang wrote:
> 
>> net_ratelimited_function() is called to simplify code.
> 
>> Signed-off-by: Kefeng Wang 
>> ---
>>   drivers/net/usb/usbnet.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
>> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
>> index bf94e10..edf81de 100644
>> --- a/drivers/net/usb/usbnet.c
>> +++ b/drivers/net/usb/usbnet.c
>> @@ -450,8 +450,8 @@ void usbnet_defer_kevent (struct usbnet *dev, int work)
>>   {
>>   set_bit (work, &dev->flags);
>>   if (!schedule_work (&dev->kevent)) {
>> -if (net_ratelimit())
>> -netdev_err(dev->net, "kevent %d may have been dropped\n", work);
>> +net_ratelimited_function(netdev_err, dev->net,
>> +"kevent %d may have been dropped\n", work);
> 
>The continuation line should start under 'netdev_err'. Same about the 
> other patches where you didn't change the indentation of the continuation 
> lines though you should have.

Got it, indentation will be changed.

> WBR, Sergei
> 
> 
> .
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] fs: nfsd: use path_equal() to simply code

2013-10-14 Thread Kefeng Wang
Signed-off-by: Kefeng Wang 
---
 fs/nfsd/export.c  | 3 +--
 fs/nfsd/nfs4xdr.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 5f38ea3..ca3610d 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -649,8 +649,7 @@ static int svc_export_match(struct cache_head *a, struct 
cache_head *b)
struct svc_export *orig = container_of(a, struct svc_export, h);
struct svc_export *new = container_of(b, struct svc_export, h);
return orig->ex_client == new->ex_client &&
-   orig->ex_path.dentry == new->ex_path.dentry &&
-   orig->ex_path.mnt == new->ex_path.mnt;
+   path_equal(&orig->ex_path, &new->ex_path);
 }
 
 static void svc_export_init(struct cache_head *cnew, struct cache_head *citem)
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index d9454fe..6af4ff1 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -1829,7 +1829,7 @@ static __be32 nfsd4_encode_path(const struct path *root,
 * dentries/path components in an array.
 */
for (;;) {
-   if (cur.dentry == root->dentry && cur.mnt == root->mnt)
+   if (path_equal(&cur, root))
break;
if (cur.dentry == cur.mnt->mnt_root) {
if (follow_up(&cur))
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] fs: notify: use path_equal() to simply code

2013-10-14 Thread Kefeng Wang
Signed-off-by: Kefeng Wang 
---
 fs/notify/fanotify/fanotify.c| 3 +--
 fs/notify/inotify/inotify_fsnotify.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index 0c2f912..777af06 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -24,8 +24,7 @@ static bool should_merge(struct fsnotify_event *old, struct 
fsnotify_event *new)
(new->mask & FAN_ALL_PERM_EVENTS))
return false;
 #endif
-   if ((old->path.mnt == new->path.mnt) &&
-   (old->path.dentry == new->path.dentry))
+   if (path_equal(&old->path, &new->path))
return true;
break;
case (FSNOTIFY_EVENT_NONE):
diff --git a/fs/notify/inotify/inotify_fsnotify.c 
b/fs/notify/inotify/inotify_fsnotify.c
index 4216308..58b638d 100644
--- a/fs/notify/inotify/inotify_fsnotify.c
+++ b/fs/notify/inotify/inotify_fsnotify.c
@@ -53,8 +53,7 @@ static bool event_compare(struct fsnotify_event *old, struct 
fsnotify_event *new
return true;
break;
case (FSNOTIFY_EVENT_PATH):
-   if ((old->path.mnt == new->path.mnt) &&
-   (old->path.dentry == new->path.dentry))
+   if (path_equal(&old->path, &new->path))
return true;
break;
case (FSNOTIFY_EVENT_NONE):
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] fs: use helper function path_foo() to simpily code

2013-10-14 Thread Kefeng Wang
Use helper function patch_equal() and path_put() to simpily code.

Kefeng Wang (3):
  fs: use path_equal() and path_put() to simplify code
  fs: nfsd: use path_equal() to simply code
  fs: notify: use path_equal() to simply code

 fs/namei.c   | 20 ++--
 fs/nfsd/export.c |  3 +--
 fs/nfsd/nfs4xdr.c|  2 +-
 fs/notify/fanotify/fanotify.c|  3 +--
 fs/notify/inotify/inotify_fsnotify.c |  3 +--
 5 files changed, 10 insertions(+), 21 deletions(-)

-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] fs: use path_equal() and path_put() to simplify code

2013-10-14 Thread Kefeng Wang
Signed-off-by: Kefeng Wang 
---
 fs/namei.c | 20 ++--
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 645268f..1a6c139 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -918,9 +918,8 @@ int follow_up(struct path *path)
mntget(&parent->mnt);
mountpoint = dget(mnt->mnt_mountpoint);
br_read_unlock(&vfsmount_lock);
-   dput(path->dentry);
+   path_put(path);
path->dentry = mountpoint;
-   mntput(path->mnt);
path->mnt = &parent->mnt;
return 1;
 }
@@ -1077,8 +1076,7 @@ int follow_down_one(struct path *path)
 
mounted = lookup_mnt(path);
if (mounted) {
-   dput(path->dentry);
-   mntput(path->mnt);
+   path_put(path);
path->mnt = mounted;
path->dentry = dget(mounted->mnt_root);
return 1;
@@ -1146,10 +1144,8 @@ static int follow_dotdot_rcu(struct nameidata *nd)
set_root_rcu(nd);
 
while (1) {
-   if (nd->path.dentry == nd->root.dentry &&
-   nd->path.mnt == nd->root.mnt) {
+   if (path_equal(&nd->path, &nd->root))
break;
-   }
if (nd->path.dentry != nd->path.mnt->mnt_root) {
struct dentry *old = nd->path.dentry;
struct dentry *parent = old->d_parent;
@@ -1214,8 +1210,7 @@ int follow_down(struct path *path)
struct vfsmount *mounted = lookup_mnt(path);
if (!mounted)
break;
-   dput(path->dentry);
-   mntput(path->mnt);
+   path_put(path);
path->mnt = mounted;
path->dentry = dget(mounted->mnt_root);
continue;
@@ -1236,8 +1231,7 @@ static void follow_mount(struct path *path)
struct vfsmount *mounted = lookup_mnt(path);
if (!mounted)
break;
-   dput(path->dentry);
-   mntput(path->mnt);
+   path_put(path);
path->mnt = mounted;
path->dentry = dget(mounted->mnt_root);
}
@@ -1250,10 +1244,8 @@ static void follow_dotdot(struct nameidata *nd)
while(1) {
struct dentry *old = nd->path.dentry;
 
-   if (nd->path.dentry == nd->root.dentry &&
-   nd->path.mnt == nd->root.mnt) {
+   if (path_equal(&nd->path, &nd->root))
break;
-   }
if (nd->path.dentry != nd->path.mnt->mnt_root) {
/* rare case of legitimate dget_parent()... */
nd->path.dentry = dget_parent(nd->path.dentry);
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 06/18] net: wireless: use wrapper functions of net_ratelimit() to simplify code

2013-10-15 Thread Kefeng Wang
Wrapper functions net_ratelimited_function() and net_XXX_ratelimited()
are called to simplify code.

Signed-off-by: Kefeng Wang 
---
 drivers/net/wireless/adm8211.c|  5 ++-
 drivers/net/wireless/ath/carl9170/cmd.c   | 15 +++--
 drivers/net/wireless/ath/carl9170/phy.c   |  7 ++---
 drivers/net/wireless/ath/carl9170/rx.c| 45 ---
 drivers/net/wireless/ath/carl9170/usb.c   | 12 +++
 drivers/net/wireless/hostap/hostap_80211_rx.c |  8 ++---
 drivers/net/wireless/hostap/hostap_80211_tx.c | 13 +++-
 drivers/net/wireless/hostap/hostap_ap.c   |  6 ++--
 drivers/net/wireless/hostap/hostap_hw.c   | 17 +++---
 drivers/net/wireless/iwlegacy/3945-mac.c  |  4 +--
 drivers/net/wireless/iwlegacy/4965-mac.c  |  6 ++--
 drivers/net/wireless/iwlwifi/pcie/rx.c|  7 ++---
 drivers/net/wireless/libertas_tf/cmd.c|  6 ++--
 drivers/net/wireless/mwl8k.c  |  5 ++-
 drivers/net/wireless/orinoco/hermes.c |  6 ++--
 drivers/net/wireless/orinoco/main.c   | 16 +++---
 drivers/net/wireless/orinoco/orinoco_usb.c|  3 +-
 drivers/net/wireless/p54/p54pci.c |  6 ++--
 18 files changed, 61 insertions(+), 126 deletions(-)

diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c
index f9a24e5..2fafb8a 100644
--- a/drivers/net/wireless/adm8211.c
+++ b/drivers/net/wireless/adm8211.c
@@ -374,9 +374,8 @@ static void adm8211_interrupt_rci(struct ieee80211_hw *dev)
 
pktlen = status & RDES0_STATUS_FL;
if (pktlen > RX_PKT_SIZE) {
-   if (net_ratelimit())
-   wiphy_debug(dev->wiphy, "frame too long (%d)\n",
-   pktlen);
+   net_ratelimited_function(wiphy_debug, dev->wiphy,
+   "frame too long (%d)\n", pktlen);
pktlen = RX_PKT_SIZE;
}
 
diff --git a/drivers/net/wireless/ath/carl9170/cmd.c 
b/drivers/net/wireless/ath/carl9170/cmd.c
index 39a6387..3f13398 100644
--- a/drivers/net/wireless/ath/carl9170/cmd.c
+++ b/drivers/net/wireless/ath/carl9170/cmd.c
@@ -50,12 +50,9 @@ int carl9170_write_reg(struct ar9170 *ar, const u32 reg, 
const u32 val)
 
err = carl9170_exec_cmd(ar, CARL9170_CMD_WREG, sizeof(buf),
(u8 *) buf, 0, NULL);
-   if (err) {
-   if (net_ratelimit()) {
-   wiphy_err(ar->hw->wiphy, "writing reg %#x "
-   "(val %#x) failed (%d)\n", reg, val, err);
-   }
-   }
+   if (err)
+   net_ratelimited_function(wiphy_err, ar->hw->wiphy,
+   "writing reg %#x (val %#x) failed (%d)\n", reg, val, 
err);
return err;
 }
 
@@ -77,10 +74,8 @@ int carl9170_read_mreg(struct ar9170 *ar, const int nregs,
4 * nregs, (u8 *)offs,
4 * nregs, (u8 *)res);
if (err) {
-   if (net_ratelimit()) {
-   wiphy_err(ar->hw->wiphy, "reading regs failed (%d)\n",
- err);
-   }
+   net_ratelimited_function(wiphy_err, ar->hw->wiphy,
+   "reading regs failed (%d)\n", err);
return err;
}
 
diff --git a/drivers/net/wireless/ath/carl9170/phy.c 
b/drivers/net/wireless/ath/carl9170/phy.c
index ab4ee7d..cae9125 100644
--- a/drivers/net/wireless/ath/carl9170/phy.c
+++ b/drivers/net/wireless/ath/carl9170/phy.c
@@ -1715,11 +1715,8 @@ int carl9170_set_channel(struct ar9170 *ar, struct 
ieee80211_channel *channel,
err = carl9170_write_reg(ar, AR9170_PHY_REG_HEAVY_CLIP_ENABLE,
 0x200 | ar->heavy_clip);
if (err) {
-   if (net_ratelimit()) {
-   wiphy_err(ar->hw->wiphy, "failed to set "
-  "heavy clip\n");
-   }
-
+   net_ratelimited_function(wiphy_err,
+   ar->hw->wiphy, "failed to set heavy clip\n");
return err;
}
}
diff --git a/drivers/net/wireless/ath/carl9170/rx.c 
b/drivers/net/wireless/ath/carl9170/rx.c
index e935f61..0ad905e 100644
--- a/drivers/net/wireless/ath/carl9170/rx.c
+++ b/drivers/net/wireless/ath/carl9170/rx.c
@@ -343,9 +343,8 @@ static int carl9170_rx_mac_status(struct ar9170 *ar,
if (unlikely(error)) {
/* TODO: update netdevice's RX dropped/errors statistics */
 
-   if (net_ratelimit())
-   wiphy_dbg(ar->hw->wiphy, "received frame with "
-  

[PATCH 01/18] netfilter: cleanup: delete Macro PRINTR

2013-10-15 Thread Kefeng Wang
Macro PRINTR is only used once in nfnetlink_log.c, so it can be
replaced by helper function net_err_ratelimited().

Signed-off-by: Kefeng Wang 
---
 net/netfilter/nfnetlink_log.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index d92cc31..8713111 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -47,9 +47,6 @@
 #define NFULNL_QTHRESH_DEFAULT 100 /* 100 packets */
 #define NFULNL_COPY_RANGE_MAX  0x  /* max packet size is limited by 16-bit 
struct nfattr nfa_len field */
 
-#define PRINTR(x, args...) do { if (net_ratelimit()) \
-printk(x, ## args); } while (0);
-
 struct nfulnl_instance {
struct hlist_node hlist;/* global list of instances */
spinlock_t lock;
@@ -587,7 +584,7 @@ __build_packet_message(struct nfnl_log_net *log,
return 0;
 
 nla_put_failure:
-   PRINTR(KERN_ERR "nfnetlink_log: error creating log nlmsg\n");
+   net_err_ratelimited("nfnetlink_log: error creating log nlmsg\n");
return -1;
 }
 
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 18/18] net: wimax: use wrapper functions of net_ratelimit() to simplify code

2013-10-15 Thread Kefeng Wang
net_ratelimited_function() is called to simplify code.

Signed-off-by: Kefeng Wang 
---
 drivers/net/wimax/i2400m/netdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wimax/i2400m/netdev.c 
b/drivers/net/wimax/i2400m/netdev.c
index 4889613..678717a 100644
--- a/drivers/net/wimax/i2400m/netdev.c
+++ b/drivers/net/wimax/i2400m/netdev.c
@@ -305,8 +305,7 @@ int i2400m_net_wake_tx(struct i2400m *i2400m, struct 
net_device *net_dev,
 * queue -- blame the queue disciplines that
 * queue without looking -- I guess there is a reason
 * for that. */
-   if (net_ratelimit())
-   d_printf(1, dev, "NETTX: device exiting idle, "
+   net_ratelimited_function(d_printf, 1, dev, "NETTX: device 
exiting idle, "
 "dropping skb %p, queue running %d\n",
 skb, netif_queue_stopped(net_dev));
result = -EBUSY;
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/18] net: ethernet: use wrapper functions of net_ratelimit() to simplify code

2013-10-15 Thread Kefeng Wang
Wrapper functions net_ratelimited_function() and net_XXX_ratelimited()
are called to simplify code.

Signed-off-by: Kefeng Wang 
---
 drivers/net/ethernet/aeroflex/greth.c| 16 
 drivers/net/ethernet/alteon/acenic.c |  3 +-
 drivers/net/ethernet/arc/emac_main.c |  7 ++--
 drivers/net/ethernet/broadcom/b44.c  |  4 +-
 drivers/net/ethernet/ethoc.c |  4 +-
 drivers/net/ethernet/faraday/ftgmac100.c | 49 +++-
 drivers/net/ethernet/faraday/ftmac100.c  | 45 +++---
 drivers/net/ethernet/freescale/fec_mpc52xx.c |  3 +-
 drivers/net/ethernet/ibm/emac/mal.c  | 15 ++--
 drivers/net/ethernet/marvell/mv643xx_eth.c   |  6 +--
 drivers/net/ethernet/marvell/pxa168_eth.c|  8 +---
 drivers/net/ethernet/marvell/sky2.c  | 42 
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c |  5 +--
 drivers/net/ethernet/realtek/r8169.c | 13 +++
 drivers/net/ethernet/sfc/rx.c|  8 ++--
 drivers/net/ethernet/sfc/siena_sriov.c   | 27 +
 drivers/net/ethernet/ti/davinci_emac.c   |  4 +-
 drivers/net/ethernet/tundra/tsi108_eth.c | 12 ++
 18 files changed, 90 insertions(+), 181 deletions(-)

diff --git a/drivers/net/ethernet/aeroflex/greth.c 
b/drivers/net/ethernet/aeroflex/greth.c
index e066945..6a1a97f 100644
--- a/drivers/net/ethernet/aeroflex/greth.c
+++ b/drivers/net/ethernet/aeroflex/greth.c
@@ -569,8 +569,8 @@ frag_map_error:
greth_write_bd(&bdp->stat, 0);
}
 map_error:
-   if (net_ratelimit())
-   dev_warn(greth->dev, "Could not create TX DMA mapping\n");
+   net_ratelimited_function(dev_warn,
+   greth->dev, "Could not create TX DMA mapping\n");
dev_kfree_skb(skb);
 out:
return err;
@@ -778,8 +778,8 @@ static int greth_rx(struct net_device *dev, int limit)
 
if (unlikely(skb == NULL)) {
 
-   if (net_ratelimit())
-   dev_warn(&dev->dev, "low on memory - " 
"packet dropped\n");
+   net_ratelimited_function(dev_warn, &dev->dev,
+   "low on memory - packet 
dropped\n");
 
dev->stats.rx_dropped++;
 
@@ -918,8 +918,8 @@ static int greth_rx_gbit(struct net_device *dev, int limit)
greth->rx_skbuff[greth->rx_cur] = newskb;
greth_write_bd(&bdp->addr, dma_addr);
} else {
-   if (net_ratelimit())
-   dev_warn(greth->dev, "Could not create 
DMA mapping, dropping packet\n");
+   net_ratelimited_function(dev_warn, greth->dev,
+   "Could not create DMA mapping, dropping 
packet\n");
dev_kfree_skb(newskb);
/* reusing current skb, so it is a drop */
dev->stats.rx_dropped++;
@@ -934,8 +934,8 @@ static int greth_rx_gbit(struct net_device *dev, int limit)
 * table handling should be divided into cleaning and
 * filling as the TX part of the driver
 */
-   if (net_ratelimit())
-   dev_warn(greth->dev, "Could not allocate SKB, 
dropping packet\n");
+   net_ratelimited_function(dev_warn, greth->dev,
+   "Could not allocate SKB, dropping packet\n");
/* reusing current skb, so it is a drop */
dev->stats.rx_dropped++;
}
diff --git a/drivers/net/ethernet/alteon/acenic.c 
b/drivers/net/ethernet/alteon/acenic.c
index 219be1b..432640b 100644
--- a/drivers/net/ethernet/alteon/acenic.c
+++ b/drivers/net/ethernet/alteon/acenic.c
@@ -1799,8 +1799,7 @@ static void ace_load_jumbo_rx_ring(struct net_device 
*dev, int nr_bufs)
clear_bit(0, &ap->jumbo_refill_busy);
return;
  error_out:
-   if (net_ratelimit())
-   printk(KERN_INFO "Out of memory when allocating "
+   net_info_ratelimited("Out of memory when allocating "
   "jumbo receive buffers\n");
goto out;
 }
diff --git a/drivers/net/ethernet/arc/emac_main.c 
b/drivers/net/ethernet/arc/emac_main.c
index 9e16014..fe659b8 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -221,8 +221,8 @@ static int arc_emac_rx(struct net_device *ndev, int budget)
   

[PATCH 17/18] net: vxlan: use wrapper functions of net_ratelimit() to simplify code

2013-10-15 Thread Kefeng Wang
net_ratelimited_function() is called to simplify code.

Signed-off-by: Kefeng Wang 
---
 drivers/net/vxlan.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 2ef5b62..56583ab 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -893,8 +893,7 @@ static bool vxlan_snoop(struct net_device *dev,
if (f->state & NUD_NOARP)
return true;
 
-   if (net_ratelimit())
-   netdev_info(dev,
+   net_ratelimited_function(netdev_info, dev,
"%pM migrated from %pIS to %pIS\n",
src_mac, &rdst->remote_ip, &src_ip);
 
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 16/18] net: virtio: use wrapper functions of net_ratelimit() to simplify code

2013-10-15 Thread Kefeng Wang
net_ratelimited_function() is called to simplify code.

Signed-off-by: Kefeng Wang 
---
 drivers/net/virtio_net.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index defec2b..4f63c12 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -753,8 +753,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct 
net_device *dev)
/* This should not happen! */
if (unlikely(err)) {
dev->stats.tx_fifo_errors++;
-   if (net_ratelimit())
-   dev_warn(&dev->dev,
+   net_ratelimited_function(dev_warn, &dev->dev,
 "Unexpected TXQ (%d) queue failure: %d\n", 
qnum, err);
dev->stats.tx_dropped++;
kfree_skb(skb);
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 10/18] net: peak_usb: use wrapper functions of net_ratelimit() to simplify code

2013-10-15 Thread Kefeng Wang
net_ratelimited_function() is called to simplify code.

Signed-off-by: Kefeng Wang 
---
 drivers/net/can/usb/peak_usb/pcan_usb_core.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c 
b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
index 0b7a4c3..5166a1f 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -191,8 +191,7 @@ static void peak_usb_read_bulk_callback(struct urb *urb)
return;
 
default:
-   if (net_ratelimit())
-   netdev_err(netdev,
+   net_ratelimited_function(netdev_err, netdev,
   "Rx urb aborted (%d)\n", urb->status);
goto resubmit_urb;
}
@@ -260,9 +259,8 @@ static void peak_usb_write_bulk_callback(struct urb *urb)
break;
 
default:
-   if (net_ratelimit())
-   netdev_err(netdev, "Tx urb aborted (%d)\n",
-  urb->status);
+   net_ratelimited_function(netdev_err, netdev,
+   "Tx urb aborted (%d)\n", urb->status);
case -EPROTO:
case -ENOENT:
case -ECONNRESET:
@@ -314,8 +312,7 @@ static netdev_tx_t peak_usb_ndo_start_xmit(struct sk_buff 
*skb,
 
err = dev->adapter->dev_encode_msg(dev, skb, obuf, &size);
if (err) {
-   if (net_ratelimit())
-   netdev_err(netdev, "packet dropped\n");
+   net_ratelimited_function(netdev_err, netdev, "packet 
dropped\n");
dev_kfree_skb(skb);
stats->tx_dropped++;
return NETDEV_TX_OK;
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 13/18] net: ppp: use wrapper functions of net_ratelimit() to simplify code

2013-10-15 Thread Kefeng Wang
net_ratelimited_function() is called to simplify code.

Signed-off-by: Kefeng Wang 
---
 drivers/net/ppp/ppp_generic.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 72ff14b..53900cd 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -1125,8 +1125,8 @@ pad_compress_skb(struct ppp *ppp, struct sk_buff *skb)
ppp->xcomp->comp_extra + PPP_HDRLEN;
new_skb = alloc_skb(new_skb_size, GFP_ATOMIC);
if (!new_skb) {
-   if (net_ratelimit())
-   netdev_err(ppp->dev, "PPP: no memory (comp pkt)\n");
+   net_ratelimited_function(netdev_err, ppp->dev,
+   "PPP: no memory (comp pkt)\n");
return NULL;
}
if (ppp->dev->hard_header_len > PPP_HDRLEN)
@@ -1155,8 +1155,8 @@ pad_compress_skb(struct ppp *ppp, struct sk_buff *skb)
 * the compress_proto because MPPE and MPPC share
 * the same number.
 */
-   if (net_ratelimit())
-   netdev_err(ppp->dev, "ppp: compressor dropped pkt\n");
+   net_ratelimited_function(netdev_err, ppp->dev,
+   "ppp: compressor dropped pkt\n");
kfree_skb(skb);
consume_skb(new_skb);
new_skb = NULL;
@@ -1251,8 +1251,7 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state &&
proto != PPP_LCP && proto != PPP_CCP) {
if (!(ppp->flags & SC_CCP_UP) && (ppp->flags & SC_MUST_COMP)) {
-   if (net_ratelimit())
-   netdev_err(ppp->dev,
+   net_ratelimited_function(netdev_err, ppp->dev,
   "ppp: compression required but "
   "down - pkt dropped.\n");
goto drop;
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/18] rt18187se: use wrapper functions of net_ratelimit() to simplify code

2013-10-15 Thread Kefeng Wang
Wrapper functions net_ratelimited_function() and net_XXX_ratelimited()
are called to simplify code.

Signed-off-by: Kefeng Wang 
---
 .../rtl8187se/ieee80211/ieee80211_crypt_ccmp.c | 16 -
 .../rtl8187se/ieee80211/ieee80211_crypt_tkip.c | 27 ++
 drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c |  4 +---
 drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c |  7 ++
 4 files changed, 14 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c 
b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
index f5949e8..be6c5a1 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
@@ -282,10 +282,8 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int 
hdr_len, void *priv)
pos = skb->data + hdr_len;
keyidx = pos[3];
if (!(keyidx & (1 << 5))) {
-   if (net_ratelimit()) {
-   pr_debug("received packet without ExtIV flag from 
%pM\n",
+   net_dbg_ratelimited("received packet without ExtIV flag from 
%pM\n",
 hdr->addr2);
-   }
key->dot11RSNAStatsCCMPFormatErrors++;
return -2;
}
@@ -296,10 +294,8 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int 
hdr_len, void *priv)
return -6;
}
if (!key->key_set) {
-   if (net_ratelimit()) {
-   pr_debug("received packet from %pM with keyid=%d that 
does not have a configured key\n",
+   net_dbg_ratelimited("received packet from %pM with keyid=%d 
that does not have a configured key\n",
 hdr->addr2, keyidx);
-   }
return -3;
}
 
@@ -312,10 +308,8 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int 
hdr_len, void *priv)
pos += 8;
 
if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) {
-   if (net_ratelimit()) {
-   pr_debug("replay detected: STA=%pM previous PN %pm 
received PN %pm\n",
+   net_dbg_ratelimited("replay detected: STA=%pM previous PN %pm 
received PN %pm\n",
 hdr->addr2, key->rx_pn, pn);
-   }
key->dot11RSNAStatsCCMPReplays++;
return -4;
}
@@ -340,9 +334,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int 
hdr_len, void *priv)
}
 
if (memcmp(mic, a, CCMP_MIC_LEN) != 0) {
-   if (net_ratelimit())
-   pr_debug("decrypt failed: STA=%pM\n", hdr->addr2);
-
+   net_dbg_ratelimited("decrypt failed: STA=%pM\n", hdr->addr2);
key->dot11RSNAStatsCCMPDecryptErrors++;
return -5;
}
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c 
b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
index da24e43..03e1961 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
@@ -381,10 +381,8 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int 
hdr_len, void *priv)
pos = skb->data + hdr_len;
keyidx = pos[3];
if (!(keyidx & (1 << 5))) {
-   if (net_ratelimit()) {
-   printk(KERN_DEBUG "TKIP: received packet without ExtIV"
+   net_dbg_ratelimited("TKIP: received packet without ExtIV"
   " flag from %pM\n", hdr->addr2);
-   }
return -2;
}
keyidx >>= 6;
@@ -394,11 +392,9 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int 
hdr_len, void *priv)
return -6;
}
if (!tkey->key_set) {
-   if (net_ratelimit()) {
-   printk(KERN_DEBUG "TKIP: received packet from %pM"
+   net_dbg_ratelimited("TKIP: received packet from %pM"
   " with keyid=%d that does not have a configured"
   " key\n", hdr->addr2, keyidx);
-   }
return -3;
}
iv16 = (pos[0] << 8) | pos[2];
@@ -407,12 +403,9 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int 
hdr_len, void *priv)
 
if (iv32 < tkey->rx_iv32 ||
(iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) {
-   if (net_ratelimit()) {
-   printk(KERN_DEBUG "TKIP: replay detected: STA=%pM"
-  " previous TSC %08x%04x received TSC "
-

  1   2   3   4   5   6   >