* [PATCH v3 1/5] pci-ids: drop PCI_DEVICE_ID_VIRTIO_IOMMU
2022-10-04 11:20 [PATCH v3 0/5] pci-ids: virtio cleanup Gerd Hoffmann
@ 2022-10-04 11:20 ` Gerd Hoffmann
2022-10-04 11:20 ` [PATCH v3 2/5] pci-ids: drop PCI_DEVICE_ID_VIRTIO_MEM Gerd Hoffmann
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2022-10-04 11:20 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, David Hildenbrand,
Eric Auger, peter.maydell, Gerd Hoffmann
Not needed for a virtio 1.0 device. virtio_pci_device_plugged()
overrides them anyway (so no functional change).
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
---
include/hw/pci/pci.h | 1 -
hw/virtio/virtio-iommu-pci.c | 4 +---
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index b54b6ef88fc3..89eaca429389 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -85,7 +85,6 @@ extern bool pci_available;
#define PCI_DEVICE_ID_VIRTIO_9P 0x1009
#define PCI_DEVICE_ID_VIRTIO_VSOCK 0x1012
#define PCI_DEVICE_ID_VIRTIO_PMEM 0x1013
-#define PCI_DEVICE_ID_VIRTIO_IOMMU 0x1014
#define PCI_DEVICE_ID_VIRTIO_MEM 0x1015
#define PCI_VENDOR_ID_REDHAT 0x1b36
diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c
index 844d64770406..79ea8334f04e 100644
--- a/hw/virtio/virtio-iommu-pci.c
+++ b/hw/virtio/virtio-iommu-pci.c
@@ -74,8 +74,6 @@ static void virtio_iommu_pci_class_init(ObjectClass *klass, void *data)
k->realize = virtio_iommu_pci_realize;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
device_class_set_props(dc, virtio_iommu_pci_properties);
- pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
- pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_IOMMU;
pcidev_k->revision = VIRTIO_PCI_ABI_VERSION;
pcidev_k->class_id = PCI_CLASS_OTHERS;
dc->hotpluggable = false;
@@ -90,7 +88,7 @@ static void virtio_iommu_pci_instance_init(Object *obj)
}
static const VirtioPCIDeviceTypeInfo virtio_iommu_pci_info = {
- .generic_name = TYPE_VIRTIO_IOMMU_PCI,
+ .generic_name = TYPE_VIRTIO_IOMMU_PCI,
.instance_size = sizeof(VirtIOIOMMUPCI),
.instance_init = virtio_iommu_pci_instance_init,
.class_init = virtio_iommu_pci_class_init,
--
2.37.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/5] pci-ids: drop PCI_DEVICE_ID_VIRTIO_MEM
2022-10-04 11:20 [PATCH v3 0/5] pci-ids: virtio cleanup Gerd Hoffmann
2022-10-04 11:20 ` [PATCH v3 1/5] pci-ids: drop PCI_DEVICE_ID_VIRTIO_IOMMU Gerd Hoffmann
@ 2022-10-04 11:20 ` Gerd Hoffmann
2022-10-04 11:20 ` [PATCH v3 3/5] pci-ids: drop PCI_DEVICE_ID_VIRTIO_PMEM Gerd Hoffmann
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2022-10-04 11:20 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, David Hildenbrand,
Eric Auger, peter.maydell, Gerd Hoffmann
Not needed for a virtio 1.0 device. virtio_pci_device_plugged()
overrides them anyway (so no functional change).
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
include/hw/pci/pci.h | 1 -
hw/virtio/virtio-mem-pci.c | 2 --
2 files changed, 3 deletions(-)
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 89eaca429389..b6aefb33fb17 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -85,7 +85,6 @@ extern bool pci_available;
#define PCI_DEVICE_ID_VIRTIO_9P 0x1009
#define PCI_DEVICE_ID_VIRTIO_VSOCK 0x1012
#define PCI_DEVICE_ID_VIRTIO_PMEM 0x1013
-#define PCI_DEVICE_ID_VIRTIO_MEM 0x1015
#define PCI_VENDOR_ID_REDHAT 0x1b36
#define PCI_DEVICE_ID_REDHAT_BRIDGE 0x0001
diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c
index be2383b0c522..5c5c1e3ae3da 100644
--- a/hw/virtio/virtio-mem-pci.c
+++ b/hw/virtio/virtio-mem-pci.c
@@ -104,8 +104,6 @@ static void virtio_mem_pci_class_init(ObjectClass *klass, void *data)
k->realize = virtio_mem_pci_realize;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
- pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
- pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_MEM;
pcidev_k->revision = VIRTIO_PCI_ABI_VERSION;
pcidev_k->class_id = PCI_CLASS_OTHERS;
--
2.37.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/5] pci-ids: drop PCI_DEVICE_ID_VIRTIO_PMEM
2022-10-04 11:20 [PATCH v3 0/5] pci-ids: virtio cleanup Gerd Hoffmann
2022-10-04 11:20 ` [PATCH v3 1/5] pci-ids: drop PCI_DEVICE_ID_VIRTIO_IOMMU Gerd Hoffmann
2022-10-04 11:20 ` [PATCH v3 2/5] pci-ids: drop PCI_DEVICE_ID_VIRTIO_MEM Gerd Hoffmann
@ 2022-10-04 11:20 ` Gerd Hoffmann
2022-10-04 11:20 ` [PATCH v3 4/5] pci-ids: drop list of modern virtio devices Gerd Hoffmann
2022-10-04 11:21 ` [PATCH v3 5/5] pci-ids: document modern virtio-pci ids in pci.h too Gerd Hoffmann
4 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2022-10-04 11:20 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, David Hildenbrand,
Eric Auger, peter.maydell, Gerd Hoffmann, Pankaj Gupta
Not needed for a virtio 1.0 device. virtio_pci_device_plugged()
overrides them anyway (so no functional change).
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Tested-by: Pankaj Gupta <pankaj.gupta@amd.com>
---
include/hw/pci/pci.h | 1 -
hw/virtio/virtio-pmem-pci.c | 2 --
2 files changed, 3 deletions(-)
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index b6aefb33fb17..42c83cb5ed00 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -84,7 +84,6 @@ extern bool pci_available;
#define PCI_DEVICE_ID_VIRTIO_RNG 0x1005
#define PCI_DEVICE_ID_VIRTIO_9P 0x1009
#define PCI_DEVICE_ID_VIRTIO_VSOCK 0x1012
-#define PCI_DEVICE_ID_VIRTIO_PMEM 0x1013
#define PCI_VENDOR_ID_REDHAT 0x1b36
#define PCI_DEVICE_ID_REDHAT_BRIDGE 0x0001
diff --git a/hw/virtio/virtio-pmem-pci.c b/hw/virtio/virtio-pmem-pci.c
index 2b2a0b1eae10..7d9f4ec189b9 100644
--- a/hw/virtio/virtio-pmem-pci.c
+++ b/hw/virtio/virtio-pmem-pci.c
@@ -90,8 +90,6 @@ static void virtio_pmem_pci_class_init(ObjectClass *klass, void *data)
k->realize = virtio_pmem_pci_realize;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
- pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
- pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_PMEM;
pcidev_k->revision = VIRTIO_PCI_ABI_VERSION;
pcidev_k->class_id = PCI_CLASS_OTHERS;
--
2.37.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 4/5] pci-ids: drop list of modern virtio devices
2022-10-04 11:20 [PATCH v3 0/5] pci-ids: virtio cleanup Gerd Hoffmann
` (2 preceding siblings ...)
2022-10-04 11:20 ` [PATCH v3 3/5] pci-ids: drop PCI_DEVICE_ID_VIRTIO_PMEM Gerd Hoffmann
@ 2022-10-04 11:20 ` Gerd Hoffmann
2022-10-04 11:21 ` [PATCH v3 5/5] pci-ids: document modern virtio-pci ids in pci.h too Gerd Hoffmann
4 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2022-10-04 11:20 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, David Hildenbrand,
Eric Auger, peter.maydell, Gerd Hoffmann
Drop the list of modern virtio devices and explain how they
are calculated instead.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
---
docs/specs/pci-ids.txt | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/docs/specs/pci-ids.txt b/docs/specs/pci-ids.txt
index dd6859d039d0..e463c4cb3a22 100644
--- a/docs/specs/pci-ids.txt
+++ b/docs/specs/pci-ids.txt
@@ -22,16 +22,14 @@ 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 (bug compatibility)
-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
+ to ID is calculated from the virtio device ID by adding the
+1af4:10ef 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
--
2.37.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 5/5] pci-ids: document modern virtio-pci ids in pci.h too
2022-10-04 11:20 [PATCH v3 0/5] pci-ids: virtio cleanup Gerd Hoffmann
` (3 preceding siblings ...)
2022-10-04 11:20 ` [PATCH v3 4/5] pci-ids: drop list of modern virtio devices Gerd Hoffmann
@ 2022-10-04 11:21 ` Gerd Hoffmann
2022-10-04 17:07 ` Eric Auger
4 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2022-10-04 11:21 UTC (permalink / raw)
To: qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, David Hildenbrand,
Eric Auger, peter.maydell, Gerd Hoffmann
While being at it add a #define for the magic 0x1040 number.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/hw/pci/pci.h | 10 ++++++++++
hw/virtio/virtio-pci.c | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 42c83cb5ed00..d1ac308574f1 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -76,6 +76,7 @@ extern bool pci_available;
#define PCI_SUBVENDOR_ID_REDHAT_QUMRANET 0x1af4
#define PCI_SUBDEVICE_ID_QEMU 0x1100
+/* legacy virtio-pci devices */
#define PCI_DEVICE_ID_VIRTIO_NET 0x1000
#define PCI_DEVICE_ID_VIRTIO_BLOCK 0x1001
#define PCI_DEVICE_ID_VIRTIO_BALLOON 0x1002
@@ -85,6 +86,15 @@ extern bool pci_available;
#define PCI_DEVICE_ID_VIRTIO_9P 0x1009
#define PCI_DEVICE_ID_VIRTIO_VSOCK 0x1012
+/*
+ * modern virtio-pci devices get their id assigned automatically,
+ * there is no need to add #defines here. It gets calculated as
+ *
+ * PCI_DEVICE_ID = PCI_DEVICE_ID_VIRTIO_10_BASE +
+ * virtio_bus_get_vdev_id(bus)
+ */
+#define PCI_DEVICE_ID_VIRTIO_10_BASE 0x1040
+
#define PCI_VENDOR_ID_REDHAT 0x1b36
#define PCI_DEVICE_ID_REDHAT_BRIDGE 0x0001
#define PCI_DEVICE_ID_REDHAT_SERIAL 0x0002
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index a50c5a57d7e5..e7d80242b73f 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1688,7 +1688,7 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
pci_set_word(config + PCI_VENDOR_ID,
PCI_VENDOR_ID_REDHAT_QUMRANET);
pci_set_word(config + PCI_DEVICE_ID,
- 0x1040 + virtio_bus_get_vdev_id(bus));
+ PCI_DEVICE_ID_VIRTIO_10_BASE + virtio_bus_get_vdev_id(bus));
pci_config_set_revision(config, 1);
}
config[PCI_INTERRUPT_PIN] = 1;
--
2.37.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 5/5] pci-ids: document modern virtio-pci ids in pci.h too
2022-10-04 11:21 ` [PATCH v3 5/5] pci-ids: document modern virtio-pci ids in pci.h too Gerd Hoffmann
@ 2022-10-04 17:07 ` Eric Auger
0 siblings, 0 replies; 7+ messages in thread
From: Eric Auger @ 2022-10-04 17:07 UTC (permalink / raw)
To: Gerd Hoffmann, qemu-devel
Cc: Marcel Apfelbaum, Michael S. Tsirkin, David Hildenbrand,
peter.maydell
Hi Gerd,
On 10/4/22 13:21, Gerd Hoffmann wrote:
> While being at it add a #define for the magic 0x1040 number.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Thanks
Eric
> ---
> include/hw/pci/pci.h | 10 ++++++++++
> hw/virtio/virtio-pci.c | 2 +-
> 2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index 42c83cb5ed00..d1ac308574f1 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -76,6 +76,7 @@ extern bool pci_available;
> #define PCI_SUBVENDOR_ID_REDHAT_QUMRANET 0x1af4
> #define PCI_SUBDEVICE_ID_QEMU 0x1100
>
> +/* legacy virtio-pci devices */
> #define PCI_DEVICE_ID_VIRTIO_NET 0x1000
> #define PCI_DEVICE_ID_VIRTIO_BLOCK 0x1001
> #define PCI_DEVICE_ID_VIRTIO_BALLOON 0x1002
> @@ -85,6 +86,15 @@ extern bool pci_available;
> #define PCI_DEVICE_ID_VIRTIO_9P 0x1009
> #define PCI_DEVICE_ID_VIRTIO_VSOCK 0x1012
>
> +/*
> + * modern virtio-pci devices get their id assigned automatically,
> + * there is no need to add #defines here. It gets calculated as
> + *
> + * PCI_DEVICE_ID = PCI_DEVICE_ID_VIRTIO_10_BASE +
> + * virtio_bus_get_vdev_id(bus)
> + */
> +#define PCI_DEVICE_ID_VIRTIO_10_BASE 0x1040
> +
> #define PCI_VENDOR_ID_REDHAT 0x1b36
> #define PCI_DEVICE_ID_REDHAT_BRIDGE 0x0001
> #define PCI_DEVICE_ID_REDHAT_SERIAL 0x0002
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index a50c5a57d7e5..e7d80242b73f 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -1688,7 +1688,7 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
> pci_set_word(config + PCI_VENDOR_ID,
> PCI_VENDOR_ID_REDHAT_QUMRANET);
> pci_set_word(config + PCI_DEVICE_ID,
> - 0x1040 + virtio_bus_get_vdev_id(bus));
> + PCI_DEVICE_ID_VIRTIO_10_BASE + virtio_bus_get_vdev_id(bus));
> pci_config_set_revision(config, 1);
> }
> config[PCI_INTERRUPT_PIN] = 1;
^ permalink raw reply [flat|nested] 7+ messages in thread