linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Milton Miller <miltonm@bga.com>
To: linuxppc-dev@ozlabs.org
Cc: Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH 14/16 v2] powerpc: expand vs demux ipi actions per message
Date: Mon, 20 Oct 2008 20:37:01 -0500 (CDT)	[thread overview]
Message-ID: <patch-ipi-2-v2@bga.com> (raw)
In-Reply-To: <patch-ipi-2@bga.com>

With the new generic smp call function helpers, I noticed the code in
smp_message_recv was a single function call in many cases.  While
getting the message number from the ipi data is easy, we can reduce
the path length by a function and data dependent switch by registering
separate ipi actions for these simple calls.

Originally I left the ipi action array exposed, but then I realized the
registration code should be common too.

The three users each had their own name array, so I made a fourth
to convert all users to use a common one.

Signed-off-by: Milton Miller <miltonm@bga.com>
---
v2: fix arg reversal noted by Geert Uytterhoeven.   This order is most
similar to request_irq and message in data field, but without casting.

Perhaps we should make the common code look like an ipi action handler
and remove this last call?  Currently we still have to allocate a stack
frame to load the return value.

Index: next.git/arch/powerpc/include/asm/smp.h
===================================================================
--- next.git.orig/arch/powerpc/include/asm/smp.h	2008-10-05 00:08:36.000000000 -0500
+++ next.git/arch/powerpc/include/asm/smp.h	2008-10-05 00:16:34.000000000 -0500
@@ -81,6 +81,13 @@ extern int cpu_to_core_id(int cpu);
 #define PPC_MSG_CALL_FUNC_SINGLE	2
 #define PPC_MSG_DEBUGGER_BREAK  3
 
+/*
+ * irq controllers that have dedicated ipis per message and don't
+ * need additional code in the action handler may use this
+ */
+extern int smp_request_message_ipi(int virq, int message);
+extern const char *smp_ipi_name[];
+
 void smp_init_iSeries(void);
 void smp_init_pSeries(void);
 void smp_init_cell(void);
Index: next.git/arch/powerpc/kernel/smp.c
===================================================================
--- next.git.orig/arch/powerpc/kernel/smp.c	2008-10-05 00:08:38.000000000 -0500
+++ next.git/arch/powerpc/kernel/smp.c	2008-10-05 00:19:12.000000000 -0500
@@ -123,6 +123,65 @@ void smp_message_recv(int msg)
 	}
 }
 
+static irqreturn_t call_function_action(int irq, void *data)
+{
+	generic_smp_call_function_interrupt();
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t reschedule_action(int irq, void *data)
+{
+	/* we just need the return path side effect of checking need_resched */
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t call_function_single_action(int irq, void *data)
+{
+	generic_smp_call_function_single_interrupt();
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t debug_ipi_action(int irq, void *data)
+{
+	smp_message_recv(PPC_MSG_DEBUGGER_BREAK);
+	return IRQ_HANDLED;
+}
+
+static irq_handler_t smp_ipi_action[] = {
+	[PPC_MSG_CALL_FUNCTION] =  call_function_action,
+	[PPC_MSG_RESCHEDULE] = reschedule_action,
+	[PPC_MSG_CALL_FUNC_SINGLE] = call_function_single_action,
+	[PPC_MSG_DEBUGGER_BREAK] = debug_ipi_action,
+};
+
+const char *smp_ipi_name[] = {
+	[PPC_MSG_CALL_FUNCTION] =  "ipi call function",
+	[PPC_MSG_RESCHEDULE] = "ipi reschedule",
+	[PPC_MSG_CALL_FUNC_SINGLE] = "ipi call function single",
+	[PPC_MSG_DEBUGGER_BREAK] = "ipi debugger",
+};
+
+/* optional function to request ipi, for controllers with >= 4 ipis */
+int smp_request_message_ipi(int virq, int msg)
+{
+	int err;
+
+	if (msg < 0 || msg > PPC_MSG_DEBUGGER_BREAK) {
+		return -EINVAL;
+	}
+#if !defined(CONFIG_DEBUGGER) && !defined(CONFIG_KEXEC)
+	if (msg == PPC_MSG_DEBUGGER_BREAK) {
+		return 1;
+	}
+#endif
+	err = request_irq(virq, smp_ipi_action[msg], IRQF_DISABLED|IRQF_PERCPU,
+			  smp_ipi_name[msg], 0);
+	WARN(err < 0, "unable to request_irq %d for %s (rc %d)\n",
+		virq, ipi_names[msg], err);
+
+	return err;
+}
+
 void smp_send_reschedule(int cpu)
 {
 	if (likely(smp_ops))

  parent reply	other threads:[~2008-10-21  1:37 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-10 11:56 [PATCH 00/16] xics and ipi cleanups for 2.6.28 Milton Miller
2008-10-10 11:56 ` [PATCH 1/16] powerpc pseries: eoi unmapped xics irqs after disable Milton Miller
2008-10-10 11:56 ` [PATCH 2/16] xics: update default_server during migrate_irqs_away Milton Miller
2008-10-13 20:04   ` Nathan Fontenot
2008-10-10 11:56 ` [PATCH 3/16] xics: consolidate ipi message encode and decode Milton Miller
2008-10-10 11:56 ` [PATCH 4/16] xics: rearrange file to group code by function Milton Miller
2008-10-10 11:56 ` [PATCH 5/16] xics: change arg type to remove casts Milton Miller
2008-10-10 11:56 ` [PATCH 6/16] xics: trim includes Milton Miller
2008-10-10 11:56 ` [PATCH 7/16] xics: initialization cleanups Milton Miller
2008-10-13  0:55   ` Benjamin Herrenschmidt
2008-10-10 11:56 ` [PATCH 8/16] xics: factor out giq set and unset Milton Miller
2008-10-10 11:56 ` [PATCH 9/16] powerpc: eoi xics ipi by hand in kexec Milton Miller
2008-10-10 11:56 ` [PATCH 11/16] powerpc: mark xics ipi percpu Milton Miller
2008-10-10 11:56 ` [PATCH 10/16] xics: make printk formats fit on one line Milton Miller
2008-10-10 11:56 ` [PATCH 12/16] powerpc: reduce and comment xics ipi memory barrier Milton Miller
2008-10-10 11:56 ` [PATCH 13/16] powerpc smp: no need to set_need_resched in resched ipi Milton Miller
2008-10-10 11:56   ` [PATCH 14/16] powerpc: expand vs demux ipi actions per message Milton Miller
2008-10-10 11:56     ` [PATCH 14/16] powerpc mpic: use smp_request_message_ipi Milton Miller
2008-10-10 11:56     ` [PATCH 15/16] powerpc cell: " Milton Miller
2008-10-10 11:56     ` [PATCH 16/16] powerpc ps3: " Milton Miller
2008-10-10 12:55     ` [PATCH 14/16] powerpc: expand vs demux ipi actions per message Geert Uytterhoeven
2008-10-21  1:37     ` Milton Miller [this message]
2008-11-06  4:42       ` [PATCH 14/16 v2] " Paul Mackerras
2008-11-11 16:12         ` Milton Miller
2008-10-13  5:28 ` [PATCH 00/16] xics and ipi cleanups for 2.6.28 Benjamin Herrenschmidt

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=patch-ipi-2-v2@bga.com \
    --to=miltonm@bga.com \
    --cc=arnd@arndb.de \
    --cc=linuxppc-dev@ozlabs.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).