From dd1248a563af6cfb024a68d21250069b5c41e25e Mon Sep 17 00:00:00 2001 From: Stas'M Date: Wed, 28 Aug 2019 20:19:51 +0300 Subject: [PATCH] nv2a: Set PCI class id and subsystem id to match hardware This patch sets the class id, subsystem id, and subsystem vendor id in the PCI device header to match what the NV2A hardware advertises. This resolves an issue with PCI device enumeration failing to detect and load the driver for the NV2A device in some operating systems, namely ReactOS version 0.2.5-xbox (custom build), which depend on these fields being programmed correctly. --- hw/xbox/nv2a/nv2a.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hw/xbox/nv2a/nv2a.c b/hw/xbox/nv2a/nv2a.c index a8b612523c..5592480590 100644 --- a/hw/xbox/nv2a/nv2a.c +++ b/hw/xbox/nv2a/nv2a.c @@ -410,6 +410,9 @@ static void nv2a_realize(PCIDevice *dev, Error **errp) d = NV2A_DEVICE(dev); + /* setting subsystem ids again, see comment in nv2a_class_init() */ + pci_set_word(dev->config + PCI_SUBSYSTEM_VENDOR_ID, 0); + pci_set_word(dev->config + PCI_SUBSYSTEM_ID, 0); dev->config[PCI_INTERRUPT_PIN] = 0x01; d->pcrtc.start = 0; @@ -478,8 +481,13 @@ static void nv2a_class_init(ObjectClass *klass, void *data) k->vendor_id = PCI_VENDOR_ID_NVIDIA; k->device_id = PCI_DEVICE_ID_NVIDIA_GEFORCE_NV2A; - k->revision = 161; - k->class_id = PCI_CLASS_DISPLAY_3D; + k->revision = 0xA1; + k->class_id = PCI_CLASS_DISPLAY_VGA; + /* When both subsystem ids are set to 0, QEMU sets them to its own + * default values. However we set them anyway in case upstream decides + * to change this behavior. */ + k->subsystem_vendor_id = 0; + k->subsystem_id = 0; k->realize = nv2a_realize; k->exit = nv2a_exitfn;