Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Jun 2012 13:09:42 -0700
From:      YongHyeon PYUN <pyunyh@gmail.com>
To:        Mike Tancsa <mike@sentex.net>
Cc:        freebsd-hardware@freebsd.org
Subject:   Re: pcie realtek issue (re driver)
Message-ID:  <20120601200942.GD10661@michelle.cdnetworks.com>
In-Reply-To: <4FC7B301.30109@sentex.net>
References:  <4FC03C83.4030109@sentex.net> <201205301126.40105.jhb@freebsd.org> <20120531161418.GF1467@michelle.cdnetworks.com> <201205311057.05234.jhb@freebsd.org> <4FC7AD6F.60004@sentex.net> <4FC7B301.30109@sentex.net>

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

--+HP7ph2BbKc20aGI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Thu, May 31, 2012 at 02:05:53PM -0400, Mike Tancsa wrote:
> On 5/31/2012 1:42 PM, Mike Tancsa wrote:
> > On 5/31/2012 10:57 AM, John Baldwin wrote:
> >>>
> >>> Right, but what if it is not(from the pciconf output)?
> >>> I'm pretty sure re(4) used RF_ACTIVE with bus_alloc_resource_any(9).
> >>
> >> Hmm, is this pciconf output when the driver is attached?
> > 
> > Hi,
> > 	Here are some of the variations attached in a txt file.  Could this
> > just be a broken card ?  I will try and boot up another OS on the box
> > and see if it works.
> 
> Oh, and doing a load post reboot,
> 
> 0{intel-i3}# kldload if_re
> pci0: driver added
> found-> vendor=0x8086, dev=0x1c3a, revid=0x04
>         domain=0, bus=0, slot=22, func=0
>         class=07-80-00, hdrtype=0x00, mfdev=1
>         cmdreg=0x0006, statreg=0x0010, cachelnsz=0 (dwords)
>         lattimer=0x00 (0 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
>         intpin=a, irq=16
>         powerspec 3  supports D0 D3  current D0
>         MSI supports 1 message, 64 bit
> pci0:0:22:0: reprobing on driver added
> found-> vendor=0x8086, dev=0x1c22, revid=0x05
>         domain=0, bus=0, slot=31, func=3
>         class=0c-05-00, hdrtype=0x00, mfdev=0
>         cmdreg=0x0003, statreg=0x0280, cachelnsz=0 (dwords)
>         lattimer=0x00 (0 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
>         intpin=c, irq=18
> pci0:0:31:3: reprobing on driver added
> pci1: driver added
> pci2: driver added
> pci3: driver added
> pci4: driver added
> found-> vendor=0x10ec, dev=0x8168, revid=0x03
>         domain=0, bus=4, slot=0, func=0
>         class=02-00-00, hdrtype=0x00, mfdev=0
>         cmdreg=0x0000, statreg=0x0010, cachelnsz=0 (dwords)
>         lattimer=0x00 (0 ns), mingnt=0x00 (0 ns), maxlat=0x00 (0 ns)
>         intpin=a, irq=255
>         powerspec 3  supports D0 D1 D2 D3  current D0
>         MSI supports 1 message, 64 bit
>         MSI-X supports 4 messages in map 0x20
> pci0:4:0:0: reprobing on driver added
> re0: <RealTek 8168/8111 B/C/CP/D/DP/E/F PCIe Gigabit Ethernet> at device
> 0.0 on pci4
> pci4: child re0 requested type 3 for rid 0x18, but the BAR says it is an
> ioport
> pcib4: allocated I/O port range (0xd000-0xd0ff) for rid 10 of re0
> re0: Lazy allocation of 0x100 bytes rid 0x10 type 4 at 0xd000

This is the first time I saw BAR2 is I/O space on RealTek PCI
express device. re(4) switched to use BAR0 with I/O space after
failing to use BAR2. Could you try attached patch?

> re0: MSI count : 1
> re0: MSI-X count : 4
> pcib4: allocated prefetch range (0xf0000000-0xf0003fff) for rid 20 of re0
> re0: Lazy allocation of 0x4000 bytes rid 0x20 type 3 at 0xf0000000
> re0: attempting to allocate 1 MSI-X vectors (4 supported)
> msi: routing MSI-X IRQ 270 to local APIC 1 vector 52
> re0: using IRQ 270 for MSI-X
> re0: Using 1 MSI-X message
> re0: Chip rev. 0x28000000
> re0: MAC rev. 0x00000000
> miibus0: <MII bus> on re0
> rgephy0: <RTL8169S/8110S/8211 1000BASE-T media interface> PHY 1 on miibus0
> rgephy0: OUI 0x00e04c, model 0x0011, rev. 2
> rgephy0:  none, 10baseT, 10baseT-FDX, 10baseT-FDX-flow, 100baseTX,
> 100baseTX-FDX, 100baseTX-FDX-flow, 100baseT4, 1000baseSX,
> 1000baseSX-FDX, 1000baseSX-FDX-flow, 1000baseT, 1000baseT-master,
> 1000baseT-FDX, 1000baseT-FDX-master, 1000baseT-FDX-flow,
> 1000baseT-FDX-flow-master, auto, auto-flow
> re0: PHY write failed
> re0: PHY write failed
> re0: bpf attached
> re0: Ethernet address: 00:0a:cd:1c:ba:89
> pci5: driver added
> pci6: driver added
> 0{intel-i3}#
> 0{intel-i3}# ifconfig re0 up
> re0: reset never completed!
> re0: PHY write failed
> re0: PHY write failed
> re0: PHY write failed
> re0: PHY write failed
> re0: PHY write failed
> re0: PHY write failed
> re0: PHY write failed
> 0{intel-i3}#

--+HP7ph2BbKc20aGI
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="re.map.diff"

Index: sys/dev/re/if_re.c
===================================================================
--- sys/dev/re/if_re.c	(revision 236345)
+++ sys/dev/re/if_re.c	(working copy)
@@ -1191,7 +1191,7 @@
 	const struct rl_hwrev	*hw_rev;
 	u_int32_t		cap, ctl;
 	int			hwrev;
-	u_int16_t		devid, re_did = 0;
+	u_int16_t		cmd, devid, re_did = 0;
 	int			error = 0, i, phy, rid;
 	int			msic, msixc, reg;
 	uint8_t			cfg;
@@ -1220,8 +1220,12 @@
 		sc->rl_res_id = PCIR_BAR(1);
 		sc->rl_res_type = SYS_RES_MEMORY;
 		/* RTL8168/8101E seems to use different BARs. */
-		if (devid == RT_DEVICEID_8168 || devid == RT_DEVICEID_8101E)
+		if (devid == RT_DEVICEID_8168 || devid == RT_DEVICEID_8101E) {
 			sc->rl_res_id = PCIR_BAR(2);
+			cmd = pci_read_config(dev, PCIR_BAR(2), 2);
+			if (PCI_BAR_IO(cmd))
+				sc->rl_res_type = SYS_RES_IOPORT;
+		}
 	} else {
 		sc->rl_res_id = PCIR_BAR(0);
 		sc->rl_res_type = SYS_RES_IOPORT;
@@ -3317,6 +3321,10 @@
 	mii = device_get_softc(sc->rl_miibus);
 
 	RL_LOCK(sc);
+	if ((ifp->if_flags & IFF_UP) == 0) {
+		RL_UNLOCK(sc);
+		return;
+	}
 	mii_pollstat(mii);
 	ifmr->ifm_active = mii->mii_media_active;
 	ifmr->ifm_status = mii->mii_media_status;

--+HP7ph2BbKc20aGI--



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