netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ieee80211softmac: Fix errors related to the work_struct changes
@ 2006-12-10 17:39 Ulrich Kunitz
  2006-12-10 17:49 ` Michael Buesch
  2006-12-11  4:24 ` Larry Finger
  0 siblings, 2 replies; 8+ messages in thread
From: Ulrich Kunitz @ 2006-12-10 17:39 UTC (permalink / raw)
  To: netdev; +Cc: Andrew Morton, John W. Linville, Johannes Berg, dsd

The signature of work functions changed recently from a context
pointer to the work structure pointer. This caused a problem in
the ieee80211softmac code, because the ieee80211softmac_assox_work
function has  been called directly with a parameter explicitly
casted to (void*). This compiled correctly but resulted in a
softlock, because mutex_lock was called with the wrong memory
address. The patch fixes the problem. Another issue was a wrong
call of the schedule_work function. Softmac works again and this
fixes the problem I mentioned earlier in the zd1211rw rx tasklet
patch. The patch is against Linus' tree (commit af1713e0).

Signed-off-by: Ulrich Kunitz <kune@deine-taler.de>
---
 net/ieee80211/softmac/ieee80211softmac_assoc.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c b/net/ieee80211/softmac/ieee80211softmac_assoc.c
index eec1a1d..a824852 100644
--- a/net/ieee80211/softmac/ieee80211softmac_assoc.c
+++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c
@@ -167,7 +167,7 @@ static void
 ieee80211softmac_assoc_notify_scan(struct net_device *dev, int event_type, void *context)
 {
 	struct ieee80211softmac_device *mac = ieee80211_priv(dev);
-	ieee80211softmac_assoc_work((void*)mac);
+	ieee80211softmac_assoc_work(&mac->associnfo.work.work);
 }
 
 static void
@@ -177,7 +177,7 @@ ieee80211softmac_assoc_notify_auth(struc
 
 	switch (event_type) {
 	case IEEE80211SOFTMAC_EVENT_AUTHENTICATED:
-		ieee80211softmac_assoc_work((void*)mac);
+		ieee80211softmac_assoc_work(&mac->associnfo.work.work);
 		break;
 	case IEEE80211SOFTMAC_EVENT_AUTH_FAILED:
 	case IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT:
@@ -438,7 +438,7 @@ ieee80211softmac_try_reassoc(struct ieee
 
 	spin_lock_irqsave(&mac->lock, flags);
 	mac->associnfo.associating = 1;
-	schedule_work(&mac->associnfo.work);
+	schedule_delayed_work(&mac->associnfo.work, 0);
 	spin_unlock_irqrestore(&mac->lock, flags);
 }

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

* Re: [PATCH] ieee80211softmac: Fix errors related to the work_struct changes
  2006-12-10 17:39 [PATCH] ieee80211softmac: Fix errors related to the work_struct changes Ulrich Kunitz
@ 2006-12-10 17:49 ` Michael Buesch
  2006-12-10 18:35   ` Ulrich Kunitz
  2006-12-11  4:24 ` Larry Finger
  1 sibling, 1 reply; 8+ messages in thread
From: Michael Buesch @ 2006-12-10 17:49 UTC (permalink / raw)
  To: Ulrich Kunitz; +Cc: netdev, Andrew Morton, John W. Linville, Johannes Berg, dsd

On Sunday 10 December 2006 18:39, Ulrich Kunitz wrote:
> The signature of work functions changed recently from a context
> pointer to the work structure pointer. This caused a problem in
> the ieee80211softmac code, because the ieee80211softmac_assox_work
> function has  been called directly with a parameter explicitly
> casted to (void*). This compiled correctly but resulted in a
> softlock, because mutex_lock was called with the wrong memory
> address. The patch fixes the problem. Another issue was a wrong
> call of the schedule_work function. Softmac works again and this
> fixes the problem I mentioned earlier in the zd1211rw rx tasklet
> patch. The patch is against Linus' tree (commit af1713e0).
> 
> Signed-off-by: Ulrich Kunitz <kune@deine-taler.de>
> ---
>  net/ieee80211/softmac/ieee80211softmac_assoc.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c b/net/ieee80211/softmac/ieee80211softmac_assoc.c
> index eec1a1d..a824852 100644
> --- a/net/ieee80211/softmac/ieee80211softmac_assoc.c
> +++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c
> @@ -167,7 +167,7 @@ static void
>  ieee80211softmac_assoc_notify_scan(struct net_device *dev, int event_type, void *context)
>  {
>  	struct ieee80211softmac_device *mac = ieee80211_priv(dev);
> -	ieee80211softmac_assoc_work((void*)mac);
> +	ieee80211softmac_assoc_work(&mac->associnfo.work.work);
>  }
>  
>  static void
> @@ -177,7 +177,7 @@ ieee80211softmac_assoc_notify_auth(struc
>  
>  	switch (event_type) {
>  	case IEEE80211SOFTMAC_EVENT_AUTHENTICATED:
> -		ieee80211softmac_assoc_work((void*)mac);
> +		ieee80211softmac_assoc_work(&mac->associnfo.work.work);
>  		break;
>  	case IEEE80211SOFTMAC_EVENT_AUTH_FAILED:
>  	case IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT:
> @@ -438,7 +438,7 @@ ieee80211softmac_try_reassoc(struct ieee
>  
>  	spin_lock_irqsave(&mac->lock, flags);
>  	mac->associnfo.associating = 1;
> -	schedule_work(&mac->associnfo.work);
> +	schedule_delayed_work(&mac->associnfo.work, 0);

Why do you use a zero delay here? What does that fix?

>  	spin_unlock_irqrestore(&mac->lock, flags);
>  }

-- 
Greetings Michael.

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

* Re: [PATCH] ieee80211softmac: Fix errors related to the work_struct changes
  2006-12-10 17:49 ` Michael Buesch
@ 2006-12-10 18:35   ` Ulrich Kunitz
  2006-12-10 18:40     ` Michael Buesch
  2006-12-10 18:40     ` Andrew Morton
  0 siblings, 2 replies; 8+ messages in thread
From: Ulrich Kunitz @ 2006-12-10 18:35 UTC (permalink / raw)
  To: Michael Buesch
  Cc: netdev, Andrew Morton, John W. Linville, Johannes Berg, dsd

On 06-12-10 18:49 Michael Buesch wrote:

> On Sunday 10 December 2006 18:39, Ulrich Kunitz wrote:
> > The signature of work functions changed recently from a context
> > pointer to the work structure pointer. This caused a problem in
> > the ieee80211softmac code, because the ieee80211softmac_assox_work
> > function has  been called directly with a parameter explicitly
> > casted to (void*). This compiled correctly but resulted in a
> > softlock, because mutex_lock was called with the wrong memory
> > address. The patch fixes the problem. Another issue was a wrong
> > call of the schedule_work function. Softmac works again and this
> > fixes the problem I mentioned earlier in the zd1211rw rx tasklet
> > patch. The patch is against Linus' tree (commit af1713e0).
> > 
> > Signed-off-by: Ulrich Kunitz <kune@deine-taler.de>
> > ---
> >  net/ieee80211/softmac/ieee80211softmac_assoc.c |    6 +++---
> >  1 files changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c b/net/ieee80211/softmac/ieee80211softmac_assoc.c
> > index eec1a1d..a824852 100644
> > --- a/net/ieee80211/softmac/ieee80211softmac_assoc.c
> > +++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c
> > @@ -167,7 +167,7 @@ static void
> >  ieee80211softmac_assoc_notify_scan(struct net_device *dev, int event_type, void *context)
> >  {
> >  	struct ieee80211softmac_device *mac = ieee80211_priv(dev);
> > -	ieee80211softmac_assoc_work((void*)mac);
> > +	ieee80211softmac_assoc_work(&mac->associnfo.work.work);
> >  }
> >  
> >  static void
> > @@ -177,7 +177,7 @@ ieee80211softmac_assoc_notify_auth(struc
> >  
> >  	switch (event_type) {
> >  	case IEEE80211SOFTMAC_EVENT_AUTHENTICATED:
> > -		ieee80211softmac_assoc_work((void*)mac);
> > +		ieee80211softmac_assoc_work(&mac->associnfo.work.work);
> >  		break;
> >  	case IEEE80211SOFTMAC_EVENT_AUTH_FAILED:
> >  	case IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT:
> > @@ -438,7 +438,7 @@ ieee80211softmac_try_reassoc(struct ieee
> >  
> >  	spin_lock_irqsave(&mac->lock, flags);
> >  	mac->associnfo.associating = 1;
> > -	schedule_work(&mac->associnfo.work);
> > +	schedule_delayed_work(&mac->associnfo.work, 0);
> 
> Why do you use a zero delay here? What does that fix?
> 

The problem is that you there are now different work structures:
struct work_struct and struct delayed_work. The quick fix seems to
have been to change all old work_structs as associnfo's work to
delayed_work. The way the structures are designed calling
schedule_work or schedule_delayed_work doesn't matter, but you
will get a gcc warning, because the pointer types are not
identical. This change works around the warning in the same way as
the other schedule_work calls for associnfo's work.

I'm not sure, whether the breaking of the workqueue API is really
worth it. What I see is that the change introduced choices and
choices make things more complex.

-- 
Uli Kunitz

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

* Re: [PATCH] ieee80211softmac: Fix errors related to the work_struct changes
  2006-12-10 18:35   ` Ulrich Kunitz
@ 2006-12-10 18:40     ` Michael Buesch
  2006-12-10 18:40     ` Andrew Morton
  1 sibling, 0 replies; 8+ messages in thread
From: Michael Buesch @ 2006-12-10 18:40 UTC (permalink / raw)
  To: Ulrich Kunitz; +Cc: dsd, Johannes Berg, John W. Linville, Andrew Morton, netdev

On Sunday 10 December 2006 19:35, Ulrich Kunitz wrote:
> On 06-12-10 18:49 Michael Buesch wrote:
> 
> > On Sunday 10 December 2006 18:39, Ulrich Kunitz wrote:
> > > The signature of work functions changed recently from a context
> > > pointer to the work structure pointer. This caused a problem in
> > > the ieee80211softmac code, because the ieee80211softmac_assox_work
> > > function has  been called directly with a parameter explicitly
> > > casted to (void*). This compiled correctly but resulted in a
> > > softlock, because mutex_lock was called with the wrong memory
> > > address. The patch fixes the problem. Another issue was a wrong
> > > call of the schedule_work function. Softmac works again and this
> > > fixes the problem I mentioned earlier in the zd1211rw rx tasklet
> > > patch. The patch is against Linus' tree (commit af1713e0).
> > > 
> > > Signed-off-by: Ulrich Kunitz <kune@deine-taler.de>
> > > ---
> > >  net/ieee80211/softmac/ieee80211softmac_assoc.c |    6 +++---
> > >  1 files changed, 3 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c b/net/ieee80211/softmac/ieee80211softmac_assoc.c
> > > index eec1a1d..a824852 100644
> > > --- a/net/ieee80211/softmac/ieee80211softmac_assoc.c
> > > +++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c
> > > @@ -167,7 +167,7 @@ static void
> > >  ieee80211softmac_assoc_notify_scan(struct net_device *dev, int event_type, void *context)
> > >  {
> > >  	struct ieee80211softmac_device *mac = ieee80211_priv(dev);
> > > -	ieee80211softmac_assoc_work((void*)mac);
> > > +	ieee80211softmac_assoc_work(&mac->associnfo.work.work);
> > >  }
> > >  
> > >  static void
> > > @@ -177,7 +177,7 @@ ieee80211softmac_assoc_notify_auth(struc
> > >  
> > >  	switch (event_type) {
> > >  	case IEEE80211SOFTMAC_EVENT_AUTHENTICATED:
> > > -		ieee80211softmac_assoc_work((void*)mac);
> > > +		ieee80211softmac_assoc_work(&mac->associnfo.work.work);
> > >  		break;
> > >  	case IEEE80211SOFTMAC_EVENT_AUTH_FAILED:
> > >  	case IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT:
> > > @@ -438,7 +438,7 @@ ieee80211softmac_try_reassoc(struct ieee
> > >  
> > >  	spin_lock_irqsave(&mac->lock, flags);
> > >  	mac->associnfo.associating = 1;
> > > -	schedule_work(&mac->associnfo.work);
> > > +	schedule_delayed_work(&mac->associnfo.work, 0);
> > 
> > Why do you use a zero delay here? What does that fix?
> > 
> 
> The problem is that you there are now different work structures:
> struct work_struct and struct delayed_work. The quick fix seems to
> have been to change all old work_structs as associnfo's work to
> delayed_work. The way the structures are designed calling
> schedule_work or schedule_delayed_work doesn't matter, but you
> will get a gcc warning, because the pointer types are not
> identical. This change works around the warning in the same way as
> the other schedule_work calls for associnfo's work.
> 
> I'm not sure, whether the breaking of the workqueue API is really
> worth it. What I see is that the change introduced choices and
> choices make things more complex.

Ah, ok. Thanks for the clarification. In this case this patch is
ACKed as well.

-- 
Greetings Michael.

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

* Re: [PATCH] ieee80211softmac: Fix errors related to the work_struct changes
  2006-12-10 18:35   ` Ulrich Kunitz
  2006-12-10 18:40     ` Michael Buesch
@ 2006-12-10 18:40     ` Andrew Morton
  2006-12-11 17:34       ` Larry Finger
  1 sibling, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2006-12-10 18:40 UTC (permalink / raw)
  To: Ulrich Kunitz
  Cc: Michael Buesch, netdev, John W. Linville, Johannes Berg, dsd

On Sun, 10 Dec 2006 19:35:36 +0100
Ulrich Kunitz <kune@deine-taler.de> wrote:

> The problem is that you there are now different work structures:
> struct work_struct and struct delayed_work. The quick fix seems to
> have been to change all old work_structs as associnfo's work to
> delayed_work. The way the structures are designed calling
> schedule_work or schedule_delayed_work doesn't matter, but you
> will get a gcc warning, because the pointer types are not
> identical. This change works around the warning in the same way as
> the other schedule_work calls for associnfo's work.

David proposed the below.  Does it fix things for you?

--- a/net/ieee80211/softmac/ieee80211softmac_assoc.c~workstruct-fix-ieee80211-softmac-compile-problem
+++ a/net/ieee80211/softmac/ieee80211softmac_assoc.c
@@ -438,7 +438,7 @@ ieee80211softmac_try_reassoc(struct ieee
 
 	spin_lock_irqsave(&mac->lock, flags);
 	mac->associnfo.associating = 1;
-	schedule_work(&mac->associnfo.work);
+	schedule_delayed_work(&mac->associnfo.work, 0);
 	spin_unlock_irqrestore(&mac->lock, flags);
 }
 
_

> I'm not sure, whether the breaking of the workqueue API is really
> worth it. What I see is that the change introduced choices and
> choices make things more complex.

It is kinda sucky.  But it saves a bit of space in kernel data structures.

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

* Re: [PATCH] ieee80211softmac: Fix errors related to the work_struct changes
  2006-12-10 17:39 [PATCH] ieee80211softmac: Fix errors related to the work_struct changes Ulrich Kunitz
  2006-12-10 17:49 ` Michael Buesch
@ 2006-12-11  4:24 ` Larry Finger
  2006-12-11 21:49   ` John W. Linville
  1 sibling, 1 reply; 8+ messages in thread
From: Larry Finger @ 2006-12-11  4:24 UTC (permalink / raw)
  To: netdev, Andrew Morton, John W. Linville, Johannes Berg, dsd
  Cc: Broadcom Linux

Ulrich Kunitz wrote:
> The signature of work functions changed recently from a context
> pointer to the work structure pointer. This caused a problem in
> the ieee80211softmac code, because the ieee80211softmac_assox_work
> function has  been called directly with a parameter explicitly
> casted to (void*). This compiled correctly but resulted in a
> softlock, because mutex_lock was called with the wrong memory
> address. The patch fixes the problem. Another issue was a wrong
> call of the schedule_work function. Softmac works again and this
> fixes the problem I mentioned earlier in the zd1211rw rx tasklet
> patch. The patch is against Linus' tree (commit af1713e0).
> 
> Signed-off-by: Ulrich Kunitz <kune@deine-taler.de>

Thanks Ulrich for this patch. I had spent the better part of 2 days bisecting Linus's git tree 
trying to isolate the problem that kept the system from booting when my bcm43xx card was installed.

I thought that when someone _BROKE_ an interface with this kind of change, it was their duty to fix 
_ALL_ parts of the system that uses this facility. At a minimum, shouldn't all maintainers get a 
heads up? I don't subscribe to LKML, but I peruse the summary and I certainly do not recall seeing a 
warning that this change was coming.

Larry

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

* Re: [PATCH] ieee80211softmac: Fix errors related to the work_struct changes
  2006-12-10 18:40     ` Andrew Morton
@ 2006-12-11 17:34       ` Larry Finger
  0 siblings, 0 replies; 8+ messages in thread
From: Larry Finger @ 2006-12-11 17:34 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Ulrich Kunitz, Michael Buesch, netdev, John W. Linville,
	Johannes Berg, dsd

Andrew Morton wrote:
> On Sun, 10 Dec 2006 19:35:36 +0100
> Ulrich Kunitz <kune@deine-taler.de> wrote:
> 
>> The problem is that you there are now different work structures:
>> struct work_struct and struct delayed_work. The quick fix seems to
>> have been to change all old work_structs as associnfo's work to
>> delayed_work. The way the structures are designed calling
>> schedule_work or schedule_delayed_work doesn't matter, but you
>> will get a gcc warning, because the pointer types are not
>> identical. This change works around the warning in the same way as
>> the other schedule_work calls for associnfo's work.
> 
> David proposed the below.  Does it fix things for you?
> 
> --- a/net/ieee80211/softmac/ieee80211softmac_assoc.c~workstruct-fix-ieee80211-softmac-compile-problem
> +++ a/net/ieee80211/softmac/ieee80211softmac_assoc.c
> @@ -438,7 +438,7 @@ ieee80211softmac_try_reassoc(struct ieee
>  
>  	spin_lock_irqsave(&mac->lock, flags);
>  	mac->associnfo.associating = 1;
> -	schedule_work(&mac->associnfo.work);
> +	schedule_delayed_work(&mac->associnfo.work, 0);
>  	spin_unlock_irqrestore(&mac->lock, flags);
>  }
>  
> _
> 
>> I'm not sure, whether the breaking of the workqueue API is really
>> worth it. What I see is that the change introduced choices and
>> choices make things more complex.
> 
> It is kinda sucky.  But it saves a bit of space in kernel data structures.

The above patch fixes a compile problem; however, the code still hangs when the network is started.
You need two additional hunks as shown below.

Larry
=========================================================================

From: Ulrich Kunitz <kune@deine-taler.de>

The signature of work functions changed recently from a context
pointer to the work structure pointer. This caused a problem in
the ieee80211softmac code, because the ieee80211softmac_assoc_work
function has  been called directly with a parameter explicitly
casted to (void*). This compiled correctly but resulted in a
softlock, because mutex_lock was called with the wrong memory
address. The patch fixes the problem. Another issue was a wrong
call of the schedule_work function. Softmac works again and this
fixes the problem I mentioned earlier in the zd1211rw rx tasklet
patch. The patch is against Linus' tree (commit af1713e0).

Signed-off-by: Ulrich Kunitz <kune@deine-taler.de>
Acked-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---

diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c 
b/net/ieee80211/softmac/ieee80211softmac_assoc.c
index eec1a1d..a824852 100644
--- a/net/ieee80211/softmac/ieee80211softmac_assoc.c
+++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c
@@ -167,7 +167,7 @@ static void
  ieee80211softmac_assoc_notify_scan(struct net_device *dev, int event_type, void *context)
  {
  	struct ieee80211softmac_device *mac = ieee80211_priv(dev);
-	ieee80211softmac_assoc_work((void*)mac);
+	ieee80211softmac_assoc_work(&mac->associnfo.work.work);
  }

  static void
@@ -177,7 +177,7 @@ ieee80211softmac_assoc_notify_auth(struc

  	switch (event_type) {
  	case IEEE80211SOFTMAC_EVENT_AUTHENTICATED:
-		ieee80211softmac_assoc_work((void*)mac);
+		ieee80211softmac_assoc_work(&mac->associnfo.work.work);
  		break;
  	case IEEE80211SOFTMAC_EVENT_AUTH_FAILED:
  	case IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT:

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

* Re: [PATCH] ieee80211softmac: Fix errors related to the work_struct changes
  2006-12-11  4:24 ` Larry Finger
@ 2006-12-11 21:49   ` John W. Linville
  0 siblings, 0 replies; 8+ messages in thread
From: John W. Linville @ 2006-12-11 21:49 UTC (permalink / raw)
  To: Larry Finger; +Cc: netdev, Andrew Morton, Johannes Berg, dsd, Broadcom Linux

On Sun, Dec 10, 2006 at 10:24:27PM -0600, Larry Finger wrote:

> I thought that when someone _BROKE_ an interface with this kind of change, 
> it was their duty to fix _ALL_ parts of the system that uses this facility. 
> At a minimum, shouldn't all maintainers get a heads up? I don't subscribe 
> to LKML, but I peruse the summary and I certainly do not recall seeing a 
> warning that this change was coming.

FWIW, there was some coverage on LWN.

-- 
John W. Linville
linville@tuxdriver.com

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

end of thread, other threads:[~2006-12-11 22:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-10 17:39 [PATCH] ieee80211softmac: Fix errors related to the work_struct changes Ulrich Kunitz
2006-12-10 17:49 ` Michael Buesch
2006-12-10 18:35   ` Ulrich Kunitz
2006-12-10 18:40     ` Michael Buesch
2006-12-10 18:40     ` Andrew Morton
2006-12-11 17:34       ` Larry Finger
2006-12-11  4:24 ` Larry Finger
2006-12-11 21:49   ` John W. Linville

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