public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Yeisley <dan.yeisley@unisys.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
	yinghai@kernel.org, stable@kernel.org, dan.yeisley@unisys.com,
	tglx@linutronix.de, mingo@elte.hu
Subject: [tip:x86/apic] x86: MSI: check for BIOS assigned addresses
Date: Fri, 6 Mar 2009 18:36:28 GMT	[thread overview]
Message-ID: <tip-affd49d36e2e2df4cbb3e07a57db901c23823b6a@git.kernel.org> (raw)
In-Reply-To: <1236352309.31604.2.camel@localhost.localdomain>

Commit-ID:  affd49d36e2e2df4cbb3e07a57db901c23823b6a
Gitweb:     http://git.kernel.org/tip/affd49d36e2e2df4cbb3e07a57db901c23823b6a
Author:     "Daniel Yeisley" <dan.yeisley@unisys.com>
AuthorDate: Fri, 6 Mar 2009 10:11:49 -0500
Commit:     Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 6 Mar 2009 19:32:44 +0100

x86: MSI: check for BIOS assigned addresses

Impact: fix ACPI hotplug on certain systems

When creating MSI addresses the kernel makes them up and writes them to
the hardware without first checking for what the system BIOS may have
assigned.  The patch below checks for already assigned values, and
leaves them alone if they exist.

Signed-off-by: Dan Yeisley <dan.yeisley@unisys.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: <stable@kernel.org>
LKML-Reference: <1236352309.31604.2.camel@localhost.localdomain>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 arch/x86/kernel/apic/io_apic.c |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 00e6071..60484e1 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -3254,6 +3254,7 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms
 	struct irq_cfg *cfg;
 	int err;
 	unsigned dest;
+	struct irq_desc *desc = irq_to_desc(irq);
 
 	if (disable_apic)
 		return -ENXIO;
@@ -3265,6 +3266,8 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms
 
 	dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus());
 
+	read_msi_msg_desc(desc, msg);
+
 #ifdef CONFIG_INTR_REMAP
 	if (irq_remapped(irq)) {
 		struct irte irte;
@@ -3294,17 +3297,18 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms
 	} else
 #endif
 	{
-		msg->address_hi = MSI_ADDR_BASE_HI;
-		msg->address_lo =
-			MSI_ADDR_BASE_LO |
-			((apic->irq_dest_mode == 0) ?
-				MSI_ADDR_DEST_MODE_PHYSICAL:
-				MSI_ADDR_DEST_MODE_LOGICAL) |
-			((apic->irq_delivery_mode != dest_LowestPrio) ?
-				MSI_ADDR_REDIRECTION_CPU:
-				MSI_ADDR_REDIRECTION_LOWPRI) |
-			MSI_ADDR_DEST_ID(dest);
-
+		if (!msg->address_hi && !msg->address_lo) {
+			msg->address_hi = MSI_ADDR_BASE_HI;
+			msg->address_lo =
+				MSI_ADDR_BASE_LO |
+				((apic->irq_dest_mode == 0) ?
+					MSI_ADDR_DEST_MODE_PHYSICAL :
+					MSI_ADDR_DEST_MODE_LOGICAL) |
+				((apic->irq_delivery_mode != dest_LowestPrio) ?
+					MSI_ADDR_REDIRECTION_CPU :
+					MSI_ADDR_REDIRECTION_LOWPRI) |
+				MSI_ADDR_DEST_ID(dest);
+		}
 		msg->data =
 			MSI_DATA_TRIGGER_EDGE |
 			MSI_DATA_LEVEL_ASSERT |
@@ -3439,11 +3443,13 @@ static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int irq)
 	int ret;
 	struct msi_msg msg;
 
+	set_irq_msi(irq, msidesc);
 	ret = msi_compose_msg(dev, irq, &msg);
-	if (ret < 0)
+	if (ret < 0) {
+		set_irq_msi(irq, NULL);
 		return ret;
+	}
 
-	set_irq_msi(irq, msidesc);
 	write_msi_msg(irq, &msg);
 
 #ifdef CONFIG_INTR_REMAP

  parent reply	other threads:[~2009-03-06 18:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-06 15:11 [PATCH] MSI: check for BIOS assigned addresses Daniel Yeisley
2009-03-06 16:24 ` Ingo Molnar
2009-03-06 15:56   ` Daniel Yeisley
2009-03-06 18:09 ` [tip:x86/urgent] x86: " Daniel Yeisley
2009-03-06 18:36 ` Daniel Yeisley [this message]
2009-03-06 18:45   ` [tip:x86/apic] " Ingo Molnar
2009-03-06 18:28     ` Daniel Yeisley
2009-03-06 19:13       ` Ingo Molnar
2009-03-07  1:06         ` Yinghai Lu
2009-03-08 10:54           ` Ingo Molnar
2009-03-09 14:32             ` Daniel Yeisley

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=tip-affd49d36e2e2df4cbb3e07a57db901c23823b6a@git.kernel.org \
    --to=dan.yeisley@unisys.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=stable@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=yinghai@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