Skip to contentSkip to conversation

pci-ids: sync docs + header

PATCH In review Gerd Hoffmann 4 participants 5 messages Sep 30, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci-ids: sync docs + header

docs/specs/pci-ids.txt and include/hw/pci/pci.h are out of sync, fix that. Try improve the comment which points to pci-ids.txt.

Also drop the list of modern virtio devices and explain how they are calculated instead.

---
 docs/specs/pci-ids.txt | 19 ++++++++++---------
 include/hw/pci/pci.h   |  7 ++++++-
 2 files changed, 16 insertions(+), 10 deletions(-)
docs/specs/pci-ids.txt +10 -9
index dd6859d039d0..6be7bc108d66 100644
@@ -22,16 +22,17 @@ maintained as part of the virtio specification.
 1af4:1004  SCSI host bus adapter device (legacy)
 1af4:1005  entropy generator device (legacy)
 1af4:1009  9p filesystem device (legacy)
+1af4:1012  vsock device (legacy)
+1af4:1013  pmem device (legacy)
+1af4:1014  iommu device (legacy)
+1af4:1015  mem device (legacy)
 
-1af4:1041  network device (modern)
-1af4:1042  block device (modern)
-1af4:1043  console device (modern)
-1af4:1044  entropy generator device (modern)
-1af4:1045  balloon device (modern)
-1af4:1048  SCSI host bus adapter device (modern)
-1af4:1049  9p filesystem device (modern)
-1af4:1050  virtio gpu device (modern)
-1af4:1052  virtio input device (modern)
+1af4:1040  Start of id range for modern virtio devices.  The pci device
+           id is is calculated from the virtio device id by adding the
+           0x1040 offset.  The virtio ids are defined in the virtio
+           specification.  The linux kernel has a header file with
+           defines for all virtio ids (linux/virtio_ids.h), qemu has a
+           copy in include/standard-headers/.
 
 1af4:10f0  Available for experimental usage without registration.  Must get
    to      official ID when the code leaves the test lab (i.e. when seeking
include/hw/pci/pci.h +6 -1
index b54b6ef88fc3..3b852199660c 100644
@@ -71,7 +71,12 @@ extern bool pci_available;
 #define PCI_DEVICE_ID_INTEL_82557        0x1229
 #define PCI_DEVICE_ID_INTEL_82801IR      0x2922
 
-/* Red Hat / Qumranet (for QEMU) -- see pci-ids.txt */
+/*
+ * Red Hat / Qumranet (for QEMU)
+ *
+ * These are documented in docs/specs/pci-ids.txt
+ * PLEASE KEEP HEADER + DOCS IN SYNC
+ */
 #define PCI_VENDOR_ID_REDHAT_QUMRANET    0x1af4
 #define PCI_SUBVENDOR_ID_REDHAT_QUMRANET 0x1af4
 #define PCI_SUBDEVICE_ID_QEMU            0x1100
Signature · 1 line
2.37.3
#1 lore raw

Hi Gerd,

Quoted 17 lines · Gerd Hoffmann

docs/specs/pci-ids.txt and include/hw/pci/pci.h are out of sync, fix that. Try improve the comment which points to pci-ids.txt.

Also drop the list of modern virtio devices and explain how they are calculated instead.

---
 docs/specs/pci-ids.txt | 19 ++++++++++---------
 include/hw/pci/pci.h   |  7 ++++++-
 2 files changed, 16 insertions(+), 10 deletions(-)
docs/specs/pci-ids.txt +0 -0
index dd6859d039d0..6be7bc108d66 100644

docs/specs/pci-ids.txt maintained as part of the virtio specification. · line 28

Quoted 7 lines
docs/specs/pci-ids.txt +4 -0
@@ -22,16 +22,17 @@ maintained as part of the virtio specification.
 1af4:1004  SCSI host bus adapter device (legacy)
 1af4:1005  entropy generator device (legacy)
 1af4:1009  9p filesystem device (legacy)
+1af4:1012  vsock device (legacy)
+1af4:1013  pmem device (legacy)
+1af4:1014  iommu device (legacy)
+1af4:1015  mem device (legacy)

While I understand the 1af4:1040 range, I do not get where the above ids come from. Could we add an explanation in the intro. Also there, we may fix s/Note that this allocation separate/Note that this allocation is separate. Also why do we have a hole inbetween 1009 and 1012?

docs/specs/pci-ids.txt maintained as part of the virtio specification. · line 31

Quoted 12 lines
docs/specs/pci-ids.txt +2 -9
-1af4:1041  network device (modern)
-1af4:1042  block device (modern)
-1af4:1043  console device (modern)
-1af4:1044  entropy generator device (modern)
-1af4:1045  balloon device (modern)
-1af4:1048  SCSI host bus adapter device (modern)
-1af4:1049  9p filesystem device (modern)
-1af4:1050  virtio gpu device (modern)
-1af4:1052  virtio input device (modern)
+1af4:1040  Start of id range for modern virtio devices.  The pci device
+           id is is calculated from the virtio device id by adding the

s/is is/is

Quoted 15 lines
docs/specs/pci-ids.txt +4 -0
+           0x1040 offset.  The virtio ids are defined in the virtio
+           specification.  The linux kernel has a header file with
+           defines for all virtio ids (linux/virtio_ids.h), qemu has a
+           copy in include/standard-headers/.
 
 1af4:10f0  Available for experimental usage without registration.  Must get
    to      official ID when the code leaves the test lab (i.e. when seeking
include/hw/pci/pci.h +0 -0
index b54b6ef88fc3..3b852199660c 100644
@@ -71,7 +71,12 @@ extern bool pci_available;
 #define PCI_DEVICE_ID_INTEL_82557        0x1229
 #define PCI_DEVICE_ID_INTEL_82801IR      0x2922
 

include/hw/pci/pci.h extern bool pci_available; · line 82

Quoted 10 lines
include/hw/pci/pci.h +6 -1
-/* Red Hat / Qumranet (for QEMU) -- see pci-ids.txt */
+/*
+ * Red Hat / Qumranet (for QEMU)
+ *
+ * These are documented in docs/specs/pci-ids.txt
+ * PLEASE KEEP HEADER + DOCS IN SYNC
+ */
 #define PCI_VENDOR_ID_REDHAT_QUMRANET    0x1af4
 #define PCI_SUBVENDOR_ID_REDHAT_QUMRANET 0x1af4
 #define PCI_SUBDEVICE_ID_QEMU            0x1100

Adding Jean in copy as we discussed that in
https://lore.kernel.org/qemu-devel/[email protected]/

Thanks

Eric

#2 lore raw
In reply to Gerd Hoffmann
Quoted 17 lines · Gerd Hoffmann

docs/specs/pci-ids.txt and include/hw/pci/pci.h are out of sync, fix that. Try improve the comment which points to pci-ids.txt.

Also drop the list of modern virtio devices and explain how they are calculated instead.

---
 docs/specs/pci-ids.txt | 19 ++++++++++---------
 include/hw/pci/pci.h   |  7 ++++++-
 2 files changed, 16 insertions(+), 10 deletions(-)
docs/specs/pci-ids.txt +0 -0
index dd6859d039d0..6be7bc108d66 100644

docs/specs/pci-ids.txt maintained as part of the virtio specification. · line 28

Quoted 7 lines
docs/specs/pci-ids.txt +4 -0
@@ -22,16 +22,17 @@ maintained as part of the virtio specification.
 1af4:1004  SCSI host bus adapter device (legacy)
 1af4:1005  entropy generator device (legacy)
 1af4:1009  9p filesystem device (legacy)
+1af4:1012  vsock device (legacy)
+1af4:1013  pmem device (legacy)
+1af4:1014  iommu device (legacy)
+1af4:1015  mem device (legacy)

Wait, how come we have legacy vsock/pmem/iommu/mem? They were only introduced after 1.0.

Quoted 39 lines
docs/specs/pci-ids.txt +6 -9
-1af4:1041  network device (modern)
-1af4:1042  block device (modern)
-1af4:1043  console device (modern)
-1af4:1044  entropy generator device (modern)
-1af4:1045  balloon device (modern)
-1af4:1048  SCSI host bus adapter device (modern)
-1af4:1049  9p filesystem device (modern)
-1af4:1050  virtio gpu device (modern)
-1af4:1052  virtio input device (modern)
+1af4:1040  Start of id range for modern virtio devices.  The pci device
+           id is is calculated from the virtio device id by adding the
+           0x1040 offset.  The virtio ids are defined in the virtio
+           specification.  The linux kernel has a header file with
+           defines for all virtio ids (linux/virtio_ids.h), qemu has a
+           copy in include/standard-headers/.
 
 1af4:10f0  Available for experimental usage without registration.  Must get
    to      official ID when the code leaves the test lab (i.e. when seeking
include/hw/pci/pci.h +6 -1
index b54b6ef88fc3..3b852199660c 100644
@@ -71,7 +71,12 @@ extern bool pci_available;
 #define PCI_DEVICE_ID_INTEL_82557        0x1229
 #define PCI_DEVICE_ID_INTEL_82801IR      0x2922
 
-/* Red Hat / Qumranet (for QEMU) -- see pci-ids.txt */
+/*
+ * Red Hat / Qumranet (for QEMU)
+ *
+ * These are documented in docs/specs/pci-ids.txt
+ * PLEASE KEEP HEADER + DOCS IN SYNC
+ */
 #define PCI_VENDOR_ID_REDHAT_QUMRANET    0x1af4
 #define PCI_SUBVENDOR_ID_REDHAT_QUMRANET 0x1af4
 #define PCI_SUBDEVICE_ID_QEMU            0x1100
Signature · 1 line
2.37.3
#3 lore raw
Quoted 13 lines · Michael S. Tsirkin
Quoted 12 lines · Gerd Hoffmann

docs/specs/pci-ids.txt and include/hw/pci/pci.h are out of sync, fix that. Try improve the comment which points to pci-ids.txt.

Also drop the list of modern virtio devices and explain how they are calculated instead.

---
 docs/specs/pci-ids.txt | 19 ++++++++++---------
 include/hw/pci/pci.h   |  7 ++++++-
 2 files changed, 16 insertions(+), 10 deletions(-)
Quoted 15 lines

docs/specs/pci-ids.txt maintained as part of the virtio specification. · line 28

Quoted 12 lines
docs/specs/pci-ids.txt +4 -0
index dd6859d039d0..6be7bc108d66 100644
@@ -22,16 +22,17 @@ maintained as part of the virtio specification.
 1af4:1004  SCSI host bus adapter device (legacy)
 1af4:1005  entropy generator device (legacy)
 1af4:1009  9p filesystem device (legacy)
+1af4:1012  vsock device (legacy)
+1af4:1013  pmem device (legacy)
+1af4:1014  iommu device (legacy)
+1af4:1015  mem device (legacy)

Wait, how come we have legacy vsock/pmem/iommu/mem? They were only introduced after 1.0.

I've just synced with the header file, and the #defines there seem to be actually used:

kraxel@sirius ~/projects/qemu (pci-ids)# git grep PCI_DEVICE_ID_VIRTIO_IOMMU
hw/virtio/virtio-iommu-pci.c: pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_IOMMU;
include/hw/pci/pci.h:#define PCI_DEVICE_ID_VIRTIO_IOMMU 0x1014

But, yes, the question is valid. 1.0-only devices should not need a legacy id. Dunno how that happened ...

take care,
Gerd

#4 lore raw
In reply to Gerd Hoffmann
Quoted 31 lines · Gerd Hoffmann

docs/specs/pci-ids.txt and include/hw/pci/pci.h are out of sync, fix that. Try improve the comment which points to pci-ids.txt.

Also drop the list of modern virtio devices and explain how they are calculated instead.

---
 docs/specs/pci-ids.txt | 19 ++++++++++---------
 include/hw/pci/pci.h   |  7 ++++++-
 2 files changed, 16 insertions(+), 10 deletions(-)
docs/specs/pci-ids.txt +4 -5
index dd6859d039d0..6be7bc108d66 100644
@@ -22,16 +22,17 @@ maintained as part of the virtio specification.
 1af4:1004  SCSI host bus adapter device (legacy)
 1af4:1005  entropy generator device (legacy)
 1af4:1009  9p filesystem device (legacy)
+1af4:1012  vsock device (legacy)
+1af4:1013  pmem device (legacy)
+1af4:1014  iommu device (legacy)
+1af4:1015  mem device (legacy)
 
-1af4:1041  network device (modern)
-1af4:1042  block device (modern)
-1af4:1043  console device (modern)
-1af4:1044  entropy generator device (modern)
-1af4:1045  balloon device (modern)

docs/specs/pci-ids.txt maintained as part of the virtio specification. · line 35

Quoted 10 lines
docs/specs/pci-ids.txt +6 -4
-1af4:1048  SCSI host bus adapter device (modern)
-1af4:1049  9p filesystem device (modern)
-1af4:1050  virtio gpu device (modern)
-1af4:1052  virtio input device (modern)
+1af4:1040  Start of id range for modern virtio devices.  The pci device
+           id is is calculated from the virtio device id by adding the
+           0x1040 offset.  The virtio ids are defined in the virtio
+           specification.  The linux kernel has a header file with
+           defines for all virtio ids (linux/virtio_ids.h), qemu has a
+           copy in include/standard-headers/.

I think you should also specify the end point of this range, in the same way that the "experimental usage" range has both a defined start and end point. Otherwise we have no way to know how much (if any) of the space before 10f0 is available for other uses.

Nits: capitalization: ID, PCI, Linux.

docs/specs/pci-ids.txt maintained as part of the virtio specification. · line 38

Quoted 2 lines
docs/specs/pci-ids.txt +0 -0
 1af4:10f0  Available for experimental usage without registration.  Must get
    to      official ID when the code leaves the test lab (i.e. when seeking

thanks
-- PMM