public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman•id.au>
To: Paul Mackerras <paulus@samba•org>
Cc: linuxppc-dev@ozlabs•org
Subject: [PATCH 5/7] Enable MSI mappings for MPIC
Date: Tue, 08 May 2007 12:58:36 +1000	[thread overview]
Message-ID: <20070508025841.A6C20DDF00@ozlabs.org> (raw)
In-Reply-To: <1178593113.675058.404575641543.qpush@cradle>

On some Apple machines the HT MSI mappings are not enabled by firmware, so
we need to do it by hand.

We can't use the pci routines as this code runs too early.

Signed-off-by: Michael Ellerman <michael@ellerman•id.au>
---

 arch/powerpc/sysdev/mpic.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

Index: msi-new/arch/powerpc/sysdev/mpic.c
===================================================================
--- msi-new.orig/arch/powerpc/sysdev/mpic.c
+++ msi-new/arch/powerpc/sysdev/mpic.c
@@ -377,6 +377,50 @@ static void mpic_shutdown_ht_interrupt(s
 	spin_unlock_irqrestore(&mpic->fixup_lock, flags);
 }
 
+#ifdef CONFIG_PCI_MSI
+static void __init mpic_scan_ht_msi(struct mpic *mpic, u8 __iomem *devbase,
+				    unsigned int devfn)
+{
+	u8 __iomem *base;
+	u8 pos, flags;
+	u64 addr = 0;
+
+	for (pos = readb(devbase + PCI_CAPABILITY_LIST); pos != 0;
+	     pos = readb(devbase + pos + PCI_CAP_LIST_NEXT)) {
+		u8 id = readb(devbase + pos + PCI_CAP_LIST_ID);
+		if (id == PCI_CAP_ID_HT) {
+			id = readb(devbase + pos + 3);
+			if ((id & HT_5BIT_CAP_MASK) == HT_CAPTYPE_MSI_MAPPING)
+				break;
+		}
+	}
+
+	if (pos == 0)
+		return;
+
+	base = devbase + pos;
+
+	flags = readb(base + HT_MSI_FLAGS);
+	if (!(flags & HT_MSI_FLAGS_FIXED)) {
+		addr = readl(base + HT_MSI_ADDR_LO) & HT_MSI_ADDR_LO_MASK;
+		addr = addr | ((u64)readl(base + HT_MSI_ADDR_HI) << 32);
+	}
+
+	printk(KERN_DEBUG "mpic:   - HT:%02x.%x %s MSI mapping found @ 0x%lx\n",
+		PCI_SLOT(devfn), PCI_FUNC(devfn),
+		flags & HT_MSI_FLAGS_ENABLE ? "enabled" : "disabled", addr);
+
+	if (!(flags & HT_MSI_FLAGS_ENABLE))
+		writeb(flags | HT_MSI_FLAGS_ENABLE, base + HT_MSI_FLAGS);
+}
+#else
+static void __init mpic_scan_ht_msi(struct mpic *mpic, u8 __iomem *devbase,
+				    unsigned int devfn)
+{
+	return;
+}
+#endif
+
 static void __init mpic_scan_ht_pic(struct mpic *mpic, u8 __iomem *devbase,
 				    unsigned int devfn, u32 vdid)
 {
@@ -468,6 +512,7 @@ static void __init mpic_scan_ht_pics(str
 			goto next;
 
 		mpic_scan_ht_pic(mpic, devbase, devfn, l);
+		mpic_scan_ht_msi(mpic, devbase, devfn);
 
 	next:
 		/* next device, if function 0 */

  parent reply	other threads:[~2007-05-08  2:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-08  2:58 [PATCH 1/7] Rip out the existing powerpc msi stubs Michael Ellerman
2007-05-08  2:58 ` [PATCH 2/7] Powerpc MSI infrastructure Michael Ellerman
2007-05-08  2:58 ` [PATCH 4/7] Tell Phyp we support MSI Michael Ellerman
2007-05-08  2:58 ` [PATCH 3/7] RTAS MSI implementation Michael Ellerman
2007-05-08  2:58 ` Michael Ellerman [this message]
2007-05-08  2:58 ` [PATCH 6/7] MPIC MSI allocator Michael Ellerman
2007-05-08  2:58 ` [PATCH 7/7] MPIC U3/U4 MSI backend Michael Ellerman
2007-05-08  8:55   ` Johannes Berg
2007-05-08  9:04     ` Johannes Berg
2007-05-08 23:43     ` Benjamin Herrenschmidt
2007-05-12  8:28   ` Johannes Berg
2007-05-12  9:06     ` Benjamin Herrenschmidt
  -- strict thread matches above, loose matches on Subject: below --
2007-04-19  7:35 [PATCH 1/7] Rip out the existing powerpc msi stubs Michael Ellerman
2007-04-19  7:35 ` [PATCH 5/7] Enable MSI mappings for MPIC Michael Ellerman
2007-04-21 23:16   ` Milton Miller
2007-04-22  0:06     ` Benjamin Herrenschmidt
2007-04-22  4:53       ` Milton Miller
2007-04-23  4:10         ` Michael Ellerman

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=20070508025841.A6C20DDF00@ozlabs.org \
    --to=michael@ellerman$(echo .)id.au \
    --cc=linuxppc-dev@ozlabs$(echo .)org \
    --cc=paulus@samba$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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