diff mbox series

[v2,2/7] hw/ide: Get rid of piix4_init function

Message ID 3240656814c804513de08bdbbf318f2f590df241.1584437958.git.balaton@eik.bme.hu
State New
Headers show
Series Misc hw/ide legacy clean up | expand

Commit Message

BALATON Zoltan March 17, 2020, 9:39 a.m. UTC
This removes pci_piix4_ide_init() function similar to clean up done to
other ide devices.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
 hw/ide/piix.c    | 12 +-----------
 hw/isa/piix4.c   |  5 ++++-
 include/hw/ide.h |  1 -
 3 files changed, 5 insertions(+), 13 deletions(-)

Comments

Philippe Mathieu-Daudé March 17, 2020, 10:41 a.m. UTC | #1
On 3/17/20 10:39 AM, BALATON Zoltan wrote:
> This removes pci_piix4_ide_init() function similar to clean up done to
> other ide devices.
> 
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>   hw/ide/piix.c    | 12 +-----------
>   hw/isa/piix4.c   |  5 ++++-
>   include/hw/ide.h |  1 -
>   3 files changed, 5 insertions(+), 13 deletions(-)
> 
> diff --git a/hw/ide/piix.c b/hw/ide/piix.c
> index 8bcd6b72c2..3b2de4c312 100644
> --- a/hw/ide/piix.c
> +++ b/hw/ide/piix.c
> @@ -208,17 +208,6 @@ static void pci_piix_ide_exitfn(PCIDevice *dev)
>       }
>   }
>   
> -/* hd_table must contain 4 block drivers */
> -/* NOTE: for the PIIX4, the IRQs and IOports are hardcoded */
> -PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)
> -{
> -    PCIDevice *dev;
> -
> -    dev = pci_create_simple(bus, devfn, "piix4-ide");
> -    pci_ide_create_devs(dev, hd_table);
> -    return dev;
> -}
> -
>   /* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */
>   static void piix3_ide_class_init(ObjectClass *klass, void *data)
>   {
> @@ -247,6 +236,7 @@ static const TypeInfo piix3_ide_xen_info = {
>       .class_init    = piix3_ide_class_init,
>   };
>   
> +/* NOTE: for the PIIX4, the IRQs and IOports are hardcoded */
>   static void piix4_ide_class_init(ObjectClass *klass, void *data)
>   {
>       DeviceClass *dc = DEVICE_CLASS(klass);
> diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
> index 7edec5e149..0ab4787658 100644
> --- a/hw/isa/piix4.c
> +++ b/hw/isa/piix4.c
> @@ -35,6 +35,7 @@
>   #include "hw/timer/i8254.h"
>   #include "hw/rtc/mc146818rtc.h"
>   #include "hw/ide.h"
> +#include "hw/ide/pci.h"
>   #include "migration/vmstate.h"
>   #include "sysemu/reset.h"
>   #include "sysemu/runstate.h"
> @@ -255,10 +256,12 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus,
>           *isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
>       }
>   
> +    pci = pci_create_simple(pci_bus, pci->devfn + 1, "piix4-ide");
>       hd = g_new(DriveInfo *, ide_drives);
>       ide_drive_get(hd, ide_drives);
> -    pci_piix4_ide_init(pci_bus, hd, pci->devfn + 1);
> +    pci_ide_create_devs(pci, hd);
>       g_free(hd);
> +
>       pci_create_simple(pci_bus, pci->devfn + 2, "piix4-usb-uhci");
>       if (smbus) {
>           *smbus = piix4_pm_init(pci_bus, pci->devfn + 3, 0x1100,
> diff --git a/include/hw/ide.h b/include/hw/ide.h
> index 883bbaeb9b..21bd8f23f1 100644
> --- a/include/hw/ide.h
> +++ b/include/hw/ide.h
> @@ -12,7 +12,6 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,
>                           DriveInfo *hd0, DriveInfo *hd1);
>   
>   /* ide-pci.c */
> -PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn);
>   int pci_piix3_xen_ide_unplug(DeviceState *dev, bool aux);
>   
>   /* ide-mmio.c */
>
Philippe Mathieu-Daudé March 17, 2020, 10:49 a.m. UTC | #2
On 3/17/20 11:41 AM, Philippe Mathieu-Daudé wrote:
> On 3/17/20 10:39 AM, BALATON Zoltan wrote:
>> This removes pci_piix4_ide_init() function similar to clean up done to
>> other ide devices.
>>
>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Please disregard this tag (I withdraw it), I mis-read the pci variable 
was not assigned.

> 
>> ---
>>   hw/ide/piix.c    | 12 +-----------
>>   hw/isa/piix4.c   |  5 ++++-
>>   include/hw/ide.h |  1 -
>>   3 files changed, 5 insertions(+), 13 deletions(-)
>>
>> diff --git a/hw/ide/piix.c b/hw/ide/piix.c
>> index 8bcd6b72c2..3b2de4c312 100644
>> --- a/hw/ide/piix.c
>> +++ b/hw/ide/piix.c
>> @@ -208,17 +208,6 @@ static void pci_piix_ide_exitfn(PCIDevice *dev)
>>       }
>>   }
>> -/* hd_table must contain 4 block drivers */
>> -/* NOTE: for the PIIX4, the IRQs and IOports are hardcoded */
>> -PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int 
>> devfn)
>> -{
>> -    PCIDevice *dev;
>> -
>> -    dev = pci_create_simple(bus, devfn, "piix4-ide");
>> -    pci_ide_create_devs(dev, hd_table);
>> -    return dev;
>> -}
>> -
>>   /* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */
>>   static void piix3_ide_class_init(ObjectClass *klass, void *data)
>>   {
>> @@ -247,6 +236,7 @@ static const TypeInfo piix3_ide_xen_info = {
>>       .class_init    = piix3_ide_class_init,
>>   };
>> +/* NOTE: for the PIIX4, the IRQs and IOports are hardcoded */
>>   static void piix4_ide_class_init(ObjectClass *klass, void *data)
>>   {
>>       DeviceClass *dc = DEVICE_CLASS(klass);
>> diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
>> index 7edec5e149..0ab4787658 100644
>> --- a/hw/isa/piix4.c
>> +++ b/hw/isa/piix4.c
>> @@ -35,6 +35,7 @@
>>   #include "hw/timer/i8254.h"
>>   #include "hw/rtc/mc146818rtc.h"
>>   #include "hw/ide.h"
>> +#include "hw/ide/pci.h"
>>   #include "migration/vmstate.h"
>>   #include "sysemu/reset.h"
>>   #include "sysemu/runstate.h"
>> @@ -255,10 +256,12 @@ DeviceState *piix4_create(PCIBus *pci_bus, 
>> ISABus **isa_bus,
>>           *isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
>>       }
>> +    pci = pci_create_simple(pci_bus, pci->devfn + 1, "piix4-ide");
>>       hd = g_new(DriveInfo *, ide_drives);
>>       ide_drive_get(hd, ide_drives);
>> -    pci_piix4_ide_init(pci_bus, hd, pci->devfn + 1);
>> +    pci_ide_create_devs(pci, hd);
>>       g_free(hd);
>> +
>>       pci_create_simple(pci_bus, pci->devfn + 2, "piix4-usb-uhci");
>>       if (smbus) {
>>           *smbus = piix4_pm_init(pci_bus, pci->devfn + 3, 0x1100,
>> diff --git a/include/hw/ide.h b/include/hw/ide.h
>> index 883bbaeb9b..21bd8f23f1 100644
>> --- a/include/hw/ide.h
>> +++ b/include/hw/ide.h
>> @@ -12,7 +12,6 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int 
>> iobase2, int isairq,
>>                           DriveInfo *hd0, DriveInfo *hd1);
>>   /* ide-pci.c */
>> -PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int 
>> devfn);
>>   int pci_piix3_xen_ide_unplug(DeviceState *dev, bool aux);
>>   /* ide-mmio.c */
>>
John Snow March 17, 2020, 1:50 p.m. UTC | #3
On 3/17/20 6:49 AM, Philippe Mathieu-Daudé wrote:
> On 3/17/20 11:41 AM, Philippe Mathieu-Daudé wrote:
>> On 3/17/20 10:39 AM, BALATON Zoltan wrote:
>>> This removes pci_piix4_ide_init() function similar to clean up done to
>>> other ide devices.
>>>
>>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>>> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> 
> Please disregard this tag (I withdraw it), I mis-read the pci variable
> was not assigned.
> 

Is there an issue you've noticed, or you are just no longer certain
enough to give an RB?
Philippe Mathieu-Daudé March 17, 2020, 2:01 p.m. UTC | #4
On 3/17/20 2:50 PM, John Snow wrote:
> On 3/17/20 6:49 AM, Philippe Mathieu-Daudé wrote:
>> On 3/17/20 11:41 AM, Philippe Mathieu-Daudé wrote:
>>> On 3/17/20 10:39 AM, BALATON Zoltan wrote:
>>>> This removes pci_piix4_ide_init() function similar to clean up done to
>>>> other ide devices.
>>>>
>>>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>>>> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>>>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>>>
>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>
>> Please disregard this tag (I withdraw it), I mis-read the pci variable
>> was not assigned.
>>
> 
> Is there an issue you've noticed, or you are just no longer certain
> enough to give an RB?

I asked Zoltan there why he was reassigning 'pci' and he replied here:
https://www.mail-archive.com/qemu-block@nongnu.org/msg63324.html

I don't know enough the PCI API (and don't have time this week to dig 
into it) to check how pci->devfn is used (is it populated by a 
pci_create() call?).

     pci = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(10, 0),
                                           true, TYPE_PIIX4_PCI_DEVICE);
     ...
+   pci = pci_create_simple(pci_bus, pci->devfn + 1, "piix4-ide");
     ...
     pci_create_simple(pci_bus, pci->devfn + 2, "piix4-usb-uhci");

What annoys me is here -------^^^^^^ I don't know if reassigning the pci 
variable can have an impact, so as I am not confident I prefer to 
withdraw my review tag.

Since the patch already has 2 R-b I'm not going to NAck it neither.
BALATON Zoltan March 17, 2020, 2:05 p.m. UTC | #5
On Tue, 17 Mar 2020, John Snow wrote:
> On 3/17/20 6:49 AM, Philippe Mathieu-Daudé wrote:
>> On 3/17/20 11:41 AM, Philippe Mathieu-Daudé wrote:
>>> On 3/17/20 10:39 AM, BALATON Zoltan wrote:
>>>> This removes pci_piix4_ide_init() function similar to clean up done to
>>>> other ide devices.
>>>>
>>>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>>>> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>>>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>>>
>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>
>> Please disregard this tag (I withdraw it), I mis-read the pci variable
>> was not assigned.
>>
>
> Is there an issue you've noticed, or you are just no longer certain
> enough to give an RB?

My previous replies to this question:

https://lists.nongnu.org/archive/html/qemu-devel/2020-03/msg04356.html
https://lists.nongnu.org/archive/html/qemu-devel/2020-03/msg04381.html

End result after all patches in the series looks like this:

DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
{
     PCIDevice *pci;
     DeviceState *dev;

     pci = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(10, 0),
                                           true, TYPE_PIIX4_PCI_DEVICE);
     dev = DEVICE(pci);
     if (isa_bus) {
         *isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
     }

     pci = pci_create_simple(pci_bus, pci->devfn + 1, "piix4-ide");
     pci_ide_create_devs(pci);

     pci_create_simple(pci_bus, pci->devfn + 2, "piix4-usb-uhci");
     if (smbus) {
         *smbus = piix4_pm_init(pci_bus, pci->devfn + 3, 0x1100,
                                isa_get_irq(NULL, 9), NULL, 0, NULL);
    }

     return dev;
}

I think it's clear enough what the pci variable is used for here and there 
was no further reply from Philippe and Michael and others were OK with 
this so there was no definitive decision here. Mayby Philippe still does 
not like reusal of this variable enough to give Reviewed tag but there 
should be no other problem with it otherwise.

Regards,
BALATON Zoltan
BALATON Zoltan March 17, 2020, 2:07 p.m. UTC | #6
On Tue, 17 Mar 2020, Philippe Mathieu-Daudé wrote:
> On 3/17/20 2:50 PM, John Snow wrote:
>> On 3/17/20 6:49 AM, Philippe Mathieu-Daudé wrote:
>>> On 3/17/20 11:41 AM, Philippe Mathieu-Daudé wrote:
>>>> On 3/17/20 10:39 AM, BALATON Zoltan wrote:
>>>>> This removes pci_piix4_ide_init() function similar to clean up done to
>>>>> other ide devices.
>>>>> 
>>>>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>>>>> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>>>>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>>>> 
>>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>> 
>>> Please disregard this tag (I withdraw it), I mis-read the pci variable
>>> was not assigned.
>>> 
>> 
>> Is there an issue you've noticed, or you are just no longer certain
>> enough to give an RB?
>
> I asked Zoltan there why he was reassigning 'pci' and he replied here:
> https://www.mail-archive.com/qemu-block@nongnu.org/msg63324.html
>
> I don't know enough the PCI API (and don't have time this week to dig into 
> it) to check how pci->devfn is used (is it populated by a pci_create() 
> call?).
>
>    pci = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(10, 0),
>                                          true, TYPE_PIIX4_PCI_DEVICE);
>    ...
> +   pci = pci_create_simple(pci_bus, pci->devfn + 1, "piix4-ide");
>    ...
>    pci_create_simple(pci_bus, pci->devfn + 2, "piix4-usb-uhci");
>
> What annoys me is here -------^^^^^^ I don't know if reassigning the pci 
> variable can have an impact, so as I am not confident I prefer to withdraw my 
> review tag.

OK, I did not know that's what you were asking about and did not notice 
this could be a problem. To avoid any doubt I'll send a new version to 
avoid this shortly.

Regards,
BALATON Zoltan
John Snow March 17, 2020, 2:09 p.m. UTC | #7
On 3/17/20 10:05 AM, BALATON Zoltan wrote:
> On Tue, 17 Mar 2020, John Snow wrote:
>> On 3/17/20 6:49 AM, Philippe Mathieu-Daudé wrote:
>>> On 3/17/20 11:41 AM, Philippe Mathieu-Daudé wrote:
>>>> On 3/17/20 10:39 AM, BALATON Zoltan wrote:
>>>>> This removes pci_piix4_ide_init() function similar to clean up done to
>>>>> other ide devices.
>>>>>
>>>>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>>>>> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>>>>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>>>>
>>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>>
>>> Please disregard this tag (I withdraw it), I mis-read the pci variable
>>> was not assigned.
>>>
>>
>> Is there an issue you've noticed, or you are just no longer certain
>> enough to give an RB?
> 
> My previous replies to this question:
> 
> https://lists.nongnu.org/archive/html/qemu-devel/2020-03/msg04356.html
> https://lists.nongnu.org/archive/html/qemu-devel/2020-03/msg04381.html
> 
> End result after all patches in the series looks like this:
> 
> DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus
> **smbus)
> {
>     PCIDevice *pci;
>     DeviceState *dev;
> 
>     pci = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(10, 0),
>                                           true, TYPE_PIIX4_PCI_DEVICE);
>     dev = DEVICE(pci);
>     if (isa_bus) {
>         *isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
>     }
> 
>     pci = pci_create_simple(pci_bus, pci->devfn + 1, "piix4-ide");
>     pci_ide_create_devs(pci);
> 
>     pci_create_simple(pci_bus, pci->devfn + 2, "piix4-usb-uhci");
>     if (smbus) {
>         *smbus = piix4_pm_init(pci_bus, pci->devfn + 3, 0x1100,
>                                isa_get_irq(NULL, 9), NULL, 0, NULL);
>    }
> 
>     return dev;
> }
> 
> I think it's clear enough what the pci variable is used for here and
> there was no further reply from Philippe and Michael and others were OK
> with this so there was no definitive decision here. Mayby Philippe still
> does not like reusal of this variable enough to give Reviewed tag but
> there should be no other problem with it otherwise.
> 
> Regards,
> BALATON Zoltan

Thanks for the pointers -- my attention was focused elsewhere, and the
discussion was so vigorous I felt comfortable letting you handle it :)

I'm seeing a compilation error -- I cleared my cache and am looking for
the commit that introduced it. Stay tuned, please.

--js
Philippe Mathieu-Daudé March 17, 2020, 2:10 p.m. UTC | #8
On Tue, Mar 17, 2020 at 3:07 PM BALATON Zoltan <balaton@eik.bme.hu> wrote:
> On Tue, 17 Mar 2020, Philippe Mathieu-Daudé wrote:
> > On 3/17/20 2:50 PM, John Snow wrote:
> >> On 3/17/20 6:49 AM, Philippe Mathieu-Daudé wrote:
> >>> On 3/17/20 11:41 AM, Philippe Mathieu-Daudé wrote:
> >>>> On 3/17/20 10:39 AM, BALATON Zoltan wrote:
> >>>>> This removes pci_piix4_ide_init() function similar to clean up done to
> >>>>> other ide devices.
> >>>>>
> >>>>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> >>>>> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> >>>>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> >>>>
> >>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> >>>
> >>> Please disregard this tag (I withdraw it), I mis-read the pci variable
> >>> was not assigned.
> >>>
> >>
> >> Is there an issue you've noticed, or you are just no longer certain
> >> enough to give an RB?
> >
> > I asked Zoltan there why he was reassigning 'pci' and he replied here:
> > https://www.mail-archive.com/qemu-block@nongnu.org/msg63324.html
> >
> > I don't know enough the PCI API (and don't have time this week to dig into
> > it) to check how pci->devfn is used (is it populated by a pci_create()
> > call?).
> >
> >    pci = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(10, 0),
> >                                          true, TYPE_PIIX4_PCI_DEVICE);
> >    ...
> > +   pci = pci_create_simple(pci_bus, pci->devfn + 1, "piix4-ide");
> >    ...
> >    pci_create_simple(pci_bus, pci->devfn + 2, "piix4-usb-uhci");
> >
> > What annoys me is here -------^^^^^^ I don't know if reassigning the pci
> > variable can have an impact, so as I am not confident I prefer to withdraw my
> > review tag.
>
> OK, I did not know that's what you were asking about and did not notice
> this could be a problem. To avoid any doubt I'll send a new version to
> avoid this shortly.

Sorry I was a bit rushed for soft-freeze, I should have spent more
time in my comment then, this would have saved everybody a bit of
email traffic.
I'll try to remember next time.

Thanks for sending an updated version.

> Regards,
> BALATON Zoltan
Mark Cave-Ayland March 17, 2020, 2:41 p.m. UTC | #9
On 17/03/2020 14:07, BALATON Zoltan wrote:

> On Tue, 17 Mar 2020, Philippe Mathieu-Daudé wrote:
>> On 3/17/20 2:50 PM, John Snow wrote:
>>> On 3/17/20 6:49 AM, Philippe Mathieu-Daudé wrote:
>>>> On 3/17/20 11:41 AM, Philippe Mathieu-Daudé wrote:
>>>>> On 3/17/20 10:39 AM, BALATON Zoltan wrote:
>>>>>> This removes pci_piix4_ide_init() function similar to clean up done to
>>>>>> other ide devices.
>>>>>>
>>>>>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>>>>>> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>>>>>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>>>>>
>>>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>>>
>>>> Please disregard this tag (I withdraw it), I mis-read the pci variable
>>>> was not assigned.
>>>>
>>>
>>> Is there an issue you've noticed, or you are just no longer certain
>>> enough to give an RB?
>>
>> I asked Zoltan there why he was reassigning 'pci' and he replied here:
>> https://www.mail-archive.com/qemu-block@nongnu.org/msg63324.html
>>
>> I don't know enough the PCI API (and don't have time this week to dig into it) to
>> check how pci->devfn is used (is it populated by a pci_create() call?).
>>
>>    pci = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(10, 0),
>>                                          true, TYPE_PIIX4_PCI_DEVICE);
>>    ...
>> +   pci = pci_create_simple(pci_bus, pci->devfn + 1, "piix4-ide");
>>    ...
>>    pci_create_simple(pci_bus, pci->devfn + 2, "piix4-usb-uhci");
>>
>> What annoys me is here -------^^^^^^ I don't know if reassigning the pci variable
>> can have an impact, so as I am not confident I prefer to withdraw my review tag.
> 
> OK, I did not know that's what you were asking about and did not notice this could be
> a problem. To avoid any doubt I'll send a new version to avoid this shortly.

Hmmm actually yes I think isn't quite right. Here you have PCI_DEVFN(10, 0) for the
PIIX4_PCI_DEVICE, and PCI_DEVFN(10, 0) + 1 for "piix4-ide". But since you've
reassigned pci then "piix4-usb-uhci" now ends up as (PCI_DEVFN(10, 0) + 1) + 2 =
PCI_DEVFN(10, 0) + 3 rather than PCI_DEVFN(10, 0) + 2 as it was before.


ATB,

Mark.
diff mbox series

Patch

diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index 8bcd6b72c2..3b2de4c312 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -208,17 +208,6 @@  static void pci_piix_ide_exitfn(PCIDevice *dev)
     }
 }
 
-/* hd_table must contain 4 block drivers */
-/* NOTE: for the PIIX4, the IRQs and IOports are hardcoded */
-PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)
-{
-    PCIDevice *dev;
-
-    dev = pci_create_simple(bus, devfn, "piix4-ide");
-    pci_ide_create_devs(dev, hd_table);
-    return dev;
-}
-
 /* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */
 static void piix3_ide_class_init(ObjectClass *klass, void *data)
 {
@@ -247,6 +236,7 @@  static const TypeInfo piix3_ide_xen_info = {
     .class_init    = piix3_ide_class_init,
 };
 
+/* NOTE: for the PIIX4, the IRQs and IOports are hardcoded */
 static void piix4_ide_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index 7edec5e149..0ab4787658 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -35,6 +35,7 @@ 
 #include "hw/timer/i8254.h"
 #include "hw/rtc/mc146818rtc.h"
 #include "hw/ide.h"
+#include "hw/ide/pci.h"
 #include "migration/vmstate.h"
 #include "sysemu/reset.h"
 #include "sysemu/runstate.h"
@@ -255,10 +256,12 @@  DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus,
         *isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
     }
 
+    pci = pci_create_simple(pci_bus, pci->devfn + 1, "piix4-ide");
     hd = g_new(DriveInfo *, ide_drives);
     ide_drive_get(hd, ide_drives);
-    pci_piix4_ide_init(pci_bus, hd, pci->devfn + 1);
+    pci_ide_create_devs(pci, hd);
     g_free(hd);
+
     pci_create_simple(pci_bus, pci->devfn + 2, "piix4-usb-uhci");
     if (smbus) {
         *smbus = piix4_pm_init(pci_bus, pci->devfn + 3, 0x1100,
diff --git a/include/hw/ide.h b/include/hw/ide.h
index 883bbaeb9b..21bd8f23f1 100644
--- a/include/hw/ide.h
+++ b/include/hw/ide.h
@@ -12,7 +12,6 @@  ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,
                         DriveInfo *hd0, DriveInfo *hd1);
 
 /* ide-pci.c */
-PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn);
 int pci_piix3_xen_ide_unplug(DeviceState *dev, bool aux);
 
 /* ide-mmio.c */