Browse Source
Set up dedicated PCIIOMMUOps for the accel SMMUv3, since it will need different callback handling in upcoming patches. This also adds a CONFIG_ARM_SMMUV3_ACCEL build option so the feature can be disabled at compile time. Because we now include CONFIG_DEVICES in the header to check for ARM_SMMUV3_ACCEL, the meson file entry for smmuv3.c needs to be changed to arm_ss.add. The “accel” property isn’t user visible yet and it will be introduced in a later patch once all the supporting pieces are ready. Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Tested-by: Zhangfei Gao <zhangfei.gao@linaro.org> Tested-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Shameer Kolothum <skolothumtho@nvidia.com> Message-id: 20260126104342.253965-6-skolothumtho@nvidia.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>pull/319/head
committed by
Peter Maydell
6 changed files with 101 additions and 1 deletions
@ -0,0 +1,59 @@ |
|||
/*
|
|||
* Copyright (c) 2025 Huawei Technologies R & D (UK) Ltd |
|||
* Copyright (C) 2025 NVIDIA |
|||
* Written by Nicolin Chen, Shameer Kolothum |
|||
* |
|||
* SPDX-License-Identifier: GPL-2.0-or-later |
|||
*/ |
|||
|
|||
#include "qemu/osdep.h" |
|||
|
|||
#include "hw/arm/smmuv3.h" |
|||
#include "smmuv3-accel.h" |
|||
|
|||
static SMMUv3AccelDevice *smmuv3_accel_get_dev(SMMUState *bs, SMMUPciBus *sbus, |
|||
PCIBus *bus, int devfn) |
|||
{ |
|||
SMMUDevice *sdev = sbus->pbdev[devfn]; |
|||
SMMUv3AccelDevice *accel_dev; |
|||
|
|||
if (sdev) { |
|||
return container_of(sdev, SMMUv3AccelDevice, sdev); |
|||
} |
|||
|
|||
accel_dev = g_new0(SMMUv3AccelDevice, 1); |
|||
sdev = &accel_dev->sdev; |
|||
|
|||
sbus->pbdev[devfn] = sdev; |
|||
smmu_init_sdev(bs, sdev, bus, devfn); |
|||
return accel_dev; |
|||
} |
|||
|
|||
/*
|
|||
* Find or add an address space for the given PCI device. |
|||
* |
|||
* If a device matching @bus and @devfn already exists, return its |
|||
* corresponding address space. Otherwise, create a new device entry |
|||
* and initialize address space for it. |
|||
*/ |
|||
static AddressSpace *smmuv3_accel_find_add_as(PCIBus *bus, void *opaque, |
|||
int devfn) |
|||
{ |
|||
SMMUState *bs = opaque; |
|||
SMMUPciBus *sbus = smmu_get_sbus(bs, bus); |
|||
SMMUv3AccelDevice *accel_dev = smmuv3_accel_get_dev(bs, sbus, bus, devfn); |
|||
SMMUDevice *sdev = &accel_dev->sdev; |
|||
|
|||
return &sdev->as; |
|||
} |
|||
|
|||
static const PCIIOMMUOps smmuv3_accel_ops = { |
|||
.get_address_space = smmuv3_accel_find_add_as, |
|||
}; |
|||
|
|||
void smmuv3_accel_init(SMMUv3State *s) |
|||
{ |
|||
SMMUState *bs = ARM_SMMU(s); |
|||
|
|||
bs->iommu_ops = &smmuv3_accel_ops; |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
/*
|
|||
* Copyright (c) 2025 Huawei Technologies R & D (UK) Ltd |
|||
* Copyright (C) 2025 NVIDIA |
|||
* Written by Nicolin Chen, Shameer Kolothum |
|||
* |
|||
* SPDX-License-Identifier: GPL-2.0-or-later |
|||
*/ |
|||
|
|||
#ifndef HW_ARM_SMMUV3_ACCEL_H |
|||
#define HW_ARM_SMMUV3_ACCEL_H |
|||
|
|||
#include "hw/arm/smmu-common.h" |
|||
#include CONFIG_DEVICES |
|||
|
|||
typedef struct SMMUv3AccelDevice { |
|||
SMMUDevice sdev; |
|||
} SMMUv3AccelDevice; |
|||
|
|||
#ifdef CONFIG_ARM_SMMUV3_ACCEL |
|||
void smmuv3_accel_init(SMMUv3State *s); |
|||
#else |
|||
static inline void smmuv3_accel_init(SMMUv3State *s) |
|||
{ |
|||
} |
|||
#endif |
|||
|
|||
#endif /* HW_ARM_SMMUV3_ACCEL_H */ |
|||
Loading…
Reference in new issue