All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: linux-kernel@vger.kernel.org, Paul Mackerras <paulus@samba.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Linus Torvalds <torvalds@osdl.org>
Subject: Re: [PATCH] PPC openpic driver cpumask_t changes [try #2]
Date: Thu, 15 Jul 2004 18:26:08 +0100	[thread overview]
Message-ID: <15090.1089912368@redhat.com> (raw)
In-Reply-To: <20214.1089829645@redhat.com>


> The attached patch fixes the PPC openpic driver to use cpumask_t where
> appropriate.

Hmmm... the patch got damaged. Try this one instead.

David


Signed-Off-By: David Howells <dhowells@redhat.com>

--- 1.33/arch/ppc/syslib/open_pic.c	2004-06-18 07:41:08 +01:00
+++ sbc85xx-2.6/arch/ppc/syslib/open_pic.c	2004-07-14 19:08:41 +01:00
@@ -64,14 +64,14 @@
 
 /* Timer Interrupts */
 static void openpic_inittimer(u_int timer, u_int pri, u_int vector);
-static void openpic_maptimer(u_int timer, u_int cpumask);
+static void openpic_maptimer(u_int timer, cpumask_t cpumask);
 
 /* Interrupt Sources */
 static void openpic_enable_irq(u_int irq);
 static void openpic_disable_irq(u_int irq);
 static void openpic_initirq(u_int irq, u_int pri, u_int vector, int polarity,
 			    int is_level);
-static void openpic_mapirq(u_int irq, u_int cpumask, u_int keepmask);
+static void openpic_mapirq(u_int irq, cpumask_t cpumask, cpumask_t keepmask);
 
 /*
  * These functions are not used but the code is kept here
@@ -89,17 +89,15 @@
  */
 static void openpic_end_irq(unsigned int irq_nr);
 static void openpic_ack_irq(unsigned int irq_nr);
-static void openpic_set_affinity(unsigned int irq_nr, unsigned long cpumask);
+static void openpic_set_affinity(unsigned int irq_nr, cpumask_t cpumask);
 
 struct hw_interrupt_type open_pic = {
-	" OpenPIC  ",
-	NULL,
-	NULL,
-	openpic_enable_irq,
-	openpic_disable_irq,
-	openpic_ack_irq,
-	openpic_end_irq,
-	openpic_set_affinity
+	.typename	= " OpenPIC  ",
+	.enable		= openpic_enable_irq,
+	.disable	= openpic_disable_irq,
+	.ack		= openpic_ack_irq,
+	.end		= openpic_end_irq,
+	.set_affinity	= openpic_set_affinity,
 };
 
 #ifdef CONFIG_SMP
@@ -109,14 +107,11 @@
 static void openpic_disable_ipi(unsigned int irq_nr);
 
 struct hw_interrupt_type open_pic_ipi = {
-	" OpenPIC  ",
-	NULL,
-	NULL,
-	openpic_enable_ipi,
-	openpic_disable_ipi,
-	openpic_ack_ipi,
-	openpic_end_ipi,
-	0
+	.typename	= " OpenPIC  ",
+	.enable		= openpic_enable_ipi,
+	.disable	= openpic_disable_ipi,
+	.ack		= openpic_ack_ipi,
+	.end		= openpic_end_ipi,
 };
 #endif /* CONFIG_SMP */
 
@@ -368,7 +363,7 @@
 		/* Disabled, Priority 0 */
 		openpic_inittimer(i, 0, OPENPIC_VEC_TIMER+i+offset);
 		/* No processor */
-		openpic_maptimer(i, 0);
+		openpic_maptimer(i, CPU_MASK_NONE);
 	}
 
 #ifdef CONFIG_SMP
@@ -408,7 +403,7 @@
 		openpic_initirq(i, 8, i+offset, (sense & IRQ_POLARITY_MASK),
 				(sense & IRQ_SENSE_MASK));
 		/* Processor 0 */
-		openpic_mapirq(i, 1<<0, 0);
+		openpic_mapirq(i, CPU_MASK_CPU0, CPU_MASK_NONE);
 	}
 
 	/* Init descriptors */
@@ -509,14 +504,17 @@
 /*
  * Convert a cpu mask from logical to physical cpu numbers.
  */
-static inline u32 physmask(u32 cpumask)
+static inline cpumask_t physmask(cpumask_t cpumask)
 {
 	int i;
-	u32 mask = 0;
+	cpumask_t mask = CPU_MASK_NONE;
+
+	cpus_and(cpumask, cpu_online_map, cpumask);
+
+	for (i = 0; i < NR_CPUS; i++)
+		if (cpu_isset(i, cpumask))
+			cpu_set(smp_hw_index[i], mask);
 
-	for (i = 0; i < NR_CPUS; ++i, cpumask >>= 1)
-		if (cpu_online(i))
-			mask |= (cpumask & 1) << smp_hw_index[i];
 	return mask;
 }
 #else
@@ -607,12 +605,12 @@
 {
 #ifdef CONFIG_IRQ_ALL_CPUS
  	int i;
-	u32 msk;
+	cpumask_t msk = CPU_MASK_NONE;
 #endif
 	spin_lock(&openpic_setup_lock);
 
 #ifdef CONFIG_IRQ_ALL_CPUS
-	msk = 1 << smp_hw_index[smp_processor_id()];
+	cpu_set(smp_hw_index[smp_processor_id()], mask);
 
  	/* let the openpic know we want intrs. default affinity
  	 * is 0xffffffff until changed via /proc
@@ -621,7 +619,7 @@
  	 * in irq.c.
  	 */
  	for (i = 0; i < NumSources; i++)
-		openpic_mapirq(i, msk, ~0U);
+		openpic_mapirq(i, msk, CPU_MASK_ALL);
 #endif /* CONFIG_IRQ_ALL_CPUS */
  	openpic_set_priority(0);
 
@@ -649,11 +647,12 @@
 /*
  *  Map a timer interrupt to one or more CPUs
  */
-static void __init openpic_maptimer(u_int timer, u_int cpumask)
+static void __init openpic_maptimer(u_int timer, cpumask_t cpumask)
 {
+	cpumask_t phys = physmask(cpumask);
 	check_arg_timer(timer);
 	openpic_write(&OpenPIC->Global.Timer[timer].Destination,
-		      physmask(cpumask));
+		      cpus_addr(phys)[0]);
 }
 
 /*
@@ -770,13 +769,16 @@
 /*
  *  Map an interrupt source to one or more CPUs
  */
-static void openpic_mapirq(u_int irq, u_int physmask, u_int keepmask)
+static void openpic_mapirq(u_int irq, cpumask_t physmask, cpumask_t keepmask)
 {
 	if (ISR[irq] == 0)
 		return;
-	if (keepmask != 0)
-		physmask |= openpic_read(&ISR[irq]->Destination) & keepmask;
-	openpic_write(&ISR[irq]->Destination, physmask);
+	if (!cpus_empty(keepmask)) {
+		cpumask_t irqdest = { .bits[0] = openpic_read(&ISR[irq]->Destination) };
+		cpus_and(irqdest, irqdest, keepmask);
+		cpus_or(physmask, physmask, irqdest);
+	}
+	openpic_write(&ISR[irq]->Destination, cpus_addr(physmask)[0]);
 }
 
 #ifdef notused
@@ -820,9 +822,9 @@
 #endif
 }
 
-static void openpic_set_affinity(unsigned int irq_nr, unsigned long cpumask)
+static void openpic_set_affinity(unsigned int irq_nr, cpumask_t cpumask)
 {
-	openpic_mapirq(irq_nr - open_pic_irq_offset, physmask(cpumask), 0);
+	openpic_mapirq(irq_nr - open_pic_irq_offset, physmask(cpumask), CPU_MASK_NONE);
 }
 
 #ifdef CONFIG_SMP
--- 1.16/include/linux/cpumask.h	2004-07-02 03:30:10 +01:00
+++ sbc85xx-2.6/include/linux/cpumask.h	2004-07-14 19:08:41 +01:00
@@ -252,6 +252,11 @@
 	[0 ... BITS_TO_LONGS(NR_CPUS)-1] =  0UL				\
 } })
 
+#define CPU_MASK_CPU0							\
+((cpumask_t) { {							\
+	[0] =  1UL							\
+} })
+
 #define cpus_addr(src) ((src).bits)
 
 #define cpumask_scnprintf(buf, len, src) \

      reply	other threads:[~2004-07-15 17:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-14 18:27 [PATCH] PPC openpic driver cpumask_t changes David Howells
2004-07-15 17:26 ` David Howells [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15090.1089912368@redhat.com \
    --to=dhowells@redhat.com \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@samba.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.