* [PATCH net] net: hyperv: initialize link status correctly
@ 2014-01-27 7:30 Jason Wang
2014-01-27 8:35 ` David Miller
2014-01-27 16:05 ` Haiyang Zhang
0 siblings, 2 replies; 8+ messages in thread
From: Jason Wang @ 2014-01-27 7:30 UTC (permalink / raw)
To: kys, haiyangz, devel, netdev, linux-kernel; +Cc: Jason Wang
Call netif_carrier_on() after register_device(). Otherwise it won't work since
the device was still in NETREG_UNINITIALIZED state.
Fixes a68f9614614749727286f675d15f1e09d13cb54a
(hyperv: Fix race between probe and open calls)
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Reported-by: Di Nie <dnie@redhat.com>
Tested-by: Di Nie <dnie@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
drivers/net/hyperv/netvsc_drv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 71baeb3..dc11601 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -444,13 +444,13 @@ static int netvsc_probe(struct hv_device *dev,
}
memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN);
- netif_carrier_on(net);
-
ret = register_netdev(net);
if (ret != 0) {
pr_err("Unable to register netdev.\n");
rndis_filter_device_remove(dev);
free_netdev(net);
+ } else {
+ netif_carrier_on(net);
}
return ret;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net] net: hyperv: initialize link status correctly
2014-01-27 7:30 [PATCH net] net: hyperv: initialize link status correctly Jason Wang
@ 2014-01-27 8:35 ` David Miller
2014-01-27 9:40 ` Jason Wang
2014-01-27 16:05 ` Haiyang Zhang
1 sibling, 1 reply; 8+ messages in thread
From: David Miller @ 2014-01-27 8:35 UTC (permalink / raw)
To: jasowang; +Cc: devel, haiyangz, linux-kernel, netdev
From: Jason Wang <jasowang@redhat.com>
Date: Mon, 27 Jan 2014 15:30:54 +0800
> Call netif_carrier_on() after register_device(). Otherwise it won't work since
> the device was still in NETREG_UNINITIALIZED state.
>
> Fixes a68f9614614749727286f675d15f1e09d13cb54a
> (hyperv: Fix race between probe and open calls)
>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: K. Y. Srinivasan <kys@microsoft.com>
> Reported-by: Di Nie <dnie@redhat.com>
> Tested-by: Di Nie <dnie@redhat.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
A device up can occur at the moment you call register_netdevice(),
therefore that up call can see the carrier as down and fail or
similar. So you really cannot resolve the carrier to be on in this
way.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net] net: hyperv: initialize link status correctly
2014-01-27 8:35 ` David Miller
@ 2014-01-27 9:40 ` Jason Wang
2014-01-27 10:22 ` Ben Hutchings
0 siblings, 1 reply; 8+ messages in thread
From: Jason Wang @ 2014-01-27 9:40 UTC (permalink / raw)
To: David Miller; +Cc: devel, haiyangz, linux-kernel, netdev
On 01/27/2014 04:35 PM, David Miller wrote:
> From: Jason Wang <jasowang@redhat.com>
> Date: Mon, 27 Jan 2014 15:30:54 +0800
>
>> Call netif_carrier_on() after register_device(). Otherwise it won't work since
>> the device was still in NETREG_UNINITIALIZED state.
>>
>> Fixes a68f9614614749727286f675d15f1e09d13cb54a
>> (hyperv: Fix race between probe and open calls)
>>
>> Cc: Haiyang Zhang <haiyangz@microsoft.com>
>> Cc: K. Y. Srinivasan <kys@microsoft.com>
>> Reported-by: Di Nie <dnie@redhat.com>
>> Tested-by: Di Nie <dnie@redhat.com>
>> Signed-off-by: Jason Wang <jasowang@redhat.com>
> A device up can occur at the moment you call register_netdevice(),
> therefore that up call can see the carrier as down and fail or
> similar. So you really cannot resolve the carrier to be on in this
> way.
True, we need a workqueue to synchronize them.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net] net: hyperv: initialize link status correctly
2014-01-27 9:40 ` Jason Wang
@ 2014-01-27 10:22 ` Ben Hutchings
2014-01-27 10:28 ` Jason Wang
0 siblings, 1 reply; 8+ messages in thread
From: Ben Hutchings @ 2014-01-27 10:22 UTC (permalink / raw)
To: Jason Wang; +Cc: netdev, haiyangz, linux-kernel, devel, David Miller
[-- Attachment #1.1: Type: text/plain, Size: 1274 bytes --]
On Mon, 2014-01-27 at 17:40 +0800, Jason Wang wrote:
> On 01/27/2014 04:35 PM, David Miller wrote:
> > From: Jason Wang <jasowang@redhat.com>
> > Date: Mon, 27 Jan 2014 15:30:54 +0800
> >
> >> Call netif_carrier_on() after register_device(). Otherwise it won't work since
> >> the device was still in NETREG_UNINITIALIZED state.
> >>
> >> Fixes a68f9614614749727286f675d15f1e09d13cb54a
> >> (hyperv: Fix race between probe and open calls)
> >>
> >> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> >> Cc: K. Y. Srinivasan <kys@microsoft.com>
> >> Reported-by: Di Nie <dnie@redhat.com>
> >> Tested-by: Di Nie <dnie@redhat.com>
> >> Signed-off-by: Jason Wang <jasowang@redhat.com>
> > A device up can occur at the moment you call register_netdevice(),
> > therefore that up call can see the carrier as down and fail or
> > similar. So you really cannot resolve the carrier to be on in this
> > way.
>
> True, we need a workqueue to synchronize them.
Whatever for? All you need to do is:
rtnl_lock();
register_netdevice();
netif_carrier_on();
rtnl_unlock();
It would be nice if we could make the current code work with a change in
the core, though.
Ben.
--
Ben Hutchings
If at first you don't succeed, you're doing about average.
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
[-- Attachment #2: Type: text/plain, Size: 169 bytes --]
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net] net: hyperv: initialize link status correctly
2014-01-27 10:22 ` Ben Hutchings
@ 2014-01-27 10:28 ` Jason Wang
2014-01-27 10:30 ` Ben Hutchings
0 siblings, 1 reply; 8+ messages in thread
From: Jason Wang @ 2014-01-27 10:28 UTC (permalink / raw)
To: Ben Hutchings; +Cc: netdev, haiyangz, linux-kernel, devel, David Miller
On 01/27/2014 06:22 PM, Ben Hutchings wrote:
> On Mon, 2014-01-27 at 17:40 +0800, Jason Wang wrote:
>> On 01/27/2014 04:35 PM, David Miller wrote:
>>> From: Jason Wang <jasowang@redhat.com>
>>> Date: Mon, 27 Jan 2014 15:30:54 +0800
>>>
>>>> Call netif_carrier_on() after register_device(). Otherwise it won't work since
>>>> the device was still in NETREG_UNINITIALIZED state.
>>>>
>>>> Fixes a68f9614614749727286f675d15f1e09d13cb54a
>>>> (hyperv: Fix race between probe and open calls)
>>>>
>>>> Cc: Haiyang Zhang <haiyangz@microsoft.com>
>>>> Cc: K. Y. Srinivasan <kys@microsoft.com>
>>>> Reported-by: Di Nie <dnie@redhat.com>
>>>> Tested-by: Di Nie <dnie@redhat.com>
>>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>>> A device up can occur at the moment you call register_netdevice(),
>>> therefore that up call can see the carrier as down and fail or
>>> similar. So you really cannot resolve the carrier to be on in this
>>> way.
>> True, we need a workqueue to synchronize them.
> Whatever for? All you need to do is:
>
> rtnl_lock();
> register_netdevice();
> netif_carrier_on();
> rtnl_unlock();
>
> It would be nice if we could make the current code work with a change in
> the core, though.
>
> Ben.
>
Looks like the link status interrupt may happen during this (after
netvsc_device_add() was called by rndis_filter_device_add()) without any
synchronization. This may lead a wrong link status here.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net] net: hyperv: initialize link status correctly
2014-01-27 10:28 ` Jason Wang
@ 2014-01-27 10:30 ` Ben Hutchings
2014-01-27 10:37 ` Jason Wang
0 siblings, 1 reply; 8+ messages in thread
From: Ben Hutchings @ 2014-01-27 10:30 UTC (permalink / raw)
To: Jason Wang; +Cc: netdev, haiyangz, linux-kernel, devel, David Miller
[-- Attachment #1.1: Type: text/plain, Size: 1785 bytes --]
On Mon, 2014-01-27 at 18:28 +0800, Jason Wang wrote:
> On 01/27/2014 06:22 PM, Ben Hutchings wrote:
> > On Mon, 2014-01-27 at 17:40 +0800, Jason Wang wrote:
> >> On 01/27/2014 04:35 PM, David Miller wrote:
> >>> From: Jason Wang <jasowang@redhat.com>
> >>> Date: Mon, 27 Jan 2014 15:30:54 +0800
> >>>
> >>>> Call netif_carrier_on() after register_device(). Otherwise it won't work since
> >>>> the device was still in NETREG_UNINITIALIZED state.
> >>>>
> >>>> Fixes a68f9614614749727286f675d15f1e09d13cb54a
> >>>> (hyperv: Fix race between probe and open calls)
> >>>>
> >>>> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> >>>> Cc: K. Y. Srinivasan <kys@microsoft.com>
> >>>> Reported-by: Di Nie <dnie@redhat.com>
> >>>> Tested-by: Di Nie <dnie@redhat.com>
> >>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
> >>> A device up can occur at the moment you call register_netdevice(),
> >>> therefore that up call can see the carrier as down and fail or
> >>> similar. So you really cannot resolve the carrier to be on in this
> >>> way.
> >> True, we need a workqueue to synchronize them.
> > Whatever for? All you need to do is:
> >
> > rtnl_lock();
> > register_netdevice();
> > netif_carrier_on();
> > rtnl_unlock();
> >
> > It would be nice if we could make the current code work with a change in
> > the core, though.
> >
> > Ben.
> >
>
> Looks like the link status interrupt may happen during this (after
> netvsc_device_add() was called by rndis_filter_device_add()) without any
> synchronization. This may lead a wrong link status here.
Now I'm confused - if there's a link status interrupt, why are you
setting the carrier on initially?
Ben.
--
Ben Hutchings
If at first you don't succeed, you're doing about average.
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
[-- Attachment #2: Type: text/plain, Size: 169 bytes --]
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net] net: hyperv: initialize link status correctly
2014-01-27 10:30 ` Ben Hutchings
@ 2014-01-27 10:37 ` Jason Wang
0 siblings, 0 replies; 8+ messages in thread
From: Jason Wang @ 2014-01-27 10:37 UTC (permalink / raw)
To: Ben Hutchings; +Cc: netdev, haiyangz, linux-kernel, devel, David Miller
On 01/27/2014 06:30 PM, Ben Hutchings wrote:
> On Mon, 2014-01-27 at 18:28 +0800, Jason Wang wrote:
>> On 01/27/2014 06:22 PM, Ben Hutchings wrote:
>>> On Mon, 2014-01-27 at 17:40 +0800, Jason Wang wrote:
>>>> On 01/27/2014 04:35 PM, David Miller wrote:
>>>>> From: Jason Wang <jasowang@redhat.com>
>>>>> Date: Mon, 27 Jan 2014 15:30:54 +0800
>>>>>
>>>>>> Call netif_carrier_on() after register_device(). Otherwise it won't work since
>>>>>> the device was still in NETREG_UNINITIALIZED state.
>>>>>>
>>>>>> Fixes a68f9614614749727286f675d15f1e09d13cb54a
>>>>>> (hyperv: Fix race between probe and open calls)
>>>>>>
>>>>>> Cc: Haiyang Zhang <haiyangz@microsoft.com>
>>>>>> Cc: K. Y. Srinivasan <kys@microsoft.com>
>>>>>> Reported-by: Di Nie <dnie@redhat.com>
>>>>>> Tested-by: Di Nie <dnie@redhat.com>
>>>>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>>>>> A device up can occur at the moment you call register_netdevice(),
>>>>> therefore that up call can see the carrier as down and fail or
>>>>> similar. So you really cannot resolve the carrier to be on in this
>>>>> way.
>>>> True, we need a workqueue to synchronize them.
>>> Whatever for? All you need to do is:
>>>
>>> rtnl_lock();
>>> register_netdevice();
>>> netif_carrier_on();
>>> rtnl_unlock();
>>>
>>> It would be nice if we could make the current code work with a change in
>>> the core, though.
>>>
>>> Ben.
>>>
>> Looks like the link status interrupt may happen during this (after
>> netvsc_device_add() was called by rndis_filter_device_add()) without any
>> synchronization. This may lead a wrong link status here.
> Now I'm confused - if there's a link status interrupt, why are you
> setting the carrier on initially?
>
> Ben.
>
I realize that setting carrier on initially was a bug after David's
comment. So I think we need a workqueue.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH net] net: hyperv: initialize link status correctly
2014-01-27 7:30 [PATCH net] net: hyperv: initialize link status correctly Jason Wang
2014-01-27 8:35 ` David Miller
@ 2014-01-27 16:05 ` Haiyang Zhang
1 sibling, 0 replies; 8+ messages in thread
From: Haiyang Zhang @ 2014-01-27 16:05 UTC (permalink / raw)
To: Jason Wang, KY Srinivasan, devel@linuxdriverproject.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
> -----Original Message-----
> From: Jason Wang [mailto:jasowang@redhat.com]
> Sent: Monday, January 27, 2014 2:31 AM
> To: KY Srinivasan; Haiyang Zhang; devel@linuxdriverproject.org;
> netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Cc: Jason Wang
> Subject: [PATCH net] net: hyperv: initialize link status correctly
>
> Call netif_carrier_on() after register_device(). Otherwise it won't work since
> the device was still in NETREG_UNINITIALIZED state.
>
> Fixes a68f9614614749727286f675d15f1e09d13cb54a
> (hyperv: Fix race between probe and open calls)
>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: K. Y. Srinivasan <kys@microsoft.com>
> Reported-by: Di Nie <dnie@redhat.com>
> Tested-by: Di Nie <dnie@redhat.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
I'm working on a fix for this, and will submit it soon.
Thanks,
- Haiyang
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-01-27 16:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-27 7:30 [PATCH net] net: hyperv: initialize link status correctly Jason Wang
2014-01-27 8:35 ` David Miller
2014-01-27 9:40 ` Jason Wang
2014-01-27 10:22 ` Ben Hutchings
2014-01-27 10:28 ` Jason Wang
2014-01-27 10:30 ` Ben Hutchings
2014-01-27 10:37 ` Jason Wang
2014-01-27 16:05 ` Haiyang Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).