qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

qemu isa irq gpio question


From: BALATON Zoltan
Subject: qemu isa irq gpio question
Date: Sat, 2 Jan 2021 10:58:44 +0100 (CET)

Hello,

While cleaning up my VIA south bridge patches I've found that with the finished version I did not get interrupts. At the end I've found a solution in a similar device (piix4) but I don't understand why that's needed. Could someone please explain?

Here's what I had originally in board code (this is from pegasos2 but fuloong2e has the same with vt82c686b instead if vt8231):

dev = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0), true, 
"vt8231");
isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(dev), "isa.0"));
// "vt8231" just created an empty isa_bus with isa_bus_new()
qemu_irq *i8259 = i8259_init(isa_bus, qdev_get_gpio_in_named(DEVICE(mv), "gpp", 
31));
isa_bus_irqs(isa_bus, i8259);

which worked but after completely moving isa_bus, PIC and other ISA devices into the vt82c686b/vt8231 model I ended up with:

dev = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0), true, 
"vt8231-isa");
qdev_connect_gpio_out(DEVICE(dev), 0, qdev_get_gpio_in_named(DEVICE(mv), "gpp", 
31));

where "vt8231-isa" having this:

struct ViaISAState {
    PCIDevice dev;
    qemu_irq cpu_intr;
};

static void vt8231_realize(PCIDevice *d, Error **errp)
{
     qdev_init_gpio_out(dev, &s->cpu_intr, 1);
     isa_bus = isa_bus_new(...);
     isa_bus_irqs(isa_bus, i8259_init(isa_bus, s->cpu_intr));
}

this compiled without warnings but irqs were not getting to the connected end. After looking for similar code I ended up with this from piix4 which works again:

static void via_isa_request_i8259_irq(void *opaque, int irq, int level)
{
    ViaISAState *s = opaque;
    qemu_set_irq(s->cpu_intr, level);
}

static void vt8231_realize(PCIDevice *d, Error **errp)
{
     qdev_init_gpio_out(dev, &s->cpu_intr, 1);
     qemu_irq *isa_irq = qemu_allocate_irqs(via_isa_request_i8259_irq, s, 1);
     isa_bus_irqs(isa_bus, i8259_init(isa_bus, *isa_irq));
}

I'm not sure if this will leak the allocated irq and why is this additional function needed inbetween these in this case but this is what works so I'll go with this one for now but still curious what did I miss.

Regards,
BALATON Zoltan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]