From: "Michael S. Tsirkin" <mst@redhat.com>
To: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 02/26] pci: add opaque argument to pci_map_irq_fn
Date: Thu, 17 Mar 2011 07:36:16 +0200 [thread overview]
Message-ID: <20110317053616.GH32049@redhat.com> (raw)
In-Reply-To: <031d7afb1ec5d42393c0fa719d87022f40661abb.1300266238.git.yamahata@valinux.co.jp>
On Wed, Mar 16, 2011 at 06:29:13PM +0900, Isaku Yamahata wrote:
> Pass opaque argument to pci_map_irq_fn like pci_set_irq_fn.
> ICH9 irq routing is not static, but configurable by chipset configuration
> registers, so the corresponding irq mapping function of pci_map_irq_fn
> needs to know the pointer to ich9.
>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Not an objection to this patch - just thinking aloud: as mapping changes
rarely, something I wanted to do for a while now is replace
the walk up the bus with indirect function calls
at each step on each set_irq call with:
- walk down the bus on each mapping change, update all devices
- pci_set_irq which is not indirect, just calls directly to
the interrupt controller
But we can do this optimization later.
> ---
> hw/apb_pci.c | 4 ++--
> hw/bonito.c | 2 +-
> hw/dec_pci.c | 2 +-
> hw/grackle_pci.c | 2 +-
> hw/gt64xxx.c | 2 +-
> hw/pci.c | 2 +-
> hw/pci.h | 2 +-
> hw/piix_pci.c | 2 +-
> hw/ppc4xx_pci.c | 2 +-
> hw/ppce500_pci.c | 2 +-
> hw/prep_pci.c | 2 +-
> hw/sh_pci.c | 2 +-
> hw/unin_pci.c | 2 +-
> hw/versatile_pci.c | 2 +-
> 14 files changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/hw/apb_pci.c b/hw/apb_pci.c
> index 84e9af7..c56ea9a 100644
> --- a/hw/apb_pci.c
> +++ b/hw/apb_pci.c
> @@ -264,12 +264,12 @@ static CPUReadMemoryFunc * const pci_apb_ioread[] = {
> };
>
> /* The APB host has an IRQ line for each IRQ line of each slot. */
> -static int pci_apb_map_irq(PCIDevice *pci_dev, int irq_num)
> +static int pci_apb_map_irq(void *opaque, PCIDevice *pci_dev, int irq_num)
> {
> return ((pci_dev->devfn & 0x18) >> 1) + irq_num;
> }
>
> -static int pci_pbm_map_irq(PCIDevice *pci_dev, int irq_num)
> +static int pci_pbm_map_irq(void *opaque, PCIDevice *pci_dev, int irq_num)
> {
> int bus_offset;
> if (pci_dev->devfn & 1)
> diff --git a/hw/bonito.c b/hw/bonito.c
> index 65a4a63..94e69f5 100644
> --- a/hw/bonito.c
> +++ b/hw/bonito.c
> @@ -632,7 +632,7 @@ static void pci_bonito_set_irq(void *opaque, int irq_num, int level)
> }
>
> /* map the original irq (0~3) to bonito irq (16~47, but 16~31 are unused) */
> -static int pci_bonito_map_irq(PCIDevice * pci_dev, int irq_num)
> +static int pci_bonito_map_irq(void *opaque, PCIDevice * pci_dev, int irq_num)
> {
> int slot;
>
> diff --git a/hw/dec_pci.c b/hw/dec_pci.c
> index bf88f2a..3cc4f04 100644
> --- a/hw/dec_pci.c
> +++ b/hw/dec_pci.c
> @@ -45,7 +45,7 @@ typedef struct DECState {
> PCIHostState host_state;
> } DECState;
>
> -static int dec_map_irq(PCIDevice *pci_dev, int irq_num)
> +static int dec_map_irq(void *opaque, PCIDevice *pci_dev, int irq_num)
> {
> return irq_num;
> }
> diff --git a/hw/grackle_pci.c b/hw/grackle_pci.c
> index d35701f..4ed1ec6 100644
> --- a/hw/grackle_pci.c
> +++ b/hw/grackle_pci.c
> @@ -44,7 +44,7 @@ typedef struct GrackleState {
> } GrackleState;
>
> /* Don't know if this matches real hardware, but it agrees with OHW. */
> -static int pci_grackle_map_irq(PCIDevice *pci_dev, int irq_num)
> +static int pci_grackle_map_irq(void *opaque, PCIDevice *pci_dev, int irq_num)
> {
> return (irq_num + (pci_dev->devfn >> 3)) & 3;
> }
> diff --git a/hw/gt64xxx.c b/hw/gt64xxx.c
> index c66188f..e6e2828 100644
> --- a/hw/gt64xxx.c
> +++ b/hw/gt64xxx.c
> @@ -862,7 +862,7 @@ static CPUReadMemoryFunc * const gt64120_read[] = {
> >64120_readl,
> };
>
> -static int gt64120_pci_map_irq(PCIDevice *pci_dev, int irq_num)
> +static int gt64120_pci_map_irq(void *opaque, PCIDevice *pci_dev, int irq_num)
> {
> int slot;
>
> diff --git a/hw/pci.c b/hw/pci.c
> index 8d7bfff..5349488 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -117,7 +117,7 @@ static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change)
> PCIBus *bus;
> for (;;) {
> bus = pci_dev->bus;
> - irq_num = bus->map_irq(pci_dev, irq_num);
> + irq_num = bus->map_irq(bus->irq_opaque, pci_dev, irq_num);
> if (bus->set_irq)
> break;
> pci_dev = bus->parent_dev;
> diff --git a/hw/pci.h b/hw/pci.h
> index 7d56337..1a08139 100644
> --- a/hw/pci.h
> +++ b/hw/pci.h
> @@ -219,7 +219,7 @@ void pci_device_save(PCIDevice *s, QEMUFile *f);
> int pci_device_load(PCIDevice *s, QEMUFile *f);
>
> typedef void (*pci_set_irq_fn)(void *opaque, int irq_num, int level);
> -typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num);
> +typedef int (*pci_map_irq_fn)(void *opaque, PCIDevice *pci_dev, int irq_num);
>
> typedef enum {
> PCI_HOTPLUG_DISABLED,
> diff --git a/hw/piix_pci.c b/hw/piix_pci.c
> index 358da58..892c576 100644
> --- a/hw/piix_pci.c
> +++ b/hw/piix_pci.c
> @@ -60,7 +60,7 @@ static void piix3_set_irq(void *opaque, int irq_num, int level);
> /* return the global irq number corresponding to a given device irq
> pin. We could also use the bus number to have a more precise
> mapping. */
> -static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
> +static int pci_slot_get_pirq(void *opaque, PCIDevice *pci_dev, int irq_num)
> {
> int slot_addend;
> slot_addend = (pci_dev->devfn >> 3) - 1;
> diff --git a/hw/ppc4xx_pci.c b/hw/ppc4xx_pci.c
> index f62f1f9..11ca763 100644
> --- a/hw/ppc4xx_pci.c
> +++ b/hw/ppc4xx_pci.c
> @@ -267,7 +267,7 @@ static void ppc4xx_pci_reset(void *opaque)
>
> /* On Bamboo, all pins from each slot are tied to a single board IRQ. This
> * may need further refactoring for other boards. */
> -static int ppc4xx_pci_map_irq(PCIDevice *pci_dev, int irq_num)
> +static int ppc4xx_pci_map_irq(void *opaque, PCIDevice *pci_dev, int irq_num)
> {
> int slot = pci_dev->devfn >> 3;
>
> diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c
> index 11edd03..029a3f9 100644
> --- a/hw/ppce500_pci.c
> +++ b/hw/ppce500_pci.c
> @@ -187,7 +187,7 @@ static CPUWriteMemoryFunc * const e500_pci_reg_write[] = {
> &pci_reg_write4,
> };
>
> -static int mpc85xx_pci_map_irq(PCIDevice *pci_dev, int irq_num)
> +static int mpc85xx_pci_map_irq(void *opaque, PCIDevice *pci_dev, int irq_num)
> {
> int devno = pci_dev->devfn >> 3, ret = 0;
>
> diff --git a/hw/prep_pci.c b/hw/prep_pci.c
> index f88b825..8287246 100644
> --- a/hw/prep_pci.c
> +++ b/hw/prep_pci.c
> @@ -98,7 +98,7 @@ static CPUReadMemoryFunc * const PPC_PCIIO_read[] = {
> &PPC_PCIIO_readl,
> };
>
> -static int prep_map_irq(PCIDevice *pci_dev, int irq_num)
> +static int prep_map_irq(void *opaque, PCIDevice *pci_dev, int irq_num)
> {
> return (irq_num + (pci_dev->devfn >> 3)) & 1;
> }
> diff --git a/hw/sh_pci.c b/hw/sh_pci.c
> index e99d8db..f108759 100644
> --- a/hw/sh_pci.c
> +++ b/hw/sh_pci.c
> @@ -93,7 +93,7 @@ static MemOp sh_pci_reg = {
> { NULL, NULL, sh_pci_reg_write },
> };
>
> -static int sh_pci_map_irq(PCIDevice *d, int irq_num)
> +static int sh_pci_map_irq(void *opaque, PCIDevice *d, int irq_num)
> {
> return (d->devfn >> 3);
> }
> diff --git a/hw/unin_pci.c b/hw/unin_pci.c
> index c57c0a1..1496625 100644
> --- a/hw/unin_pci.c
> +++ b/hw/unin_pci.c
> @@ -44,7 +44,7 @@ typedef struct UNINState {
> ReadWriteHandler data_handler;
> } UNINState;
>
> -static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
> +static int pci_unin_map_irq(void *opaque, PCIDevice *pci_dev, int irq_num)
> {
> int retval;
> int devfn = pci_dev->devfn & 0x00FFFFFF;
> diff --git a/hw/versatile_pci.c b/hw/versatile_pci.c
> index 2fed8a0..c002fb2 100644
> --- a/hw/versatile_pci.c
> +++ b/hw/versatile_pci.c
> @@ -74,7 +74,7 @@ static CPUReadMemoryFunc * const pci_vpb_config_read[] = {
> &pci_vpb_config_readl,
> };
>
> -static int pci_vpb_map_irq(PCIDevice *d, int irq_num)
> +static int pci_vpb_map_irq(void *opaque, PCIDevice *d, int irq_num)
> {
> return irq_num;
> }
> --
> 1.7.1.1
next prev parent reply other threads:[~2011-03-17 5:36 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-16 9:29 [Qemu-devel] [PATCH 00/26] q35 chipset support for native pci express support Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 01/26] pci: replace the magic, 256, for the maximum of slot Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 02/26] pci: add opaque argument to pci_map_irq_fn Isaku Yamahata
2011-03-17 5:36 ` Michael S. Tsirkin [this message]
2011-03-16 9:29 ` [Qemu-devel] [PATCH 03/26] pci: introduce pci_swizzle_map_irq_fn() for standardized interrupt pin swizzle Isaku Yamahata
2011-03-17 14:43 ` [Qemu-devel] " Michael S. Tsirkin
2011-03-17 15:29 ` Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 04/26] pci: add accessor function to get irq levels Isaku Yamahata
2011-03-17 5:29 ` [Qemu-devel] " Michael S. Tsirkin
2011-03-17 6:05 ` Isaku Yamahata
2011-03-17 8:19 ` Michael S. Tsirkin
2011-03-16 9:29 ` [Qemu-devel] [PATCH 05/26] piix_pci: eliminate PIIX3State::pci_irq_levels Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 06/26] pci_bridge: add helper function to convert PCIBridge into PCIDevice Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 07/26] pci/p2pbr: generic pci p2p bridge Isaku Yamahata
2011-03-16 21:34 ` [Qemu-devel] " Michael S. Tsirkin
2011-03-17 2:08 ` Isaku Yamahata
2011-03-17 5:17 ` Michael S. Tsirkin
2011-03-17 5:26 ` Isaku Yamahata
2011-03-17 5:31 ` Michael S. Tsirkin
2011-03-16 9:29 ` [Qemu-devel] [PATCH 08/26] apb_pci: simplify apb_pci.c by using pci_p2pbr Isaku Yamahata
2011-03-19 8:14 ` [Qemu-devel] " Blue Swirl
2011-03-16 9:29 ` [Qemu-devel] [PATCH 09/26] dec_pci: simplify dec_pci.c " Isaku Yamahata
2011-03-19 8:13 ` [Qemu-devel] " Blue Swirl
2011-03-16 9:29 ` [Qemu-devel] [PATCH 10/26] ide/ahci/ich: use qdev.reset Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 11/26] ahci: add ide device initialization helper Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 12/26] usb/uhci: generalize initialization Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 13/26] usb/uhci: add ich9 usb uhci id's device Isaku Yamahata
2011-03-19 8:15 ` Blue Swirl
2011-03-16 9:29 ` [Qemu-devel] [PATCH 14/26] ide: consolidate drive_get(IF_IDE) Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 15/26] smbus_eeprom: consolidate smbus eeprom creation Isaku Yamahata
2011-04-01 20:36 ` Aurelien Jarno
2011-03-16 9:29 ` [Qemu-devel] [PATCH 16/26] pc, pc_piix: split out allocating isa irqs Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 17/26] pc, pc_piix: split out pc nic initialization Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 18/26] ioapic: move ioapic_init() from pc_piix.c to pc.c Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 19/26] pc/piix_pci: factor out smram/pam logic Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 20/26] pc, i440fx: simply i440fx initialization Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 21/26] acpi, acpi_piix: factor out PM_TMR logic Isaku Yamahata
2011-03-19 8:18 ` Blue Swirl
2011-03-16 9:29 ` [Qemu-devel] [PATCH 22/26] acpi, acpi_piix: factor out PM1a EVT logic Isaku Yamahata
2011-03-19 8:21 ` Blue Swirl
2011-03-16 9:29 ` [Qemu-devel] [PATCH 23/26] acpi, acpi_piix: factor out PM1_CNT logic Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 24/26] acpi, acpi_piix: factor out GPE logic Isaku Yamahata
2011-04-17 13:17 ` Avi Kivity
2011-04-17 13:50 ` Isaku Yamahata
2011-04-17 15:53 ` Avi Kivity
2011-04-18 7:47 ` Isaku Yamahata
2011-04-18 8:22 ` Avi Kivity
2011-04-18 13:45 ` Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 25/26] pci_ids: add intel 82801BA pci-to-pci bridge id and PCI_CLASS_SERIAL_SMBUS Isaku Yamahata
2011-03-16 9:29 ` [Qemu-devel] [PATCH 26/26] pc q35 based chipset emulator Isaku Yamahata
2011-03-16 10:12 ` [Qemu-devel] ACPI table loading [was: q35 chipset support for native pci express support] Michael Tokarev
2011-03-16 12:10 ` Isaku Yamahata
2011-03-16 13:47 ` [Qemu-devel] RFC: ACPI table loading Michael Tokarev
2011-03-17 3:35 ` Isaku Yamahata
2011-04-19 8:28 ` [Qemu-devel] [PATCH 00/26] q35 chipset support for native pci express support Hu Tao
2011-04-19 8:51 ` Isaku Yamahata
2011-04-19 8:58 ` Hu Tao
2011-04-20 22:46 ` Isaku Yamahata
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=20110317053616.GH32049@redhat.com \
--to=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yamahata@valinux.co.jp \
/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).