diff mbox series

[02/11] net: etraxfs_eth: add a reset method

Message ID 20180928135003.8650-3-clg@kaod.org (mailing list archive)
State New, archived
Headers show
Series net: convert SysBus init method to a realize method | expand

Commit Message

Cédric Le Goater Sept. 28, 2018, 1:49 p.m. UTC
Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/net/etraxfs_eth.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Peter Maydell Sept. 28, 2018, 2:47 p.m. UTC | #1
On 28 September 2018 at 14:49, Cédric Le Goater <clg@kaod.org> wrote:
> Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  hw/net/etraxfs_eth.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c
> index 64ab3df1ae38..552a18c7c730 100644
> --- a/hw/net/etraxfs_eth.c
> +++ b/hw/net/etraxfs_eth.c
> @@ -585,6 +585,13 @@ static NetClientInfo net_etraxfs_info = {
>      .link_status_changed = eth_set_link,
>  };
>
> +static void etraxfs_eth_reset(DeviceState *dev)
> +{
> +    ETRAXFSEthState *s = ETRAX_FS_ETH(dev);
> +
> +    tdk_init(&s->phy);
> +}
> +
>  static void etraxfs_eth_realize(DeviceState *dev, Error **errp)
>  {
>      SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
> @@ -609,8 +616,6 @@ static void etraxfs_eth_realize(DeviceState *dev, Error **errp)
>                            object_get_typename(OBJECT(s)), dev->id, s);
>      qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
>
> -
> -    tdk_init(&s->phy);
>      mdio_attach(&s->mdio_bus, &s->phy, s->phyaddr);
>  }
>
> @@ -627,6 +632,7 @@ static void etraxfs_eth_class_init(ObjectClass *klass, void *data)
>      DeviceClass *dc = DEVICE_CLASS(klass);
>
>      dc->realize = etraxfs_eth_realize;
> +    dc->reset = etraxfs_eth_reset;
>      dc->props = etraxfs_eth_properties;
>      /* Reason: pointer properties "dma_out", "dma_in" */
>      dc->user_creatable = false;

This device definitely needs a reset method, but I'm pretty sure
that we need to do more than just call tdk_init(). eth->regs[]
needs to be reset, and very likely other state too.

thanks
-- PMM
Cédric Le Goater Sept. 28, 2018, 3:15 p.m. UTC | #2
On 9/28/18 4:47 PM, Peter Maydell wrote:
> On 28 September 2018 at 14:49, Cédric Le Goater <clg@kaod.org> wrote:
>> Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>  hw/net/etraxfs_eth.c | 10 ++++++++--
>>  1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c
>> index 64ab3df1ae38..552a18c7c730 100644
>> --- a/hw/net/etraxfs_eth.c
>> +++ b/hw/net/etraxfs_eth.c
>> @@ -585,6 +585,13 @@ static NetClientInfo net_etraxfs_info = {
>>      .link_status_changed = eth_set_link,
>>  };
>>
>> +static void etraxfs_eth_reset(DeviceState *dev)
>> +{
>> +    ETRAXFSEthState *s = ETRAX_FS_ETH(dev);
>> +
>> +    tdk_init(&s->phy);
>> +}
>> +
>>  static void etraxfs_eth_realize(DeviceState *dev, Error **errp)
>>  {
>>      SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
>> @@ -609,8 +616,6 @@ static void etraxfs_eth_realize(DeviceState *dev, Error **errp)
>>                            object_get_typename(OBJECT(s)), dev->id, s);
>>      qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
>>
>> -
>> -    tdk_init(&s->phy);
>>      mdio_attach(&s->mdio_bus, &s->phy, s->phyaddr);
>>  }
>>
>> @@ -627,6 +632,7 @@ static void etraxfs_eth_class_init(ObjectClass *klass, void *data)
>>      DeviceClass *dc = DEVICE_CLASS(klass);
>>
>>      dc->realize = etraxfs_eth_realize;
>> +    dc->reset = etraxfs_eth_reset;
>>      dc->props = etraxfs_eth_properties;
>>      /* Reason: pointer properties "dma_out", "dma_in" */
>>      dc->user_creatable = false;
> 
> This device definitely needs a reset method, but I'm pretty sure
> that we need to do more than just call tdk_init(). eth->regs[]
> needs to be reset, and very likely other state too.

Yes. That was a start with obvious calls from the former init routine. 

Thanks,

C. 

> 
> thanks
> -- PMM
>
diff mbox series

Patch

diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c
index 64ab3df1ae38..552a18c7c730 100644
--- a/hw/net/etraxfs_eth.c
+++ b/hw/net/etraxfs_eth.c
@@ -585,6 +585,13 @@  static NetClientInfo net_etraxfs_info = {
     .link_status_changed = eth_set_link,
 };
 
+static void etraxfs_eth_reset(DeviceState *dev)
+{
+    ETRAXFSEthState *s = ETRAX_FS_ETH(dev);
+
+    tdk_init(&s->phy);
+}
+
 static void etraxfs_eth_realize(DeviceState *dev, Error **errp)
 {
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
@@ -609,8 +616,6 @@  static void etraxfs_eth_realize(DeviceState *dev, Error **errp)
                           object_get_typename(OBJECT(s)), dev->id, s);
     qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
 
-
-    tdk_init(&s->phy);
     mdio_attach(&s->mdio_bus, &s->phy, s->phyaddr);
 }
 
@@ -627,6 +632,7 @@  static void etraxfs_eth_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = etraxfs_eth_realize;
+    dc->reset = etraxfs_eth_reset;
     dc->props = etraxfs_eth_properties;
     /* Reason: pointer properties "dma_out", "dma_in" */
     dc->user_creatable = false;