From nobody@FreeBSD.org  Fri Jan  4 21:02:56 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id 8DA87B3E
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  4 Jan 2013 21:02:56 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 7CD9090A
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  4 Jan 2013 21:02:56 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r04L2utC023180
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 4 Jan 2013 21:02:56 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r04L2uj7023179;
	Fri, 4 Jan 2013 21:02:56 GMT
	(envelope-from nobody)
Message-Id: <201301042102.r04L2uj7023179@red.freebsd.org>
Date: Fri, 4 Jan 2013 21:02:56 GMT
From: Monthadar Al Jaberi <monthadar@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Routerboard RB433AH has slot 18 and not 17 as base slot.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         174978
>Category:       kern
>Synopsis:       Routerboard RB433AH has slot 18 and not 17 as base slot.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    monthadar
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 04 21:10:00 UTC 2013
>Closed-Date:    Sun Mar 10 05:01:19 UTC 2013
>Last-Modified:  Sun Mar 10 05:01:19 UTC 2013
>Originator:     Monthadar Al Jaberi
>Release:        Head r245006
>Organization:
>Environment:
FreeBSD rb433ah 10.0-CURRENT FreeBSD 10.0-CURRENT #179: Fri Jan  4 23:21:47 CET 2013     root@mechy:/usr/obj/mips.mips/usr/src/sys/RB433AH_MFS  mips
>Description:
The Mikrotik Routerboard RB433AH have the PCI bus connections routed diffrently. 

This results in that the base slot for RB433AH is 18 and not the default value of 17. FreeBSD will fail to assign the corret IRQ number. And no interrupts will be received from the connected miniPCI peripheral.
>How-To-Repeat:
Connect a wifi device on slot marked 'J401' on the RB433AH PCB.

Compile a simple kernel following Luiz instructions (http://loos.no-ip.org/routerboard/).

Boot the board. Create a wlan0 device. The wlan0 device is unusable. Error messages like the following will print out when ever running (e.g.):

# ifconfig wlan0 scan
root@rb433ah:~ # ath0: device timeout
ath0: ath_raw_xmit: sc_inreset_cnt > 0; bailing
ath0: ath_raw_xmit: sc_inreset_cnt > 0; bailing
ath0: ath_raw_xmit: sc_inreset_cnt > 0; bailing




>Fix:
Change the base slot value to 18 for the RB433AH board. This can be done by supplying a hint. If no hint is supplied the default value of 17 is used.

An example patch is added.
 

Patch attached with submission follows:

diff --git a/sys/mips/atheros/ar71xx_pci.c b/sys/mips/atheros/ar71xx_pci.c
index 126537c..9b88f60 100644
--- a/sys/mips/atheros/ar71xx_pci.c
+++ b/sys/mips/atheros/ar71xx_pci.c
@@ -81,6 +81,7 @@ struct ar71xx_pci_softc {
 	device_t		sc_dev;
 
 	int			sc_busno;
+	int			sc_baseslot;
 	struct rman		sc_mem_rman;
 	struct rman		sc_irq_rman;
 
@@ -395,6 +396,16 @@ ar71xx_pci_attach(device_t dev)
 	        AR71XX_PCI_IRQ_END) != 0)
 		panic("ar71xx_pci_attach: failed to set up IRQ rman");
 
+	/*
+	 * Check if there is a base slot hint. Otherwise use default value.
+	 */
+	if (resource_int_value(device_get_name(dev),
+	    device_get_unit(dev), "baseslot", &sc->sc_baseslot) != 0) {
+		device_printf(dev,
+		    "%s: missing hint '%s', default to AR71XX_PCI_BASE_SLOT\n",
+		    __func__, "baseslot");
+		sc->sc_baseslot = AR71XX_PCI_BASE_SLOT;
+	}
 
 	ATH_WRITE_REG(AR71XX_PCI_INTR_STATUS, 0);
 	ATH_WRITE_REG(AR71XX_PCI_INTR_MASK, 0);
@@ -648,11 +659,13 @@ ar71xx_pci_maxslots(device_t dev)
 static int
 ar71xx_pci_route_interrupt(device_t pcib, device_t device, int pin)
 {
-	if (pci_get_slot(device) < AR71XX_PCI_BASE_SLOT)
+	struct ar71xx_pci_softc *sc = device_get_softc(pcib);
+	
+	if (pci_get_slot(device) < sc->sc_baseslot)
 		panic("%s: PCI slot %d is less then AR71XX_PCI_BASE_SLOT",
 		    __func__, pci_get_slot(device));
 
-	return (pci_get_slot(device) - AR71XX_PCI_BASE_SLOT);
+	return (pci_get_slot(device) - sc->sc_baseslot);
 }
 
 static device_method_t ar71xx_pci_methods[] = {
diff --git a/sys/mips/conf/RB433AH.hints b/sys/mips/conf/RB433AH.hints
index c2c0c53..08961f9 100644
--- a/sys/mips/conf/RB433AH.hints
+++ b/sys/mips/conf/RB433AH.hints
@@ -24,6 +24,7 @@ hint.ehci.0.irq=1
 # pci
 hint.pcib.0.at="nexus0"
 hint.pcib.0.irq=0
+hint.pcib.0.baseslot=18
 
 hint.arge.0.at="nexus0"
 hint.arge.0.maddr=0x19000000


>Release-Note:
>Audit-Trail:

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/174978: commit references a PR
Date: Sun,  6 Jan 2013 20:50:38 +0000 (UTC)

 Author: monthadar
 Date: Sun Jan  6 20:50:31 2013
 New Revision: 245112
 URL: http://svnweb.freebsd.org/changeset/base/245112
 
 Log:
   Mips Atheros AR71XX: make PCI base slot configurable through hints.
   
   * Mikrotik RouterBoard 433AH have PCI slot 18 wired to INT0 on the PCI Bus.
     This is different from e.g. Atheros PB42 and Ubiquiti boards.
   * Check for hint hint.pcib.0.baseslot=X, where X is number of base slot;
   * If hint not supplied print a warning and use default AR71XX_PCI_BASE_SLOT;
   
   PR:		kern/174978
   Approved by:	adrian (mentor)
 
 Modified:
   head/sys/mips/atheros/ar71xx_pci.c
 
 Modified: head/sys/mips/atheros/ar71xx_pci.c
 ==============================================================================
 --- head/sys/mips/atheros/ar71xx_pci.c	Sun Jan  6 19:27:28 2013	(r245111)
 +++ head/sys/mips/atheros/ar71xx_pci.c	Sun Jan  6 20:50:31 2013	(r245112)
 @@ -81,6 +81,7 @@ struct ar71xx_pci_softc {
  	device_t		sc_dev;
  
  	int			sc_busno;
 +	int			sc_baseslot;
  	struct rman		sc_mem_rman;
  	struct rman		sc_irq_rman;
  
 @@ -395,6 +396,16 @@ ar71xx_pci_attach(device_t dev)
  	        AR71XX_PCI_IRQ_END) != 0)
  		panic("ar71xx_pci_attach: failed to set up IRQ rman");
  
 +	/*
 +	 * Check if there is a base slot hint. Otherwise use default value.
 +	 */
 +	if (resource_int_value(device_get_name(dev),
 +	    device_get_unit(dev), "baseslot", &sc->sc_baseslot) != 0) {
 +		device_printf(dev,
 +		    "%s: missing hint '%s', default to AR71XX_PCI_BASE_SLOT\n",
 +		    __func__, "baseslot");
 +		sc->sc_baseslot = AR71XX_PCI_BASE_SLOT;
 +	}
  
  	ATH_WRITE_REG(AR71XX_PCI_INTR_STATUS, 0);
  	ATH_WRITE_REG(AR71XX_PCI_INTR_MASK, 0);
 @@ -648,11 +659,13 @@ ar71xx_pci_maxslots(device_t dev)
  static int
  ar71xx_pci_route_interrupt(device_t pcib, device_t device, int pin)
  {
 -	if (pci_get_slot(device) < AR71XX_PCI_BASE_SLOT)
 +	struct ar71xx_pci_softc *sc = device_get_softc(pcib);
 +	
 +	if (pci_get_slot(device) < sc->sc_baseslot)
  		panic("%s: PCI slot %d is less then AR71XX_PCI_BASE_SLOT",
  		    __func__, pci_get_slot(device));
  
 -	return (pci_get_slot(device) - AR71XX_PCI_BASE_SLOT);
 +	return (pci_get_slot(device) - sc->sc_baseslot);
  }
  
  static device_method_t ar71xx_pci_methods[] = {
 _______________________________________________
 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"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/174978: commit references a PR
Date: Sun,  6 Jan 2013 20:50:39 +0000 (UTC)

 Author: monthadar
 Date: Sun Jan  6 20:50:31 2013
 New Revision: 245112
 URL: http://svnweb.freebsd.org/changeset/base/245112
 
 Log:
   Mips Atheros AR71XX: make PCI base slot configurable through hints.
   
   * Mikrotik RouterBoard 433AH have PCI slot 18 wired to INT0 on the PCI Bus.
     This is different from e.g. Atheros PB42 and Ubiquiti boards.
   * Check for hint hint.pcib.0.baseslot=X, where X is number of base slot;
   * If hint not supplied print a warning and use default AR71XX_PCI_BASE_SLOT;
   
   PR:		kern/174978
   Approved by:	adrian (mentor)
 
 Modified:
   head/sys/mips/atheros/ar71xx_pci.c
 
 Modified: head/sys/mips/atheros/ar71xx_pci.c
 ==============================================================================
 --- head/sys/mips/atheros/ar71xx_pci.c	Sun Jan  6 19:27:28 2013	(r245111)
 +++ head/sys/mips/atheros/ar71xx_pci.c	Sun Jan  6 20:50:31 2013	(r245112)
 @@ -81,6 +81,7 @@ struct ar71xx_pci_softc {
  	device_t		sc_dev;
  
  	int			sc_busno;
 +	int			sc_baseslot;
  	struct rman		sc_mem_rman;
  	struct rman		sc_irq_rman;
  
 @@ -395,6 +396,16 @@ ar71xx_pci_attach(device_t dev)
  	        AR71XX_PCI_IRQ_END) != 0)
  		panic("ar71xx_pci_attach: failed to set up IRQ rman");
  
 +	/*
 +	 * Check if there is a base slot hint. Otherwise use default value.
 +	 */
 +	if (resource_int_value(device_get_name(dev),
 +	    device_get_unit(dev), "baseslot", &sc->sc_baseslot) != 0) {
 +		device_printf(dev,
 +		    "%s: missing hint '%s', default to AR71XX_PCI_BASE_SLOT\n",
 +		    __func__, "baseslot");
 +		sc->sc_baseslot = AR71XX_PCI_BASE_SLOT;
 +	}
  
  	ATH_WRITE_REG(AR71XX_PCI_INTR_STATUS, 0);
  	ATH_WRITE_REG(AR71XX_PCI_INTR_MASK, 0);
 @@ -648,11 +659,13 @@ ar71xx_pci_maxslots(device_t dev)
  static int
  ar71xx_pci_route_interrupt(device_t pcib, device_t device, int pin)
  {
 -	if (pci_get_slot(device) < AR71XX_PCI_BASE_SLOT)
 +	struct ar71xx_pci_softc *sc = device_get_softc(pcib);
 +	
 +	if (pci_get_slot(device) < sc->sc_baseslot)
  		panic("%s: PCI slot %d is less then AR71XX_PCI_BASE_SLOT",
  		    __func__, pci_get_slot(device));
  
 -	return (pci_get_slot(device) - AR71XX_PCI_BASE_SLOT);
 +	return (pci_get_slot(device) - sc->sc_baseslot);
  }
  
  static device_method_t ar71xx_pci_methods[] = {
 _______________________________________________
 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"
 
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Sun Mar 10 05:00:26 UTC 2013 
State-Changed-Why:  
Already committed. 


Responsible-Changed-From-To: freebsd-bugs->monthadar 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Mar 10 05:00:26 UTC 2013 
Responsible-Changed-Why:  

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