Skip to contentSkip to conversation

ssb: return -ENOMEM on alloc fail (instead of CRC check's result)

PATCH New Rafał Miłecki 4 participants 15 messages Nov 3, 2010 – Nov 18, 2010 Sonics silicon backplane driver (ssb)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ssb: return -ENOMEM on alloc fail (instead of CRC check's result)

---
John: it's for 2.6.38.

---
 drivers/ssb/pci.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/ssb/pci.c +3 -4
index 3226832..b5343ac 100644
@@ -619,7 +619,7 @@ static int ssb_pci_sprom_get(struct ssb_bus *bus,
 			     struct ssb_sprom *sprom)
 {
 	const struct ssb_sprom *fallback;
-	int err = -ENOMEM;
+	int err;
 	u16 *buf;
 
 	if (!ssb_is_sprom_available(bus)) {
@@ -646,7 +646,7 @@ static int ssb_pci_sprom_get(struct ssb_bus *bus,
 
 	buf = kcalloc(SSB_SPROMSIZE_WORDS_R123, sizeof(u16), GFP_KERNEL);
 	if (!buf)
-		goto out;
+		return -ENOMEM;
 	bus->sprom_size = SSB_SPROMSIZE_WORDS_R123;
 	sprom_do_read(bus, buf);
 	err = sprom_check_crc(buf, bus->sprom_size);
@@ -656,7 +656,7 @@ static int ssb_pci_sprom_get(struct ssb_bus *bus,
 		buf = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
 			      GFP_KERNEL);
 		if (!buf)
-			goto out;
+			return -ENOMEM;
 		bus->sprom_size = SSB_SPROMSIZE_WORDS_R4;
 		sprom_do_read(bus, buf);
 		err = sprom_check_crc(buf, bus->sprom_size);
@@ -678,7 +678,6 @@ static int ssb_pci_sprom_get(struct ssb_bus *bus,
 
 out_free:
 	kfree(buf);
-out:
 	return err;
 }
 
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH 1/1 ssb: fail registration for unknown SPROM revision

---
As noticed my Michael we have this left from old times of limited amount of revisions. It's not reliable to treat unknown as rev1.

Michael: would you like to add Reported-by?

John: it's for 2.6.38.

---
 drivers/ssb/pci.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
drivers/ssb/pci.c +3 -5
index b5343ac..41a7337 100644
@@ -600,11 +600,9 @@ static int sprom_extract(struct ssb_bus *bus, struct ssb_sprom *out,
 		sprom_extract_r8(out, in);
 		break;
 	default:
-		ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
-			   "  revision %d detected. Will extract"
-			   " v1\n", out->revision);
-		out->revision = 1;
-		sprom_extract_r123(out, in);
+		ssb_printk(KERN_ERR PFX "Unsupported SPROM revision %d"
+			   " detected\n", out->revision);
+		return -EINVAL;
 	}
 
 	if (out->boardflags_lo == 0xFFFF)
Signature · 1 line
1.6.0.4
#2 lore raw

PATCH 1/1 ssb: fail registration for unknown SPROM revision

Quoted 6 lines · Rafa? Mi?ecki

---
As noticed my Michael we have this left from old times of limited amount of revisions. It's not reliable to treat unknown as rev1.

Michael: would you like to add Reported-by?

Isn't that only for bugs? This isn't a bug.
But you can add my acked-by, if that's desired.

Quoted 24 lines

John: it's for 2.6.38.

---
 drivers/ssb/pci.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
drivers/ssb/pci.c +3 -5
index b5343ac..41a7337 100644
@@ -600,11 +600,9 @@ static int sprom_extract(struct ssb_bus *bus, struct ssb_sprom *out,
 		sprom_extract_r8(out, in);
 		break;
 	default:
-		ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
-			   "  revision %d detected. Will extract"
-			   " v1\n", out->revision);
-		out->revision = 1;
-		sprom_extract_r123(out, in);
+		ssb_printk(KERN_ERR PFX "Unsupported SPROM revision %d"
+			   " detected\n", out->revision);
+		return -EINVAL;
 	}
 
 	if (out->boardflags_lo == 0xFFFF)
Signature · 1 line
Greetings Michael.
#3 lore raw

PATCH 1/1 ssb: fail registration for unknown SPROM revision

In reply to Rafał Miłecki
Quoted 21 lines · Rafa? Mi?ecki

---
As noticed my Michael we have this left from old times of limited amount of revisions. It's not reliable to treat unknown as rev1.

Michael: would you like to add Reported-by?

John: it's for 2.6.38.

---
 drivers/ssb/pci.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
drivers/ssb/pci.c +0 -1
index b5343ac..41a7337 100644
@@ -600,11 +600,9 @@ static int sprom_extract(struct ssb_bus *bus, struct ssb_sprom *out,
 		sprom_extract_r8(out, in);
 		break;
 	default:
-		ssb_printk(KERN_WARNING PFX "Unsupported SPROM"

drivers/ssb/pci.c static int sprom_extract(struct ssb_bus *bus, struct ssb_sprom *out, · line 608

Quoted 10 lines
drivers/ssb/pci.c +3 -4
-			   "  revision %d detected. Will extract"
-			   " v1\n", out->revision);
-		out->revision = 1;
-		sprom_extract_r123(out, in);
+		ssb_printk(KERN_ERR PFX "Unsupported SPROM revision %d"
+			   " detected\n", out->revision);
+		return -EINVAL;
 	}
 
 	if (out->boardflags_lo == 0xFFFF)

I think this is going to make my b43 PCI-E card not work...I'll try it and get back to you...

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
linville at tuxdriver.com			might be all we have.  Be ready.
#4 lore raw

PATCH 1/1 ssb: fail registration for unknown SPROM revision

Quoted 10 lines · John W. Linville
Quoted 10 lines
drivers/ssb/pci.c +3 -5
-		ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
-			   "  revision %d detected. Will extract"
-			   " v1\n", out->revision);
-		out->revision = 1;
-		sprom_extract_r123(out, in);
+		ssb_printk(KERN_ERR PFX "Unsupported SPROM revision %d"
+			   " detected\n", out->revision);
+		return -EINVAL;
 	}
Quoted 4 lines
Quoted 1 line

if (out->boardflags_lo == 0xFFFF)

I think this is going to make my b43 PCI-E card not work...I'll try it and get back to you...

Hm, what version does it report?

Signature · 1 line
Greetings Michael.
#5 lore raw

Re: [PATCH] ssb: fail registration for unknown SPROM revision

Quoted 11 lines · Michael Büsch
Quoted 10 lines · John W. Linville
Quoted 10 lines
drivers/ssb/pci.c +3 -5
-		ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
-			   "  revision %d detected. Will extract"
-			   " v1\n", out->revision);
-		out->revision = 1;
-		sprom_extract_r123(out, in);
+		ssb_printk(KERN_ERR PFX "Unsupported SPROM revision %d"
+			   " detected\n", out->revision);
+		return -EINVAL;
 	}
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

if (out->boardflags_lo == 0xFFFF)

I think this is going to make my b43 PCI-E card not work...I'll try it and get back to you...

Hm, what version does it report?

This is what I see in dmesg (w/o the patch):

[ 1036.277235] ssb: Core 0 found: ChipCommon (cc 0x800, rev 0x11, vendor 0x4243)
[ 1036.277249] ssb: Core 1 found: IEEE 802.11 (cc 0x812, rev 0x0A, vendor 0x4243)
[ 1036.277267] ssb: Core 2 found: USB 1.1 Host (cc 0x817, rev 0x03, vendor 0x4243)
[ 1036.277277] ssb: Core 3 found: PCI-E (cc 0x820, rev 0x01, vendor 0x4243)
[ 1036.293856] ssb: WARNING: Invalid SPROM CRC (corrupt SPROM)
[ 1036.293865] ssb: Unsupported SPROM  revision 255 detected. Will extract v1
[ 1036.301254] ssb: Sonics Silicon Backplane found on PCI device 0000:04:00.0
[ 1036.420643] b43-phy1: Broadcom 4311 WLAN found (core revision 10)
[ 1036.435060] b43-phy1 debug: Found PHY: Analog 4, Type 2, Revision 8
[ 1036.435082] b43-phy1 debug: Found Radio: Manuf 0x17F, Version 0x2050, Revision 2
[ 1036.445105] ieee80211 phy1: Selected rate control algorithm 'minstrel_ht'
[ 1036.450914] Registered led device: b43-phy1::tx
[ 1036.451466] Registered led device: b43-phy1::rx
[ 1036.451890] Registered led device: b43-phy1::radio
[ 1036.452226] Broadcom 43xx driver loaded [ Features: PMLS, Firmware-ID: FW13 ]
[ 1036.480736] udev[2440]: renamed network interface wlan1 to wlan2
[ 1036.513712] cfg80211: Calling CRDA for country: US
[ 1036.623061] b43-phy1: Loading OpenSource firmware version 410.31754
[ 1036.623075] b43-phy1: Hardware crypto acceleration not supported by firmware
[ 1036.623083] b43-phy1: QoS not supported by firmware
[ 1036.656362] b43-phy1 debug: Chip initialized
[ 1036.661477] b43-phy1 debug: 32-bit DMA initialized
[ 1036.661499] b43-phy1 debug: QoS disabled
[ 1036.672035] b43-phy1 debug: Wireless interface started
[ 1036.674628] b43-phy1 debug: Adding Interface type 2
Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
#6 lore raw

PATCH 1/1 ssb: fail registration for unknown SPROM revision

Quoted 12 lines · John W. Linville
Quoted 11 lines · Michael B?sch
Quoted 10 lines · John W. Linville
Quoted 10 lines
drivers/ssb/pci.c +3 -5
-		ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
-			   "  revision %d detected. Will extract"
-			   " v1\n", out->revision);
-		out->revision = 1;
-		sprom_extract_r123(out, in);
+		ssb_printk(KERN_ERR PFX "Unsupported SPROM revision %d"
+			   " detected\n", out->revision);
+		return -EINVAL;
 	}
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

if (out->boardflags_lo == 0xFFFF)

I think this is going to make my b43 PCI-E card not work...I'll try it and get back to you...

Hm, what version does it report?

[ 1036.293865] ssb: Unsupported SPROM  revision 255 detected. Will extract v1

So what about specialcasing 255 instead of defaulting to 1 in general?

if (rev == 255)
rev = 1;

255 basically means "Vendor forgot to set this field". So it would only default to 1 for those broken sproms.

Signature · 1 line
Greetings Michael.
#7 lore raw

PATCH 1/1 ssb: fail registration for unknown SPROM revision

2010/11/18 Michael B?sch <[email protected]>:

Quoted 22 lines · John W. Linville
Quoted 12 lines · Michael B?sch
Quoted 11 lines · John W. Linville
Quoted 10 lines
Quoted 10 lines

- ? ? ? ? ? ? ? ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
- ? ? ? ? ? ? ? ? ? ? ? ? ?" ?revision %d detected. Will extract"
- ? ? ? ? ? ? ? ? ? ? ? ? ?" v1\n", out->revision);
- ? ? ? ? ? ? ? out->revision = 1;
- ? ? ? ? ? ? ? sprom_extract_r123(out, in);
+ ? ? ? ? ? ? ? ssb_printk(KERN_ERR PFX "Unsupported SPROM revision %d"
+ ? ? ? ? ? ? ? ? ? ? ? ? ?" detected\n", out->revision);
+ ? ? ? ? ? ? ? return -EINVAL;
? ? ? ? }

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

? ? ? ? if (out->boardflags_lo == 0xFFFF)

I think this is going to make my b43 PCI-E card not work...I'll try it and get back to you...

Hm, what version does it report?

[ 1036.293865] ssb: Unsupported SPROM ?revision 255 detected. Will extract v1
Quoted 7 lines

So what about specialcasing 255 instead of defaulting to 1 in general?

if (rev == 255)
rev = 1;

255 basically means "Vendor forgot to set this field". So it would only default to 1 for those broken sproms.

Will work as long as there won't appear new vendor who will forget to set this and will use new SPROM...

But hopefully it won't happen and it should not hurt too much to register device with incorrectly parsed SPROM.

Signature · 1 line
Rafa?
#8 lore raw

PATCH 1/1 ssb: fail registration for unknown SPROM revision

Quoted 5 lines · Rafa? Mi?ecki

2010/11/18 Michael B?sch <[email protected]>:

Quoted 4 lines
Quoted 1 line
[ 1036.293865] ssb: Unsupported SPROM  revision 255 detected. Will extract v1

So what about specialcasing 255 instead of defaulting to 1 in general?

Quoted 8 lines
Quoted 5 lines

if (rev == 255)
rev = 1;

255 basically means "Vendor forgot to set this field". So it would only default to 1 for those broken sproms.

Will work as long as there won't appear new vendor who will forget to set this and will use new SPROM...

The old code will break for that, too.

Quoted 2 lines

But hopefully it won't happen and it should not hurt too much to register device with incorrectly parsed SPROM.

If it would really succeed to initialize the device, this would be a regulatory issue, because the sprom contains various power amplifier calibration data. I think it should rather fail and be fixed correctly instead of incorrectly using rev1 in that case.

Signature · 1 line
Greetings Michael.
#9 lore raw

PATCH 1/1 ssb: fail registration for unknown SPROM revision

Quoted 4 lines · Michael B?sch

If it would really succeed to initialize the device, this would be a regulatory issue, because the sprom contains various power amplifier calibration data. I think it should rather fail and be fixed correctly instead of incorrectly using rev1 in that case.

I agree that it is better to fail than use incorrect power data.

Would it be useful if the SPROM data were logged when the revision is crap?

John: could you dump and post the data from yours? I would like to see how bad it is.

Larry

#10 lore raw

PATCH 1/1 ssb: fail registration for unknown SPROM revision

Quoted 9 lines · Larry Finger
Quoted 4 lines · Michael B?sch

If it would really succeed to initialize the device, this would be a regulatory issue, because the sprom contains various power amplifier calibration data. I think it should rather fail and be fixed correctly instead of incorrectly using rev1 in that case.

I agree that it is better to fail than use incorrect power data.

Would it be useful if the SPROM data were logged when the revision is crap?

We need to keep in mind that there will be no new SSB devices. It seems pretty much EOL'ed by Broadcom.
So I'm not sure whether this would be of any use or just random dead code.

Signature · 1 line
Greetings Michael.
#11 lore raw

PATCH 1/1 ssb: fail registration for unknown SPROM revision

Quoted 9 lines · Michael B?sch
Quoted 8 lines · Larry Finger
Quoted 4 lines · Michael B?sch

If it would really succeed to initialize the device, this would be a regulatory issue, because the sprom contains various power amplifier calibration data. I think it should rather fail and be fixed correctly instead of incorrectly using rev1 in that case.

I agree that it is better to fail than use incorrect power data.

Quoted 7 lines
Quoted 1 line

Would it be useful if the SPROM data were logged when the revision is crap?

We need to keep in mind that there will be no new SSB devices. It seems pretty much EOL'ed by Broadcom.
So I'm not sure whether this would be of any use or just random dead code.

Good point. When we get the data for the one case we know exists, we will have a better idea if a special quirk for this case is feasible. Assuming that this is not the only example of this hardware, then we might limit the breakage from this patch. At least the random code would be needed and useful in keeping our maintainer happy, which has a some merit.

Larry

#12 lore raw

Re: [PATCH] ssb: fail registration for unknown SPROM revision

In reply to John W. Linville
Quoted 31 lines · John W. Linville
Quoted 30 lines · Rafał Miłecki

---
As noticed my Michael we have this left from old times of limited amount of revisions. It's not reliable to treat unknown as rev1.

Michael: would you like to add Reported-by?

John: it's for 2.6.38.

---
 drivers/ssb/pci.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
drivers/ssb/pci.c +3 -5
index b5343ac..41a7337 100644
@@ -600,11 +600,9 @@ static int sprom_extract(struct ssb_bus *bus, struct ssb_sprom *out,
 		sprom_extract_r8(out, in);
 		break;
 	default:
-		ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
-			   "  revision %d detected. Will extract"
-			   " v1\n", out->revision);
-		out->revision = 1;
-		sprom_extract_r123(out, in);
+		ssb_printk(KERN_ERR PFX "Unsupported SPROM revision %d"
+			   " detected\n", out->revision);
+		return -EINVAL;
 	}
 
Quoted 4 lines

drivers/ssb/pci.c static int sprom_extract(struct ssb_bus *bus, struct ssb_sprom *out, · line 608

Quoted 1 line
drivers/ssb/pci.c +0 -0
 	if (out->boardflags_lo == 0xFFFF)

I think this is going to make my b43 PCI-E card not work...I'll try it and get back to you...

Yeah...

[  125.520348] b43-pci-bridge 0000:04:00.0: enabling device (0000 -> 0002)
[  125.520359] b43-pci-bridge 0000:04:00.0: PCI INT A -> GSI 18 (level, low) -> IRQ 18
[  125.520373] b43-pci-bridge 0000:04:00.0: setting latency timer to 64
[  125.529241] ssb: Core 0 found: ChipCommon (cc 0x800, rev 0x11, vendor 0x4243)
[  125.529255] ssb: Core 1 found: IEEE 802.11 (cc 0x812, rev 0x0A, vendor 0x4243)
[  125.529268] ssb: Core 2 found: USB 1.1 Host (cc 0x817, rev 0x03, vendor 0x4243)
[  125.529280] ssb: Core 3 found: PCI-E (cc 0x820, rev 0x01, vendor 0x4243)
[  125.545750] ssb: WARNING: Invalid SPROM CRC (corrupt SPROM)
[  125.545752] ssb: Unsupported SPROM revision 255 detected
[  125.545797] ssb: Failed to register PCI version of SSB with error -22
[  125.545810] b43-pci-bridge 0000:04:00.0: PCI INT A disabled
[  125.545827] b43-pci-bridge: probe of 0000:04:00.0 failed with error -22
Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
#13 lore raw

PATCH 1/1 ssb: fail registration for unknown SPROM revision

2010/11/18 John W. Linville <[email protected]>:

Quoted 39 lines · John W. Linville
Quoted 31 lines · Rafa? Mi?ecki
Quoted 30 lines

---
As noticed my Michael we have this left from old times of limited amount of revisions. It's not reliable to treat unknown as rev1.

Michael: would you like to add Reported-by?

John: it's for 2.6.38.
---
?drivers/ssb/pci.c | ? ?8 +++-----
?1 files changed, 3 insertions(+), 5 deletions(-)

drivers/ssb/pci.c +0 -0
index b5343ac..41a7337 100644
@@ -600,11 +600,9 @@ static int sprom_extract(struct ssb_bus *bus, struct ssb_sprom *out,
 ? ? ? ? ? ? sprom_extract_r8(out, in);
 ? ? ? ? ? ? break;

? ? default:
- ? ? ? ? ? ssb_printk(KERN_WARNING PFX "Unsupported SPROM"
- ? ? ? ? ? ? ? ? ? ? ?" ?revision %d detected. Will extract"
- ? ? ? ? ? ? ? ? ? ? ?" v1\n", out->revision);
- ? ? ? ? ? out->revision = 1;
- ? ? ? ? ? sprom_extract_r123(out, in);
+ ? ? ? ? ? ssb_printk(KERN_ERR PFX "Unsupported SPROM revision %d"
+ ? ? ? ? ? ? ? ? ? ? ?" detected\n", out->revision);
+ ? ? ? ? ? return -EINVAL;
? ? }

Quoted 4 lines
Quoted 1 line

? ? if (out->boardflags_lo == 0xFFFF)

I think this is going to make my b43 PCI-E card not work...I'll try it and get back to you...

Yeah...

Quoted 12 lines

[ ?125.520348] b43-pci-bridge 0000:04:00.0: enabling device (0000 -> 0002) [ ?125.520359] b43-pci-bridge 0000:04:00.0: PCI INT A -> GSI 18 (level, low) -> IRQ 18 [ ?125.520373] b43-pci-bridge 0000:04:00.0: setting latency timer to 64 [ ?125.529241] ssb: Core 0 found: ChipCommon (cc 0x800, rev 0x11, vendor 0x4243) [ ?125.529255] ssb: Core 1 found: IEEE 802.11 (cc 0x812, rev 0x0A, vendor 0x4243) [ ?125.529268] ssb: Core 2 found: USB 1.1 Host (cc 0x817, rev 0x03, vendor 0x4243) [ ?125.529280] ssb: Core 3 found: PCI-E (cc 0x820, rev 0x01, vendor 0x4243) [ ?125.545750] ssb: WARNING: Invalid SPROM CRC (corrupt SPROM)
[ ?125.545752] ssb: Unsupported SPROM revision 255 detected
[ ?125.545797] ssb: Failed to register PCI version of SSB with error -22 [ ?125.545810] b43-pci-bridge 0000:04:00.0: PCI INT A disabled
[ ?125.545827] b43-pci-bridge: probe of 0000:04:00.0 failed with error -22

Hm, now I wonder if we should create sth like list of devices with invalid SPROM, or maybe we should keep current fallback method?

Signature · 1 line
Rafa?
#14 lore raw

PATCH 1/1 ssb: return -ENOMEM on alloc fail (instead of CRC check's result)

In reply to Rafał Miłecki

W dniu 3 listopada 2010 23:28 u?ytkownik Rafa? Mi?ecki <[email protected]> napisa?:

Quoted 1 line

1.6.0.4

Whoops, that old git doesn't nicely numerate patches like 1/2, 2/2. Sorry.

Signature · 1 line
Rafa?