Skip to content

Commit 601368a

Browse files
mnissler-rivosdgreid
authored andcommitted
drivers/iommu: Recognize alternative IOMMU PCI ids
There are a few different PCI device/vendor ID pairs used for RISCV IOMMUs. Match against a list instead of expecting a specific pair.
1 parent b45532b commit 601368a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/src/iommu/core.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ pub struct Iommu {
3030
static IOMMUS: [Once<Iommu>; 8] = [Once::INIT; 8];
3131

3232
// Identifiers from the QEMU RFC implementation.
33-
const IOMMU_VENDOR_ID: u16 = 0x1efd;
34-
const IOMMU_DEVICE_ID: u16 = 0xedf1;
33+
const IOMMU_PCI_ID_TABLE: [(u16, u16); 3] = [
34+
(0x1b36, 0x0014), // vanilla qemu IOMMU model
35+
(0x1efd, 0xedf1), // Rivos qemu IOMMU model
36+
(0x1efd, 0x0008), // Rivos hardware IOMMU
37+
];
3538

3639
// Suppress clippy warning about common suffix in favor or matching mode names as per IOMMU spec.
3740
#[allow(clippy::enum_variant_names)]
@@ -72,9 +75,8 @@ impl Iommu {
7275
) -> Result<&'static Iommu> {
7376
let mut dev = dev.lock();
7477

75-
if dev.info().vendor_id().bits() != IOMMU_VENDOR_ID
76-
|| dev.info().device_id().bits() != IOMMU_DEVICE_ID
77-
{
78+
let pci_ids = (dev.info().vendor_id().bits(), dev.info().device_id().bits());
79+
if !IOMMU_PCI_ID_TABLE.contains(&pci_ids) {
7880
return Err(Error::NotAnIommu);
7981
}
8082

0 commit comments

Comments
 (0)