69 lines
2.1 KiB
Diff
69 lines
2.1 KiB
Diff
|
|
From 2fea4f93632679afcb15f0c35b3d9abeede37778 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Nicolin Chen <nicolinc@nvidia.com>
|
||
|
|
Date: Wed, 10 Apr 2024 16:37:25 +0000
|
||
|
|
Subject: [PATCH] hw/arm/smmu-common: Extract smmu_get_sbus and smmu_get_sdev
|
||
|
|
helpers
|
||
|
|
|
||
|
|
Add two helpers to get sbus and sdev respectively. These will be used
|
||
|
|
by the following patch adding set/unset_iommu_device ops.
|
||
|
|
|
||
|
|
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
|
||
|
|
---
|
||
|
|
hw/arm/smmu-common.c | 24 +++++++++++++++++++-----
|
||
|
|
1 file changed, 19 insertions(+), 5 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
|
||
|
|
index 016418a48c..03d9ff58d4 100644
|
||
|
|
--- a/hw/arm/smmu-common.c
|
||
|
|
+++ b/hw/arm/smmu-common.c
|
||
|
|
@@ -589,12 +589,9 @@ SMMUPciBus *smmu_find_smmu_pcibus(SMMUState *s, uint8_t bus_num)
|
||
|
|
return NULL;
|
||
|
|
}
|
||
|
|
|
||
|
|
-static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)
|
||
|
|
+static SMMUPciBus *smmu_get_sbus(SMMUState *s, PCIBus *bus)
|
||
|
|
{
|
||
|
|
- SMMUState *s = opaque;
|
||
|
|
SMMUPciBus *sbus = g_hash_table_lookup(s->smmu_pcibus_by_busptr, bus);
|
||
|
|
- SMMUDevice *sdev;
|
||
|
|
- static unsigned int index;
|
||
|
|
|
||
|
|
if (!sbus) {
|
||
|
|
sbus = g_malloc0(sizeof(SMMUPciBus) +
|
||
|
|
@@ -603,7 +600,15 @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)
|
||
|
|
g_hash_table_insert(s->smmu_pcibus_by_busptr, bus, sbus);
|
||
|
|
}
|
||
|
|
|
||
|
|
- sdev = sbus->pbdev[devfn];
|
||
|
|
+ return sbus;
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
+static SMMUDevice *smmu_get_sdev(SMMUState *s, SMMUPciBus *sbus,
|
||
|
|
+ PCIBus *bus, int devfn)
|
||
|
|
+{
|
||
|
|
+ SMMUDevice *sdev = sbus->pbdev[devfn];
|
||
|
|
+ static unsigned int index;
|
||
|
|
+
|
||
|
|
if (!sdev) {
|
||
|
|
char *name = g_strdup_printf("%s-%d-%d", s->mrtypename, devfn, index++);
|
||
|
|
|
||
|
|
@@ -622,6 +627,15 @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)
|
||
|
|
g_free(name);
|
||
|
|
}
|
||
|
|
|
||
|
|
+ return sdev;
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
+static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)
|
||
|
|
+{
|
||
|
|
+ SMMUState *s = opaque;
|
||
|
|
+ SMMUPciBus *sbus = smmu_get_sbus(s, bus);
|
||
|
|
+ SMMUDevice *sdev = smmu_get_sdev(s, sbus, bus, devfn);
|
||
|
|
+
|
||
|
|
return &sdev->as;
|
||
|
|
}
|
||
|
|
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|