Message ID | 20170403073550.29162-1-shah.suramya@gmail.com |
---|---|
State | New |
Headers | show |
On 03-Apr-2017 1:06 PM, "Suramya Shah" <shah.suramya@gmail.com> wrote: > The lance device needs pointer to ISA DMA device to operate. But according > to > qdev-properties.h, properties of pointer type should be avoided. > A link type property is a good substitution. > > Signed-off-by: Suramya Shah <shah.suramya@gmail.com> > --- > hw/net/lance.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/hw/net/lance.c b/hw/net/lance.c > index 573d724..3996b9c 100644 > --- a/hw/net/lance.c > +++ b/hw/net/lance.c > @@ -44,6 +44,7 @@ > #include "pcnet.h" > #include "trace.h" > #include "sysemu/sysemu.h" > +#include "qapi/error.h" > > #define TYPE_LANCE "lance" > #define SYSBUS_PCNET(obj) \ > @@ -145,10 +146,14 @@ static void lance_instance_init(Object *obj) > device_add_bootindex_property(obj, &s->conf.bootindex, > "bootindex", "/ethernet-phy@0", > DEVICE(obj), NULL); > + > + object_property_add_link(obj, "dma", TYPE_LANCE, > + (Object **)&d->state.dma_opaque, > + qdev_prop_allow_set_link_before_realize, > + 0, &error_abort); > } > > static Property lance_properties[] = { > - DEFINE_PROP_PTR("dma", SysBusPCNetState, state.dma_opaque), > DEFINE_NIC_PROPERTIES(SysBusPCNetState, state.conf), > DEFINE_PROP_END_OF_LIST(), > }; > @@ -164,7 +169,6 @@ static void lance_class_init(ObjectClass *klass, void > *data) > dc->reset = lance_reset; > dc->vmsd = &vmstate_lance; > dc->props = lance_properties; > - /* Reason: pointer property "dma" */ > dc->cannot_instantiate_with_device_add_yet = true; > } > > -- > 2.9.3 > >
On 3 April 2017 at 08:35, Suramya Shah <shah.suramya@gmail.com> wrote: > The lance device needs pointer to ISA DMA device to operate. But according to > qdev-properties.h, properties of pointer type should be avoided. > A link type property is a good substitution. > > Signed-off-by: Suramya Shah <shah.suramya@gmail.com> > --- > hw/net/lance.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/hw/net/lance.c b/hw/net/lance.c > index 573d724..3996b9c 100644 > --- a/hw/net/lance.c > +++ b/hw/net/lance.c > @@ -44,6 +44,7 @@ > #include "pcnet.h" > #include "trace.h" > #include "sysemu/sysemu.h" > +#include "qapi/error.h" > > #define TYPE_LANCE "lance" > #define SYSBUS_PCNET(obj) \ > @@ -145,10 +146,14 @@ static void lance_instance_init(Object *obj) > device_add_bootindex_property(obj, &s->conf.bootindex, > "bootindex", "/ethernet-phy@0", > DEVICE(obj), NULL); > + > + object_property_add_link(obj, "dma", TYPE_LANCE, > + (Object **)&d->state.dma_opaque, > + qdev_prop_allow_set_link_before_realize, > + 0, &error_abort); > } > > static Property lance_properties[] = { > - DEFINE_PROP_PTR("dma", SysBusPCNetState, state.dma_opaque), > DEFINE_NIC_PROPERTIES(SysBusPCNetState, state.conf), > DEFINE_PROP_END_OF_LIST(), > }; Hi. I'm afraid that this doesn't pass "make check": TEST: tests/qom-test... (pid=5185) /sparc/qom/SS-10: qemu-system-sparc: /home/petmay01/linaro/qemu-from-laptop/qemu/hw/core/qdev-properties.c:1037: qdev_prop_set_ptr: Assertion `prop && prop->info == &qdev_prop_ptr' failed. Broken pipe FAIL This is because you've changed the device implementation from a pointer property to a link, but you haven't changed the code that uses it, so now when that code tries to set the pointer property it crashes. It's always a good idea to use "make check" to do at least a basic test of your changes (and if you can find test images that exercise the devices you're changing that's also good, because 'make check' often doesn't cover as much as we'd like). > @@ -164,7 +169,6 @@ static void lance_class_init(ObjectClass *klass, void *data) > dc->reset = lance_reset; > dc->vmsd = &vmstate_lance; > dc->props = lance_properties; > - /* Reason: pointer property "dma" */ > dc->cannot_instantiate_with_device_add_yet = true; This comment is describing the reason why the line below it sets dc->cannot_instantiate_with_device_add_yet, so you can't remove only the comment. Either: (1) this change means it is now possible to instantiate with device-add, in which case remove both the comment and the setting of the flag, or (2) it's still not possible to instantiate with device-add, in which case update the comment to give the new reason. thanks -- PMM
diff --git a/hw/net/lance.c b/hw/net/lance.c index 573d724..3996b9c 100644 --- a/hw/net/lance.c +++ b/hw/net/lance.c @@ -44,6 +44,7 @@ #include "pcnet.h" #include "trace.h" #include "sysemu/sysemu.h" +#include "qapi/error.h" #define TYPE_LANCE "lance" #define SYSBUS_PCNET(obj) \ @@ -145,10 +146,14 @@ static void lance_instance_init(Object *obj) device_add_bootindex_property(obj, &s->conf.bootindex, "bootindex", "/ethernet-phy@0", DEVICE(obj), NULL); + + object_property_add_link(obj, "dma", TYPE_LANCE, + (Object **)&d->state.dma_opaque, + qdev_prop_allow_set_link_before_realize, + 0, &error_abort); } static Property lance_properties[] = { - DEFINE_PROP_PTR("dma", SysBusPCNetState, state.dma_opaque), DEFINE_NIC_PROPERTIES(SysBusPCNetState, state.conf), DEFINE_PROP_END_OF_LIST(), }; @@ -164,7 +169,6 @@ static void lance_class_init(ObjectClass *klass, void *data) dc->reset = lance_reset; dc->vmsd = &vmstate_lance; dc->props = lance_properties; - /* Reason: pointer property "dma" */ dc->cannot_instantiate_with_device_add_yet = true; }
The lance device needs pointer to ISA DMA device to operate. But according to qdev-properties.h, properties of pointer type should be avoided. A link type property is a good substitution. Signed-off-by: Suramya Shah <shah.suramya@gmail.com> --- hw/net/lance.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)