All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] via-ide: fixes and improvements
@ 2020-03-13  8:24 Mark Cave-Ayland
  2020-03-13  8:24 ` [PATCH 1/7] via-ide: move registration of VMStateDescription to DeviceClass Mark Cave-Ayland
                   ` (9 more replies)
  0 siblings, 10 replies; 16+ messages in thread
From: Mark Cave-Ayland @ 2020-03-13  8:24 UTC (permalink / raw)
  To: jsnow, philmd, amarkovic, mst, qemu-block, qemu-devel, balaton

Following on from the earlier thread "Implement "non 100% native mode"
in via-ide", here is an updated patchset based upon the test cases
sent to me off-list.

The VIA IDE controller is similar to early versions of the PIIX
controller in that the primary and secondary IDE channels are hardwired
to IRQs 14 and 15 respectively. Guest OSs typically handle this by
either switching the controller to legacy mode, or using native mode and
using a combination of PCI device/vendor ID and/or checking various
registers in PCI configuration space to detect this condition and apply
a special fixed IRQ 14/15 routing.

This patchset effectively updates the VIA IDE PCI device to follow the
behaviour in the datasheet in two ways: fixing some PCI configuration
space register defaults and behaviours, and always using legacy IRQ 14/15
routing, and once applied allows all our known test images to boot
correctly.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


BALATON Zoltan (2):
  ide/via: Get rid of via_ide_init()
  pci: Honour wmask when resetting PCI_INTERRUPT_LINE

Mark Cave-Ayland (5):
  via-ide: move registration of VMStateDescription to DeviceClass
  via-ide: ensure that PCI_INTERRUPT_LINE is hard-wired to its default
    value
  via-ide: initialise IDE controller in legacy mode
  via-ide: allow guests to write to PCI_CLASS_PROG
  via-ide: always use legacy IRQ 14/15 routing

 hw/ide/via.c            | 21 +++++----------------
 hw/mips/mips_fulong2e.c |  5 ++++-
 hw/pci/pci.c            |  5 ++++-
 include/hw/ide.h        |  1 -
 4 files changed, 13 insertions(+), 19 deletions(-)

-- 
2.20.1



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/7] via-ide: move registration of VMStateDescription to DeviceClass
  2020-03-13  8:24 [PATCH 0/7] via-ide: fixes and improvements Mark Cave-Ayland
@ 2020-03-13  8:24 ` Mark Cave-Ayland
  2020-03-13 19:50   ` Philippe Mathieu-Daudé
  2020-03-13  8:24 ` [PATCH 2/7] ide/via: Get rid of via_ide_init() Mark Cave-Ayland
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Mark Cave-Ayland @ 2020-03-13  8:24 UTC (permalink / raw)
  To: jsnow, philmd, amarkovic, mst, qemu-block, qemu-devel, balaton

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ide/via.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/ide/via.c b/hw/ide/via.c
index 096de8dba0..84f0efff94 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -190,8 +190,6 @@ static void via_ide_realize(PCIDevice *dev, Error **errp)
     bmdma_setup_bar(d);
     pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &d->bmdma_bar);
 
-    vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d);
-
     for (i = 0; i < 2; i++) {
         ide_bus_new(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2);
         ide_init2(&d->bus[i], qemu_allocate_irq(via_ide_set_irq, d, i));
@@ -227,6 +225,7 @@ static void via_ide_class_init(ObjectClass *klass, void *data)
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
     dc->reset = via_ide_reset;
+    dc->vmsd = &vmstate_ide_pci;
     k->realize = via_ide_realize;
     k->exit = via_ide_exitfn;
     k->vendor_id = PCI_VENDOR_ID_VIA;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/7] ide/via: Get rid of via_ide_init()
  2020-03-13  8:24 [PATCH 0/7] via-ide: fixes and improvements Mark Cave-Ayland
  2020-03-13  8:24 ` [PATCH 1/7] via-ide: move registration of VMStateDescription to DeviceClass Mark Cave-Ayland
@ 2020-03-13  8:24 ` Mark Cave-Ayland
  2020-03-13  8:24 ` [PATCH 3/7] pci: Honour wmask when resetting PCI_INTERRUPT_LINE Mark Cave-Ayland
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Mark Cave-Ayland @ 2020-03-13  8:24 UTC (permalink / raw)
  To: jsnow, philmd, amarkovic, mst, qemu-block, qemu-devel, balaton

From: BALATON Zoltan <balaton@eik.bme.hu>

Follow example of CMD646 and remove via_ide_init function and do it
directly in board code instead.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ide/via.c            | 8 --------
 hw/mips/mips_fulong2e.c | 5 ++++-
 include/hw/ide.h        | 1 -
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/hw/ide/via.c b/hw/ide/via.c
index 84f0efff94..3153be8862 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -211,14 +211,6 @@ static void via_ide_exitfn(PCIDevice *dev)
     }
 }
 
-void via_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)
-{
-    PCIDevice *dev;
-
-    dev = pci_create_simple(bus, devfn, "via-ide");
-    pci_ide_create_devs(dev, hd_table);
-}
-
 static void via_ide_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
index 4727b1d3a4..639ba2a091 100644
--- a/hw/mips/mips_fulong2e.c
+++ b/hw/mips/mips_fulong2e.c
@@ -37,6 +37,7 @@
 #include "qemu/log.h"
 #include "hw/loader.h"
 #include "hw/ide.h"
+#include "hw/ide/pci.h"
 #include "elf.h"
 #include "hw/isa/vt82c686.h"
 #include "hw/rtc/mc146818rtc.h"
@@ -239,6 +240,7 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq intc,
     qemu_irq *i8259;
     ISABus *isa_bus;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
+    PCIDevice *dev;
 
     isa_bus = vt82c686b_isa_init(pci_bus, PCI_DEVFN(slot, 0));
     if (!isa_bus) {
@@ -256,8 +258,9 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq intc,
     /* Super I/O */
     isa_create_simple(isa_bus, TYPE_VT82C686B_SUPERIO);
 
+    dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide");
     ide_drive_get(hd, ARRAY_SIZE(hd));
-    via_ide_init(pci_bus, hd, PCI_DEVFN(slot, 1));
+    pci_ide_create_devs(dev, hd);
 
     pci_create_simple(pci_bus, PCI_DEVFN(slot, 2), "vt82c686b-usb-uhci");
     pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), "vt82c686b-usb-uhci");
diff --git a/include/hw/ide.h b/include/hw/ide.h
index 28d8a06439..575c099b5b 100644
--- a/include/hw/ide.h
+++ b/include/hw/ide.h
@@ -18,7 +18,6 @@ PCIDevice *pci_piix3_xen_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn);
 PCIDevice *pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn);
 PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn);
 int pci_piix3_xen_ide_unplug(DeviceState *dev, bool aux);
-void via_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn);
 
 /* ide-mmio.c */
 void mmio_ide_init_drives(DeviceState *dev, DriveInfo *hd0, DriveInfo *hd1);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/7] pci: Honour wmask when resetting PCI_INTERRUPT_LINE
  2020-03-13  8:24 [PATCH 0/7] via-ide: fixes and improvements Mark Cave-Ayland
  2020-03-13  8:24 ` [PATCH 1/7] via-ide: move registration of VMStateDescription to DeviceClass Mark Cave-Ayland
  2020-03-13  8:24 ` [PATCH 2/7] ide/via: Get rid of via_ide_init() Mark Cave-Ayland
@ 2020-03-13  8:24 ` Mark Cave-Ayland
  2020-03-13  8:24 ` [PATCH 4/7] via-ide: ensure that PCI_INTERRUPT_LINE is hard-wired to its default value Mark Cave-Ayland
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Mark Cave-Ayland @ 2020-03-13  8:24 UTC (permalink / raw)
  To: jsnow, philmd, amarkovic, mst, qemu-block, qemu-devel, balaton

From: BALATON Zoltan <balaton@eik.bme.hu>

The pci_do_device_reset() function (called from pci_device_reset)
clears the PCI_INTERRUPT_LINE config reg of devices on the bus but did
this without taking wmask into account. We'll have a device model now
that needs to set a constant value for this reg and this patch allows
to do that without additional workaround in device emulation to
reverse the effect of this PCI bus reset function.

Suggested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/pci/pci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index e1ed6677e1..b5bc842fac 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -302,8 +302,11 @@ static void pci_do_device_reset(PCIDevice *dev)
     pci_word_test_and_clear_mask(dev->config + PCI_STATUS,
                                  pci_get_word(dev->wmask + PCI_STATUS) |
                                  pci_get_word(dev->w1cmask + PCI_STATUS));
+    /* Some devices make bits of PCI_INTERRUPT_LINE read only */
+    pci_byte_test_and_clear_mask(dev->config + PCI_INTERRUPT_LINE,
+                              pci_get_word(dev->wmask + PCI_INTERRUPT_LINE) |
+                              pci_get_word(dev->w1cmask + PCI_INTERRUPT_LINE));
     dev->config[PCI_CACHE_LINE_SIZE] = 0x0;
-    dev->config[PCI_INTERRUPT_LINE] = 0x0;
     for (r = 0; r < PCI_NUM_REGIONS; ++r) {
         PCIIORegion *region = &dev->io_regions[r];
         if (!region->size) {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/7] via-ide: ensure that PCI_INTERRUPT_LINE is hard-wired to its default value
  2020-03-13  8:24 [PATCH 0/7] via-ide: fixes and improvements Mark Cave-Ayland
                   ` (2 preceding siblings ...)
  2020-03-13  8:24 ` [PATCH 3/7] pci: Honour wmask when resetting PCI_INTERRUPT_LINE Mark Cave-Ayland
@ 2020-03-13  8:24 ` Mark Cave-Ayland
  2020-03-13  8:24 ` [PATCH 5/7] via-ide: initialise IDE controller in legacy mode Mark Cave-Ayland
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Mark Cave-Ayland @ 2020-03-13  8:24 UTC (permalink / raw)
  To: jsnow, philmd, amarkovic, mst, qemu-block, qemu-devel, balaton

Some firmwares accidentally write to PCI_INTERRUPT_LINE on startup which has
no effect on real hardware since it is hard-wired to its default value, but
causes the guest OS to become confused trying to initialise IDE devices
when running under QEMU.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ide/via.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ide/via.c b/hw/ide/via.c
index 3153be8862..8363bd4802 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -169,7 +169,7 @@ static void via_ide_realize(PCIDevice *dev, Error **errp)
 
     pci_config_set_prog_interface(pci_conf, 0x8f); /* native PCI ATA mode */
     pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0);
-    dev->wmask[PCI_INTERRUPT_LINE] = 0xf;
+    dev->wmask[PCI_INTERRUPT_LINE] = 0;
 
     memory_region_init_io(&d->data_bar[0], OBJECT(d), &pci_ide_data_le_ops,
                           &d->bus[0], "via-ide0-data", 8);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 5/7] via-ide: initialise IDE controller in legacy mode
  2020-03-13  8:24 [PATCH 0/7] via-ide: fixes and improvements Mark Cave-Ayland
                   ` (3 preceding siblings ...)
  2020-03-13  8:24 ` [PATCH 4/7] via-ide: ensure that PCI_INTERRUPT_LINE is hard-wired to its default value Mark Cave-Ayland
@ 2020-03-13  8:24 ` Mark Cave-Ayland
  2020-03-13  8:24 ` [PATCH 6/7] via-ide: allow guests to write to PCI_CLASS_PROG Mark Cave-Ayland
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Mark Cave-Ayland @ 2020-03-13  8:24 UTC (permalink / raw)
  To: jsnow, philmd, amarkovic, mst, qemu-block, qemu-devel, balaton

According to both the VT82C686B and VT8231 datasheets the VIA Southbridge IDE
controller is initialised in legacy mode.

This allows Linux to correctly determine that legacy rather than PCI IRQ routing
should be used since the boot console text in the fulong2e test image changes from:

scsi0 : pata_via
scsi1 : pata_via
ata1: PATA max UDMA/100 cmd 0xffffffffbfd04050 ctl 0xffffffffbfd04062 \
  bmdma 0xffffffffbfd04040 irq 14
ata2: PATA max UDMA/100 cmd 0xffffffffbfd04058 ctl 0xffffffffbfd04066 \
  bmdma 0xffffffffbfd04048 irq 14

to:

scsi0 : pata_via
scsi1 : pata_via
ata1: PATA max UDMA/100 cmd 0xffffffffbfd001f0 ctl 0xffffffffbfd003f6 \
  bmdma 0xffffffffbfd04040 irq 14
ata2: PATA max UDMA/100 cmd 0xffffffffbfd00170 ctl 0xffffffffbfd00376 \
  bmdma 0xffffffffbfd04048 irq 15

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ide/via.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ide/via.c b/hw/ide/via.c
index 8363bd4802..c8835de01b 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -167,7 +167,7 @@ static void via_ide_realize(PCIDevice *dev, Error **errp)
     uint8_t *pci_conf = dev->config;
     int i;
 
-    pci_config_set_prog_interface(pci_conf, 0x8f); /* native PCI ATA mode */
+    pci_config_set_prog_interface(pci_conf, 0x8a); /* legacy mode */
     pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0);
     dev->wmask[PCI_INTERRUPT_LINE] = 0;
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 6/7] via-ide: allow guests to write to PCI_CLASS_PROG
  2020-03-13  8:24 [PATCH 0/7] via-ide: fixes and improvements Mark Cave-Ayland
                   ` (4 preceding siblings ...)
  2020-03-13  8:24 ` [PATCH 5/7] via-ide: initialise IDE controller in legacy mode Mark Cave-Ayland
@ 2020-03-13  8:24 ` Mark Cave-Ayland
  2020-03-13  8:24 ` [PATCH 7/7] via-ide: always use legacy IRQ 14/15 routing Mark Cave-Ayland
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Mark Cave-Ayland @ 2020-03-13  8:24 UTC (permalink / raw)
  To: jsnow, philmd, amarkovic, mst, qemu-block, qemu-devel, balaton

MorphOS writes to PCI_CLASS_PROG during IDE initialisation to place the
controller in native mode, but thinks the initialisation has failed
because the native mode bits aren't set when reading the register back.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ide/via.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/ide/via.c b/hw/ide/via.c
index c8835de01b..3c4d474e48 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -170,6 +170,7 @@ static void via_ide_realize(PCIDevice *dev, Error **errp)
     pci_config_set_prog_interface(pci_conf, 0x8a); /* legacy mode */
     pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0);
     dev->wmask[PCI_INTERRUPT_LINE] = 0;
+    dev->wmask[PCI_CLASS_PROG] = 5;
 
     memory_region_init_io(&d->data_bar[0], OBJECT(d), &pci_ide_data_le_ops,
                           &d->bus[0], "via-ide0-data", 8);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 7/7] via-ide: always use legacy IRQ 14/15 routing
  2020-03-13  8:24 [PATCH 0/7] via-ide: fixes and improvements Mark Cave-Ayland
                   ` (5 preceding siblings ...)
  2020-03-13  8:24 ` [PATCH 6/7] via-ide: allow guests to write to PCI_CLASS_PROG Mark Cave-Ayland
@ 2020-03-13  8:24 ` Mark Cave-Ayland
  2020-03-13 12:12 ` [PATCH 0/7] via-ide: fixes and improvements BALATON Zoltan
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: Mark Cave-Ayland @ 2020-03-13  8:24 UTC (permalink / raw)
  To: jsnow, philmd, amarkovic, mst, qemu-block, qemu-devel, balaton

The existing code uses fixed PCI IRQ routing on IRQ 14 rather than legacy IRQ
14/15 routing as documented in the datasheet.

With the changes in this patchset guest OSs now correctly detect and configure
the VIA controller in legacy IRQ routing mode, allowing the incorrect fixed
PCI IRQ routing to be removed.

Note that this fixed legacy IRQ 14/15 routing is identical to similar behaviour
in the early PIIX IDE controllers.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ide/via.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/hw/ide/via.c b/hw/ide/via.c
index 3c4d474e48..8de4945cc1 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -113,10 +113,7 @@ static void via_ide_set_irq(void *opaque, int n, int level)
     }
 
     level = (d->config[0x70] & 0x80) || (d->config[0x78] & 0x80);
-    n = pci_get_byte(d->config + PCI_INTERRUPT_LINE);
-    if (n) {
-        qemu_set_irq(isa_get_irq(NULL, n), level);
-    }
+    qemu_set_irq(isa_get_irq(NULL, 14 + n), level);
 }
 
 static void via_ide_reset(DeviceState *dev)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/7] via-ide: fixes and improvements
  2020-03-13  8:24 [PATCH 0/7] via-ide: fixes and improvements Mark Cave-Ayland
                   ` (6 preceding siblings ...)
  2020-03-13  8:24 ` [PATCH 7/7] via-ide: always use legacy IRQ 14/15 routing Mark Cave-Ayland
@ 2020-03-13 12:12 ` BALATON Zoltan
  2020-03-13 16:34 ` [EXTERNAL][PATCH " Aleksandar Markovic
  2020-03-13 17:57 ` [PATCH " John Snow
  9 siblings, 0 replies; 16+ messages in thread
From: BALATON Zoltan @ 2020-03-13 12:12 UTC (permalink / raw)
  To: Mark Cave-Ayland; +Cc: qemu-block, mst, jsnow, qemu-devel, amarkovic, philmd

On Fri, 13 Mar 2020, Mark Cave-Ayland wrote:
> Following on from the earlier thread "Implement "non 100% native mode"
> in via-ide", here is an updated patchset based upon the test cases
> sent to me off-list.
>
> The VIA IDE controller is similar to early versions of the PIIX
> controller in that the primary and secondary IDE channels are hardwired
> to IRQs 14 and 15 respectively. Guest OSs typically handle this by
> either switching the controller to legacy mode, or using native mode and
> using a combination of PCI device/vendor ID and/or checking various
> registers in PCI configuration space to detect this condition and apply
> a special fixed IRQ 14/15 routing.
>
> This patchset effectively updates the VIA IDE PCI device to follow the
> behaviour in the datasheet in two ways: fixing some PCI configuration
> space register defaults and behaviours, and always using legacy IRQ 14/15
> routing, and once applied allows all our known test images to boot
> correctly.

This supersedes my series and also works with the clients that I've also 
checked so for the series:

Tested-by: BALATON Zoltan <balaton@eik.bme.hu>

> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>
>
> BALATON Zoltan (2):
>  ide/via: Get rid of via_ide_init()
>  pci: Honour wmask when resetting PCI_INTERRUPT_LINE
>
> Mark Cave-Ayland (5):
>  via-ide: move registration of VMStateDescription to DeviceClass
>  via-ide: ensure that PCI_INTERRUPT_LINE is hard-wired to its default
>    value
>  via-ide: initialise IDE controller in legacy mode
>  via-ide: allow guests to write to PCI_CLASS_PROG
>  via-ide: always use legacy IRQ 14/15 routing
>
> hw/ide/via.c            | 21 +++++----------------
> hw/mips/mips_fulong2e.c |  5 ++++-
> hw/pci/pci.c            |  5 ++++-
> include/hw/ide.h        |  1 -
> 4 files changed, 13 insertions(+), 19 deletions(-)
>
>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [EXTERNAL][PATCH 0/7] via-ide: fixes and improvements
  2020-03-13  8:24 [PATCH 0/7] via-ide: fixes and improvements Mark Cave-Ayland
                   ` (7 preceding siblings ...)
  2020-03-13 12:12 ` [PATCH 0/7] via-ide: fixes and improvements BALATON Zoltan
@ 2020-03-13 16:34 ` Aleksandar Markovic
  2020-03-13 17:15   ` BALATON Zoltan
  2020-03-13 17:57 ` [PATCH " John Snow
  9 siblings, 1 reply; 16+ messages in thread
From: Aleksandar Markovic @ 2020-03-13 16:34 UTC (permalink / raw)
  To: Mark Cave-Ayland, jsnow, philmd, mst, qemu-block, qemu-devel, balaton


> From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> This patchset effectively updates the VIA IDE PCI device to follow the
> behaviour in the datasheet in two ways: fixing some PCI configuration
> space register defaults and behaviours, and always using legacy IRQ 14/15
> routing, and once applied allows all our known test images to boot
> correctly.
> 

Hi, Mark, could you just enumerate those test images, download
locations, etc. and whatever else is needed to reproduce the boot
processes in question - it would be useful not only for this patch
set, but for possible future work, wouldn't it?

Sorry in advance if that info in possibly in another message, and
was missed by me.

Many thanks,
Aleksandar


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [EXTERNAL][PATCH 0/7] via-ide: fixes and improvements
  2020-03-13 16:34 ` [EXTERNAL][PATCH " Aleksandar Markovic
@ 2020-03-13 17:15   ` BALATON Zoltan
  0 siblings, 0 replies; 16+ messages in thread
From: BALATON Zoltan @ 2020-03-13 17:15 UTC (permalink / raw)
  To: Aleksandar Markovic
  Cc: qemu-block, mst, philmd, Mark Cave-Ayland, qemu-devel, jsnow

Hello,

On Fri, 13 Mar 2020, Aleksandar Markovic wrote:
> Hi, Mark, could you just enumerate those test images, download
> locations, etc. and whatever else is needed to reproduce the boot
> processes in question - it would be useful not only for this patch
> set, but for possible future work, wouldn't it?
>
> Sorry in advance if that info in possibly in another message, and
> was missed by me.

I've sent it to Mark off-list but here it is:

On Tue, 10 Mar 2020, BALATON Zoltan wrote:
> I was testing fulong2e with this kernel:
> 
> http://distfiles.gentoo.org/experimental/mips/livecd/loongson-2007.1/
> 
> running it as
> 
> qemu-system-mips64el -M fulong2e -serial stdio -net none -vga none \
> -trace enable="pci*" -kernel gentoo-loongson-2.6.22.6-20070902 \
> -cdrom debian-8.11.0-mipsel-netinst.iso
> 
> adding the cdrom proabably does not really matter and I could not find 
> corresponding gentoo iso so using a debian one, it's just useful to have 
> something on the ide bus and also -cdrom adds it to second channel 
> because if you test with something on first channel only it might work 
> as that uses IRQ14 anyway.
> 
> On pegasos2 I've used:
> 
> qemu-system-ppc -M pegasos2 -net none -serial stdio \
> -vga none -device ati-vga,romfile=VGABIOS-lgpl-latest.bin \
> -cdrom morphos-3.13.iso
> 
> then enter "boot cd boot.img" at the firmware ok prompt.
> 
> And also the same pegasos2 command with
> 
> -cdrom debian-8.11.0-powerpc-netinst.iso
> 
> and enter "boot cd install/pegasos" then I usually select 3 for rescue 
> mode which can get to a command prompt.

For more info on VGABIOS-lgpl-latest.bin and pegrom.bin needed for 
pegasos2 see Pegasos2 emulation subproject on my http://qmiga.osdn.io/ 
page.

The fulong2e probably still has some problem correctly emulating pci 
devices becuase without -net none -vga none the kernel panics, I have no 
interest trying to debug and fix that, I only using fulong2e to 
cross-check changes needed for pegasos2. It could also be that the kernel 
being experimental have some problems, I can't test if it works on real 
hardware.

Regards,
BALATON Zoltan


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/7] via-ide: fixes and improvements
  2020-03-13  8:24 [PATCH 0/7] via-ide: fixes and improvements Mark Cave-Ayland
                   ` (8 preceding siblings ...)
  2020-03-13 16:34 ` [EXTERNAL][PATCH " Aleksandar Markovic
@ 2020-03-13 17:57 ` John Snow
  2020-03-13 20:50   ` BALATON Zoltan
  2020-03-14  9:15   ` Mark Cave-Ayland
  9 siblings, 2 replies; 16+ messages in thread
From: John Snow @ 2020-03-13 17:57 UTC (permalink / raw)
  To: Mark Cave-Ayland, philmd, amarkovic, mst, qemu-block, qemu-devel,
	balaton



On 3/13/20 4:24 AM, Mark Cave-Ayland wrote:
> Following on from the earlier thread "Implement "non 100% native mode"
> in via-ide", here is an updated patchset based upon the test cases
> sent to me off-list.
> 
> The VIA IDE controller is similar to early versions of the PIIX
> controller in that the primary and secondary IDE channels are hardwired
> to IRQs 14 and 15 respectively. Guest OSs typically handle this by
> either switching the controller to legacy mode, or using native mode and
> using a combination of PCI device/vendor ID and/or checking various
> registers in PCI configuration space to detect this condition and apply
> a special fixed IRQ 14/15 routing.
> 
> This patchset effectively updates the VIA IDE PCI device to follow the
> behaviour in the datasheet in two ways: fixing some PCI configuration
> space register defaults and behaviours, and always using legacy IRQ 14/15
> routing, and once applied allows all our known test images to boot
> correctly.
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> 
> 
> BALATON Zoltan (2):
>   ide/via: Get rid of via_ide_init()
>   pci: Honour wmask when resetting PCI_INTERRUPT_LINE
> 
> Mark Cave-Ayland (5):
>   via-ide: move registration of VMStateDescription to DeviceClass
>   via-ide: ensure that PCI_INTERRUPT_LINE is hard-wired to its default
>     value
>   via-ide: initialise IDE controller in legacy mode
>   via-ide: allow guests to write to PCI_CLASS_PROG
>   via-ide: always use legacy IRQ 14/15 routing
> 
>  hw/ide/via.c            | 21 +++++----------------
>  hw/mips/mips_fulong2e.c |  5 ++++-
>  hw/pci/pci.c            |  5 ++++-
>  include/hw/ide.h        |  1 -
>  4 files changed, 13 insertions(+), 19 deletions(-)
> 

Does this supersede everything else so far? (Except the two cmd646
related series, four patches total, which are already staged)



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/7] via-ide: move registration of VMStateDescription to DeviceClass
  2020-03-13  8:24 ` [PATCH 1/7] via-ide: move registration of VMStateDescription to DeviceClass Mark Cave-Ayland
@ 2020-03-13 19:50   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-13 19:50 UTC (permalink / raw)
  To: Mark Cave-Ayland, jsnow, amarkovic, mst, qemu-block, qemu-devel, balaton

On 3/13/20 9:24 AM, Mark Cave-Ayland wrote:
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>   hw/ide/via.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/hw/ide/via.c b/hw/ide/via.c
> index 096de8dba0..84f0efff94 100644
> --- a/hw/ide/via.c
> +++ b/hw/ide/via.c
> @@ -190,8 +190,6 @@ static void via_ide_realize(PCIDevice *dev, Error **errp)
>       bmdma_setup_bar(d);
>       pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &d->bmdma_bar);
>   
> -    vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d);
> -
>       for (i = 0; i < 2; i++) {
>           ide_bus_new(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2);
>           ide_init2(&d->bus[i], qemu_allocate_irq(via_ide_set_irq, d, i));
> @@ -227,6 +225,7 @@ static void via_ide_class_init(ObjectClass *klass, void *data)
>       PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
>   
>       dc->reset = via_ide_reset;
> +    dc->vmsd = &vmstate_ide_pci;
>       k->realize = via_ide_realize;
>       k->exit = via_ide_exitfn;
>       k->vendor_id = PCI_VENDOR_ID_VIA;
> 

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



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/7] via-ide: fixes and improvements
  2020-03-13 17:57 ` [PATCH " John Snow
@ 2020-03-13 20:50   ` BALATON Zoltan
  2020-03-14  9:15   ` Mark Cave-Ayland
  1 sibling, 0 replies; 16+ messages in thread
From: BALATON Zoltan @ 2020-03-13 20:50 UTC (permalink / raw)
  To: John Snow
  Cc: qemu-block, mst, Mark Cave-Ayland, qemu-devel, amarkovic, philmd

On Fri, 13 Mar 2020, John Snow wrote:
> On 3/13/20 4:24 AM, Mark Cave-Ayland wrote:
>> Following on from the earlier thread "Implement "non 100% native mode"
>> in via-ide", here is an updated patchset based upon the test cases
>> sent to me off-list.
>>
>> The VIA IDE controller is similar to early versions of the PIIX
>> controller in that the primary and secondary IDE channels are hardwired
>> to IRQs 14 and 15 respectively. Guest OSs typically handle this by
>> either switching the controller to legacy mode, or using native mode and
>> using a combination of PCI device/vendor ID and/or checking various
>> registers in PCI configuration space to detect this condition and apply
>> a special fixed IRQ 14/15 routing.
>>
>> This patchset effectively updates the VIA IDE PCI device to follow the
>> behaviour in the datasheet in two ways: fixing some PCI configuration
>> space register defaults and behaviours, and always using legacy IRQ 14/15
>> routing, and once applied allows all our known test images to boot
>> correctly.
>>
>> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>>
>>
>> BALATON Zoltan (2):
>>   ide/via: Get rid of via_ide_init()
>>   pci: Honour wmask when resetting PCI_INTERRUPT_LINE
>>
>> Mark Cave-Ayland (5):
>>   via-ide: move registration of VMStateDescription to DeviceClass
>>   via-ide: ensure that PCI_INTERRUPT_LINE is hard-wired to its default
>>     value
>>   via-ide: initialise IDE controller in legacy mode
>>   via-ide: allow guests to write to PCI_CLASS_PROG
>>   via-ide: always use legacy IRQ 14/15 routing
>>
>>  hw/ide/via.c            | 21 +++++----------------
>>  hw/mips/mips_fulong2e.c |  5 ++++-
>>  hw/pci/pci.c            |  5 ++++-
>>  include/hw/ide.h        |  1 -
>>  4 files changed, 13 insertions(+), 19 deletions(-)
>>
>
> Does this supersede everything else so far?

Yes, this includes all needed changes from my series (two patches directly 
and other changes split up in smaller commits) so none of my previous 
series is needed just this series.

> (Except the two cmd646
> related series, four patches total, which are already staged)

Yes those are not included here and independent changes that should stay. 
Your tree seemed to have the commits twice though at least on web 
interface of github.

I've also done some more clean ups that I'm polishing now and will submit 
soon but those are unrelated and a different series on top of this and the 
cmd646 clean up.

Regards,
BALATON Zoltan


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/7] via-ide: fixes and improvements
  2020-03-13 17:57 ` [PATCH " John Snow
  2020-03-13 20:50   ` BALATON Zoltan
@ 2020-03-14  9:15   ` Mark Cave-Ayland
  2020-03-17  4:22     ` John Snow
  1 sibling, 1 reply; 16+ messages in thread
From: Mark Cave-Ayland @ 2020-03-14  9:15 UTC (permalink / raw)
  To: John Snow, philmd, amarkovic, mst, qemu-block, qemu-devel, balaton

On 13/03/2020 17:57, John Snow wrote:

> On 3/13/20 4:24 AM, Mark Cave-Ayland wrote:
>> Following on from the earlier thread "Implement "non 100% native mode"
>> in via-ide", here is an updated patchset based upon the test cases
>> sent to me off-list.
>>
>> The VIA IDE controller is similar to early versions of the PIIX
>> controller in that the primary and secondary IDE channels are hardwired
>> to IRQs 14 and 15 respectively. Guest OSs typically handle this by
>> either switching the controller to legacy mode, or using native mode and
>> using a combination of PCI device/vendor ID and/or checking various
>> registers in PCI configuration space to detect this condition and apply
>> a special fixed IRQ 14/15 routing.
>>
>> This patchset effectively updates the VIA IDE PCI device to follow the
>> behaviour in the datasheet in two ways: fixing some PCI configuration
>> space register defaults and behaviours, and always using legacy IRQ 14/15
>> routing, and once applied allows all our known test images to boot
>> correctly.
>>
>> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>>
>>
>> BALATON Zoltan (2):
>>   ide/via: Get rid of via_ide_init()
>>   pci: Honour wmask when resetting PCI_INTERRUPT_LINE
>>
>> Mark Cave-Ayland (5):
>>   via-ide: move registration of VMStateDescription to DeviceClass
>>   via-ide: ensure that PCI_INTERRUPT_LINE is hard-wired to its default
>>     value
>>   via-ide: initialise IDE controller in legacy mode
>>   via-ide: allow guests to write to PCI_CLASS_PROG
>>   via-ide: always use legacy IRQ 14/15 routing
>>
>>  hw/ide/via.c            | 21 +++++----------------
>>  hw/mips/mips_fulong2e.c |  5 ++++-
>>  hw/pci/pci.c            |  5 ++++-
>>  include/hw/ide.h        |  1 -
>>  4 files changed, 13 insertions(+), 19 deletions(-)
>>
> 
> Does this supersede everything else so far? (Except the two cmd646
> related series, four patches total, which are already staged)

Yes, that's correct. It passes all our tests, and even better allows the fulong2e CD
image at the link Zoltan posted to boot.

So I believe it's good unless Alexander has any objections?


ATB,

Mark.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/7] via-ide: fixes and improvements
  2020-03-14  9:15   ` Mark Cave-Ayland
@ 2020-03-17  4:22     ` John Snow
  0 siblings, 0 replies; 16+ messages in thread
From: John Snow @ 2020-03-17  4:22 UTC (permalink / raw)
  To: Mark Cave-Ayland, philmd, amarkovic, mst, qemu-block, qemu-devel,
	balaton



On 3/14/20 5:15 AM, Mark Cave-Ayland wrote:
> On 13/03/2020 17:57, John Snow wrote:
> 
>> On 3/13/20 4:24 AM, Mark Cave-Ayland wrote:
>>> Following on from the earlier thread "Implement "non 100% native mode"
>>> in via-ide", here is an updated patchset based upon the test cases
>>> sent to me off-list.
>>>
>>> The VIA IDE controller is similar to early versions of the PIIX
>>> controller in that the primary and secondary IDE channels are hardwired
>>> to IRQs 14 and 15 respectively. Guest OSs typically handle this by
>>> either switching the controller to legacy mode, or using native mode and
>>> using a combination of PCI device/vendor ID and/or checking various
>>> registers in PCI configuration space to detect this condition and apply
>>> a special fixed IRQ 14/15 routing.
>>>
>>> This patchset effectively updates the VIA IDE PCI device to follow the
>>> behaviour in the datasheet in two ways: fixing some PCI configuration
>>> space register defaults and behaviours, and always using legacy IRQ 14/15
>>> routing, and once applied allows all our known test images to boot
>>> correctly.
>>>
>>> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>>>
>>>
>>> BALATON Zoltan (2):
>>>   ide/via: Get rid of via_ide_init()
>>>   pci: Honour wmask when resetting PCI_INTERRUPT_LINE
>>>
>>> Mark Cave-Ayland (5):
>>>   via-ide: move registration of VMStateDescription to DeviceClass
>>>   via-ide: ensure that PCI_INTERRUPT_LINE is hard-wired to its default
>>>     value
>>>   via-ide: initialise IDE controller in legacy mode
>>>   via-ide: allow guests to write to PCI_CLASS_PROG
>>>   via-ide: always use legacy IRQ 14/15 routing
>>>
>>>  hw/ide/via.c            | 21 +++++----------------
>>>  hw/mips/mips_fulong2e.c |  5 ++++-
>>>  hw/pci/pci.c            |  5 ++++-
>>>  include/hw/ide.h        |  1 -
>>>  4 files changed, 13 insertions(+), 19 deletions(-)
>>>
>>
>> Does this supersede everything else so far? (Except the two cmd646
>> related series, four patches total, which are already staged)
> 
> Yes, that's correct. It passes all our tests, and even better allows the fulong2e CD
> image at the link Zoltan posted to boot.
> 
> So I believe it's good unless Alexander has any objections?
> 
> 
> ATB,
> 
> Mark.
> 

Tentatively staged! Please let me know during the RC testing phase if
you discover problems.

Thanks, applied to my IDE tree:

https://github.com/jnsnow/qemu/commits/ide
https://github.com/jnsnow/qemu.git

--js



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-03-17  4:24 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-13  8:24 [PATCH 0/7] via-ide: fixes and improvements Mark Cave-Ayland
2020-03-13  8:24 ` [PATCH 1/7] via-ide: move registration of VMStateDescription to DeviceClass Mark Cave-Ayland
2020-03-13 19:50   ` Philippe Mathieu-Daudé
2020-03-13  8:24 ` [PATCH 2/7] ide/via: Get rid of via_ide_init() Mark Cave-Ayland
2020-03-13  8:24 ` [PATCH 3/7] pci: Honour wmask when resetting PCI_INTERRUPT_LINE Mark Cave-Ayland
2020-03-13  8:24 ` [PATCH 4/7] via-ide: ensure that PCI_INTERRUPT_LINE is hard-wired to its default value Mark Cave-Ayland
2020-03-13  8:24 ` [PATCH 5/7] via-ide: initialise IDE controller in legacy mode Mark Cave-Ayland
2020-03-13  8:24 ` [PATCH 6/7] via-ide: allow guests to write to PCI_CLASS_PROG Mark Cave-Ayland
2020-03-13  8:24 ` [PATCH 7/7] via-ide: always use legacy IRQ 14/15 routing Mark Cave-Ayland
2020-03-13 12:12 ` [PATCH 0/7] via-ide: fixes and improvements BALATON Zoltan
2020-03-13 16:34 ` [EXTERNAL][PATCH " Aleksandar Markovic
2020-03-13 17:15   ` BALATON Zoltan
2020-03-13 17:57 ` [PATCH " John Snow
2020-03-13 20:50   ` BALATON Zoltan
2020-03-14  9:15   ` Mark Cave-Ayland
2020-03-17  4:22     ` John Snow

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.