| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
 Re: [PATCH] hw/i386/pc_piix: Make piix_intx_routing_notifier_xen() more device independent
 
To: Bernhard Beschow <shentey@xxxxxxxxx>, qemu-devel@xxxxxxxxxxFrom: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>Date: Mon, 8 Jan 2024 13:14:32 +0100Cc: Chuck Zmudzinski <brchuckz@xxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, David Woodhouse <dwmw2@xxxxxxxxxxxxx>, Eduardo Habkost <eduardo@xxxxxxxxxxx>, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Richard Henderson <richard.henderson@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>Delivery-date: Mon, 08 Jan 2024 12:14:44 +0000List-id: Xen developer discussion <xen-devel.lists.xenproject.org> 
 
On 8/1/24 00:16, Bernhard Beschow wrote:
 
This is a follow-up on commit 89965db43cce "hw/isa/piix3: Avoid Xen-specific
variant of piix3_write_config()" which introduced
piix_intx_routing_notifier_xen(). This function is implemented in board code but
accesses the PCI configuration space of the PIIX ISA function to determine the
PCI interrupt routes. Avoid this by reusing pci_device_route_intx_to_irq() which
makes piix_intx_routing_notifier_xen() more device-agnostic.
One remaining improvement would be making piix_intx_routing_notifier_xen()
agnostic towards the number of PCI interrupt routes and move it to xen-hvm.
This might be useful for possible Q35 Xen efforts but remains a future exercise
for now.
Signed-off-by: Bernhard Beschow <shentey@xxxxxxxxx>
---
  hw/i386/pc_piix.c | 9 +++------
  1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 042c13cdbc..abfcfe4d2b 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -92,13 +92,10 @@ static void piix_intx_routing_notifier_xen(PCIDevice *dev)
  {
      int i;
-    /* Scan for updates to PCI link routes (0x60-0x63). */
+    /* Scan for updates to PCI link routes. */
      for (i = 0; i < PIIX_NUM_PIRQS; i++) {
-        uint8_t v = dev->config_read(dev, PIIX_PIRQCA + i, 1);
-        if (v & 0x80) {
-            v = 0;
-        }
-        v &= 0xf;
+        const PCIINTxRoute route = pci_device_route_intx_to_irq(dev, i);
 
This indeed dispatch to piix_route_intx_pin_to_irq().
Reviewed-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
 
+        const uint8_t v = route.mode == PCI_INTX_ENABLED ? route.irq : 0;
          xen_set_pci_link_route(i, v);
      }
  }
 
 
 |