[PATCH for-8.2] ide/via: Fix BAR4 value in legacy mode

BALATON Zoltan posted 1 patch 1 year ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20231125140135.AF6A075A4C3@zero.eik.bme.hu
Maintainers: John Snow <jsnow@redhat.com>
hw/ide/via.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
[PATCH for-8.2] ide/via: Fix BAR4 value in legacy mode
Posted by BALATON Zoltan 1 year ago
Return default value in legacy mode for BAR4 when unset. This can't be
set in reset method because BARs are cleared on reset so we return it
instead when BARs are read in legacy mode.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
This fixes UDMA on amigaone with AmigaOS and I'd like to include for
8.2 release.

 hw/ide/via.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/hw/ide/via.c b/hw/ide/via.c
index 2d3124ebd7..3f3c484253 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -163,14 +163,19 @@ static uint32_t via_ide_cfg_read(PCIDevice *pd, uint32_t addr, int len)
     uint32_t val = pci_default_read_config(pd, addr, len);
     uint8_t mode = pd->config[PCI_CLASS_PROG];
 
-    if ((mode & 0xf) == 0xa && ranges_overlap(addr, len,
-                                              PCI_BASE_ADDRESS_0, 16)) {
-        /* BARs always read back zero in legacy mode */
-        for (int i = addr; i < addr + len; i++) {
-            if (i >= PCI_BASE_ADDRESS_0 && i < PCI_BASE_ADDRESS_0 + 16) {
-                val &= ~(0xffULL << ((i - addr) << 3));
+    if ((mode & 0xf) == 0xa) {
+        if (ranges_overlap(addr, len, PCI_BASE_ADDRESS_0, 16)) {
+            /* BARs 0-3 always read back zero in legacy mode */
+            for (int i = addr; i < addr + len; i++) {
+                if (i >= PCI_BASE_ADDRESS_0 && i < PCI_BASE_ADDRESS_0 + 16) {
+                    val &= ~(0xffULL << ((i - addr) << 3));
+                }
             }
         }
+        if (addr == PCI_BASE_ADDRESS_4 && val == PCI_BASE_ADDRESS_SPACE_IO) {
+            /* BAR4 default value if unset */
+            val = 0xcc00 | PCI_BASE_ADDRESS_SPACE_IO;
+        }
     }
 
     return val;
-- 
2.30.9
Re: [PATCH for-8.2] ide/via: Fix BAR4 value in legacy mode
Posted by Kevin Wolf 1 year ago
Am 25.11.2023 um 15:01 hat BALATON Zoltan geschrieben:
> Return default value in legacy mode for BAR4 when unset. This can't be
> set in reset method because BARs are cleared on reset so we return it
> instead when BARs are read in legacy mode.
> 
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
> This fixes UDMA on amigaone with AmigaOS and I'd like to include for
> 8.2 release.

Thanks, applied to the block branch.

Kevin