diff mbox series

Add PCI_CAP_ID_PM capability for educational PCI device.

Message ID BYAPR11MB2664EBDC4811C39D45CB6D54EC140@BYAPR11MB2664.namprd11.prod.outlook.com
State New, archived
Headers show
Series Add PCI_CAP_ID_PM capability for educational PCI device. | expand

Commit Message

d0u9 Oct. 29, 2020, 7:56 a.m. UTC
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 mbox series

Patch

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;