From: Artyom Tarasenko <atar4qemu@gmail.com>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCHv3 11/16] apb: split pci_pbm_map_irq() into separate functions for bus A and bus B
Date: Thu, 21 Dec 2017 11:17:07 +0100 [thread overview]
Message-ID: <CACXAS8DLXDkC2ssjQcEXU7nrE_P2_S62MJkA3dpHwDC6DEKvpQ@mail.gmail.com> (raw)
In-Reply-To: <20171221082045.14022-12-mark.cave-ayland@ilande.co.uk>
On Thu, Dec 21, 2017 at 9:20 AM, Mark Cave-Ayland
<mark.cave-ayland@ilande.co.uk> wrote:
> After the previous refactoring it is now possible to use separate functions
> to improve the clarity of the interrupt paths.
>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Artyom Tarasenko <atar4qemu@gmail.com>
> ---
> hw/pci-host/apb.c | 45 ++++++++++++++++++++-------------------------
> 1 file changed, 20 insertions(+), 25 deletions(-)
>
> diff --git a/hw/pci-host/apb.c b/hw/pci-host/apb.c
> index 6c20285b04..3ebb9dc304 100644
> --- a/hw/pci-host/apb.c
> +++ b/hw/pci-host/apb.c
> @@ -517,32 +517,27 @@ static int pci_apb_map_irq(PCIDevice *pci_dev, int irq_num)
> return irq_num;
> }
>
> -static int pci_pbm_map_irq(PCIDevice *pci_dev, int irq_num)
> +static int pci_pbmA_map_irq(PCIDevice *pci_dev, int irq_num)
> {
> - PBMPCIBridge *br = PBM_PCI_BRIDGE(pci_bridge_get_device(
> - PCI_BUS(qdev_get_parent_bus(DEVICE(pci_dev)))));
> -
> - int bus_offset;
> - if (br->busA) {
> - bus_offset = 0x0;
> + /* The on-board devices have fixed (legacy) OBIO intnos */
> + switch (PCI_SLOT(pci_dev->devfn)) {
> + case 1:
> + /* Onboard NIC */
> + return 0x21;
> + case 3:
> + /* Onboard IDE */
> + return 0x20;
> + default:
> + /* Normal intno, fall through */
> + break;
> + }
>
> - /* The on-board devices have fixed (legacy) OBIO intnos */
> - switch (PCI_SLOT(pci_dev->devfn)) {
> - case 1:
> - /* Onboard NIC */
> - return 0x21;
> - case 3:
> - /* Onboard IDE */
> - return 0x20;
> + return ((PCI_SLOT(pci_dev->devfn) << 2) + irq_num) & 0x1f;
> +}
>
> - default:
> - /* Normal intno, fall through */
> - break;
> - }
> - } else {
> - bus_offset = 0x10;
> - }
> - return (bus_offset + (PCI_SLOT(pci_dev->devfn) << 2) + irq_num) & 0x1f;
> +static int pci_pbmB_map_irq(PCIDevice *pci_dev, int irq_num)
> +{
> + return (0x10 + (PCI_SLOT(pci_dev->devfn) << 2) + irq_num) & 0x1f;
> }
>
> static void pci_apb_set_irq(void *opaque, int irq_num, int level)
> @@ -673,13 +668,13 @@ static void pci_pbm_realize(DeviceState *dev, Error **errp)
> pci_dev = pci_create_multifunction(phb->bus, PCI_DEVFN(1, 0), true,
> TYPE_PBM_PCI_BRIDGE);
> s->bridgeB = PCI_BRIDGE(pci_dev);
> - pci_bridge_map_irq(s->bridgeB, "pciB", pci_pbm_map_irq);
> + pci_bridge_map_irq(s->bridgeB, "pciB", pci_pbmB_map_irq);
> qdev_init_nofail(&pci_dev->qdev);
>
> pci_dev = pci_create_multifunction(phb->bus, PCI_DEVFN(1, 1), true,
> TYPE_PBM_PCI_BRIDGE);
> s->bridgeA = PCI_BRIDGE(pci_dev);
> - pci_bridge_map_irq(s->bridgeA, "pciA", pci_pbm_map_irq);
> + pci_bridge_map_irq(s->bridgeA, "pciA", pci_pbmA_map_irq);
> qdev_prop_set_bit(DEVICE(pci_dev), "busA", true);
> qdev_init_nofail(&pci_dev->qdev);
> }
> --
> 2.11.0
>
--
Regards,
Artyom Tarasenko
SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu
next prev parent reply other threads:[~2017-12-21 10:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 8:20 [Qemu-devel] [PATCHv3 00/16] sun4u: tidy-up CPU, APB and ebus Mark Cave-Ayland
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 01/16] apb: move QOM macros and typedefs from apb.c to apb.h Mark Cave-Ayland
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 02/16] sun4u: ebus QOMify tidy-up Mark Cave-Ayland
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 03/16] sun4u: move ISABus inside of EBusState Mark Cave-Ayland
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 04/16] sun4u: remove pci_ebus_init() function Mark Cave-Ayland
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 05/16] sun4u: move initialisation of all ISABus devices into ebus_realize() Mark Cave-Ayland
2017-12-21 10:21 ` Artyom Tarasenko
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 06/16] apb: APB QOMify tidy-up Mark Cave-Ayland
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 07/16] apb: return APBState from pci_apb_init() rather than PCIBus Mark Cave-Ayland
2017-12-21 10:20 ` Artyom Tarasenko
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 08/16] apb: use gpios to wire up the apb device to the SPARC CPU IRQs Mark Cave-Ayland
2017-12-21 10:20 ` Artyom Tarasenko
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 09/16] apb: move the two secondary PCI bridges objects into APBState Mark Cave-Ayland
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 10/16] apb: remove pci_apb_init() and instantiate APB device using qdev Mark Cave-Ayland
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 11/16] apb: split pci_pbm_map_irq() into separate functions for bus A and bus B Mark Cave-Ayland
2017-12-21 10:17 ` Artyom Tarasenko [this message]
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 12/16] apb: remove busA property from PBMPCIBridge state Mark Cave-Ayland
2017-12-21 10:16 ` Artyom Tarasenko
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 13/16] ebus: wire up OBIO interrupts to APB pbm via qdev GPIOs Mark Cave-Ayland
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 14/16] apb: replace OBIO interrupt numbers in pci_pbmA_map_irq() with constants Mark Cave-Ayland
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 15/16] sparc64: introduce trace-events for hw/sparc64 Mark Cave-Ayland
2017-12-21 8:20 ` [Qemu-devel] [PATCHv3 16/16] sun4u: switch from EBUS_DPRINTF() macro to trace-events Mark Cave-Ayland
2017-12-21 10:18 ` Artyom Tarasenko
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=CACXAS8DLXDkC2ssjQcEXU7nrE_P2_S62MJkA3dpHwDC6DEKvpQ@mail.gmail.com \
--to=atar4qemu@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=qemu-devel@nongnu.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).