Skip to contentSkip to conversation

pci: Display PCI IRQ pin in "info pci"

PATCH In review Peter Xu 6 participants 16 messages Mar 17, 2020 – Jun 9, 2020

lore
Share & tools
lore

Peter Xu

author
#0 lore raw

PATCH 1/1 pci: Display PCI IRQ pin in "info pci"

Sometimes it would be good to be able to read the pin number along with the IRQ number allocated. Since we'll dump the IRQ number, no reason to not dump the pin information. For example, the vfio-pci device will overwrite the pin with the hardware pin number. It would be nice to know the pin number of one assigned device from QMP/HMP.

CC Dr. David Alan Gilbert <[email protected]>
CC Alex Williamson <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Julia Suvorova <[email protected]>
CC Markus Armbruster <[email protected]>

---

This helped me to debug an IRQ sharing issue, so may good to have it in master too.

---
 hw/pci/pci.c       | 1 +
 monitor/hmp-cmds.c | 3 ++-
 qapi/misc.json     | 6 ++++--
 3 files changed, 7 insertions(+), 3 deletions(-)
hw/pci/pci.c +1 -0
index e1ed6677e1..7ebf532ac9 100644
@@ -1769,6 +1769,7 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus,
     info->regions = qmp_query_pci_regions(dev);
     info->qdev_id = g_strdup(dev->qdev.id ? dev->qdev.id : "");
 
+    info->irq_pin = dev->config[PCI_INTERRUPT_PIN];
     if (dev->config[PCI_INTERRUPT_PIN] != 0) {
         info->has_irq = true;
         info->irq = dev->config[PCI_INTERRUPT_LINE];
monitor/hmp-cmds.c +2 -1
index 58724031ea..04c86bbb03 100644
@@ -680,7 +680,8 @@ static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev)
     }
 
     if (dev->has_irq) {
-        monitor_printf(mon, "      IRQ %" PRId64 ".\n", dev->irq);
+        monitor_printf(mon, "      IRQ %" PRId64 ", pin %c\n",
+                       dev->irq, (char)('A' + dev->irq_pin - 1));
     }
 
     if (dev->has_pci_bridge) {
qapi/misc.json +4 -2
index c18fe681fb..f8d33ddb4e 100644
@@ -403,6 +403,8 @@
 #
 # @irq: if an IRQ is assigned to the device, the IRQ number
 #
+# @irq_pin: the IRQ pin, zero means no IRQ (since 5.1)
+#
 # @qdev_id: the device name of the PCI device
 #
 # @pci_bridge: if the device is a PCI bridge, the bridge information
@@ -417,8 +419,8 @@
 { 'struct': 'PciDeviceInfo',
   'data': {'bus': 'int', 'slot': 'int', 'function': 'int',
            'class_info': 'PciDeviceClass', 'id': 'PciDeviceId',
-           '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo',
-           'regions': ['PciMemoryRegion']} }
+           '*irq': 'int', 'irq_pin': 'int', 'qdev_id': 'str',
+           '*pci_bridge': 'PciBridgeInfo', 'regions': ['PciMemoryRegion'] }}
 
 ##
 # @PciInfo:
Signature · 1 line
2.24.1
#1 lore raw
Quoted 13 lines · Peter Xu

Sometimes it would be good to be able to read the pin number along with the IRQ number allocated. Since we'll dump the IRQ number, no reason to not dump the pin information. For example, the vfio-pci device will overwrite the pin with the hardware pin number. It would be nice to know the pin number of one assigned device from QMP/HMP.

CC Dr. David Alan Gilbert <[email protected]>
CC Alex Williamson <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Julia Suvorova <[email protected]>
CC Markus Armbruster <[email protected]>
Quoted 4 lines

---

This helped me to debug an IRQ sharing issue, so may good to have it in master too.

We're right at soft freeze.

qapi/misc.json line 407

Quoted 7 lines

+++ b/qapi/misc.json

qapi/misc.json +2 -0
@@ -403,6 +403,8 @@
  #
  # @irq: if an IRQ is assigned to the device, the IRQ number
  #
+# @irq_pin: the IRQ pin, zero means no IRQ (since 5.1)
+#

But if we really do want it in 5.0, this needs a tweak. Does the delay hurt?

Naming convention: We prefer 'irq-pin' unless there is a consistency issue....

qapi/misc.json line 423

Quoted 11 lines
qapi/misc.json +2 -2
  # @qdev_id: the device name of the PCI device
  #
  # @pci_bridge: if the device is a PCI bridge, the bridge information
@@ -417,8 +419,8 @@
  { 'struct': 'PciDeviceInfo',
    'data': {'bus': 'int', 'slot': 'int', 'function': 'int',
             'class_info': 'PciDeviceClass', 'id': 'PciDeviceId',
-           '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo',
-           'regions': ['PciMemoryRegion']} }
+           '*irq': 'int', 'irq_pin': 'int', 'qdev_id': 'str',
+           '*pci_bridge': 'PciBridgeInfo', 'regions': ['PciMemoryRegion'] }}

and the pre-existing pci_bridge is indeed the consistency issue.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
author
#2 lore raw
Quoted 22 lines · Eric Blake
Quoted 13 lines · Peter Xu

Sometimes it would be good to be able to read the pin number along with the IRQ number allocated. Since we'll dump the IRQ number, no reason to not dump the pin information. For example, the vfio-pci device will overwrite the pin with the hardware pin number. It would be nice to know the pin number of one assigned device from QMP/HMP.

CC Dr. David Alan Gilbert <[email protected]>
CC Alex Williamson <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Julia Suvorova <[email protected]>
CC Markus Armbruster <[email protected]>
Quoted 4 lines

---

This helped me to debug an IRQ sharing issue, so may good to have it in master too.

We're right at soft freeze.

Quoted 10 lines

qapi/misc.json line 407

Quoted 7 lines

+++ b/qapi/misc.json

qapi/misc.json +2 -0
@@ -403,6 +403,8 @@
  #
  # @irq: if an IRQ is assigned to the device, the IRQ number
  #
+# @irq_pin: the IRQ pin, zero means no IRQ (since 5.1)
+#

But if we really do want it in 5.0, this needs a tweak. Does the delay hurt?

No it won't; it's something good to have only. I'll let the maintainers to decide...

Quoted 4 lines

Naming convention: We prefer 'irq-pin' unless there is a consistency issue....

Quoted 13 lines

qapi/misc.json line 423

Quoted 11 lines
qapi/misc.json +2 -2
  # @qdev_id: the device name of the PCI device
  #
  # @pci_bridge: if the device is a PCI bridge, the bridge information
@@ -417,8 +419,8 @@
  { 'struct': 'PciDeviceInfo',
    'data': {'bus': 'int', 'slot': 'int', 'function': 'int',
             'class_info': 'PciDeviceClass', 'id': 'PciDeviceId',
-           '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo',
-           'regions': ['PciMemoryRegion']} }
+           '*irq': 'int', 'irq_pin': 'int', 'qdev_id': 'str',
+           '*pci_bridge': 'PciBridgeInfo', 'regions': ['PciMemoryRegion'] }}

and the pre-existing pci_bridge is indeed the consistency issue.

Yeh, actually every key in this struct. :)

Thanks,

Signature · 1 line
Peter Xu
#3 lore raw
Quoted 55 lines · Peter Xu
Quoted 22 lines · Eric Blake
Quoted 13 lines · Peter Xu

Sometimes it would be good to be able to read the pin number along with the IRQ number allocated. Since we'll dump the IRQ number, no reason to not dump the pin information. For example, the vfio-pci device will overwrite the pin with the hardware pin number. It would be nice to know the pin number of one assigned device from QMP/HMP.

CC Dr. David Alan Gilbert <[email protected]>
CC Alex Williamson <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Julia Suvorova <[email protected]>
CC Markus Armbruster <[email protected]>
Quoted 4 lines

---

This helped me to debug an IRQ sharing issue, so may good to have it in master too.

We're right at soft freeze.

Quoted 10 lines

qapi/misc.json line 407

Quoted 7 lines

+++ b/qapi/misc.json

qapi/misc.json +2 -0
@@ -403,6 +403,8 @@
   #
   # @irq: if an IRQ is assigned to the device, the IRQ number
   #
+# @irq_pin: the IRQ pin, zero means no IRQ (since 5.1)
+#

But if we really do want it in 5.0, this needs a tweak. Does the delay hurt?

No it won't; it's something good to have only. I'll let the maintainers to decide...

Quoted 4 lines

Naming convention: We prefer unless there is a consistency issue....

Quoted 13 lines

qapi/misc.json line 423

Quoted 11 lines
qapi/misc.json +2 -2
   # @qdev_id: the device name of the PCI device
   #
   # @pci_bridge: if the device is a PCI bridge, the bridge information
@@ -417,8 +419,8 @@
   { 'struct': 'PciDeviceInfo',
     'data': {'bus': 'int', 'slot': 'int', 'function': 'int',
              'class_info': 'PciDeviceClass', 'id': 'PciDeviceId',
-           '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo',
-           'regions': ['PciMemoryRegion']} }
+           '*irq': 'int', 'irq_pin': 'int', 'qdev_id': 'str',
+           '*pci_bridge': 'PciBridgeInfo', 'regions': ['PciMemoryRegion'] }}

and the pre-existing pci_bridge is indeed the consistency issue.

Quoted 1 line

Yeh, actually every key in this struct. :)

Using 'irq-pin':

Quoted 3 lines

Thanks,

#4 lore raw
Quoted 56 lines · Philippe Mathieu-Daudé
Quoted 55 lines · Peter Xu
Quoted 22 lines · Eric Blake
Quoted 13 lines · Peter Xu

Sometimes it would be good to be able to read the pin number along with the IRQ number allocated. Since we'll dump the IRQ number, no reason to not dump the pin information. For example, the vfio-pci device will overwrite the pin with the hardware pin number. It would be nice to know the pin number of one assigned device from QMP/HMP.

CC Dr. David Alan Gilbert <[email protected]>
CC Alex Williamson <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Julia Suvorova <[email protected]>
CC Markus Armbruster <[email protected]>
Quoted 4 lines

---

This helped me to debug an IRQ sharing issue, so may good to have it in master too.

We're right at soft freeze.

Quoted 10 lines

qapi/misc.json line 407

Quoted 7 lines

+++ b/qapi/misc.json

qapi/misc.json +2 -0
@@ -403,6 +403,8 @@
   #
   # @irq: if an IRQ is assigned to the device, the IRQ number
   #
+# @irq_pin: the IRQ pin, zero means no IRQ (since 5.1)
+#

But if we really do want it in 5.0, this needs a tweak. Does the delay hurt?

No it won't; it's something good to have only. I'll let the maintainers to decide...

Quoted 17 lines

Naming convention: We prefer unless there is a consistency issue....

qapi/misc.json line 423

Quoted 11 lines
qapi/misc.json +2 -2
   # @qdev_id: the device name of the PCI device
   #
   # @pci_bridge: if the device is a PCI bridge, the bridge information
@@ -417,8 +419,8 @@
   { 'struct': 'PciDeviceInfo',
     'data': {'bus': 'int', 'slot': 'int', 'function': 'int',
              'class_info': 'PciDeviceClass', 'id': 'PciDeviceId',
-           '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo',
-           'regions': ['PciMemoryRegion']} }
+           '*irq': 'int', 'irq_pin': 'int', 'qdev_id': 'str',
+           '*pci_bridge': 'PciBridgeInfo', 'regions': ['PciMemoryRegion'] }}

and the pre-existing pci_bridge is indeed the consistency issue.

Quoted 4 lines
Quoted 1 line

Yeh, actually every key in this struct. :)

Using 'irq-pin':

Peter can you fix and repost pls?

Quoted 3 lines
Quoted 3 lines

Thanks,

author
#5 lore raw
Quoted 11 lines · Michael S. Tsirkin
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

qapi/misc.json line 423

Quoted 8 lines
qapi/misc.json +2 -2
@@ -417,8 +419,8 @@
   { 'struct': 'PciDeviceInfo',
     'data': {'bus': 'int', 'slot': 'int', 'function': 'int',
              'class_info': 'PciDeviceClass', 'id': 'PciDeviceId',
-           '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo',
-           'regions': ['PciMemoryRegion']} }
+           '*irq': 'int', 'irq_pin': 'int', 'qdev_id': 'str',
+           '*pci_bridge': 'PciBridgeInfo', 'regions': ['PciMemoryRegion'] }}

and the pre-existing pci_bridge is indeed the consistency issue.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Yeh, actually every key in this struct. :)

Using 'irq-pin':

Peter can you fix and repost pls?

I still think irq_pin is better because as I mentioned previously all the existing keys are using underscores... Phil?

Thanks,

Signature · 1 line
Peter Xu
#6 lore raw
Quoted 14 lines · Peter Xu
Quoted 13 lines · Michael S. Tsirkin
Quoted 13 lines
Quoted 12 lines
Quoted 10 lines

qapi/misc.json line 423

Quoted 8 lines
qapi/misc.json +2 -2
@@ -417,8 +419,8 @@
   { 'struct': 'PciDeviceInfo',
     'data': {'bus': 'int', 'slot': 'int', 'function': 'int',
              'class_info': 'PciDeviceClass', 'id': 'PciDeviceId',
-           '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo',
-           'regions': ['PciMemoryRegion']} }
+           '*irq': 'int', 'irq_pin': 'int', 'qdev_id': 'str',
+           '*pci_bridge': 'PciBridgeInfo', 'regions': ['PciMemoryRegion'] }}

and the pre-existing pci_bridge is indeed the consistency issue.

Yeh, actually every key in this struct. :)

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Using 'irq-pin':

Peter can you fix and repost pls?

I still think irq_pin is better because as I mentioned previously all the existing keys are using underscores... Phil?

No problem!

author
#7 lore raw
Quoted 1 line · Philippe Mathieu-Daudé

No problem!

Thanks!

Signature · 1 line
Peter Xu
#8 lore raw
Quoted 4 lines · Peter Xu
Quoted 1 line · Philippe Mathieu-Daudé

No problem!

Thanks!

OK so any chance of an ack?

Quoted 2 lines
Signature · 1 line
Peter Xu
#9 lore raw
In reply to Peter Xu
Quoted 40 lines · * Peter Xu ([email protected]) wrote:

Sometimes it would be good to be able to read the pin number along with the IRQ number allocated. Since we'll dump the IRQ number, no reason to not dump the pin information. For example, the vfio-pci device will overwrite the pin with the hardware pin number. It would be nice to know the pin number of one assigned device from QMP/HMP.

CC Dr. David Alan Gilbert <[email protected]>
CC Alex Williamson <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Julia Suvorova <[email protected]>
CC Markus Armbruster <[email protected]>

---

This helped me to debug an IRQ sharing issue, so may good to have it in master too.

---
 hw/pci/pci.c       | 1 +
 monitor/hmp-cmds.c | 3 ++-
 qapi/misc.json     | 6 ++++--
 3 files changed, 7 insertions(+), 3 deletions(-)
hw/pci/pci.c +1 -0
index e1ed6677e1..7ebf532ac9 100644
@@ -1769,6 +1769,7 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus,
     info->regions = qmp_query_pci_regions(dev);
     info->qdev_id = g_strdup(dev->qdev.id ? dev->qdev.id : "");
 
+    info->irq_pin = dev->config[PCI_INTERRUPT_PIN];
     if (dev->config[PCI_INTERRUPT_PIN] != 0) {
         info->has_irq = true;
         info->irq = dev->config[PCI_INTERRUPT_LINE];
monitor/hmp-cmds.c +0 -0
index 58724031ea..04c86bbb03 100644

monitor/hmp-cmds.c static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev) · line 684

Quoted 6 lines
monitor/hmp-cmds.c +2 -1
@@ -680,7 +680,8 @@ static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev)
     }
 
     if (dev->has_irq) {
-        monitor_printf(mon, "      IRQ %" PRId64 ".\n", dev->irq);
+        monitor_printf(mon, "      IRQ %" PRId64 ", pin %c\n",
+                       dev->irq, (char)('A' + dev->irq_pin - 1));

Can we trust dev->irq_pin not to be something silly and generate a non-printable?

Dave

Quoted 30 lines
monitor/hmp-cmds.c +0 -0
     }
 
     if (dev->has_pci_bridge) {
qapi/misc.json +4 -2
index c18fe681fb..f8d33ddb4e 100644
@@ -403,6 +403,8 @@
 #
 # @irq: if an IRQ is assigned to the device, the IRQ number
 #
+# @irq_pin: the IRQ pin, zero means no IRQ (since 5.1)
+#
 # @qdev_id: the device name of the PCI device
 #
 # @pci_bridge: if the device is a PCI bridge, the bridge information
@@ -417,8 +419,8 @@
 { 'struct': 'PciDeviceInfo',
   'data': {'bus': 'int', 'slot': 'int', 'function': 'int',
            'class_info': 'PciDeviceClass', 'id': 'PciDeviceId',
-           '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo',
-           'regions': ['PciMemoryRegion']} }
+           '*irq': 'int', 'irq_pin': 'int', 'qdev_id': 'str',
+           '*pci_bridge': 'PciBridgeInfo', 'regions': ['PciMemoryRegion'] }}
 
 ##
 # @PciInfo:
Signature · 1 line
2.24.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

author
#10 lore raw
Quoted 43 lines · Dr. David Alan Gilbert
Quoted 42 lines · * Peter Xu ([email protected]) wrote:

Sometimes it would be good to be able to read the pin number along with the IRQ number allocated. Since we'll dump the IRQ number, no reason to not dump the pin information. For example, the vfio-pci device will overwrite the pin with the hardware pin number. It would be nice to know the pin number of one assigned device from QMP/HMP.

CC Dr. David Alan Gilbert <[email protected]>
CC Alex Williamson <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Julia Suvorova <[email protected]>
CC Markus Armbruster <[email protected]>

---

This helped me to debug an IRQ sharing issue, so may good to have it in master too.

---
 hw/pci/pci.c       | 1 +
 monitor/hmp-cmds.c | 3 ++-
 qapi/misc.json     | 6 ++++--
 3 files changed, 7 insertions(+), 3 deletions(-)
hw/pci/pci.c +1 -0
index e1ed6677e1..7ebf532ac9 100644
@@ -1769,6 +1769,7 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus,
     info->regions = qmp_query_pci_regions(dev);
     info->qdev_id = g_strdup(dev->qdev.id ? dev->qdev.id : "");
 
+    info->irq_pin = dev->config[PCI_INTERRUPT_PIN];
     if (dev->config[PCI_INTERRUPT_PIN] != 0) {
         info->has_irq = true;
         info->irq = dev->config[PCI_INTERRUPT_LINE];
monitor/hmp-cmds.c +0 -0
index 58724031ea..04c86bbb03 100644
@@ -680,7 +680,8 @@ static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev)
     }
 
Quoted 7 lines

monitor/hmp-cmds.c static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev) · line 684

Quoted 4 lines
monitor/hmp-cmds.c +2 -1
     if (dev->has_irq) {
-        monitor_printf(mon, "      IRQ %" PRId64 ".\n", dev->irq);
+        monitor_printf(mon, "      IRQ %" PRId64 ", pin %c\n",
+                       dev->irq, (char)('A' + dev->irq_pin - 1));

Can we trust dev->irq_pin not to be something silly and generate a non-printable?

It should be strictly a value between 1-4 corresponds to irq pin A-D (note the has_irq check masked out the zero value, or it could be 0-4), so I think it should always make sense. Otherwise I see it a qemu bug somewhere...

Thanks,

Signature · 1 line
Peter Xu
#11 lore raw
Quoted 52 lines · * Peter Xu ([email protected]) wrote:
Quoted 43 lines · Dr. David Alan Gilbert
Quoted 42 lines · * Peter Xu ([email protected]) wrote:

Sometimes it would be good to be able to read the pin number along with the IRQ number allocated. Since we'll dump the IRQ number, no reason to not dump the pin information. For example, the vfio-pci device will overwrite the pin with the hardware pin number. It would be nice to know the pin number of one assigned device from QMP/HMP.

CC Dr. David Alan Gilbert <[email protected]>
CC Alex Williamson <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Julia Suvorova <[email protected]>
CC Markus Armbruster <[email protected]>

---

This helped me to debug an IRQ sharing issue, so may good to have it in master too.

---
 hw/pci/pci.c       | 1 +
 monitor/hmp-cmds.c | 3 ++-
 qapi/misc.json     | 6 ++++--
 3 files changed, 7 insertions(+), 3 deletions(-)
hw/pci/pci.c +1 -0
index e1ed6677e1..7ebf532ac9 100644
@@ -1769,6 +1769,7 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus,
     info->regions = qmp_query_pci_regions(dev);
     info->qdev_id = g_strdup(dev->qdev.id ? dev->qdev.id : "");
 
+    info->irq_pin = dev->config[PCI_INTERRUPT_PIN];
     if (dev->config[PCI_INTERRUPT_PIN] != 0) {
         info->has_irq = true;
         info->irq = dev->config[PCI_INTERRUPT_LINE];
monitor/hmp-cmds.c +0 -0
index 58724031ea..04c86bbb03 100644
@@ -680,7 +680,8 @@ static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev)
     }
 
Quoted 7 lines

monitor/hmp-cmds.c static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev) · line 684

Quoted 4 lines
monitor/hmp-cmds.c +2 -1
     if (dev->has_irq) {
-        monitor_printf(mon, "      IRQ %" PRId64 ".\n", dev->irq);
+        monitor_printf(mon, "      IRQ %" PRId64 ", pin %c\n",
+                       dev->irq, (char)('A' + dev->irq_pin - 1));

Can we trust dev->irq_pin not to be something silly and generate a non-printable?

Quoted 4 lines

It should be strictly a value between 1-4 corresponds to irq pin A-D (note the has_irq check masked out the zero value, or it could be 0-4), so I think it should always make sense. Otherwise I see it a qemu bug somewhere...

OK, then

for HMP.

Dave

Quoted 5 lines

Thanks,

Signature · 1 line
Peter Xu

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

author
#12 lore raw
In reply to Peter Xu
Quoted 6 lines · Peter Xu

Sometimes it would be good to be able to read the pin number along with the IRQ number allocated. Since we'll dump the IRQ number, no reason to not dump the pin information. For example, the vfio-pci device will overwrite the pin with the hardware pin number. It would be nice to know the pin number of one assigned device from QMP/HMP.

Quoted 7 lines
CC Dr. David Alan Gilbert <[email protected]>
CC Alex Williamson <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Julia Suvorova <[email protected]>
CC Markus Armbruster <[email protected]>

Ping?

Signature · 1 line
Peter Xu
#13 lore raw
In reply to Peter Xu
Quoted 18 lines · Peter Xu

Sometimes it would be good to be able to read the pin number along with the IRQ number allocated. Since we'll dump the IRQ number, no reason to not dump the pin information. For example, the vfio-pci device will overwrite the pin with the hardware pin number. It would be nice to know the pin number of one assigned device from QMP/HMP.

CC Dr. David Alan Gilbert <[email protected]>
CC Alex Williamson <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Julia Suvorova <[email protected]>
CC Markus Armbruster <[email protected]>

---

This helped me to debug an IRQ sharing issue, so may good to have it in master too.
---

[...]

qapi/misc.json line 407

Quoted 10 lines
qapi/misc.json +2 -0
index c18fe681fb..f8d33ddb4e 100644
@@ -403,6 +403,8 @@
 #
 # @irq: if an IRQ is assigned to the device, the IRQ number
 #
+# @irq_pin: the IRQ pin, zero means no IRQ (since 5.1)
+#

For the IRQ number, we make the member optional, and use "member absent" for "no IRQ assigned".

For the IRQ pin, we make the member mandatory, and use zero value for "no IRQ assigned".

Any particular reason for the difference?

Quoted 14 lines
qapi/misc.json +2 -2
 # @qdev_id: the device name of the PCI device
 #
 # @pci_bridge: if the device is a PCI bridge, the bridge information
@@ -417,8 +419,8 @@
 { 'struct': 'PciDeviceInfo',
   'data': {'bus': 'int', 'slot': 'int', 'function': 'int',
            'class_info': 'PciDeviceClass', 'id': 'PciDeviceId',
-           '*irq': 'int', 'qdev_id': 'str', '*pci_bridge': 'PciBridgeInfo',
-           'regions': ['PciMemoryRegion']} }
+           '*irq': 'int', 'irq_pin': 'int', 'qdev_id': 'str',
+           '*pci_bridge': 'PciBridgeInfo', 'regions': ['PciMemoryRegion'] }}
 
 ##
 # @PciInfo:
author
#14 lore raw

Hi, Markus,

Thanks for commenting. Please see below.

Quoted 35 lines · Markus Armbruster
Quoted 18 lines · Peter Xu

Sometimes it would be good to be able to read the pin number along with the IRQ number allocated. Since we'll dump the IRQ number, no reason to not dump the pin information. For example, the vfio-pci device will overwrite the pin with the hardware pin number. It would be nice to know the pin number of one assigned device from QMP/HMP.

CC Dr. David Alan Gilbert <[email protected]>
CC Alex Williamson <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Julia Suvorova <[email protected]>
CC Markus Armbruster <[email protected]>

---

This helped me to debug an IRQ sharing issue, so may good to have it in master too.
---

[...]

qapi/misc.json line 407

Quoted 10 lines
qapi/misc.json +2 -0
index c18fe681fb..f8d33ddb4e 100644
@@ -403,6 +403,8 @@
 #
 # @irq: if an IRQ is assigned to the device, the IRQ number
 #
+# @irq_pin: the IRQ pin, zero means no IRQ (since 5.1)
+#

For the IRQ number, we make the member optional, and use "member absent" for "no IRQ assigned".

Quoted 4 lines

For the IRQ pin, we make the member mandatory, and use zero value for "no IRQ assigned".

Any particular reason for the difference?

I have two reasons.

Spec-wise, "irq" (PCI_INTERRUPT_LINE) is optional which should depend on "irq_pin" (PCI_INTERRUPT_PIN), while "irq_pin" itself is not optional according to PCI local bus spec 3.0:

Interrupt Pin

The Interrupt Pin register tells which interrupt pin the device (or device function) uses. A value of 1 corresponds to INTA# . A value of 2 corresponds to INTB# . A value of 3 corresponds to INTC# . A value of 4 corresponds to INTD# . Devices (or device functions) that do not use an interrupt pin must put a 0 in this register. The values 05h through FFh are reserved. This register is read-only. Refer to Section 2.2.6 for further description of the usage of the INTx# pins.

So it should be a value between 0-4, inclusive. It applies even if the device does not support INTx.

Code-wise, we can also make "irq_pin" optional just like "irq" (which will automatically create the has_irq_pin variable). However, then it means we'll have two booleans for the same purpose for intx in PciDeviceInfo, which seems to be an unnecessary duplication.

So I chose the simple to make it mandatory.

Thanks,

Signature · 1 line
Peter Xu
#15 lore raw
Quoted 61 lines · Peter Xu

Hi, Markus,

Thanks for commenting. Please see below.

Quoted 35 lines · Markus Armbruster
Quoted 18 lines · Peter Xu

Sometimes it would be good to be able to read the pin number along with the IRQ number allocated. Since we'll dump the IRQ number, no reason to not dump the pin information. For example, the vfio-pci device will overwrite the pin with the hardware pin number. It would be nice to know the pin number of one assigned device from QMP/HMP.

CC Dr. David Alan Gilbert <[email protected]>
CC Alex Williamson <[email protected]>
CC Michael S. Tsirkin <[email protected]>
CC Marcel Apfelbaum <[email protected]>
CC Julia Suvorova <[email protected]>
CC Markus Armbruster <[email protected]>

---

This helped me to debug an IRQ sharing issue, so may good to have it in master too.
---

[...]

qapi/misc.json line 407

Quoted 10 lines
qapi/misc.json +2 -0
index c18fe681fb..f8d33ddb4e 100644
@@ -403,6 +403,8 @@
 #
 # @irq: if an IRQ is assigned to the device, the IRQ number
 #
+# @irq_pin: the IRQ pin, zero means no IRQ (since 5.1)
+#

For the IRQ number, we make the member optional, and use "member absent" for "no IRQ assigned".

Quoted 4 lines

For the IRQ pin, we make the member mandatory, and use zero value for "no IRQ assigned".

Any particular reason for the difference?

I have two reasons.

Spec-wise, "irq" (PCI_INTERRUPT_LINE) is optional which should depend on "irq_pin" (PCI_INTERRUPT_PIN), while "irq_pin" itself is not optional according to PCI local bus spec 3.0:

Interrupt Pin

The Interrupt Pin register tells which interrupt pin the device (or device function) uses. A value of 1 corresponds to INTA# . A value of 2 corresponds to INTB# . A value of 3 corresponds to INTC# . A value of 4 corresponds to INTD# . Devices (or device functions) that do not use an interrupt pin must put a 0 in this register. The values 05h through FFh are reserved. This register is read-only. Refer to Section 2.2.6 for further description of the usage of the INTx# pins.

Quoted 7 lines

So it should be a value between 0-4, inclusive. It applies even if the device does not support INTx.

Code-wise, we can also make "irq_pin" optional just like "irq" (which will automatically create the has_irq_pin variable). However, then it means we'll have two booleans for the same purpose for intx in PciDeviceInfo, which seems to be an unnecessary duplication.

I agree encoding "uses an interrupt pin" in multiple seemingly independent ways is somewhat ugly. But making @irq_pin mandatory merely hides it better: if (has_irq_pin) becomes if (irq_pin). Same redundancy with if (has_irq).

Quoted 1 line

So I chose the simple to make it mandatory.

No big deal either way, thus

I'm *not* passing judgement on whether exposing the pin register via QMP makes sense. That's for the PCI maintainers to decide.