On 12/28/20 9:50 PM, BALATON Zoltan via wrote: > On Mon, 28 Dec 2020, Mark Cave-Ayland wrote: >> On 27/12/2020 22:13, BALATON Zoltan via wrote: >> >>> From: Guenter Roeck <li...@roeck-us.net> >>> >>> The IDE legacy mode emulation has been removed in commit 4ea98d317eb >>> ("ide/via: Implement and use native PCI IDE mode") but some Linux >>> kernels (probably including def_config) require legacy mode on the >>> Fuloong2e so only emulating native mode did not turn out feasible. >>> Add property to via-ide model to make the mode configurable, and set >>> legacy mode for Fuloong2e. >>> >>> Signed-off-by: Guenter Roeck <li...@roeck-us.net> >>> [balaton: Use bit in flags for property, add comment for missing BAR4] >>> Signed-off-by: BALATON Zoltan <bala...@eik.bme.hu> >>> Reviewed-by: Philippe Mathieu-Daudé <f4...@amsat.org> >>> Tested-by: Guenter Roeck <li...@roeck-us.net> >>> --- >>> v2: Reworded commit message >>> >>> hw/ide/via.c | 19 +++++++++++++++++-- >>> hw/mips/fuloong2e.c | 4 +++- >>> 2 files changed, 20 insertions(+), 3 deletions(-) >>> >>> diff --git a/hw/ide/via.c b/hw/ide/via.c >>> index be09912b33..7d54d7e829 100644 >>> --- a/hw/ide/via.c >>> +++ b/hw/ide/via.c >>> @@ -26,6 +26,7 @@ >>> #include "qemu/osdep.h" >>> #include "hw/pci/pci.h" >>> +#include "hw/qdev-properties.h" >>> #include "migration/vmstate.h" >>> #include "qemu/module.h" >>> #include "sysemu/dma.h" >>> @@ -185,12 +186,19 @@ static void via_ide_realize(PCIDevice *dev, >>> Error **errp) >>> &d->bus[1], "via-ide1-cmd", 4); >>> pci_register_bar(dev, 3, PCI_BASE_ADDRESS_SPACE_IO, >>> &d->cmd_bar[1]); >>> - bmdma_setup_bar(d); >>> - pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &d->bmdma_bar); >>> + if (!(d->flags & BIT(PCI_IDE_LEGACY_MODE))) { >>> + /* Missing BAR4 will make Linux driver fall back to legacy >>> PIO mode */ >>> + bmdma_setup_bar(d); >>> + pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, >>> &d->bmdma_bar); >>> + } >> >> Since the default value of the legacy mode parameter is false, then >> this means the device assumes native mode by default. Therefore >> PCI_CLASS_PROG should be set to 0x8f unless legacy mode is being used, >> in which case it should be 0x8a. > > I think this casued problems before because if it's not set to 0x8a > (legacy) at start then guests may assume it's already switched to native > mode by firmware and won't program the BARs and it will not work. This > way, even if it looks odd all guests I've tested work so I don't want to > touch this, because I don't want to test all guests again.
If you can describe on the list how you do your testing (mostly command line used, where image/demo can be downloaded), we might help writing an integration test to automate the testing. Don't worry if it involves using close-source binaries, we'll try to figure out a way. Regards, Phil.