mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@avionic-design.de>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] x86/ioapic: Fix fallout from IRQ domain conversion
Date: Thu,  2 Aug 2012 08:51:10 +0200	[thread overview]
Message-ID: <1343890270-13007-1-git-send-email-thierry.reding@avionic-design.de> (raw)

When I/O APIC support was converted to the generic IRQ domain code,
various things were broken. First, the number of interrupts required for
an I/O APIC can be dynamically obtained from the mp_ioapic_gsi structure
instead of hardcoded to 32. Furthermore, the legacy IRQ domain requires
the irq_domain_ops.map() function to be implemented, which it currently
isn't. This function can be empty because all the programming is done in
io_apic_setup_irq_pin_once().

Another issue is that the number of interrupts reserved is currently
determined by the value of the NR_IRQS_LEGACY macro (16). However the
legacy IRQ domain mapping needs at least the number of interrupts
provided by the I/O APIC. If an I/O APIC has been registered that number
is dynamically computed and used instead of NR_IRQS_LEGACY.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
---
 arch/x86/kernel/apic/io_apic.c |  5 +++++
 arch/x86/kernel/devicetree.c   | 13 +++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 5f0ff59..2674ab0 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -3465,6 +3465,7 @@ int get_nr_irqs_gsi(void)
 
 int __init arch_probe_nr_irqs(void)
 {
+	struct mp_ioapic_gsi *gsi_cfg;
 	int nr;
 
 	if (nr_irqs > (NR_VECTORS * nr_cpu_ids))
@@ -3480,6 +3481,10 @@ int __init arch_probe_nr_irqs(void)
 	if (nr < nr_irqs)
 		nr_irqs = nr;
 
+	gsi_cfg = mp_ioapic_gsi_routing(0);
+	if (gsi_cfg)
+		return gsi_cfg->gsi_end - gsi_cfg->gsi_base;
+
 	return NR_IRQS_LEGACY;
 }
 
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index 3ae2ced..ecc405a 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -338,8 +338,15 @@ static int ioapic_xlate(struct irq_domain *domain,
 	return 0;
 }
 
+static int ioapic_map(struct irq_domain *domain, unsigned int virq,
+		      irq_hw_number_t hw)
+{
+	return 0;
+}
+
 const struct irq_domain_ops ioapic_irq_domain_ops = {
 	.xlate = ioapic_xlate,
+	.map = ioapic_map,
 };
 
 static void __init ioapic_add_ofnode(struct device_node *np)
@@ -358,11 +365,13 @@ static void __init ioapic_add_ofnode(struct device_node *np)
 		if (r.start == mpc_ioapic_addr(i)) {
 			struct irq_domain *id;
 			struct mp_ioapic_gsi *gsi_cfg;
+			unsigned int num;
 
 			gsi_cfg = mp_ioapic_gsi_routing(i);
+			num = gsi_cfg->gsi_end - gsi_cfg->gsi_base;
 
-			id = irq_domain_add_legacy(np, 32, gsi_cfg->gsi_base, 0,
-						   &ioapic_irq_domain_ops,
+			id = irq_domain_add_legacy(np, num, gsi_cfg->gsi_base,
+						   0, &ioapic_irq_domain_ops,
 						   (void*)i);
 			BUG_ON(!id);
 			return;
-- 
1.7.11.3


             reply	other threads:[~2012-08-02  6:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-02  6:51 Thierry Reding [this message]
2012-08-06  7:38 ` [PATCH] x86/dt: use linear irq domain for ioapic(s) Sebastian Andrzej Siewior
2012-08-06 16:04   ` Thierry Reding
2012-08-08 10:46   ` Thierry Reding
2012-08-08 11:51     ` Sebastian Andrzej Siewior
2012-08-08 12:07       ` Thierry Reding
2012-08-11 17:26         ` Sebastian Andrzej Siewior
2012-08-12  6:48           ` Thierry Reding
2012-10-19 11:36       ` Florian Fainelli
2012-10-19 13:40         ` Florian Fainelli
2012-10-26 15:52           ` Sebastian Andrzej Siewior
2012-08-13 20:23     ` [PATCH v2] " Sebastian Andrzej Siewior
2012-08-21 20:25       ` [tip:x86/apic] x86: dt: Use " tip-bot for Sebastian Andrzej Siewior

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=1343890270-13007-1-git-send-email-thierry.reding@avionic-design.de \
    --to=thierry.reding@avionic-design.de \
    --cc=bigeasy@linutronix.de \
    --cc=grant.likely@secretlab.ca \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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

all inboxes | Powered by JetHome®