@@ -11,6 +11,40 @@
#include "hw/arm/smmuv3-accel.h"
#include "hw/pci/pci_bridge.h"
+static SMMUv3AccelDevice *smmuv3_accel_get_dev(SMMUState *s, SMMUPciBus *sbus,
+ PCIBus *bus, int devfn)
+{
+ SMMUDevice *sdev = sbus->pbdev[devfn];
+ SMMUv3AccelDevice *accel_dev;
+
+ if (sdev) {
+ accel_dev = container_of(sdev, SMMUv3AccelDevice, sdev);
+ } else {
+ accel_dev = g_new0(SMMUv3AccelDevice, 1);
+ sdev = &accel_dev->sdev;
+
+ sbus->pbdev[devfn] = sdev;
+ smmu_init_sdev(s, sdev, bus, devfn);
+ }
+
+ return accel_dev;
+}
+
+static AddressSpace *smmuv3_accel_find_add_as(PCIBus *bus, void *opaque,
+ int devfn)
+{
+ SMMUState *s = opaque;
+ SMMUPciBus *sbus;
+ SMMUv3AccelDevice *accel_dev;
+ SMMUDevice *sdev;
+
+ sbus = smmu_get_sbus(s, bus);
+ accel_dev = smmuv3_accel_get_dev(s, sbus, bus, devfn);
+ sdev = &accel_dev->sdev;
+
+ return &sdev->as;
+}
+
static int smmuv3_accel_pxb_pcie_bus(Object *obj, void *opaque)
{
DeviceState *d = opaque;
@@ -30,6 +64,7 @@ static void smmu_accel_realize(DeviceState *d, Error **errp)
SMMUv3AccelState *s_accel = ARM_SMMUV3_ACCEL(d);
SMMUv3AccelClass *c = ARM_SMMUV3_ACCEL_GET_CLASS(s_accel);
SysBusDevice *dev = SYS_BUS_DEVICE(d);
+ SMMUState *bs = ARM_SMMU(d);
Error *local_err = NULL;
object_child_foreach_recursive(object_get_root(),
@@ -41,6 +76,7 @@ static void smmu_accel_realize(DeviceState *d, Error **errp)
error_propagate(errp, local_err);
return;
}
+ bs->get_address_space = smmuv3_accel_find_add_as;
}
static void smmuv3_accel_class_init(ObjectClass *klass, void *data)
@@ -16,6 +16,10 @@
#define TYPE_ARM_SMMUV3_ACCEL "arm-smmuv3-accel"
OBJECT_DECLARE_TYPE(SMMUv3AccelState, SMMUv3AccelClass, ARM_SMMUV3_ACCEL)
+typedef struct SMMUv3AccelDevice {
+ SMMUDevice sdev;
+} SMMUv3AccelDevice;
+
struct SMMUv3AccelState {
SMMUv3State smmuv3_state;
};
Also introduce a struct SMMUv3AccelDevice to hold accelerator specific device info. This will be populated accordingly in subsequent patches. Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> --- hw/arm/smmuv3-accel.c | 36 +++++++++++++++++++++++++++++++++++ include/hw/arm/smmuv3-accel.h | 4 ++++ 2 files changed, 40 insertions(+)