[PATCH] Add PCI_CAP_ID_PM capability for educational PCI device.

d0u9 posted 1 patch 3 years, 6 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/BYAPR11MB2664EBDC4811C39D45CB6D54EC140@BYAPR11MB2664.namprd11.prod.outlook.com
Maintainers: Jiri Slaby <jslaby@suse.cz>
hw/misc/edu.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] Add PCI_CAP_ID_PM capability for educational PCI device.
Posted by d0u9 3 years, 6 months ago
Linux can't recognise device's MSI/MISX capability after a
load-reload operation on kernel module due to the fact that the Linux
sets PCI device's power state to `PCI_D0` and the device cannot
automatically wakeup itself when module reinitialize it.

In this patch, we add this `PCI_CAP_ID_PM` here to device's PCI
capabilities table to fix this problem.

Signed-off-by: d0u9 <d0u9.su@outlook.com>
---
 hw/misc/edu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/misc/edu.c b/hw/misc/edu.c
index e935c418d4..7ce32a0f0b 100644
--- a/hw/misc/edu.c
+++ b/hw/misc/edu.c
@@ -365,6 +365,9 @@ static void pci_edu_realize(PCIDevice *pdev, Error **errp)
     uint8_t *pci_conf = pdev->config;
 
     pci_config_set_interrupt_pin(pci_conf, 1);
+    if (pci_add_capability(pdev, PCI_CAP_ID_PM, 0, PCI_PM_SIZEOF, errp) < 0) {
+        return;
+    }
 
     if (msi_init(pdev, 0, 1, true, false, errp)) {
         return;
-- 
2.24.2 (Apple Git-127)