From patchwork Thu Jan 12 19:08:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Torvalds X-Patchwork-Id: 135681 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7491FB6FBB for ; Fri, 13 Jan 2012 06:09:08 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754951Ab2ALTIt (ORCPT ); Thu, 12 Jan 2012 14:08:49 -0500 Received: from mail-yw0-f46.google.com ([209.85.213.46]:40428 "EHLO mail-yw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754560Ab2ALTIp (ORCPT ); Thu, 12 Jan 2012 14:08:45 -0500 Received: by yhjj63 with SMTP id j63so1124043yhj.19 for ; Thu, 12 Jan 2012 11:08:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=zpKlqHOazie7WtirDqaKsEQkGY0Zl4uNAe8cDDxyoBY=; b=K8PXpEG0Pjksu38lcCaSVN1WAqcJ31J6bth7qXWbcLHqyU38qO46rLJNY7fL4pI3Nu UkxzugQUibZz74Bo3kS/F/eq6q8YoYvqHWoMP5sQl85sj/ktrFFseom3mrRId9R96ikz rWr11MYZlN53uLs8uJhdYxsVa8EqDWMi3kfvk= Received: by 10.236.9.40 with SMTP id 28mr7866224yhs.29.1326395325291; Thu, 12 Jan 2012 11:08:45 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.175.170 with HTTP; Thu, 12 Jan 2012 11:08:24 -0800 (PST) In-Reply-To: References: <4F0D6806.4080201@broadcom.com> <4F0DC030.6090500@lwfinger.net> <4F0E3B7E.8040005@lwfinger.net> <4F0E5E57.9060204@lwfinger.net> From: Linus Torvalds Date: Thu, 12 Jan 2012 11:08:24 -0800 X-Google-Sender-Auth: hcqxWXI79HBoxDJttqXFaMA8cM4 Message-ID: Subject: Re: brcm80211 breakage.. To: Larry Finger , Arend van Spriel , Alwin Beukers , Roland Vossen Cc: "John W. Linville" , Network Development , "Franky (Zhenhui) Lin" , =?ISO-8859-2?Q?Rafa=B3_Mi=B3ecki?= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Jan 12, 2012 at 11:00 AM, Linus Torvalds wrote: > > I'll send out a patch that seems to get things to a working state for > me. At least I have wireless connectivity again, I don't know if there > are some other problems remaining. Ok, this is the patch that gets me going, and this is sent from the Macbook Air. NOTE! The BCMA confusion about the sprom still exists, but doesn't seem to matter: bcma: Core 0 found: ChipCommon (manuf 0x4BF, id 0x800, rev 0x22, class 0x0) bcma: Core 1 found: IEEE 802.11 (manuf 0x4BF, id 0x812, rev 0x17, class 0x0) bcma: Core 2 found: PCIe (manuf 0x4BF, id 0x820, rev 0x0F, class 0x0) bcma: Found rev 6 PMU (capabilities 0x108C2606) bcma: Unsupported SPROM revision: 255 bcma: No SPROM available bcma: Bus registered .. brcmsmac bcma0:0: mfg 4bf core 812 rev 23 class 0 irq 17 brcmsmac: Found chip type AI (0x1381a8d8) brcmsmac: Applying 43224B0+ WARs bcma: Switched to core: 0x812 ieee80211 phy0: Selected rate control algorithm 'minstrel_ht' brcms_module_init: register returned 0 so this does seem to work, but there are clearly some issues still.. Linus drivers/net/wireless/brcm80211/Makefile | 2 +- drivers/net/wireless/brcm80211/brcmsmac/srom.c | 31 +++++++++++++++-------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/brcm80211/Makefile b/drivers/net/wireless/brcm80211/Makefile index f41c047eca82..bae5219cd8be 100644 --- a/drivers/net/wireless/brcm80211/Makefile +++ b/drivers/net/wireless/brcm80211/Makefile @@ -16,7 +16,7 @@ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # common flags -subdir-ccflags-$(CONFIG_BRCMDBG) += -DBCMDBG +subdir-ccflags-$(CONFIG_BRCMDBG) += -DBCMDBG -DDEBUG obj-$(CONFIG_BRCMUTIL) += brcmutil/ obj-$(CONFIG_BRCMFMAC) += brcmfmac/ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.c b/drivers/net/wireless/brcm80211/brcmsmac/srom.c index 61092156755e..563743643038 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.c @@ -764,6 +764,22 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) } /* + * The crc check is done on a little-endian array, we need + * to switch the bytes around before checking crc (and + * then switch it back). + */ +static int do_crc_check(u16 *buf, unsigned nwords) +{ + u8 crc; + + cpu_to_le16_buf(buf, nwords); + crc = crc8(brcms_srom_crc8_table, (void *)buf, nwords << 1, CRC8_INIT_VALUE); + le16_to_cpu_buf(buf, nwords); + + return crc == CRC8_GOOD_VALUE(brcms_srom_crc8_table); +} + +/* * Read in and validate sprom. * Return 0 on success, nonzero on error. */ @@ -772,8 +788,6 @@ sprom_read_pci(struct si_pub *sih, u16 *buf, uint nwords, bool check_crc) { int err = 0; uint i; - u8 *bbuf = (u8 *)buf; /* byte buffer */ - uint nbytes = nwords << 1; struct bcma_device *core; uint sprom_offset; @@ -786,9 +800,9 @@ sprom_read_pci(struct si_pub *sih, u16 *buf, uint nwords, bool check_crc) sprom_offset = CHIPCREGOFFS(sromotp); } - /* read the sprom in bytes */ - for (i = 0; i < nbytes; i++) - bbuf[i] = bcma_read8(core, sprom_offset+i); + /* read the sprom */ + for (i = 0; i < nwords; i++) + buf[i] = bcma_read16(core, sprom_offset+i*2); if (buf[0] == 0xffff) /* @@ -798,13 +812,8 @@ sprom_read_pci(struct si_pub *sih, u16 *buf, uint nwords, bool check_crc) */ return -ENODATA; - if (check_crc && - crc8(brcms_srom_crc8_table, bbuf, nbytes, CRC8_INIT_VALUE) != - CRC8_GOOD_VALUE(brcms_srom_crc8_table)) + if (check_crc && !do_crc_check(buf, nwords)) err = -EIO; - else - /* now correct the endianness of the byte array */ - le16_to_cpu_buf(buf, nwords); return err; }