Re: [PATCH 5/6] hw/ide/via: Connect IDE function output IRQs to the ISA function input

2021-03-25 Thread John Snow

On 3/24/21 1:54 PM, Philippe Mathieu-Daudé wrote:

To avoid abusing isa_get_irq(NULL) using a hidden ISA bridge
under the hood, let the IDE function expose 2 output IRQs,
and connect them to the ISA function inputs when creating
the south bridge chipset model in vt82c686b_southbridge_init.

Signed-off-by: Philippe Mathieu-Daudé 


No real opinion, how was it tested? Can probably ack in good faith after 
review comments from Richard Henderson and BALATON Zoltan.


--js


---
  hw/ide/via.c| 19 +--
  hw/mips/fuloong2e.c |  9 -
  2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/hw/ide/via.c b/hw/ide/via.c
index 6c667a92130..7887bf181e6 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -33,6 +33,17 @@
  #include "hw/ide/pci.h"
  #include "trace.h"
  
+#define TYPE_VIA_IDE "via-ide"

+OBJECT_DECLARE_SIMPLE_TYPE(VIAIDEState, VIA_IDE)
+
+struct VIAIDEState {
+/*  */
+PCIIDEState parent_obj;
+/*  */
+
+qemu_irq irq[2];
+};
+
  static uint64_t bmdma_read(void *opaque, hwaddr addr,
 unsigned size)
  {
@@ -105,6 +116,7 @@ static void bmdma_setup_bar(PCIIDEState *d)
  static void via_ide_set_irq(void *opaque, int n, int level)
  {
  PCIDevice *d = PCI_DEVICE(opaque);
+VIAIDEState *s = VIA_IDE(d);
  
  if (level) {

  d->config[0x70 + n * 8] |= 0x80;
@@ -112,7 +124,7 @@ static void via_ide_set_irq(void *opaque, int n, int level)
  d->config[0x70 + n * 8] &= ~0x80;
  }
  
-qemu_set_irq(isa_get_irq(NULL, 14 + n), level);

+qemu_set_irq(s->irq[n], level);
  }
  
  static void via_ide_reset(DeviceState *dev)

@@ -159,6 +171,7 @@ static void via_ide_reset(DeviceState *dev)
  
  static void via_ide_realize(PCIDevice *dev, Error **errp)

  {
+VIAIDEState *s = VIA_IDE(dev);
  PCIIDEState *d = PCI_IDE(dev);
  DeviceState *ds = DEVICE(dev);
  uint8_t *pci_conf = dev->config;
@@ -188,6 +201,7 @@ static void via_ide_realize(PCIDevice *dev, Error **errp)
  bmdma_setup_bar(d);
  pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, >bmdma_bar);
  
+qdev_init_gpio_out_named(ds, s->irq, "ide-irq", ARRAY_SIZE(s->irq));

  qdev_init_gpio_in(ds, via_ide_set_irq, ARRAY_SIZE(d->bus));
  for (i = 0; i < ARRAY_SIZE(d->bus); i++) {
  ide_bus_new(>bus[i], sizeof(d->bus[i]), ds, i, MAX_IDE_DEVS);
@@ -227,8 +241,9 @@ static void via_ide_class_init(ObjectClass *klass, void 
*data)
  }
  
  static const TypeInfo via_ide_info = {

-.name  = "via-ide",
+.name  = TYPE_VIA_IDE,
  .parent= TYPE_PCI_IDE,
+.instance_size = sizeof(VIAIDEState),
  .class_init= via_ide_class_init,
  };
  
diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c

index 931385c760f..f1c5db13b78 100644
--- a/hw/mips/fuloong2e.c
+++ b/hw/mips/fuloong2e.c
@@ -203,12 +203,19 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, 
int slot, qemu_irq intc,
 I2CBus **i2c_bus)
  {
  PCIDevice *dev;
+DeviceState *isa;
  
  dev = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(slot, 0), true,

TYPE_VT82C686B_ISA);
-qdev_connect_gpio_out_named(DEVICE(dev), "intr", 0, intc);
+isa = DEVICE(dev);
+qdev_connect_gpio_out_named(isa, "intr", 0, intc);
  
  dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide");

+for (unsigned i = 0; i < 2; i++) {
+qdev_connect_gpio_out_named(DEVICE(dev), "ide-irq", i,
+qdev_get_gpio_in_named(isa,
+   "isa-irq", 14 + i));
+}
  pci_ide_create_devs(dev);
  
  pci_create_simple(pci_bus, PCI_DEVFN(slot, 2), "vt82c686b-usb-uhci");







Re: [PATCH 5/6] hw/ide/via: Connect IDE function output IRQs to the ISA function input

2021-03-25 Thread Philippe Mathieu-Daudé
On 3/25/21 1:29 PM, Richard Henderson wrote:
> On 3/24/21 11:54 AM, Philippe Mathieu-Daudé wrote:
>> To avoid abusing isa_get_irq(NULL) using a hidden ISA bridge
>> under the hood, let the IDE function expose 2 output IRQs,
>> and connect them to the ISA function inputs when creating
>> the south bridge chipset model in vt82c686b_southbridge_init.
>>
>> Signed-off-by: Philippe Mathieu-Daudé 
>> ---
>>   hw/ide/via.c    | 19 +--
>>   hw/mips/fuloong2e.c |  9 -
>>   2 files changed, 25 insertions(+), 3 deletions(-)

>> diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
>> index 931385c760f..f1c5db13b78 100644
>> --- a/hw/mips/fuloong2e.c
>> +++ b/hw/mips/fuloong2e.c
>> @@ -203,12 +203,19 @@ static void vt82c686b_southbridge_init(PCIBus
>> *pci_bus, int slot, qemu_irq intc,
>>  I2CBus **i2c_bus)
>>   {
>>   PCIDevice *dev;
>> +    DeviceState *isa;
>>     dev = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(slot,
>> 0), true,
>>     TYPE_VT82C686B_ISA);
>> -    qdev_connect_gpio_out_named(DEVICE(dev), "intr", 0, intc);
>> +    isa = DEVICE(dev);
>> +    qdev_connect_gpio_out_named(isa, "intr", 0, intc);
>>     dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide");
>> +    for (unsigned i = 0; i < 2; i++) {
>> +    qdev_connect_gpio_out_named(DEVICE(dev), "ide-irq", i,
> 
>    ^^^ isa?

OK.

>> +    qdev_get_gpio_in_named(isa,
>> +   "isa-irq",
>> 14 + i));
>> +    }
> 
> It all looks a little funny, but I think I follow it, and see that it
> can't be split further, because of the movement of the +14.

I can break the indent to shift left. Anyway this disappear in the next
commit.

> Reviewed-by: Richard Henderson 
> 

Thanks!

Phil.



Re: [PATCH 5/6] hw/ide/via: Connect IDE function output IRQs to the ISA function input

2021-03-25 Thread Richard Henderson

On 3/24/21 11:54 AM, Philippe Mathieu-Daudé wrote:

To avoid abusing isa_get_irq(NULL) using a hidden ISA bridge
under the hood, let the IDE function expose 2 output IRQs,
and connect them to the ISA function inputs when creating
the south bridge chipset model in vt82c686b_southbridge_init.

Signed-off-by: Philippe Mathieu-Daudé 
---
  hw/ide/via.c| 19 +--
  hw/mips/fuloong2e.c |  9 -
  2 files changed, 25 insertions(+), 3 deletions(-)





@@ -112,7 +124,7 @@ static void via_ide_set_irq(void *opaque, int n, int level)
  d->config[0x70 + n * 8] &= ~0x80;
  }
  
-qemu_set_irq(isa_get_irq(NULL, 14 + n), level);

+qemu_set_irq(s->irq[n], level);
  }
  
  static void via_ide_reset(DeviceState *dev)

...

diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
index 931385c760f..f1c5db13b78 100644
--- a/hw/mips/fuloong2e.c
+++ b/hw/mips/fuloong2e.c
@@ -203,12 +203,19 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, 
int slot, qemu_irq intc,
 I2CBus **i2c_bus)
  {
  PCIDevice *dev;
+DeviceState *isa;
  
  dev = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(slot, 0), true,

TYPE_VT82C686B_ISA);
-qdev_connect_gpio_out_named(DEVICE(dev), "intr", 0, intc);
+isa = DEVICE(dev);
+qdev_connect_gpio_out_named(isa, "intr", 0, intc);
  
  dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide");

+for (unsigned i = 0; i < 2; i++) {
+qdev_connect_gpio_out_named(DEVICE(dev), "ide-irq", i,


   ^^^ isa?


+qdev_get_gpio_in_named(isa,
+   "isa-irq", 14 + i));
+}


It all looks a little funny, but I think I follow it, and see that it can't be 
split further, because of the movement of the +14.


Reviewed-by: Richard Henderson 

r~