qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel.a@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, peter.crosthwaite@xilinx.com,
	stefanha@redhat.com, mst@redhat.com, sw@weilnetz.de,
	jasowang@redhat.com, dkoch@verizon.com,
	alex.williamson@redhat.com, av1474@comtv.ru,
	paul@codesourcery.com, anthony@codemonkey.ws,
	pbonzini@redhat.com, afaerber@suse.de, kraxel@redhat.com
Subject: [Qemu-devel] [PATCH 1/3] hw/pci: set irq without selecting INTx pin
Date: Sun, 29 Sep 2013 17:40:55 +0300	[thread overview]
Message-ID: <1380465657-22600-2-git-send-email-marcel.a@redhat.com> (raw)
In-Reply-To: <1380465657-22600-1-git-send-email-marcel.a@redhat.com>

Interrupt pin is selected and saved into PCI_INTERRUPT_PIN
register during device initialization. Devices should not call
directly qemu_set_irq and specify the INTx pin on each call.

Replaced the call to qemu_set_irq with a new wrapper
pci_set_irq which triggers the irq based on PCI_INTERRUPT_PIN.

Renamed a static method which was named already pci_set_irq.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 hw/pci/pci.c         | 6 +++---
 include/hw/pci/pci.h | 7 +++++++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 1f4e707..f16f4de 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -83,7 +83,7 @@ static const TypeInfo pcie_bus_info = {
 
 static PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_num);
 static void pci_update_mappings(PCIDevice *d);
-static void pci_set_irq(void *opaque, int irq_num, int level);
+static void pci_irq_handler(void *opaque, int irq_num, int level);
 static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom);
 static void pci_del_option_rom(PCIDevice *pdev);
 
@@ -975,7 +975,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
     pci_dev->config_read = config_read;
     pci_dev->config_write = config_write;
     bus->devices[devfn] = pci_dev;
-    pci_dev->irq = qemu_allocate_irqs(pci_set_irq, pci_dev, PCI_NUM_PINS);
+    pci_dev->irq = qemu_allocate_irqs(pci_irq_handler, pci_dev, PCI_NUM_PINS);
     pci_dev->version_id = 2; /* Current pci device vmstate version */
     return pci_dev;
 }
@@ -1292,7 +1292,7 @@ void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l)
 /* generic PCI irq support */
 
 /* 0 <= irq_num <= 3. level must be 0 or 1 */
-static void pci_set_irq(void *opaque, int irq_num, int level)
+static void pci_irq_handler(void *opaque, int irq_num, int level)
 {
     PCIDevice *pci_dev = opaque;
     int change;
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index d69e06d..0d4521c 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -634,6 +634,13 @@ PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn,
 PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name);
 PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name);
 
+static inline void pci_set_irq(PCIDevice *pci_dev, int level)
+{
+    uint8_t intx = pci_get_byte(pci_dev->config + PCI_INTERRUPT_PIN) - 1;
+
+    qemu_set_irq(pci_dev->irq[intx], level);
+}
+
 static inline int pci_is_express(const PCIDevice *d)
 {
     return d->cap_present & QEMU_PCI_CAP_EXPRESS;
-- 
1.8.3.1

  reply	other threads:[~2013-09-29 14:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-29 14:40 [Qemu-devel] [PATCH 0/3] hw: set irq without selecting INTx pin Marcel Apfelbaum
2013-09-29 14:40 ` Marcel Apfelbaum [this message]
2013-09-29 14:40 ` [Qemu-devel] [PATCH 2/3] hw/pci-bridge: set PCI_INTERRUPT_PIN register before shpc init Marcel Apfelbaum
2013-09-29 14:40 ` [Qemu-devel] [PATCH 3/3] hw: assert/deassert interrupts using pci_set_irq wrapper Marcel Apfelbaum
2013-09-29 15:06 ` [Qemu-devel] [PATCH 0/3] hw: set irq without selecting INTx pin Michael S. Tsirkin
2013-09-29 15:24   ` Marcel Apfelbaum
2013-09-29 15:31     ` Michael S. Tsirkin
2013-09-30  8:14   ` Marcel Apfelbaum
2013-09-30  8:58     ` Michael S. Tsirkin
2013-09-30  9:02       ` Paolo Bonzini
2013-09-30  9:14         ` Michael S. Tsirkin
2013-09-30  9:43           ` Marcel Apfelbaum
2013-09-30 10:10             ` Michael S. Tsirkin
2013-09-30 10:39               ` Marcel Apfelbaum
2013-09-30 10:58                 ` Paolo Bonzini

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=1380465657-22600-2-git-send-email-marcel.a@redhat.com \
    --to=marcel.a@redhat.com \
    --cc=afaerber@suse.de \
    --cc=alex.williamson@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=av1474@comtv.ru \
    --cc=dkoch@verizon.com \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=paul@codesourcery.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=sw@weilnetz.de \
    /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).