From: Michael Ellerman <michael@ellerman.id.au>
To: <linux-kernel@vger.kernel.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>, linuxppc-dev@ozlabs.org
Subject: [RFC/PATCH 7/7] Preliminary MPIC MSI backend
Date: Fri, 29 Sep 2006 07:53:46 +1000 [thread overview]
Message-ID: <20060928215349.45C0667C47@ozlabs.org> (raw)
In-Reply-To: <1159480412.269240.988552559176.qpush@concordia>
A pretty hackish MPIC backend, just enough to flesh out the design.
Based on code from Segher.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/kernel/Makefile | 1
arch/powerpc/kernel/msi-mpic.c | 90 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 91 insertions(+)
Index: to-merge/arch/powerpc/kernel/Makefile
===================================================================
--- to-merge.orig/arch/powerpc/kernel/Makefile
+++ to-merge/arch/powerpc/kernel/Makefile
@@ -70,6 +70,7 @@ obj-$(CONFIG_PCI) += $(pci64-y) $(pci32
msiobj-y := msi.o
msiobj-$(CONFIG_PPC_PSERIES) += msi-rtas.o
+msiobj-$(CONFIG_PPC_PMAC) += msi-mpic.o
obj-$(CONFIG_PCI_MSI) += $(msiobj-y)
kexec-$(CONFIG_PPC64) := machine_kexec_64.o
Index: to-merge/arch/powerpc/kernel/msi-mpic.c
===================================================================
--- /dev/null
+++ to-merge/arch/powerpc/kernel/msi-mpic.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2006 Segher Boessenkool, IBM Corp.
+ * Copyright (C) 2006 Michael Ellerman, IBM Corp.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2 of the
+ * License.
+ *
+ */
+
+#define DEBUG 1
+
+#include <linux/irq.h>
+#include <asm/msi.h>
+#include <asm/hw_irq.h>
+#include <asm/ppc-pci.h>
+
+static int msi_mpic_check(struct pci_dev *pdev, int num,
+ struct msix_entry *entries, int type)
+{
+ /* The irq allocator needs more work to support MSI-X/multi-MSI */
+ if (type == PCI_CAP_ID_MSIX || num != 1)
+ return 1;
+
+ return 0;
+}
+
+static void msi_mpic_free(struct pci_dev *pdev, int num,
+ struct msix_entry *entries, int type)
+{
+ for (i = 0; i < num; i++)
+ irq_dispose_mapping(entries[i].vector);
+}
+
+static int msi_mpic_alloc(struct pci_dev *pdev, int num,
+ struct msix_entry *entries, int type)
+{
+ irq_hw_number_t hwirq;
+ unsigned int virq;
+
+ /* We need a smarter allocator for MSI-X/multi-MSI */
+ hwirq = irq_map[pdev->irq].hwirq;
+ hwirq += 100;
+
+ virq = irq_create_mapping(NULL, hwirq);
+ if (virq == NO_IRQ) {
+ pr_debug("msi_mpic_alloc: Failed mapping hwirq %d\n", hwirq);
+ return -1;
+ }
+
+ set_irq_type(virq, IRQ_TYPE_EDGE_RISING);
+ entries[i].vector = virq;
+
+ return 0;
+}
+
+static int msi_mpic_setup_msi_msg(struct pci_dev *pdev,
+ struct msix_entry *entry, struct msi_msg *msg, int type)
+{
+ msg->address_lo = 0xfee00000; /* XXX What is this value? */
+ msg->address_hi = 0;
+ msg->data = pdev->irq | 0x8000;
+
+ return 0;
+}
+
+static struct ppc_msi_ops mpic_msi_ops = {
+ .check = msi_mpic_check,
+ .alloc = msi_mpic_alloc,
+ .free = msi_mpic_free
+ .enable = msi_raw_enable,
+ .disable = msi_raw_disable,
+ .setup_msi_msg = msi_mpic_setup_msi_msg,
+};
+
+static struct ppc_msi_ops *mpic_get_msi_ops(struct pci_dev *pdev)
+{
+ return &mpic_msi_ops;
+}
+
+static int msi_mpic_init(void)
+{
+ /* XXX Do this in mpic_init ? */
+ pr_debug("mpic_msi_init: Registering MPIC MSI ops.\n");
+ ppc_md.get_msi_ops = mpic_get_msi_ops;
+
+ return 0;
+}
+__initcall(msi_mpic_init);
next prev parent reply other threads:[~2006-09-28 21:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-28 21:53 [RFC/PATCH 0/7] Powerpc MSI stuff Michael Ellerman
2006-09-28 21:53 ` [RFC/PATCH 1/7] Rip out the existing powerpc msi stubs Michael Ellerman
2006-09-28 21:53 ` [RFC/PATCH 2/7] Make some MSIX defines generic Michael Ellerman
2006-09-28 21:53 ` [RFC/PATCH 3/7] Powerpc MSI ops layer Michael Ellerman
2006-10-03 21:54 ` Jake Moilanen
2006-10-24 1:51 ` Michael Ellerman
2006-10-24 13:44 ` Jake Moilanen
2006-09-28 21:53 ` [RFC/PATCH 4/7] Allow for non-Intel MSI implementations Michael Ellerman
2006-09-28 21:53 ` [RFC/PATCH 5/7] Enable MSI on Powerpc Michael Ellerman
2006-09-28 21:53 ` [RFC/PATCH 6/7] RTAS MSI implementation Michael Ellerman
2006-10-03 21:53 ` Jake Moilanen
2006-10-24 2:49 ` Michael Ellerman
2006-09-28 21:53 ` Michael Ellerman [this message]
2006-09-28 23:37 ` [RFC/PATCH 7/7] Preliminary MPIC MSI backend Michael Ellerman
2006-09-29 0:16 ` [PATCH] " Michael Ellerman
2006-09-30 8:43 ` Segher Boessenkool
2006-10-24 1:46 ` 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=20060928215349.45C0667C47@ozlabs.org \
--to=michael@ellerman.id.au \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--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).