2011-04-28 15:04:43

by KOSAKI Motohiro

[permalink] [raw]
Subject: [PATCH] cris: convert old cpumask API into new one

Adapt new API.

Signed-off-by: KOSAKI Motohiro <[email protected]>
Cc: Mikael Starvik <[email protected]>
Cc: Jesper Nilsson <[email protected]>
Cc: [email protected]

---
arch/cris/arch-v32/kernel/irq.c | 4 ++--
arch/cris/arch-v32/kernel/smp.c | 33 ++++++++++++++++++---------------
2 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/arch/cris/arch-v32/kernel/irq.c b/arch/cris/arch-v32/kernel/irq.c
index 68a1a59..5ebe6e8 100644
--- a/arch/cris/arch-v32/kernel/irq.c
+++ b/arch/cris/arch-v32/kernel/irq.c
@@ -266,11 +266,11 @@ static int irq_cpu(int irq)


/* Let the interrupt stay if possible */
- if (cpu_isset(cpu, irq_allocations[irq - FIRST_IRQ].mask))
+ if (cpumask_test_cpu(cpu, &irq_allocations[irq - FIRST_IRQ].mask))
goto out;

/* IRQ must be moved to another CPU. */
- cpu = first_cpu(irq_allocations[irq - FIRST_IRQ].mask);
+ cpu = cpumask_first(&irq_allocations[irq - FIRST_IRQ].mask);
irq_allocations[irq - FIRST_IRQ].cpu = cpu;
out:
spin_unlock_irqrestore(&irq_lock, flags);
diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c
index 66cc756..54467ec 100644
--- a/arch/cris/arch-v32/kernel/smp.c
+++ b/arch/cris/arch-v32/kernel/smp.c
@@ -81,7 +81,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)

/* Mark all possible CPUs as present */
for (i = 0; i < max_cpus; i++)
- cpu_set(i, phys_cpu_present_map);
+ cpumask_set_cpu(i, &phys_cpu_present_map);
}

void __devinit smp_prepare_boot_cpu(void)
@@ -98,7 +98,7 @@ void __devinit smp_prepare_boot_cpu(void)
SUPP_REG_WR(RW_MM_TLB_PGD, pgd);

set_cpu_online(0, true);
- cpu_set(0, phys_cpu_present_map);
+ cpumask_set_cpu(0, &phys_cpu_present_map);
set_cpu_possible(0, true);
}

@@ -112,8 +112,9 @@ smp_boot_one_cpu(int cpuid)
{
unsigned timeout;
struct task_struct *idle;
- cpumask_t cpu_mask = CPU_MASK_NONE;
+ cpumask_t cpu_mask;

+ cpumask_clear(&cpu_mask);
idle = fork_idle(cpuid);
if (IS_ERR(idle))
panic("SMP: fork failed for CPU:%d", cpuid);
@@ -125,10 +126,10 @@ smp_boot_one_cpu(int cpuid)
cpu_now_booting = cpuid;

/* Kick it */
- cpu_set(cpuid, cpu_online_map);
- cpu_set(cpuid, cpu_mask);
+ set_cpu_online(cpuid, true);
+ cpumask_set_cpu(cpuid, &cpu_mask);
send_ipi(IPI_BOOT, 0, cpu_mask);
- cpu_clear(cpuid, cpu_online_map);
+ set_cpu_online(cpuid, false);

/* Wait for CPU to come online */
for (timeout = 0; timeout < 10000; timeout++) {
@@ -176,7 +177,7 @@ void __init smp_callin(void)
notify_cpu_starting(cpu);
local_irq_enable();

- cpu_set(cpu, cpu_online_map);
+ set_cpu_online(cpu, true);
cpu_idle();
}

@@ -214,8 +215,9 @@ int __cpuinit __cpu_up(unsigned int cpu)

void smp_send_reschedule(int cpu)
{
- cpumask_t cpu_mask = CPU_MASK_NONE;
- cpu_set(cpu, cpu_mask);
+ cpumask_t cpu_mask;
+ cpumask_clear(&cpu_mask);
+ cpumask_set_cpu(cpu, &cpu_mask);
send_ipi(IPI_SCHEDULE, 0, cpu_mask);
}

@@ -232,7 +234,7 @@ void flush_tlb_common(struct mm_struct* mm, struct vm_area_struct* vma, unsigned

spin_lock_irqsave(&tlbstate_lock, flags);
cpu_mask = (mm == FLUSH_ALL ? cpu_all_mask : *mm_cpumask(mm));
- cpu_clear(smp_processor_id(), cpu_mask);
+ cpumask_clear_cpu(smp_processor_id(), &cpu_mask);
flush_mm = mm;
flush_vma = vma;
flush_addr = addr;
@@ -277,10 +279,10 @@ int send_ipi(int vector, int wait, cpumask_t cpu_mask)
int ret = 0;

/* Calculate CPUs to send to. */
- cpus_and(cpu_mask, cpu_mask, cpu_online_map);
+ cpumask_and(&cpu_mask, &cpu_mask, cpu_online_mask);

/* Send the IPI. */
- for_each_cpu_mask(i, cpu_mask)
+ for_each_cpu(i,&cpu_mask)
{
ipi.vector |= vector;
REG_WR(intr_vect, irq_regs[i], rw_ipi, ipi);
@@ -288,7 +290,7 @@ int send_ipi(int vector, int wait, cpumask_t cpu_mask)

/* Wait for IPI to finish on other CPUS */
if (wait) {
- for_each_cpu_mask(i, cpu_mask) {
+ for_each_cpu(i,&cpu_mask) {
int j;
for (j = 0 ; j < 1000; j++) {
ipi = REG_RD(intr_vect, irq_regs[i], rw_ipi);
@@ -314,11 +316,12 @@ int send_ipi(int vector, int wait, cpumask_t cpu_mask)
*/
int smp_call_function(void (*func)(void *info), void *info, int wait)
{
- cpumask_t cpu_mask = CPU_MASK_ALL;
+ cpumask_t cpu_mask;
struct call_data_struct data;
int ret;

- cpu_clear(smp_processor_id(), cpu_mask);
+ cpumask_setall(&cpu_mask);
+ cpumask_clear_cpu(smp_processor_id(), &cpu_mask);

WARN_ON(irqs_disabled());

--
1.7.3.1



2011-04-28 15:10:04

by Thiago Farina

[permalink] [raw]
Subject: Re: [PATCH] cris: convert old cpumask API into new one

On Thu, Apr 28, 2011 at 12:04 PM, KOSAKI Motohiro
<[email protected]> wrote:
> Adapt new API.
>
> Signed-off-by: KOSAKI Motohiro <[email protected]>
> Cc: Mikael Starvik <[email protected]>
> Cc: Jesper Nilsson <[email protected]>
> Cc: [email protected]
>
> ---
>  arch/cris/arch-v32/kernel/irq.c |    4 ++--
>  arch/cris/arch-v32/kernel/smp.c |   33 ++++++++++++++++++---------------
>  2 files changed, 20 insertions(+), 17 deletions(-)
>
> diff --git a/arch/cris/arch-v32/kernel/irq.c b/arch/cris/arch-v32/kernel/irq.c
> index 68a1a59..5ebe6e8 100644
> --- a/arch/cris/arch-v32/kernel/irq.c
> +++ b/arch/cris/arch-v32/kernel/irq.c
> @@ -266,11 +266,11 @@ static int irq_cpu(int irq)
>
>
>        /* Let the interrupt stay if possible */
> -       if (cpu_isset(cpu, irq_allocations[irq - FIRST_IRQ].mask))
> +       if (cpumask_test_cpu(cpu, &irq_allocations[irq - FIRST_IRQ].mask))
>                goto out;
>
>        /* IRQ must be moved to another CPU. */
> -       cpu = first_cpu(irq_allocations[irq - FIRST_IRQ].mask);
> +       cpu = cpumask_first(&irq_allocations[irq - FIRST_IRQ].mask);
>        irq_allocations[irq - FIRST_IRQ].cpu = cpu;
>  out:
>        spin_unlock_irqrestore(&irq_lock, flags);
> diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c
> index 66cc756..54467ec 100644
> --- a/arch/cris/arch-v32/kernel/smp.c
> +++ b/arch/cris/arch-v32/kernel/smp.c
> @@ -81,7 +81,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
>
>        /* Mark all possible CPUs as present */
>        for (i = 0; i < max_cpus; i++)
> -           cpu_set(i, phys_cpu_present_map);
> +           cpumask_set_cpu(i, &phys_cpu_present_map);
>  }
>
>  void __devinit smp_prepare_boot_cpu(void)
> @@ -98,7 +98,7 @@ void __devinit smp_prepare_boot_cpu(void)
>        SUPP_REG_WR(RW_MM_TLB_PGD, pgd);
>
>        set_cpu_online(0, true);
> -       cpu_set(0, phys_cpu_present_map);
> +       cpumask_set_cpu(0, &phys_cpu_present_map);
>        set_cpu_possible(0, true);
>  }
>
> @@ -112,8 +112,9 @@ smp_boot_one_cpu(int cpuid)
>  {
>        unsigned timeout;
>        struct task_struct *idle;
> -       cpumask_t cpu_mask = CPU_MASK_NONE;
> +       cpumask_t cpu_mask;
>
> +       cpumask_clear(&cpu_mask);
>        idle = fork_idle(cpuid);
>        if (IS_ERR(idle))
>                panic("SMP: fork failed for CPU:%d", cpuid);
> @@ -125,10 +126,10 @@ smp_boot_one_cpu(int cpuid)
>        cpu_now_booting = cpuid;
>
>        /* Kick it */
> -       cpu_set(cpuid, cpu_online_map);
> -       cpu_set(cpuid, cpu_mask);
> +       set_cpu_online(cpuid, true);
> +       cpumask_set_cpu(cpuid, &cpu_mask);
>        send_ipi(IPI_BOOT, 0, cpu_mask);
> -       cpu_clear(cpuid, cpu_online_map);
> +       set_cpu_online(cpuid, false);
>
>        /* Wait for CPU to come online */
>        for (timeout = 0; timeout < 10000; timeout++) {
> @@ -176,7 +177,7 @@ void __init smp_callin(void)
>        notify_cpu_starting(cpu);
>        local_irq_enable();
>
> -       cpu_set(cpu, cpu_online_map);
> +       set_cpu_online(cpu, true);
>        cpu_idle();
>  }
>
> @@ -214,8 +215,9 @@ int __cpuinit __cpu_up(unsigned int cpu)
>
>  void smp_send_reschedule(int cpu)
>  {
> -       cpumask_t cpu_mask = CPU_MASK_NONE;
> -       cpu_set(cpu, cpu_mask);
> +       cpumask_t cpu_mask;
> +       cpumask_clear(&cpu_mask);
> +       cpumask_set_cpu(cpu, &cpu_mask);
>        send_ipi(IPI_SCHEDULE, 0, cpu_mask);
>  }
>
> @@ -232,7 +234,7 @@ void flush_tlb_common(struct mm_struct* mm, struct vm_area_struct* vma, unsigned
>
>        spin_lock_irqsave(&tlbstate_lock, flags);
>        cpu_mask = (mm == FLUSH_ALL ? cpu_all_mask : *mm_cpumask(mm));
> -       cpu_clear(smp_processor_id(), cpu_mask);
> +       cpumask_clear_cpu(smp_processor_id(), &cpu_mask);
>        flush_mm = mm;
>        flush_vma = vma;
>        flush_addr = addr;
> @@ -277,10 +279,10 @@ int send_ipi(int vector, int wait, cpumask_t cpu_mask)
>        int ret = 0;
>
>        /* Calculate CPUs to send to. */
> -       cpus_and(cpu_mask, cpu_mask, cpu_online_map);
> +       cpumask_and(&cpu_mask, &cpu_mask, cpu_online_mask);
>
>        /* Send the IPI. */
> -       for_each_cpu_mask(i, cpu_mask)
> +       for_each_cpu(i,&cpu_mask)

please, could you add a space between i,&cpu_mask?

>        {
>                ipi.vector |= vector;
>                REG_WR(intr_vect, irq_regs[i], rw_ipi, ipi);
> @@ -288,7 +290,7 @@ int send_ipi(int vector, int wait, cpumask_t cpu_mask)
>
>        /* Wait for IPI to finish on other CPUS */
>        if (wait) {
> -               for_each_cpu_mask(i, cpu_mask) {
> +               for_each_cpu(i,&cpu_mask) {

please, could you add a space between i,&cpu_mask?

>                         int j;
>                         for (j = 0 ; j < 1000; j++) {
>                                ipi = REG_RD(intr_vect, irq_regs[i], rw_ipi);
> @@ -314,11 +316,12 @@ int send_ipi(int vector, int wait, cpumask_t cpu_mask)
>  */
>  int smp_call_function(void (*func)(void *info), void *info, int wait)
>  {
> -       cpumask_t cpu_mask = CPU_MASK_ALL;
> +       cpumask_t cpu_mask;
>        struct call_data_struct data;
>        int ret;
>
> -       cpu_clear(smp_processor_id(), cpu_mask);
> +       cpumask_setall(&cpu_mask);
> +       cpumask_clear_cpu(smp_processor_id(), &cpu_mask);
>
>        WARN_ON(irqs_disabled());
>

2011-04-28 15:17:08

by KOSAKI Motohiro

[permalink] [raw]
Subject: Re: [PATCH] cris: convert old cpumask API into new one

> > @@ -277,10 +279,10 @@ int send_ipi(int vector, int wait, cpumask_t cpu_mask)
> >        int ret = 0;
> >
> >        /* Calculate CPUs to send to. */
> > -       cpus_and(cpu_mask, cpu_mask, cpu_online_map);
> > +       cpumask_and(&cpu_mask, &cpu_mask, cpu_online_mask);
> >
> >        /* Send the IPI. */
> > -       for_each_cpu_mask(i, cpu_mask)
> > +       for_each_cpu(i,&cpu_mask)
>
> please, could you add a space between i,&cpu_mask?

Sure.
Incrementa patch is here.


>From c338d6f323efc7ed92a19bbf312f7830b352fbda Mon Sep 17 00:00:00 2001
From: KOSAKI Motohiro <[email protected]>
Date: Fri, 29 Apr 2011 00:15:34 +0900
Subject: [PATCH] cris: fix style issue

Signed-off-by: KOSAKI Motohiro <[email protected]>
---
arch/cris/arch-v32/kernel/smp.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c
index 54467ec..f96ddfd 100644
--- a/arch/cris/arch-v32/kernel/smp.c
+++ b/arch/cris/arch-v32/kernel/smp.c
@@ -282,7 +282,7 @@ int send_ipi(int vector, int wait, cpumask_t cpu_mask)
cpumask_and(&cpu_mask, &cpu_mask, cpu_online_mask);

/* Send the IPI. */
- for_each_cpu(i,&cpu_mask)
+ for_each_cpu(i, &cpu_mask)
{
ipi.vector |= vector;
REG_WR(intr_vect, irq_regs[i], rw_ipi, ipi);
@@ -290,7 +290,7 @@ int send_ipi(int vector, int wait, cpumask_t cpu_mask)

/* Wait for IPI to finish on other CPUS */
if (wait) {
- for_each_cpu(i,&cpu_mask) {
+ for_each_cpu(i, &cpu_mask) {
int j;
for (j = 0 ; j < 1000; j++) {
ipi = REG_RD(intr_vect, irq_regs[i], rw_ipi);
--
1.7.3.1