All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Maciej W. Rozycki" <macro@linux-mips.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] x86: io-apic - get rid of __DO_ACTION macro
Date: Tue, 9 Sep 2008 22:46:15 +0400	[thread overview]
Message-ID: <20080909184615.GA7303@lenovo> (raw)

Replace __DO_ACTION macro with io_apic_modify_irq function.
This allow us to 'grep' definitions being hided by
the macro, ie the following:

	__unmask_IO_APIC_irq
	__mask_IO_APIC_irq
	__mask_and_edge_IO_APIC_irq
	__unmask_and_level_IO_APIC_irq

Also I removed R parameter which was to define offset inside
route table but always being zero for now and I don't think
if it ever will be other then that.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---

Please review. This modification doesn't map object file into the
same former state 'cause of 'for(entry)' cycle form changed and
new mask 'mask_and_not' added to be able to fill register with
pure zeros - ie clear register completely.

Any comments are quite welcome!

Index: linux-2.6.git/arch/x86/kernel/io_apic.c
===================================================================
--- linux-2.6.git.orig/arch/x86/kernel/io_apic.c	2008-09-09 22:27:57.000000000 +0400
+++ linux-2.6.git/arch/x86/kernel/io_apic.c	2008-09-09 22:34:03.000000000 +0400
@@ -643,65 +643,66 @@ static void __init replace_pin_at_irq(un
 		add_pin_to_irq(irq, newapic, newpin);
 }
 
-#define __DO_ACTION(R, ACTION_ENABLE, ACTION_DISABLE, FINAL)		\
-									\
-{									\
-	int pin;							\
-	struct irq_cfg *cfg;						\
-	struct irq_pin_list *entry;					\
-									\
-	cfg = irq_cfg(irq);						\
-	entry = cfg->irq_2_pin;						\
-	for (;;) {							\
-		unsigned int reg;					\
-		if (!entry)						\
-			break;						\
-		pin = entry->pin;					\
-		reg = io_apic_read(entry->apic, 0x10 + R + pin*2);	\
-		reg ACTION_DISABLE;					\
-		reg ACTION_ENABLE;					\
-		io_apic_modify(entry->apic, 0x10 + R + pin*2, reg);	\
-		FINAL;							\
-		if (!entry->next)					\
-			break;						\
-		entry = entry->next;					\
-	}								\
-}
-
-#define DO_ACTION(name,R, ACTION_ENABLE, ACTION_DISABLE, FINAL)		\
-									\
-	static void name##_IO_APIC_irq (unsigned int irq)		\
-	__DO_ACTION(R, ACTION_ENABLE, ACTION_DISABLE, FINAL)
+static inline void io_apic_modify_irq(unsigned int irq,
+				int mask_and, int mask_or,
+				int mask_and_not, int read_after_mod)
+{
+	int pin;
+	struct irq_cfg *cfg;
+	struct irq_pin_list *entry;
 
-/* mask = 0 */
-DO_ACTION(__unmask,	0, |= 0, &= ~IO_APIC_REDIR_MASKED, )
+	cfg = irq_cfg(irq);
+	for (entry = cfg->irq_2_pin; entry != NULL; entry = entry->next) {
+		unsigned int reg;
+		pin = entry->pin;
+		reg = io_apic_read(entry->apic, 0x10 + pin * 2);
+		if (mask_and)
+			reg &= mask_and;
+		if (mask_or)
+			reg |= mask_or;
+		if (mask_and_not)
+			reg &= !mask_and_not;
+		io_apic_modify(entry->apic, 0x10 + pin * 2, reg);
+		if (read_after_mod) {
+			/*
+			 * Synchronize the IO-APIC and the CPU by doing
+			 * a dummy read from the IO-APIC
+			 */
+			struct io_apic __iomem *io_apic;
+			io_apic = io_apic_base(entry->apic);
+			readl(&io_apic->data);
+		}
+	}
+}
 
-#ifdef CONFIG_X86_64
-/*
- * Synchronize the IO-APIC and the CPU by doing
- * a dummy read from the IO-APIC
- */
-static inline void io_apic_sync(unsigned int apic)
+static void __unmask_IO_APIC_irq(unsigned int irq)
 {
-	struct io_apic __iomem *io_apic = io_apic_base(apic);
-	readl(&io_apic->data);
+	io_apic_modify_irq(irq, ~IO_APIC_REDIR_MASKED, 0, 0, 0);
 }
 
-/* mask = 1 */
-DO_ACTION(__mask,	0, |= IO_APIC_REDIR_MASKED, &= ~0, io_apic_sync(entry->apic))
-
-#else
-
-/* mask = 1 */
-DO_ACTION(__mask,	0, |= IO_APIC_REDIR_MASKED, &= ~0, )
-
-/* mask = 1, trigger = 0 */
-DO_ACTION(__mask_and_edge, 0, |= IO_APIC_REDIR_MASKED, &= ~IO_APIC_REDIR_LEVEL_TRIGGER, )
+#ifdef CONFIG_X86_64
+static void __mask_IO_APIC_irq(unsigned int irq)
+{
+	io_apic_modify_irq(irq, ~0, IO_APIC_REDIR_MASKED, 0, 1);
+}
+#else /* CONFIG_X86_32 */
+static void __mask_IO_APIC_irq(unsigned int irq)
+{
+	io_apic_modify_irq(irq, ~0, IO_APIC_REDIR_MASKED, 0, 0);
+}
 
-/* mask = 0, trigger = 1 */
-DO_ACTION(__unmask_and_level, 0, |= IO_APIC_REDIR_LEVEL_TRIGGER, &= ~IO_APIC_REDIR_MASKED, )
+static void __mask_and_edge_IO_APIC_irq(unsigned int irq)
+{
+	io_apic_modify_irq(irq, ~IO_APIC_REDIR_LEVEL_TRIGGER,
+			IO_APIC_REDIR_MASKED, 0, 0);
+}
 
-#endif
+static void __unmask_and_level_IO_APIC_irq(unsigned int irq)
+{
+	io_apic_modify_irq(irq, ~IO_APIC_REDIR_MASKED,
+			IO_APIC_REDIR_LEVEL_TRIGGER, 0, 0);
+}
+#endif /* CONFIG_X86_32 */
 
 static void mask_IO_APIC_irq (unsigned int irq)
 {

             reply	other threads:[~2008-09-09 18:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-09 18:46 Cyrill Gorcunov [this message]
2008-09-09 20:13 ` [PATCH] x86: io-apic - get rid of __DO_ACTION macro Yinghai Lu
2008-09-09 20:28   ` Cyrill Gorcunov
2008-09-10  6:02   ` Cyrill Gorcunov
2008-09-10  6:22     ` Yinghai Lu
2008-09-10  8:40       ` Cyrill Gorcunov
2008-09-10  9:31       ` Ingo Molnar
2008-09-10 10:53         ` Cyrill Gorcunov
2008-09-10 17:30         ` Yinghai Lu
2008-09-10 17:44           ` Cyrill Gorcunov
2008-09-10 18:19           ` Cyrill Gorcunov
2008-09-10 18:40             ` Yinghai Lu
2008-09-11  7:08               ` Ingo Molnar

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=20080909184615.GA7303@lenovo \
    --to=gorcunov@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macro@linux-mips.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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.