[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/39] hw/misc/edu: support MSI interrupt
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 03/39] hw/misc/edu: support MSI interrupt |
Date: |
Fri, 7 Oct 2016 18:57:27 +0200 |
From: Peter Xu <address@hidden>
So now edu device can support both line or msi interrupt, depending on
how user configures it.
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
docs/specs/edu.txt | 7 ++++++-
hw/misc/edu.c | 18 ++++++++++++++++--
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/docs/specs/edu.txt b/docs/specs/edu.txt
index 7f81467..0876310 100644
--- a/docs/specs/edu.txt
+++ b/docs/specs/edu.txt
@@ -52,7 +52,7 @@ size == 8 for the rest.
0x20 (RW) : status register, bitwise OR
0x01 -- computing factorial (RO)
- 0x80 -- raise interrupt 0x01 after finishing factorial computation
+ 0x80 -- raise interrupt after finishing factorial computation
0x24 (RO) : interrupt status register
It contains values which raised the interrupt (see interrupt raise
@@ -87,6 +87,11 @@ An IRQ is generated when written to the interrupt raise
register. The value
appears in interrupt status register when the interrupt is raised and has to
be written to the interrupt acknowledge register to lower it.
+The device supports both INTx and MSI interrupt. By default, INTx is
+used. Even if the driver disabled INTx and only uses MSI, it still
+needs to update the acknowledge register at the end of the IRQ handler
+routine.
+
DMA controller
--------------
One has to specify, source, destination, size, and start the transfer. One
diff --git a/hw/misc/edu.c b/hw/misc/edu.c
index 888ba49..401039c 100644
--- a/hw/misc/edu.c
+++ b/hw/misc/edu.c
@@ -24,6 +24,7 @@
#include "qemu/osdep.h"
#include "hw/pci/pci.h"
+#include "hw/pci/msi.h"
#include "qemu/timer.h"
#include "qemu/main-loop.h" /* iothread mutex */
#include "qapi/visitor.h"
@@ -69,11 +70,20 @@ typedef struct {
uint64_t dma_mask;
} EduState;
+static bool edu_msi_enabled(EduState *edu)
+{
+ return msi_enabled(&edu->pdev);
+}
+
static void edu_raise_irq(EduState *edu, uint32_t val)
{
edu->irq_status |= val;
if (edu->irq_status) {
- pci_set_irq(&edu->pdev, 1);
+ if (edu_msi_enabled(edu)) {
+ msi_notify(&edu->pdev, 0);
+ } else {
+ pci_set_irq(&edu->pdev, 1);
+ }
}
}
@@ -81,7 +91,7 @@ static void edu_lower_irq(EduState *edu, uint32_t val)
{
edu->irq_status &= ~val;
- if (!edu->irq_status) {
+ if (!edu->irq_status && !edu_msi_enabled(edu)) {
pci_set_irq(&edu->pdev, 0);
}
}
@@ -342,6 +352,10 @@ static void pci_edu_realize(PCIDevice *pdev, Error **errp)
pci_config_set_interrupt_pin(pci_conf, 1);
+ if (msi_init(pdev, 0, 1, true, false, errp)) {
+ return;
+ }
+
memory_region_init_io(&edu->mmio, OBJECT(edu), &edu_mmio_ops, edu,
"edu-mmio", 1 << 20);
pci_register_bar(pdev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &edu->mmio);
--
2.7.4
- [Qemu-devel] [PULL 00/39] Misc patches for 2016-10-07, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 02/39] MC146818 RTC: coordinate guest clock base to destination host after migration, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 01/39] hw/iommu: Fix problems reported by Coverity scan, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 03/39] hw/misc/edu: support MSI interrupt,
Paolo Bonzini <=
- [Qemu-devel] [PULL 04/39] intc: add an interface to gather statistics/informations on interrupt controllers, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 05/39] intc/i8259: implement InterruptStatsProvider interface, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 06/39] intc/slavio_intctl: implement InterruptStatsProvider interface, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 07/39] intc/lm32_pic: implement InterruptStatsProvider interface, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 08/39] intc: make HMP 'info irq' and 'info pic' commands use InterruptStatsProvider interface, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 09/39] intc: make HMP 'info irq' and 'info pic' commands available on all targets, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 10/39] atomic.h: fix __SANITIZE_THREAD__ build, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 11/39] atomic.h: comment on use of atomic_read/set, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 12/39] tcg/optimize: move default return out of if statement, Paolo Bonzini, 2016/10/07
- [Qemu-devel] [PULL 13/39] seqlock: use atomic writes for the sequence, Paolo Bonzini, 2016/10/07