Skip to contentSkip to conversation

bcm43xx: fix unexpected LED control values in BCM4303 sprom

PATCH In review Larry Finger 4 participants 6 messages Oct 18, 2006 – Nov 1, 2006 4 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bcm43xx: fix unexpected LED control values in BCM4303 sprom

The bcm43xx driver uses 4 locations in the devices sprom to determine the behavior of the leds. Certain defaults are assigned if all bits are set in those locations. On at least one BCM4303 chip, the sprom contains values other than the default, which executes an assertion placed in the default case of a following switch statement. This patch makes the leds on the above mentioned interface behave correctly. In addition, it limits the number of logged messages to 20 for the case of unexpected values in the sprom locations.

---

 bcm43xx_leds.c |   12 +++++++++++-
 bcm43xx_leds.h |    4 ++++
 2 files changed, 15 insertions(+), 1 deletion(-)

John,

This patch should be applied to wireless-2.6 so as to be ready for 2.6.20.

Larry

drivers/net/wireless/bcm43xx/bcm43xx_leds.c +11 -1
Index: wireless-2.6/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
===================================================================
@@ -168,6 +168,8 @@ void bcm43xx_leds_exit(struct bcm43xx_pr
 	bcm43xx_leds_switch_all(bcm, 0);
 }
 
+static int bcm43xx_max_led_err = 20;
+
 void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
 {
 	struct bcm43xx_led *led;
@@ -189,20 +191,24 @@ void bcm43xx_leds_update(struct bcm43xx_
 		case BCM43xx_LED_INACTIVE:
 			continue;
 		case BCM43xx_LED_OFF:
+		case BCM43xx_LED_BCM4303_3:
 			break;
 		case BCM43xx_LED_ON:
 			turn_on = 1;
 			break;
 		case BCM43xx_LED_ACTIVITY:
+		case BCM43xx_LED_BCM4303_0:
 			turn_on = activity;
 			break;
 		case BCM43xx_LED_RADIO_ALL:
 			turn_on = radio->enabled;
 			break;
 		case BCM43xx_LED_RADIO_A:
+		case BCM43xx_LED_BCM4303_2:
 			turn_on = (radio->enabled && phy->type == BCM43xx_PHYTYPE_A);
 			break;
 		case BCM43xx_LED_RADIO_B:
+		case BCM43xx_LED_BCM4303_1:
 			turn_on = (radio->enabled &&
 				   (phy->type == BCM43xx_PHYTYPE_B ||
 				    phy->type == BCM43xx_PHYTYPE_G));
@@ -257,7 +263,11 @@ void bcm43xx_leds_update(struct bcm43xx_
 			continue;
 #endif /* CONFIG_BCM43XX_DEBUG */
 		default:
-			assert(0);
+			if (bcm43xx_max_led_err) {
+				printkl(KERN_INFO PFX "Bad value in leds_update,"
+					" led->behaviour: 0x%x\n", led->behaviour);
+				--bcm43xx_max_led_err;
+			}
 		};
 
 		if (led->activelow)
drivers/net/wireless/bcm43xx/bcm43xx_leds.h +4 -0
Index: wireless-2.6/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
===================================================================
@@ -24,6 +24,10 @@ struct bcm43xx_led {
 
 #define BCM43xx_LED_BEHAVIOUR		0x7F
 #define BCM43xx_LED_ACTIVELOW		0x80
+#define BCM43xx_LED_BCM4303_0		0x2B
+#define BCM43xx_LED_BCM4303_1		0x78
+#define BCM43xx_LED_BCM4303_2		0x2E
+#define BCM43xx_LED_BCM4303_3		0x19
 enum { /* LED behaviour values */
 	BCM43xx_LED_OFF,
 	BCM43xx_LED_ON,

========

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 65 lines · Larry Finger

The bcm43xx driver uses 4 locations in the devices sprom to determine the behavior of the leds. Certain defaults are assigned if all bits are set in those locations. On at least one BCM4303 chip, the sprom contains values other than the default, which executes an assertion placed in the default case of a following switch statement. This patch makes the leds on the above mentioned interface behave correctly. In addition, it limits the number of logged messages to 20 for the case of unexpected values in the sprom locations.

---

 bcm43xx_leds.c |   12 +++++++++++-
 bcm43xx_leds.h |    4 ++++
 2 files changed, 15 insertions(+), 1 deletion(-)

John,

This patch should be applied to wireless-2.6 so as to be ready for 2.6.20.

Larry

Index: wireless-2.6/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
===================================================================

drivers/net/wireless/bcm43xx/bcm43xx_leds.c +6 -0
@@ -168,6 +168,8 @@ void bcm43xx_leds_exit(struct bcm43xx_pr
 	bcm43xx_leds_switch_all(bcm, 0);
 }
 
+static int bcm43xx_max_led_err = 20;
+
 void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
 {
 	struct bcm43xx_led *led;
@@ -189,20 +191,24 @@ void bcm43xx_leds_update(struct bcm43xx_
 		case BCM43xx_LED_INACTIVE:
 			continue;
 		case BCM43xx_LED_OFF:
+		case BCM43xx_LED_BCM4303_3:
 			break;
 		case BCM43xx_LED_ON:
 			turn_on = 1;
 			break;
 		case BCM43xx_LED_ACTIVITY:
+		case BCM43xx_LED_BCM4303_0:
 			turn_on = activity;
 			break;
 		case BCM43xx_LED_RADIO_ALL:
 			turn_on = radio->enabled;
 			break;
 		case BCM43xx_LED_RADIO_A:
+		case BCM43xx_LED_BCM4303_2:
 			turn_on = (radio->enabled && phy->type == BCM43xx_PHYTYPE_A);
 			break;
 		case BCM43xx_LED_RADIO_B:
+		case BCM43xx_LED_BCM4303_1:
 			turn_on = (radio->enabled &&
 				   (phy->type == BCM43xx_PHYTYPE_B ||
 				    phy->type == BCM43xx_PHYTYPE_G));

drivers/net/wireless/bcm43xx/bcm43xx_leds.c void bcm43xx_leds_update(struct bcm43xx_ · line 270

Quoted 9 lines
drivers/net/wireless/bcm43xx/bcm43xx_leds.c +5 -1
@@ -257,7 +263,11 @@ void bcm43xx_leds_update(struct bcm43xx_
 			continue;
 #endif /* CONFIG_BCM43XX_DEBUG */
 		default:
-			assert(0);
+			if (bcm43xx_max_led_err) {
+				printkl(KERN_INFO PFX "Bad value in leds_update,"
+					" led->behaviour: 0x%x\n", led->behaviour);
+				--bcm43xx_max_led_err;
+			}

I'd call this message bloat. ;) This is the first time the assertion triggers since it was added.
You could instead remove the assert(), remove bcm43xx_max_led_err and use dprintkl instead of printkl.

Quoted 8 lines
drivers/net/wireless/bcm43xx/bcm43xx_leds.c +0 -0
 		};
 
 		if (led->activelow)

Index: wireless-2.6/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
===================================================================

drivers/net/wireless/bcm43xx/bcm43xx_leds.h struct bcm43xx_led { · line 30

Quoted 7 lines
drivers/net/wireless/bcm43xx/bcm43xx_leds.h +4 -0
@@ -24,6 +24,10 @@ struct bcm43xx_led {
 
 #define BCM43xx_LED_BEHAVIOUR		0x7F
 #define BCM43xx_LED_ACTIVELOW		0x80
+#define BCM43xx_LED_BCM4303_0		0x2B
+#define BCM43xx_LED_BCM4303_1		0x78
+#define BCM43xx_LED_BCM4303_2		0x2E
+#define BCM43xx_LED_BCM4303_3		0x19

Add these to the enum below, instead, please. The defines above are masks and not the behaviour values.

Quoted 7 lines
drivers/net/wireless/bcm43xx/bcm43xx_leds.h +0 -0
 enum { /* LED behaviour values */
 	BCM43xx_LED_OFF,
 	BCM43xx_LED_ON,

========

Signature · 1 line
Greetings Michael.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 25 lines · Michael Buesch

drivers/net/wireless/bcm43xx/bcm43xx_leds.c void bcm43xx_leds_update(struct bcm43xx_ · line 270

Quoted 10 lines
drivers/net/wireless/bcm43xx/bcm43xx_leds.c +5 -1
@@ -257,7 +263,11 @@ void bcm43xx_leds_update(struct bcm43xx_
 			continue;
 #endif /* CONFIG_BCM43XX_DEBUG */
 		default:
-			assert(0);
+			if (bcm43xx_max_led_err) {
+				printkl(KERN_INFO PFX "Bad value in leds_update,"
+					" led->behaviour: 0x%x\n", led->behaviour);
+				--bcm43xx_max_led_err;
+			}

I'd call this message bloat. ;) This is the first time the assertion triggers since it was added.
You could instead remove the assert(), remove bcm43xx_max_led_err and use dprintkl instead of printkl.

Quoted 9 lines
drivers/net/wireless/bcm43xx/bcm43xx_leds.c +0 -0
 		};
 
 		if (led->activelow)

Index: wireless-2.6/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
===================================================================

drivers/net/wireless/bcm43xx/bcm43xx_leds.h +0 -0
@@ -24,6 +24,10 @@ struct bcm43xx_led {
 
Quoted 13 lines

drivers/net/wireless/bcm43xx/bcm43xx_leds.h struct bcm43xx_led { · line 30

Quoted 6 lines
drivers/net/wireless/bcm43xx/bcm43xx_leds.h +4 -0
 #define BCM43xx_LED_BEHAVIOUR		0x7F
 #define BCM43xx_LED_ACTIVELOW		0x80
+#define BCM43xx_LED_BCM4303_0		0x2B
+#define BCM43xx_LED_BCM4303_1		0x78
+#define BCM43xx_LED_BCM4303_2		0x2E
+#define BCM43xx_LED_BCM4303_3		0x19

Add these to the enum below, instead, please. The defines above are masks and not the behaviour values.

Quoted 3 lines
drivers/net/wireless/bcm43xx/bcm43xx_leds.h +0 -0
 enum { /* LED behaviour values */
 	BCM43xx_LED_OFF,
 	BCM43xx_LED_ON,

I took Michael's suggestions before merging your patch...FYI! :-)

John

Signature · 2 lines
John W. Linville
[email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

John,

I had not responded to Michael's comments as I heard from another user with thousands of these assertions in his logs, and I have been waiting for his sprom values and hoped to make a single patch. It is good, however, that you pushed the patch upstream.

Quoted 16 lines · John W. Linville
Quoted 6 lines · Michael Buesch
Quoted 6 lines
drivers/net/wireless/bcm43xx/bcm43xx_leds.c +1 -1
@@ -257,7 +263,11 @@ void bcm43xx_leds_update(struct bcm43xx_
 			continue;
 #endif /* CONFIG_BCM43XX_DEBUG */
 		default:
-			assert(0);
+			if (bcm43xx_max_led_err) {
Quoted 8 lines

drivers/net/wireless/bcm43xx/bcm43xx_leds.c void bcm43xx_leds_update(struct bcm43xx_ · line 270

Quoted 4 lines
drivers/net/wireless/bcm43xx/bcm43xx_leds.c +4 -0
+				printkl(KERN_INFO PFX "Bad value in leds_update,"
+					" led->behaviour: 0x%x\n", led->behaviour);
+				--bcm43xx_max_led_err;
+			}

I'd call this message bloat. ;) This is the first time the assertion triggers since it was added.
You could instead remove the assert(), remove bcm43xx_max_led_err and use dprintkl instead of printkl.

I disagree with part of Michael's comments. I think we should have a dprintk, rather than dprintkl, so that we get printouts from all four of the sprom values. That way the user will be able to report the numbers we need. As this would not limit the log entries and potentially generate thousands, there should be a variable like bcm43xx_max_led_err to limit the number of log entries.

I will propose a new patch once I get the data for the second case. In the meantime, the patch you have pushed upstream will fix the BCM4303 led assertions.

Larry

#7 lore raw
Quoted 24 lines · Larry Finger

John,

I had not responded to Michael's comments as I heard from another user with thousands of these assertions in his logs, and I have been waiting for his sprom values and hoped to make a single patch. It is good, however, that you pushed the patch upstream.

Quoted 16 lines · John W. Linville
Quoted 6 lines · Michael Buesch
Quoted 6 lines
(quoted diff) +1 -1
@@ -257,7 +263,11 @@ void bcm43xx_leds_update(struct bcm43xx_
 			continue;
 #endif /* CONFIG_BCM43XX_DEBUG */
 		default:
-			assert(0);
+			if (bcm43xx_max_led_err) {
Quoted 8 lines

Review void bcm43xx_leds_update(struct bcm43xx_ · line 270

Quoted 4 lines
(quoted diff) +4 -0
+				printkl(KERN_INFO PFX "Bad value in leds_update,"
+					" led->behaviour: 0x%x\n", led->behaviour);
+				--bcm43xx_max_led_err;
+			}

I'd call this message bloat. ;) This is the first time the assertion triggers since it was added.
You could instead remove the assert(), remove bcm43xx_max_led_err and use dprintkl instead of printkl.

Quoted 1 line

I disagree with part of Michael's comments. I think we should have a dprintk, rather than dprintkl,

An unlimited printk will hang the system on UP.

Quoted 1 line

so that we get printouts from all four of the sprom values.

I don't really think that dprintkl will prevent this.

Quoted 6 lines

That way the user will be able to report
the numbers we need. As this would not limit the log entries and potentially generate thousands, there should be a variable like bcm43xx_max_led_err to limit the number of log entries.

I will propose a new patch once I get the data for the second case. In the meantime, the patch you have pushed upstream will fix the BCM4303 led assertions.

I still think it's a waste to add a variable, a printk and a long string which all eat unswappable kernel memory for this cornercase.
I don't think it's really hard to tell somebody to execute "iwpriv ethX read_sprom" when he reports the assert() is triggering.
You must communicate with him anyway to find out how the LEDs are mapped to the physical descriptions on the device case.

Signature · 1 line
Greetings Michael.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw
Quoted 27 lines · Larry Finger
Quoted 18 lines · John W. Linville
Quoted 8 lines · Michael Buesch
Quoted 8 lines
(quoted diff) +2 -1
@@ -257,7 +263,11 @@ void bcm43xx_leds_update(struct bcm43xx_
 			continue;
 #endif /* CONFIG_BCM43XX_DEBUG */
 		default:
-			assert(0);
+			if (bcm43xx_max_led_err) {
+				printkl(KERN_INFO PFX "Bad value in 

leds_update,"

Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +1 -0
+					" led->behaviour: 0x%x\n", 

led->behaviour);

(quoted diff) +2 -0
+				--bcm43xx_max_led_err;
+			}

I'd call this message bloat. ;) This is the first time the assertion triggers since it was added.
You could instead remove the assert(), remove bcm43xx_max_led_err and use dprintkl instead of printkl.

I disagree with part of Michael's comments. I think we should have a dprintk, rather than dprintkl, so that we get printouts from all four of the sprom values. That way the user will be able to report the numbers we need. As this would not limit the log entries and potentially generate thousands, there should be a variable like bcm43xx_max_led_err to limit the number of log entries.

Quoted 3 lines

I will propose a new patch once I get the data for the second case. In the meantime, the patch you have pushed upstream will fix the BCM4303 led assertions.

OK, cool. I'm happy for you to send another patch.

John

Signature · 2 lines
John W. Linville
[email protected]