@samitouri / QOSamiQemu / commits / 4c7fefc2d0

hw/arm/smmuv3: Have smmuv3_accel_init() take an Error* parameter

By giving smmuv3_accel_init() the ability to populate an error, we can fail early in smmu_realize() when CONFIG_ARM_SMMUV3_ACCEL is not available, simplifying smmu_validate_property(). Suggested-by: Shameer Kolothum Thodi <skolothumtho@nvidia.com> Co-developed-by: Shameer Kolothum Thodi <skolothumtho@nvidia.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Shameer Kolothum <skolothumtho@nvidia.com> Message-Id: <20260410200031.18572-2-philmd@linaro.org>

Philippe Mathieu-Daudé committed Apr 9, 2026 at 13:35 UTC 4c7fefc2d043a66f799cf2c2e34ed680b1b44b5c
3 files changed +10 -11
hw/arm/smmuv3-accel.c
+2 -1
@@ -918,11 +918,12 @@ static void smmuv3_accel_as_init(SMMUv3State *s)
918 address_space_init(shared_as_sysmem, &root, "smmuv3-accel-as-sysmem");
919 }
920
921 -void smmuv3_accel_init(SMMUv3State *s)
921 +bool smmuv3_accel_init(SMMUv3State *s, Error **errp)
922 {
923 SMMUState *bs = ARM_SMMU(s);
924
925 s->s_accel = g_new0(SMMUv3AccelState, 1);
926 bs->iommu_ops = &smmuv3_accel_ops;
927 smmuv3_accel_as_init(s);
928 + return true;
929 }
hw/arm/smmuv3-accel.h
+5 -2
@@ -42,7 +42,7 @@ typedef struct SMMUv3AccelDevice {
42 } SMMUv3AccelDevice;
43
44 #ifdef CONFIG_ARM_SMMUV3_ACCEL
45 -void smmuv3_accel_init(SMMUv3State *s);
45 +bool smmuv3_accel_init(SMMUv3State *s, Error **errp);
46 bool smmuv3_accel_install_ste(SMMUv3State *s, SMMUDevice *sdev, int sid,
47 Error **errp);
48 bool smmuv3_accel_install_ste_range(SMMUv3State *s, SMMUSIDRange *range,
@@ -54,8 +54,11 @@ void smmuv3_accel_idr_override(SMMUv3State *s);
54 bool smmuv3_accel_alloc_veventq(SMMUv3State *s, Error **errp);
55 void smmuv3_accel_reset(SMMUv3State *s);
56 #else
57 -static inline void smmuv3_accel_init(SMMUv3State *s)
57 +#include "qapi/error.h"
58 +static inline bool smmuv3_accel_init(SMMUv3State *s, Error **errp)
59 {
60 + error_setg(errp, "accel=on support not compiled in");
61 + return false;
62 }
63 static inline bool
64 smmuv3_accel_install_ste(SMMUv3State *s, SMMUDevice *sdev, int sid,
hw/arm/smmuv3.c
+3 -8
@@ -1965,13 +1965,6 @@ static void smmu_reset_exit(Object *obj, ResetType type)
1965
1966 static bool smmu_validate_property(SMMUv3State *s, Error **errp)
1967 {
1968 -#ifndef CONFIG_ARM_SMMUV3_ACCEL
1969 - if (s->accel) {
1970 - error_setg(errp, "accel=on support not compiled in");
1971 - return false;
1972 - }
1973 -#endif
1974 -
1968 if (s->ats == ON_OFF_AUTO_AUTO) {
1969 error_setg(errp, "ats auto mode is not supported");
1970 return false;
@@ -2033,7 +2026,9 @@ static void smmu_realize(DeviceState *d, Error **errp)
2026 }
2027
2028 if (s->accel) {
2036 - smmuv3_accel_init(s);
2029 + if (!smmuv3_accel_init(s, errp)) {
2030 + return;
2031 + }
2032 error_setg(&s->migration_blocker, "Migration not supported with SMMUv3 "
2033 "accelerator mode enabled");
2034 if (migrate_add_blocker(&s->migration_blocker, errp) < 0) {