All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/net: convert "dma" property type from ptr to link
@ 2017-04-03  7:35 Suramya Shah
  2017-04-03 14:14 ` Suramya Shah
  2017-04-03 14:41 ` Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Suramya Shah @ 2017-04-03  7:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Suramya Shah

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/net: convert "dma" property type from ptr to link
  2017-04-03  7:35 [Qemu-devel] [PATCH] hw/net: convert "dma" property type from ptr to link Suramya Shah
@ 2017-04-03 14:14 ` Suramya Shah
  2017-04-03 14:41 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Suramya Shah @ 2017-04-03 14:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: jasowang

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
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/net: convert "dma" property type from ptr to link
  2017-04-03  7:35 [Qemu-devel] [PATCH] hw/net: convert "dma" property type from ptr to link Suramya Shah
  2017-04-03 14:14 ` Suramya Shah
@ 2017-04-03 14:41 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2017-04-03 14:41 UTC (permalink / raw)
  To: Suramya Shah; +Cc: QEMU Developers, Jason Wang

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-03 14:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-03  7:35 [Qemu-devel] [PATCH] hw/net: convert "dma" property type from ptr to link Suramya Shah
2017-04-03 14:14 ` Suramya Shah
2017-04-03 14:41 ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.