Skip to contentSkip to conversation

b43: fix ieee80211_rx() context

PATCH In review Johannes Berg 8 participants 15 messages Oct 11, 2009 – Oct 12, 2009 Networking drivers (wireless)

lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

PATCH 1/1 b43: fix ieee80211_rx() context

Due to the way it interacts with the networking stack and other parts of mac80211, ieee80211_rx() must be called with disabled softirqs.

Michael, the former maintainer of this driver, has refused to fix the problem this way instead proposing a much more invasive patch that could not even be proved correct wrt. locking inside mac80211. Regardless of that, he believes this to be a bug in mac80211, and has also publicly stated [1] that he does not care about this even though it is a regression introduced by his own patches.

Since nobody else seems to be wanting to fix the problem, I'll just fix it for the benefit of the many users of this driver.

[1] http://thread.gmane.org/gmane.linux.kernel.wireless.general/39440/focus=40266

---
 drivers/net/wireless/b43/xmit.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/net/wireless/b43/xmit.c +3 -0
@@ -690,7 +690,10 @@ void b43_rx(struct b43_wldev *dev, struc
 	}
 
 	memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status));
+
+	local_bh_disable();
 	ieee80211_rx(dev->wl->hw, skb);
+	local_bh_enable();
 
 #if B43_DEBUG
 	dev->rx_count++;
#1 lore raw
Quoted 3 lines · On Sunday 11 October 2009 12:19:21 Johannes Berg wrote:

Due to the way it interacts with the networking stack and other parts of mac80211, ieee80211_rx() must be called with disabled softirqs.

Is this stated in the documentation somewhere?

Quoted 9 lines

Michael, the former maintainer of this driver, has refused to fix the problem this way instead proposing a much more invasive patch that could not even be proved correct wrt. locking inside mac80211. Regardless of that, he believes this to be a bug in mac80211, and has also publicly stated [1] that he does not care about this even though it is a regression introduced by his own patches.

What if we leave slander out of the commit messages?

Quoted 25 lines

Since nobody else seems to be wanting to fix the problem, I'll just fix it for the benefit of the many users of this driver.

[1] http://thread.gmane.org/gmane.linux.kernel.wireless.general/39440/focus=40266

---
 drivers/net/wireless/b43/xmit.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/net/wireless/b43/xmit.c +3 -0
@@ -690,7 +690,10 @@ void b43_rx(struct b43_wldev *dev, struc
 	}
 
 	memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status));
+
+	local_bh_disable();
 	ieee80211_rx(dev->wl->hw, skb);
+	local_bh_enable();
 
 #if B43_DEBUG
 	dev->rx_count++;
Signature · 1 line
Greetings, Michael.
author maintainer
#2 lore raw
Quoted 6 lines · Michael Buesch
Quoted 3 lines · On Sunday 11 October 2009 12:19:21 Johannes Berg wrote:

Due to the way it interacts with the networking stack and other parts of mac80211, ieee80211_rx() must be called with disabled softirqs.

Is this stated in the documentation somewhere?

No. However, there are many things that aren't in the documentation, I'm working on a patch to add a note.

Quoted 11 lines
Quoted 9 lines

Michael, the former maintainer of this driver, has refused to fix the problem this way instead proposing a much more invasive patch that could not even be proved correct wrt. locking inside mac80211. Regardless of that, he believes this to be a bug in mac80211, and has also publicly stated [1] that he does not care about this even though it is a regression introduced by his own patches.

What if we leave slander out of the commit messages?

As far as I know, it is an accurate account of what happened in the other thread, and as such is not slander. I just wanted to provide a rationale for me fixing this bug instead of you. If you disagree that this is an accurate representation, I invite you to summarise the thread that caused this miserable situation of a known bug not being fixed for a very long time despite appropriate fixes being known in your own words for the commit message.

johannes

#3 lore raw
Quoted 10 lines · On Sunday 11 October 2009 12:31:06 Johannes Berg wrote:
Quoted 6 lines · Michael Buesch
Quoted 3 lines · On Sunday 11 October 2009 12:19:21 Johannes Berg wrote:

Due to the way it interacts with the networking
stack and other parts of mac80211, ieee80211_rx()
must be called with disabled softirqs.

Is this stated in the documentation somewhere?

No. However, there are many things that aren't in the documentation, I'm working on a patch to add a note.

Ok, thanks a lot.

Quoted 2 lines

I just wanted to provide a
rationale for me fixing this bug instead of you.

Since when do we require that in commit messages?

Quoted 5 lines

If you disagree that
this is an accurate representation, I invite you to summarise the thread that caused this miserable situation of a known bug not being fixed for a very long time despite appropriate fixes being known in your own words for the commit message.

If you'd care _that_ much, you could have just reverted my commit.
Yes, I introduced the regression and I was unable to cook up a fix for it. So the logical reaction to that would be to revert my commit.

Signature · 1 line
Greetings, Michael.
#4 lore raw
In reply to Johannes Berg
Quoted 2 lines

As far as I know, it is an accurate account of what happened in the other thread, and as such is not slander.

It might not be slander, but it's still not polite.

Signature · 1 line
http://www.holgerschurig.de
Acked-by on v1 1/1
#5 lore raw
In reply to Johannes Berg

From: Johannes Berg <[email protected]>
Date: Sun, 11 Oct 2009 12:19:21 +0200

Quoted 14 lines

Due to the way it interacts with the networking stack and other parts of mac80211, ieee80211_rx() must be called with disabled softirqs.

Michael, the former maintainer of this driver, has refused to fix the problem this way instead proposing a much more invasive patch that could not even be proved correct wrt. locking inside mac80211. Regardless of that, he believes this to be a bug in mac80211, and has also publicly stated [1] that he does not care about this even though it is a regression introduced by his own patches.

Quoted 8 lines

Since nobody else seems to be wanting to fix the problem, I'll just fix it for the benefit of the many users of this driver.

[1] http://thread.gmane.org/gmane.linux.kernel.wireless.general/39440/focus=40266

Tested-by
#6 lore raw
Quoted 21 lines · David Miller

From: Johannes Berg <[email protected]>
Date: Sun, 11 Oct 2009 12:19:21 +0200

Quoted 18 lines

Due to the way it interacts with the networking stack and other parts of mac80211, ieee80211_rx() must be called with disabled softirqs.

Michael, the former maintainer of this driver, has refused to fix the problem this way instead proposing a much more invasive patch that could not even be proved correct wrt. locking inside mac80211. Regardless of that, he believes this to be a bug in mac80211, and has also publicly stated [1] that he does not care about this even though it is a regression introduced by his own patches.

Since nobody else seems to be wanting to fix the problem, I'll just fix it for the benefit of the many users of this driver.

Quoted 7 lines
Quoted 4 lines

[1] http://thread.gmane.org/gmane.linux.kernel.wireless.general/39440/focus=40266

Signature · 2 lines
Regards
dave
#7 lore raw
In reply to Johannes Berg
Quoted 3 lines · Johannes Berg

Due to the way it interacts with the networking
stack and other parts of mac80211, ieee80211_rx()
must be called with disabled softirqs.

[...]

drivers/net/wireless/b43/xmit.c void b43_rx(struct b43_wldev *dev, struc · line 696

Quoted 3 lines
drivers/net/wireless/b43/xmit.c +2 -0
+	local_bh_disable();
 	ieee80211_rx(dev->wl->hw, skb);
+	local_bh_enable();

This is a bit awkward from drivers' point of view, we have to add the same code to all mac80211 drivers using either SPI or SDIO buses.

What about adding a new inline function ieee80211_rx_ni() which would disable bottom halves like above and call ieee80211_rx()? IMHO that's easier for the driver developers to understand and also easier to document ("use this function when calling from process context"). If this is acceptable, I can create a patch.

Signature · 1 line
Kalle Valo
author maintainer
#8 lore raw
Quoted 15 lines · Kalle Valo
Quoted 3 lines · Johannes Berg

Due to the way it interacts with the networking
stack and other parts of mac80211, ieee80211_rx()
must be called with disabled softirqs.

[...]

drivers/net/wireless/b43/xmit.c void b43_rx(struct b43_wldev *dev, struc · line 696

Quoted 3 lines
drivers/net/wireless/b43/xmit.c +2 -0
+	local_bh_disable();
 	ieee80211_rx(dev->wl->hw, skb);
+	local_bh_enable();

This is a bit awkward from drivers' point of view, we have to add the same code to all mac80211 drivers using either SPI or SDIO buses.

Quoted 5 lines

What about adding a new inline function ieee80211_rx_ni() which would disable bottom halves like above and call ieee80211_rx()? IMHO that's easier for the driver developers to understand and also easier to document ("use this function when calling from process context"). If this is acceptable, I can create a patch.

I really don't see the point, since it's just three lines of code, but I wouldn't mind all that much either.

johannes

#9 lore raw
Quoted 7 lines · Johannes Berg
Quoted 7 lines

drivers/net/wireless/b43/xmit.c void b43_rx(struct b43_wldev *dev, struc · line 696

Quoted 3 lines
drivers/net/wireless/b43/xmit.c +2 -0
+	local_bh_disable();
 	ieee80211_rx(dev->wl->hw, skb);
+	local_bh_enable();

This is a bit awkward from drivers' point of view, we have to add the same code to all mac80211 drivers using either SPI or SDIO buses.

Quoted 8 lines
Quoted 5 lines

What about adding a new inline function ieee80211_rx_ni() which would disable bottom halves like above and call ieee80211_rx()? IMHO that's easier for the driver developers to understand and also easier to document ("use this function when calling from process context"). If this is acceptable, I can create a patch.

I really don't see the point, since it's just three lines of code, but I wouldn't mind all that much either.

My worry are the developers who even don't know what is a bottom half and might get it all wrong. (Yes, there really are such people.)

But if you don't see any benefit from adding a new function, I'll drop the idea. No need to complicate this anymore :)

Signature · 1 line
Kalle Valo
#10 lore raw

From: Kalle Valo <[email protected]>
Date: Sun, 11 Oct 2009 19:08:58 +0300

Quoted 15 lines
Quoted 13 lines · Johannes Berg
Quoted 12 lines

drivers/net/wireless/b43/xmit.c void b43_rx(struct b43_wldev *dev, struc · line 696

Quoted 3 lines
drivers/net/wireless/b43/xmit.c +2 -0
+	local_bh_disable();
 	ieee80211_rx(dev->wl->hw, skb);
+	local_bh_enable();

This is a bit awkward from drivers' point of view, we have to add the same code to all mac80211 drivers using either SPI or SDIO buses.

What about adding a new inline function ieee80211_rx_ni() which would disable bottom halves like above and call ieee80211_rx()? IMHO that's easier for the driver developers to understand and also easier to document ("use this function when calling from process context"). If this is acceptable, I can create a patch.

Quoted 5 lines
Quoted 2 lines

I really don't see the point, since it's just three lines of code, but I wouldn't mind all that much either.

My worry are the developers who even don't know what is a bottom half and might get it all wrong. (Yes, there really are such people.)

And the difference between this and knowing you need to call the ieee80211_rx_ni() thing is?

You have to know what the heck a bottom half is to even know that you would need to call the ieee80211_rx_ni() thing.

And that's the same amount of knowledge necessary to simply wrap the thing in a BH disable/enable sequence.

#11 lore raw
Quoted 6 lines · David Miller
Quoted 5 lines
Quoted 2 lines

I really don't see the point, since it's just three lines of code, but I wouldn't mind all that much either.

My worry are the developers who even don't know what is a bottom half and might get it all wrong. (Yes, there really are such people.)

Quoted 8 lines

And the difference between this and knowing you need to call the ieee80211_rx_ni() thing is?

You have to know what the heck a bottom half is to even know that you would need to call the ieee80211_rx_ni() thing.

And that's the same amount of knowledge necessary to simply wrap the thing in a BH disable/enable sequence.

I was thinking that it's possible to document it something like this:

o in irq context use ieee80211_rx_irqsafe()
o in a tasklet use ieee80211_rx()
o in process context use ieee80211_rx_ni()

Also in the future it might be easier to optimise something based on these functions. Maybe.

But as Johannes didn't like the idea, and neither do you, I'm going to drop the idea. I'll add the BH disable/enable to wl1251 instead and hopefully Luciano does the same to wl1271.

Signature · 1 line
Kalle Valo
#12 lore raw
Quoted 21 lines · ext Kalle Valo
Quoted 4 lines · David Miller
Quoted 4 lines
Quoted 2 lines

I really don't see the point, since it's just three lines of code, but I wouldn't mind all that much either.

My worry are the developers who even don't know what is a bottom half and might get it all wrong. (Yes, there really are such people.)

Quoted 8 lines

And the difference between this and knowing you need to call the ieee80211_rx_ni() thing is?

You have to know what the heck a bottom half is to even know that you would need to call the ieee80211_rx_ni() thing.

And that's the same amount of knowledge necessary to simply wrap the thing in a BH disable/enable sequence.

I was thinking that it's possible to document it something like this:

o in irq context use ieee80211_rx_irqsafe()
o in a tasklet use ieee80211_rx()
o in process context use ieee80211_rx_ni()

Quoted 6 lines

Also in the future it might be easier to optimise something based on these functions. Maybe.

But as Johannes didn't like the idea, and neither do you, I'm going to drop the idea. I'll add the BH disable/enable to wl1251 instead and hopefully Luciano does the same to wl1271.

Yeps, I can do the same for wl1271.

Signature · 2 lines
Cheers,
Luca.
#13 lore raw
In reply to David Miller
Quoted 24 lines · David Miller

From: Kalle Valo <[email protected]>
Date: Sun, 11 Oct 2009 19:08:58 +0300

Quoted 15 lines
Quoted 13 lines · Johannes Berg
Quoted 12 lines

drivers/net/wireless/b43/xmit.c void b43_rx(struct b43_wldev *dev, struc · line 696

Quoted 3 lines
drivers/net/wireless/b43/xmit.c +2 -0
+	local_bh_disable();
 	ieee80211_rx(dev->wl->hw, skb);
+	local_bh_enable();

This is a bit awkward from drivers' point of view, we have to add the same code to all mac80211 drivers using either SPI or SDIO buses.

What about adding a new inline function ieee80211_rx_ni() which would disable bottom halves like above and call ieee80211_rx()? IMHO that's easier for the driver developers to understand and also easier to document ("use this function when calling from process context"). If this is acceptable, I can create a patch.

Quoted 5 lines
Quoted 2 lines

I really don't see the point, since it's just three lines of code, but I wouldn't mind all that much either.

My worry are the developers who even don't know what is a bottom half and might get it all wrong. (Yes, there really are such people.)

Quoted 8 lines

And the difference between this and knowing you need to call the ieee80211_rx_ni() thing is?

You have to know what the heck a bottom half is to even know that you would need to call the ieee80211_rx_ni() thing.

And that's the same amount of knowledge necessary to simply wrap the thing in a BH disable/enable sequence.

I'm not sure I see the difference between this and the rationale for having netif_rx_ni vs. an open-coded version of it? ieee80211_rx_ni seems like a small amount of code (could even be inline) that potentially avoids some stupid bugs...?

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
#14 lore raw

From: "John W. Linville" <[email protected]>
Date: Mon, 12 Oct 2009 09:38:36 -0400

Quoted 4 lines

I'm not sure I see the difference between this and the rationale for having netif_rx_ni vs. an open-coded version of it? ieee80211_rx_ni seems like a small amount of code (could even be inline) that potentially avoids some stupid bugs...?

Sure, no problem, feel free to add ieee80211_rx_ni().