[PATCH v6 12/19] hw/i386/pc_piix.c: always initialise ISA IDE drives in pc_init_isa()

Mark Cave-Ayland posted 19 patches 2 months, 3 weeks ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>
There is a newer version of this series
[PATCH v6 12/19] hw/i386/pc_piix.c: always initialise ISA IDE drives in pc_init_isa()
Posted by Mark Cave-Ayland 2 months, 3 weeks ago
By definition an isapc machine must always use ISA IDE drives so ensure that they
are always enabled. At the same time also remove the surrounding CONFIG_IDE_ISA
define since it will be enabled via the ISAPC Kconfig.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/i386/pc_piix.c | 35 +++++++++++++++--------------------
 1 file changed, 15 insertions(+), 20 deletions(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index bbd5f9d17f..924888b59d 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -444,6 +444,8 @@ static void pc_init_isa(MachineState *machine)
     GSIState *gsi_state;
     MemoryRegion *ram_memory;
     MemoryRegion *rom_memory = system_memory;
+    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
+    int i;
 
     /*
      * There is no RAM split for the isapc machine
@@ -519,27 +521,20 @@ static void pc_init_isa(MachineState *machine)
 
     pc_nic_init(pcmc, isa_bus, pcms->pcibus);
 
-#ifdef CONFIG_IDE_ISA
-    if (!pcmc->pci_enabled) {
-        DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
-        int i;
-
-        ide_drive_get(hd, ARRAY_SIZE(hd));
-        for (i = 0; i < MAX_IDE_BUS; i++) {
-            ISADevice *dev;
-            char busname[] = "ide.0";
-            dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
-                               ide_irq[i],
-                               hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
-            /*
-             * The ide bus name is ide.0 for the first bus and ide.1 for the
-             * second one.
-             */
-            busname[4] = '0' + i;
-            pcms->idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
-        }
+    ide_drive_get(hd, ARRAY_SIZE(hd));
+    for (i = 0; i < MAX_IDE_BUS; i++) {
+        ISADevice *dev;
+        char busname[] = "ide.0";
+        dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
+                            ide_irq[i],
+                            hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
+        /*
+         * The ide bus name is ide.0 for the first bus and ide.1 for the
+         * second one.
+         */
+        busname[4] = '0' + i;
+        pcms->idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
     }
-#endif
 }
 #endif
 
-- 
2.43.0


Re: [PATCH v6 12/19] hw/i386/pc_piix.c: always initialise ISA IDE drives in pc_init_isa()
Posted by Xiaoyao Li 2 months, 2 weeks ago
On 8/22/2025 8:11 PM, Mark Cave-Ayland wrote:
> By definition an isapc machine must always use ISA IDE drives so ensure that they
> are always enabled. At the same time also remove the surrounding CONFIG_IDE_ISA
> define since it will be enabled via the ISAPC Kconfig.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>

> ---
>   hw/i386/pc_piix.c | 35 +++++++++++++++--------------------
>   1 file changed, 15 insertions(+), 20 deletions(-)
> 
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index bbd5f9d17f..924888b59d 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -444,6 +444,8 @@ static void pc_init_isa(MachineState *machine)
>       GSIState *gsi_state;
>       MemoryRegion *ram_memory;
>       MemoryRegion *rom_memory = system_memory;
> +    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
> +    int i;
>   
>       /*
>        * There is no RAM split for the isapc machine
> @@ -519,27 +521,20 @@ static void pc_init_isa(MachineState *machine)
>   
>       pc_nic_init(pcmc, isa_bus, pcms->pcibus);
>   
> -#ifdef CONFIG_IDE_ISA
> -    if (!pcmc->pci_enabled) {
> -        DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
> -        int i;
> -
> -        ide_drive_get(hd, ARRAY_SIZE(hd));
> -        for (i = 0; i < MAX_IDE_BUS; i++) {
> -            ISADevice *dev;
> -            char busname[] = "ide.0";
> -            dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
> -                               ide_irq[i],
> -                               hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
> -            /*
> -             * The ide bus name is ide.0 for the first bus and ide.1 for the
> -             * second one.
> -             */
> -            busname[4] = '0' + i;
> -            pcms->idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
> -        }
> +    ide_drive_get(hd, ARRAY_SIZE(hd));
> +    for (i = 0; i < MAX_IDE_BUS; i++) {
> +        ISADevice *dev;
> +        char busname[] = "ide.0";
> +        dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
> +                            ide_irq[i],
> +                            hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
> +        /*
> +         * The ide bus name is ide.0 for the first bus and ide.1 for the
> +         * second one.
> +         */
> +        busname[4] = '0' + i;
> +        pcms->idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
>       }
> -#endif
>   }
>   #endif
>