From nobody@FreeBSD.org  Sat Jan 22 16:09:44 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id F3505106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 22 Jan 2011 16:09:44 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (unknown [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id C82628FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 22 Jan 2011 16:09:44 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p0MG9ija046402
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 22 Jan 2011 16:09:44 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p0MG9in8046401;
	Sat, 22 Jan 2011 16:09:44 GMT
	(envelope-from nobody)
Message-Id: <201101221609.p0MG9in8046401@red.freebsd.org>
Date: Sat, 22 Jan 2011 16:09:44 GMT
From: Adrian Chadd <adrian@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [ath] AR9280 based Ubiquiti SR71-12/15 panics on interface up (on mips)
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         154220
>Category:       kern
>Synopsis:       [ath] AR9280 based Ubiquiti SR71-12/15 panics on interface up (on mips)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    adrian
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 22 16:10:10 UTC 2011
>Closed-Date:    Sat Apr 09 03:05:12 UTC 2011
>Last-Modified:  Sat Apr 09 03:05:12 UTC 2011
>Originator:     Adrian Chadd
>Release:        FreeBSD-HEAD r217687
>Organization:
>Environment:
mipsbFreeBSD adrian-home-mips 9.0-CURRENT FreeBSD 9.0-CURRENT #13 r217691M: Sat Jan 22 01:04:38 WST 2011     adrian@pcbsd-3114:/data/freebsd/mips/head/obj/rspro_head/mips.
mipseb/data/freebsd/mips/head/src/sys/RSPRO_STANDALONE  mips

>Description:
The AR9220 is detected:

ath0: <Atheros 9280> irq 0 at device 17.0 on pci0
ath0: AR9280 mac 128.2 RF5133 phy 13.0

But the mips kernel panics when the interface is brought up.
>How-To-Repeat:
# ifconfig wlan0 create wlandev ath0
# ifconfig wlan0 up
>Fix:
This was obtained from a linux ath9k patch:

https://patchwork.kernel.org/patch/90926/

Some AR9220 parts require a tweak to the inivals based on the contents of the EEPROM.

There's also a register which, at least at the reset time, generates a bus error when read.

Here's how to fix it enough for testing:

[adrian@pcbsd-3114]/data/freebsd/mips/head/src/sys/dev/ath/ath_hal(252)% svn diff .
Index: ar5416/ar5416_reset.c
===================================================================
--- ar5416/ar5416_reset.c       (revision 217691)
+++ ar5416/ar5416_reset.c       (working copy)
@@ -187,10 +187,12 @@
 
        OS_MARK(ah, AH_MARK_RESET_LINE, __LINE__);
 
+#if 0
        HALDEBUG(ah, HAL_DEBUG_RESET, ">>>2 %s: AR_PHY_DAG_CTRLCCK=0x%x\n",
                __func__, OS_REG_READ(ah,AR_PHY_DAG_CTRLCCK));
        HALDEBUG(ah, HAL_DEBUG_RESET, ">>>2 %s: AR_PHY_ADC_CTL=0x%x\n",
                __func__, OS_REG_READ(ah,AR_PHY_ADC_CTL));
+#endif
 
        /* Set the mute mask to the correct default */
        if (AH_PRIVATE(ah)->ah_phyRev >= AR_PHY_CHIP_ID_REV_2)
Index: ar9002/ar9280v2.ini
===================================================================
--- ar9002/ar9280v2.ini (revision 217691)
+++ ar9002/ar9280v2.ini (working copy)
@@ -67,7 +67,11 @@
     { 0x0000a274, 0x0a19c652, 0x0a19c652, 0x0a1aa652, 0x0a1aa652, 0x0a1aa652 },
     { 0x0000a358, 0x7999aa02, 0x7999aa02, 0x7999aa0e, 0x7999aa0e, 0x7999aa0e },
     { 0x0000a3d8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+#if 0
     { 0x00007894, 0x5a508000, 0x5a508000, 0x5a508000, 0x5a508000, 0x5a508000 },
+#else
+    { 0x00007894, 0x5a108000, 0x5a108000, 0x5a108000, 0x5a108000, 0x5a108000 },
+#endif
 };
 
The true fix is to read the relevant EEPROM value and make sure the right inivalue is written. That way multiple AR9220's of different types can be run on the same board.


>Release-Note:
>Audit-Trail:

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/154220: commit references a PR
Date: Thu, 27 Jan 2011 02:56:15 +0000 (UTC)

 Author: adrian
 Date: Thu Jan 27 02:56:03 2011
 New Revision: 217921
 URL: http://svn.freebsd.org/changeset/base/217921
 
 Log:
   Writing to the analog registers on the AR9220 (Merlin PCI) seems to require a delay.
   
   This, along with an initval change which will appear in a subsequent commit,
   fixes bus panics that I have been seing with the AR9220 on a Routerstation Pro
   (AR7161 MIPS board.)
   
   Obtained from: Linux ath9k
   PR: kern/154220
 
 Modified:
   head/sys/dev/ath/ath_hal/ah.c
 
 Modified: head/sys/dev/ath/ath_hal/ah.c
 ==============================================================================
 --- head/sys/dev/ath/ath_hal/ah.c	Thu Jan 27 02:27:17 2011	(r217920)
 +++ head/sys/dev/ath/ath_hal/ah.c	Thu Jan 27 02:56:03 2011	(r217921)
 @@ -858,6 +858,11 @@ ath_hal_ini_write(struct ath_hal *ah, co
  	for (r = 0; r < ia->rows; r++) {
  		OS_REG_WRITE(ah, HAL_INI_VAL(ia, r, 0),
  		    HAL_INI_VAL(ia, r, col));
 +
 +		/* Analog shift register delay seems needed for Merlin - PR kern/154220 */
 +		if (HAL_INI_VAL(ia, r, 0) >= 0x7800 && HAL_INI_VAL(ia, r, 0) < 0x78a0)
 +			OS_DELAY(100);
 +
  		DMA_YIELD(regWr);
  	}
  	return regWr;
 @@ -881,6 +886,10 @@ ath_hal_ini_bank_write(struct ath_hal *a
  
  	for (r = 0; r < ia->rows; r++) {
  		OS_REG_WRITE(ah, HAL_INI_VAL(ia, r, 0), data[r]);
 +
 +		/* Analog shift register delay seems needed for Merlin - PR kern/154220 */
 +		if (HAL_INI_VAL(ia, r, 0) >= 0x7800 && HAL_INI_VAL(ia, r, 0) < 0x78a0)
 +			OS_DELAY(100);
  		DMA_YIELD(regWr);
  	}
  	return regWr;
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
Responsible-Changed-From-To: freebsd-bugs->adrian 
Responsible-Changed-By: adrian 
Responsible-Changed-When: Thu Jan 27 06:46:29 UTC 2011 
Responsible-Changed-Why:  
My bug 

http://www.freebsd.org/cgi/query-pr.cgi?pr=154220 
State-Changed-From-To: open->closed 
State-Changed-By: adrian 
State-Changed-When: Sat Apr 9 03:04:52 UTC 2011 
State-Changed-Why:  
This has been committed to -HEAD and verifies to work. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=154220 
>Unformatted:
