Skip to contentSkip to conversation

pci: allocate a PCI ID for RISC-V IOMMU

RFC PATCH In review Daniel Henrique Barboza 4 participants 11 messages May 3, 2024 – May 20, 2024

lore
Share & tools
lore
#0 lore raw

cover pci: allocate a PCI ID for RISC-V IOMMU

Hi,

In this RFC I want to check with Gerd and others if it's ok to add a PCI id for the RISC-V IOMMU device. It's currently under review in [1]. The idea is to fold this patch into the RISC-V IOMMU series if we're all ok with this change.

Gerd, we picked the ID right after the PCI UFS device. Let me know if you want another ID instead.

Daniel Henrique Barboza (1):
pci-ids.rst: add Red Hat pci-id for generic IOMMU device

 docs/specs/pci-ids.rst | 2 ++
 include/hw/pci/pci.h   | 1 +
 2 files changed, 3 insertions(+)
Signature · 1 line
2.44.0
#1 lore raw

RFC PATCH 1/1 pci-ids.rst: add Red Hat pci-id for generic IOMMU device

Reserve an id to be used by the RISC-V IOMMU PCI device.

---
 docs/specs/pci-ids.rst | 2 ++
 include/hw/pci/pci.h   | 1 +
 2 files changed, 3 insertions(+)
docs/specs/pci-ids.rst +2 -0
index c0a3dec2e7..a89a9d0939 100644
@@ -94,6 +94,8 @@ PCI devices (other than virtio):
   PCI ACPI ERST device (``-device acpi-erst``)
 1b36:0013
   PCI UFS device (``-device ufs``)
+1b36:0014
+  PCI RISC-V IOMMU device
 
 All these devices are documented in :doc:`index`.
 
include/hw/pci/pci.h +1 -0
index eaa3fc99d8..462aed1503 100644
@@ -115,6 +115,7 @@ extern bool pci_available;
 #define PCI_DEVICE_ID_REDHAT_PVPANIC     0x0011
 #define PCI_DEVICE_ID_REDHAT_ACPI_ERST   0x0012
 #define PCI_DEVICE_ID_REDHAT_UFS         0x0013
+#define PCI_DEVICE_ID_REDHAT_RISCV_IOMMU 0x0014
 #define PCI_DEVICE_ID_REDHAT_QXL         0x0100
 
 #define FMT_PCIBUS                      PRIx64
Signature · 1 line
2.44.0
Reviewed-by on v1 1/1
#2 lore raw

Re: [RFC PATCH 1/1] pci-ids.rst: add Red Hat pci-id for generic IOMMU device

Hi Daniel,

It's glad to see that we have the dedicate PCIe device ID for RISC-V IOMMU.

Daniel Henrique Barboza <[email protected]> 於 2024年5月3日 週五 下午8:44寫道:

Quoted 39 lines

Reserve an id to be used by the RISC-V IOMMU PCI device.

---
 docs/specs/pci-ids.rst | 2 ++
 include/hw/pci/pci.h   | 1 +
 2 files changed, 3 insertions(+)
docs/specs/pci-ids.rst +2 -0
index c0a3dec2e7..a89a9d0939 100644
@@ -94,6 +94,8 @@ PCI devices (other than virtio):
   PCI ACPI ERST device (``-device acpi-erst``)
 1b36:0013
   PCI UFS device (``-device ufs``)
+1b36:0014
+  PCI RISC-V IOMMU device
 
 All these devices are documented in :doc:`index`.
 
include/hw/pci/pci.h +1 -1
index eaa3fc99d8..462aed1503 100644
@@ -115,6 +115,7 @@ extern bool pci_available;
 #define PCI_DEVICE_ID_REDHAT_PVPANIC     0x0011
 #define PCI_DEVICE_ID_REDHAT_ACPI_ERST   0x0012
 #define PCI_DEVICE_ID_REDHAT_UFS         0x0013
+#define PCI_DEVICE_ID_REDHAT_RISCV_IOMMU 0x0014
 #define PCI_DEVICE_ID_REDHAT_QXL         0x0100
 
 #define FMT_PCIBUS                      PRIx64
--

2.44.0

#3 lore raw
In reply to Daniel Henrique Barboza

Hi Daniel,

Daniel Henrique Barboza <[email protected]> 於 2024年5月3日 週五 下午8:43寫道:

Quoted 5 lines

Hi,

In this RFC I want to check with Gerd and others if it's ok to add a PCI id for the RISC-V IOMMU device. It's currently under review in [1]. The

Is the link [1] missing?

Regards,
Frank Chang

Quoted 18 lines

idea is to fold this patch into the RISC-V IOMMU series if we're all ok with this change.

Gerd, we picked the ID right after the PCI UFS device. Let me know if you want another ID instead.

Daniel Henrique Barboza (1):
pci-ids.rst: add Red Hat pci-id for generic IOMMU device

 docs/specs/pci-ids.rst | 2 ++
 include/hw/pci/pci.h   | 1 +
 2 files changed, 3 insertions(+)

--
2.44.0

#7 lore raw
In reply to Daniel Henrique Barboza
Quoted 7 lines · Daniel Henrique Barboza

Hi,

In this RFC I want to check with Gerd and others if it's ok to add a PCI id for the RISC-V IOMMU device. It's currently under review in [1]. The idea is to fold this patch into the RISC-V IOMMU series if we're all ok with this change.

My question here would be "why is this risc-v specific?" (and more generally "what is this for?" -- the cover letter and patch and documentation page provide almost no information about what this device is and why it needs to exist rather than using either virtio-iommu or else a model of a real hardware IOMMU.)

thanks
-- PMM

#4 lore raw
In reply to Frank Chang
Quoted 10 lines · Frank Chang

Hi Daniel,

Daniel Henrique Barboza <[email protected]> 於 2024年5月3日 週五 下午8:43寫道:

Quoted 5 lines

Hi,

In this RFC I want to check with Gerd and others if it's ok to add a PCI id for the RISC-V IOMMU device. It's currently under review in [1]. The

Is the link [1] missing?

Yes ;)

Also: A bit more background on the iommu would be great, for example a pointer to the specification.

take care,
Gerd

#6 lore raw
In reply to Frank Chang
Quoted 10 lines · Frank Chang

Hi Daniel,

Daniel Henrique Barboza <[email protected]> 於 2024年5月3日 週五 下午8:43寫道:

Quoted 5 lines

Hi,

In this RFC I want to check with Gerd and others if it's ok to add a PCI id for the RISC-V IOMMU device. It's currently under review in [1]. The

Is the link [1] missing?

Ooops. Here's the link:

[1] https://lore.kernel.org/qemu-riscv/[email protected]/

Thanks,

Daniel

Quoted 22 lines

Regards,
Frank Chang

Quoted 18 lines

idea is to fold this patch into the RISC-V IOMMU series if we're all ok with this change.

Gerd, we picked the ID right after the PCI UFS device. Let me know if you want another ID instead.

Daniel Henrique Barboza (1):
pci-ids.rst: add Red Hat pci-id for generic IOMMU device

  docs/specs/pci-ids.rst | 2 ++
  include/hw/pci/pci.h   | 1 +
  2 files changed, 3 insertions(+)

--
2.44.0

#5 lore raw
In reply to Gerd Hoffmann
Quoted 10 lines · Gerd Hoffmann
Quoted 9 lines · Frank Chang

Hi Daniel,

Daniel Henrique Barboza <[email protected]> 於 2024年5月3日 週五 下午8:43寫道:

Quoted 5 lines

Hi,

In this RFC I want to check with Gerd and others if it's ok to add a PCI id for the RISC-V IOMMU device. It's currently under review in [1]. The

Quoted 6 lines
Quoted 1 line

Is the link [1] missing?

Yes ;)

Also: A bit more background on the iommu would be great, for example a pointer to the specification.

Fair enough. I'll add a pointer to the latest version of the spec:

https://github.com/riscv-non-isa/riscv-iommu/releases/tag/v1.0.0

Thanks,

Daniel

Quoted 4 lines

take care,
Gerd

#8 lore raw
In reply to Peter Maydell
Quoted 10 lines · Peter Maydell
Quoted 7 lines · Daniel Henrique Barboza

Hi,

In this RFC I want to check with Gerd and others if it's ok to add a PCI id for the RISC-V IOMMU device. It's currently under review in [1]. The idea is to fold this patch into the RISC-V IOMMU series if we're all ok with this change.

Quoted 5 lines

My question here would be "why is this risc-v specific?" (and more generally "what is this for?" -- the cover letter and patch and documentation page provide almost no information about what this device is and why it needs to exist rather than using either virtio-iommu or else a model of a real hardware IOMMU.)

The RISC-V IOMMU device emulation under review ([1]) is a reference implementation of the riscv-iommu spec [2]. AFAIK it is similar to what we already have with aarch64 'smmuv3' 'virt' bus, i.e. an impl of ARM's SMMUv3 that isn't tied to a specific vendor.

The difference here is that the riscv-iommu spec, ratified by RISC-V International (RVI), predicts that the device could be implemented as a PCIe device. But RVI didn't bother assigning a PCI ID for their reference IOMMU. The existing implementation in [1] is using a Rivos PCI ID that we're treating as a placeholder only. We need an ID that reflects that this is a device that adheres to the riscv-iommu spec, not to an IOMMU of any particular vendor.

Since RVI doesn't provide a PCI ID for it we went to Red Hat, and they were kind enough to give us a PCI ID for the RISC-V IOMMU reference device.

I'll do a proper job this time and add all this context in the commit msg. Including a proper shout-out to Gerd and Red Hat.

Thanks,

Daniel

[1] https://lore.kernel.org/qemu-riscv/[email protected]/
[2] https://github.com/riscv-non-isa/riscv-iommu/releases/tag/v1.0.0

Quoted 3 lines

thanks
-- PMM

#9 lore raw

Hi Daniel,

Daniel Henrique Barboza <[email protected]> 於 2024年5月8日 週三 下午8:42寫道:

Quoted 31 lines · Peter Maydell
Quoted 10 lines
Quoted 7 lines · Daniel Henrique Barboza

Hi,

In this RFC I want to check with Gerd and others if it's ok to add a PCI id for the RISC-V IOMMU device. It's currently under review in [1]. The idea is to fold this patch into the RISC-V IOMMU series if we're all ok with this change.

Quoted 5 lines

My question here would be "why is this risc-v specific?" (and more generally "what is this for?" -- the cover letter and patch and documentation page provide almost no information about what this device is and why it needs to exist rather than using either virtio-iommu or else a model of a real hardware IOMMU.)

The RISC-V IOMMU device emulation under review ([1]) is a reference implementation of the riscv-iommu spec [2]. AFAIK it is similar to what we already have with aarch64 'smmuv3' 'virt' bus, i.e. an impl of ARM's SMMUv3 that isn't tied to a specific vendor.

The difference here is that the riscv-iommu spec, ratified by RISC-V International (RVI), predicts that the device could be implemented as a PCIe device. But RVI didn't bother assigning a PCI ID for their reference IOMMU. The existing implementation in [1] is using a Rivos PCI ID that we're treating as a placeholder only. We need an ID that reflects that this is a device that adheres to the riscv-iommu spec, not to an IOMMU of any particular vendor.

Quoted 2 lines

Since RVI doesn't provide a PCI ID for it we went to Red Hat, and they were kind enough to give us a PCI ID for the RISC-V IOMMU reference device.

That's great. Thanks to Red Hat.
I'm wondering do we have the plan to document the new PCI ID to the IOMMU spec or somewhere else that's publicly accessible?

Regards,
Frank Chang

Quoted 19 lines

I'll do a proper job this time and add all this context in the commit msg. Including a proper shout-out to Gerd and Red Hat.

Thanks,

Daniel

[1] https://lore.kernel.org/qemu-riscv/[email protected]/
[2] https://github.com/riscv-non-isa/riscv-iommu/releases/tag/v1.0.0

Quoted 3 lines

thanks
-- PMM

#10 lore raw
Quoted 34 lines · Frank Chang

Hi Daniel,

Daniel Henrique Barboza <[email protected]> 於 2024年5月8日 週三 下午8:42寫道:

Quoted 31 lines · Peter Maydell
Quoted 10 lines
Quoted 7 lines · Daniel Henrique Barboza

Hi,

In this RFC I want to check with Gerd and others if it's ok to add a PCI id for the RISC-V IOMMU device. It's currently under review in [1]. The idea is to fold this patch into the RISC-V IOMMU series if we're all ok with this change.

Quoted 5 lines

My question here would be "why is this risc-v specific?" (and more generally "what is this for?" -- the cover letter and patch and documentation page provide almost no information about what this device is and why it needs to exist rather than using either virtio-iommu or else a model of a real hardware IOMMU.)

The RISC-V IOMMU device emulation under review ([1]) is a reference implementation of the riscv-iommu spec [2]. AFAIK it is similar to what we already have with aarch64 'smmuv3' 'virt' bus, i.e. an impl of ARM's SMMUv3 that isn't tied to a specific vendor.

The difference here is that the riscv-iommu spec, ratified by RISC-V International (RVI), predicts that the device could be implemented as a PCIe device. But RVI didn't bother assigning a PCI ID for their reference IOMMU. The existing implementation in [1] is using a Rivos PCI ID that we're treating as a placeholder only. We need an ID that reflects that this is a device that adheres to the riscv-iommu spec, not to an IOMMU of any particular vendor.

Quoted 6 lines
Quoted 2 lines

Since RVI doesn't provide a PCI ID for it we went to Red Hat, and they were kind enough to give us a PCI ID for the RISC-V IOMMU reference device.

That's great. Thanks to Red Hat.
I'm wondering do we have the plan to document the new PCI ID to the IOMMU spec or somewhere else that's publicly accessible?

It will be documented in QEMU, as you've already seen in this patch. I'm sure that this info will be cascaded for other databases but I'm not sure how or when. I think Gerd can give us more info about it.

I guess we'll end up using this same generic ID from QEMU in the kernel side too. As of now the kernel IOMMU support is using a Rivos ID ([1], patch 3). Assuming that
[1] stays this way (I'm not sure if the kernel driver is a Rivos implementation or a canonical implementation like we're doing here), we'll need to add a generic kernel support that uses the generic ID too.

Thanks,

Daniel

[1] https://lore.kernel.org/linux-riscv/[email protected]/

Quoted 23 lines

Regards,
Frank Chang

Quoted 19 lines

I'll do a proper job this time and add all this context in the commit msg. Including a proper shout-out to Gerd and Red Hat.

Thanks,

Daniel

[1] https://lore.kernel.org/qemu-riscv/[email protected]/
[2] https://github.com/riscv-non-isa/riscv-iommu/releases/tag/v1.0.0

Quoted 3 lines

thanks
-- PMM