> -----Original Message----- > From: Daniel P. Berrangé <berra...@redhat.com> > Sent: Thursday, January 30, 2025 4:30 PM > To: Shameerali Kolothum Thodi <shameerali.kolothum.th...@huawei.com> > Cc: qemu-...@nongnu.org; qemu-devel@nongnu.org; > eric.au...@redhat.com; peter.mayd...@linaro.org; j...@nvidia.com; > nicol...@nvidia.com; ddut...@redhat.com; Linuxarm > <linux...@huawei.com>; Wangzhou (B) <wangzh...@hisilicon.com>; > jiangkunkun <jiangkun...@huawei.com>; Jonathan Cameron > <jonathan.came...@huawei.com>; zhangfei....@linaro.org > Subject: Re: [RFC PATCH 3/5] hw/arm/smmuv3: Associate a pci bus with a > SMMUv3 Nested device > > On Fri, Nov 08, 2024 at 12:52:40PM +0000, Shameer Kolothum via wrote: > > Subsequent patches will add IORT modifications to get this working. > > > > Signed-off-by: Shameer Kolothum > <shameerali.kolothum.th...@huawei.com> > > --- > > hw/arm/smmuv3.c | 27 +++++++++++++++++++++++++++ > > include/hw/arm/smmuv3.h | 2 ++ > > 2 files changed, 29 insertions(+) > > > > diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c > > index 0033eb8125..9b0a776769 100644 > > --- a/hw/arm/smmuv3.c > > +++ b/hw/arm/smmuv3.c > > @@ -24,6 +24,7 @@ > > #include "hw/qdev-properties.h" > > #include "hw/qdev-core.h" > > #include "hw/pci/pci.h" > > +#include "hw/pci/pci_bridge.h" > > #include "cpu.h" > > #include "trace.h" > > #include "qemu/log.h" > > @@ -2201,12 +2202,32 @@ static void smmu_realize(DeviceState *d, > Error **errp) > > smmu_init_irq(s, dev); > > } > > > > +static int smmuv3_nested_pci_host_bridge(Object *obj, void *opaque) > > +{ > > + DeviceState *d = opaque; > > + SMMUv3NestedState *s_nested = ARM_SMMUV3_NESTED(d); > > + > > + if (object_dynamic_cast(obj, TYPE_PCI_HOST_BRIDGE)) { > > + PCIBus *bus = PCI_HOST_BRIDGE(obj)->bus; > > + if (s_nested->pci_bus && !strcmp(bus->qbus.name, s_nested- > >pci_bus)) { > > + object_property_set_link(OBJECT(d), "primary-bus", OBJECT(bus), > > + &error_abort); > > Is the SMMUv3Nested useful if no 'primary-bus' is set ? > > If not, then the 'realize' method ought to validate 'pci-bus' is not > NULL and and raise an error if NULL. > > After object_child_foreach_recursive returns, 'realize' should > also validate that 'primary-bus' has been set, and raise an error > it not set, to detect typos in the 'pci-bus' property.
I think that gets checked in the parent->realize() smmu_base_realize() if (s->primary_bus) { pci_setup_iommu(s->primary_bus, &smmu_ops, s); } else { error_setg(errp, "SMMU is not attached to any PCI bus!"); } I will double check if that covers all the corner cases or not. Thanks, Shameer