Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Jan 2013 21:02:56 GMT
From:      Monthadar Al Jaberi <monthadar@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/174978: Routerboard RB433AH has slot 18 and not 17 as base slot.
Message-ID:  <201301042102.r04L2uj7023179@red.freebsd.org>
Resent-Message-ID: <201301042110.r04LA0cj064763@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         174978
>Category:       kern
>Synopsis:       Routerboard RB433AH has slot 18 and not 17 as base slot.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 04 21:10:00 UTC 2013
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201301042102.r04L2uj7023179>