armv7/imx/wandboard freezing autoinstall

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

armv7/imx/wandboard freezing autoinstall

Artturi Alm
Hi,

same install.conf does work w/atleast bbb, panda and cubie2.
I did try several times and it always freezes like shown below.
and no problems going over manual install/upgrade w/the same board.

imxuart0 at simplebus2: console

I think i initially had the "do you want to set com0 as console"-type
of question w/= yes, but now when i looked at bbb/cubie2 log of install,
i don't see the question even coming up.
So this might irrelevant, but fwiw. imx doesn't have com0 to begin with.

-Artturi


install.conf used w/o passwords&keys:

Password for root =
Which speed should = 115200
Setup a user = aalm
Password for user =
What timezone are you in = Europe/Helsinki
Which disk is the root disk = sd0
Location of sets = nfs
Server IP address or hostname = 192.168.2.1
Filesystem on server to mount = /tmnt/exp
Use TCP transport = yes
Pathname to the sets = 6.2/armv7
Public ssh key for root account =
Public ssh key for user aalm =



U-Boot SPL 2017.09 (Sep 13 2017 - 01:57:10)
Trying to boot from MMC1


U-Boot 2017.09 (Sep 13 2017 - 01:57:10 -0600)

CPU:   Freescale i.MX6Q rev1.2 at 792 MHz
Reset cause: POR
Board: Wandboard rev B1
I2C:   ready
DRAM:  2 GiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
*** Warning - bad CRC, using default environment

No panel detected: default to HDMI
Display: HDMI (1024x768)
In:    serial
Out:   serial
Err:   serial
Net:   FEC [PRIME]
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
reading /imx6q-wandboard-revb1.dtb
35762 bytes read in 21 ms (1.6 MiB/s)
Found EFI removable media binary efi/boot/bootarm.efi
reading efi/boot/bootarm.efi
67372 bytes read in 30 ms (2.1 MiB/s)
## Starting EFI application at 12000000 ...
Scanning disks on usb...
Scanning disks on mmc...
MMC: no card present
mmc_init: -123, time 2
MMC Device 2 not found
MMC Device 3 not found
Scanning disks on sata...
Found 6 disks
>> OpenBSD/armv7 BOOTARM 1.0
boot> boot bsd.rd
booting sd0a:bsd.rd: 2290956+7990812+446804 [174061+90+318688+151881]=0xad97ac

OpenBSD/armv7 booting ...
arg0 0xc0dd97ac arg1 0x0 arg2 0x18000000
Allocating page tables
freestart = 0x10dda000, free_pages = 520742 (0x0007f226)
IRQ stack: p0x10e08000 v0xc0e08000
ABT stack: p0x10e09000 v0xc0e09000
UND stack: p0x10e0a000 v0xc0e0a000
SVC stack: p0x10e0b000 v0xc0e0b000
Creating L1 page table at 0x10ddc000
Mapping kernel
Constructing L2 page tables
undefined page pmap board type: 0
Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2017 OpenBSD. All rights reserved.  https://www.OpenBSD.org

OpenBSD 6.2-beta (RAMDISK) #69: Sat Sep 16 21:52:11 MDT 2017
    [hidden email]:/usr/src/sys/arch/armv7/compile/RAMDISK
real mem  = 2147483648 (2048MB)
avail mem = 2091585536 (1994MB)
mainbus0 at root: Wandboard i.MX6 Quad Board rev B1
cpu0 at mainbus0: ARM Cortex-A9 r2p10 (ARMv7)
cpu0: DC enabled IC enabled WB disabled EABT branch prediction enabled
cpu0: 32KB(32b/l,4way) I-cache, 32KB(32b/l,4way) wr-back D-cache
cortex0 at mainbus0
amptimer0 at cortex0: tick rate 396000 KHz
armliicc0 at cortex0: rtl 7 waymask: 0x0000000f
simplebus0 at mainbus0: "soc"
ampintc0 at simplebus0 nirq 160, ncpu 4
simplebus1 at simplebus0: "aips-bus"
imxccm0 at simplebus1: imx6 rev 1.2 CPU freq: 792 MHz
imxiomuxc0 at simplebus1
simplebus2 at simplebus1: "spba-bus"
imxuart0 at simplebus2: console
imxgpio0 at simplebus1
imxgpio1 at simplebus1
imxgpio2 at simplebus1
imxgpio3 at simplebus1
imxgpio4 at simplebus1
imxgpio5 at simplebus1
imxgpio6 at simplebus1
imxdog0 at simplebus1
simplebus3 at simplebus1: "anatop"
imxgpc0 at simplebus1
simplebus4 at simplebus0: "aips-bus"
imxehci0 at simplebus4
usb0 at imxehci0: USB revision 2.0
uhub0 at usb0 configuration 1 interface 0 "i.MX6 EHCI root hub" rev 2.00/1.00 addr 1
imxehci1 at simplebus4
usb1 at imxehci1: USB revision 2.0
uhub1 at usb1 configuration 1 interface 0 "i.MX6 EHCI root hub" rev 2.00/1.00 addr 1
fec0 at simplebus4
fec0: address 00:1f:7b:b4:04:49
atphy0 at fec0 phy 1: AR8035 10/100/1000 PHY, rev. 4
imxesdhc0 at simplebus4
imxesdhc0: 198 MHz base clock
sdmmc0 at imxesdhc0: 4-bit, mmc high-speed, dma
imxesdhc1 at simplebus4
imxesdhc1: 198 MHz base clock
sdmmc1 at imxesdhc1: 4-bit, mmc high-speed, dma
imxesdhc2 at simplebus4
imxesdhc2: 198 MHz base clock
sdmmc2 at imxesdhc2: 4-bit, mmc high-speed, dma
imxiic0 at simplebus4
iic0 at imxiic0
imxiic1 at simplebus4
iic1 at imxiic1
"fsl,sgtl5000" at iic1 addr 0xa not configured
imxocotp0 at simplebus4
imxuart1 at simplebus4
imxahci0 at simplebus0: AHCI 1.3
scsibus0 at imxahci0: 32 targets
simplebus5 at mainbus0: "regulators"
sdmmc1: can't enable card
scsibus1 at sdmmc2: 2 targets, initiator 0
sd0 at scsibus1 targ 1 lun 0: <SD/MMC, SD16G, 0030> SCSI2 0/direct removable
sd0: 14804MB, 512 bytes/sector, 30318592 sectors
boot device: sd0
root on rd0a swap on rd0b dump on rd0b
WARNING: CHECK AND RESET THE DATE!
erase ^?, werase ^W, kill ^U, intr ^C, status ^T

Welcome to the OpenBSD/armv7 6.2 installation program.
(I)nstall, (U)pgrade, (A)utoinstall or (S)hell? a
DHCPDISCOVER on fec0 - interval 1
DHCPOFFER from 192.168.2.2 (00:22:68:10:3d:f0)
DHCPREQUEST on fec0 to 255.255.255.255
DHCPACK from 192.168.2.2 (00:22:68:10:3d:f0)
bound to 192.168.2.88 -- renewal in 21600 seconds.
Fetching http://192.168.2.2/00:1f:7b:b4:04:49-install.conf?path=snapshots/armv7
Fetching http://192.168.2.2/av7wandb-install.conf?path=snapshots/armv7
Fetching http://192.168.2.2/install.conf?path=snapshots/armv7
Performing non-interactive install...
Terminal type? [vt220] vt220
System hostname? (short form, e.g. 'foo') [av7wandb] av7wandb


Reply | Threaded
Open this post in threaded view
|

Re: armv7/imx/wandboard freezing autoinstall

Artturi Alm
On Tue, Oct 10, 2017 at 12:53:54PM +0300, Artturi Alm wrote:

> Hi,
>
> same install.conf does work w/atleast bbb, panda and cubie2.
> I did try several times and it always freezes like shown below.
> and no problems going over manual install/upgrade w/the same board.
>
> imxuart0 at simplebus2: console
>
> I think i initially had the "do you want to set com0 as console"-type
> of question w/= yes, but now when i looked at bbb/cubie2 log of install,
> i don't see the question even coming up.
> So this might irrelevant, but fwiw. imx doesn't have com0 to begin with.
>
> -Artturi
>

Hi,

noticed this difference on : console reporting:

pandaboard-es:
com0 at simplebus0: ti16750, 64 byte fifo
com0: probed fifo depth: 0 bytes
com1 at simplebus0: ti16750, 64 byte fifo
com1: probed fifo depth: 0 bytes
com2 at simplebus0: ti16750, 64 byte fifo
com2: console
com3 at simplebus0: ti16750, 64 byte fifo
com3: probed fifo depth: 0 bytes

beagleboneblack:
com0 at simplebus0: ti16750, 64 byte fifo
com0: console

cubieboard2:
com0 at simplebus0: ns16550, no working fifo
com0: console

wandboard:
imxuart0 at simplebus2: console
imxuart1 at simplebus4

i honestly don't want to stare at this long enough figure it out
if this is related or not given above difference.
src/distrib/miniroot/install.sub:
3165 # Scan /var/run/dmesg.boot for console device.
3166 CONSOLE=$(scan_dmesg '/^\([^ ]*\).*: console$/s//\1/p')
3167 [[ -n $CONSOLE ]] && CSPEED=$(stty speed </dev/console)

i do saw how armv7 install.md has only this:
md_consoleinfo() {
}

so it's likely not helping out in this situation.
to anyone looking at this, thanks in advance:)
-Artturi

>
> install.conf used w/o passwords&keys:
>
> Password for root =
> Which speed should = 115200
> Setup a user = aalm
> Password for user =
> What timezone are you in = Europe/Helsinki
> Which disk is the root disk = sd0
> Location of sets = nfs
> Server IP address or hostname = 192.168.2.1
> Filesystem on server to mount = /tmnt/exp
> Use TCP transport = yes
> Pathname to the sets = 6.2/armv7
> Public ssh key for root account =
> Public ssh key for user aalm =
>
>
>
> U-Boot SPL 2017.09 (Sep 13 2017 - 01:57:10)
> Trying to boot from MMC1
>
>
> U-Boot 2017.09 (Sep 13 2017 - 01:57:10 -0600)
>
> CPU:   Freescale i.MX6Q rev1.2 at 792 MHz
> Reset cause: POR
> Board: Wandboard rev B1
> I2C:   ready
> DRAM:  2 GiB
> MMC:   FSL_SDHC: 0, FSL_SDHC: 1
> *** Warning - bad CRC, using default environment
>
> No panel detected: default to HDMI
> Display: HDMI (1024x768)
> In:    serial
> Out:   serial
> Err:   serial
> Net:   FEC [PRIME]
> Hit any key to stop autoboot:  0
> switch to partitions #0, OK
> mmc0 is current device
> Scanning mmc 0:1...
> reading /imx6q-wandboard-revb1.dtb
> 35762 bytes read in 21 ms (1.6 MiB/s)
> Found EFI removable media binary efi/boot/bootarm.efi
> reading efi/boot/bootarm.efi
> 67372 bytes read in 30 ms (2.1 MiB/s)
> ## Starting EFI application at 12000000 ...
> Scanning disks on usb...
> Scanning disks on mmc...
> MMC: no card present
> mmc_init: -123, time 2
> MMC Device 2 not found
> MMC Device 3 not found
> Scanning disks on sata...
> Found 6 disks
> >> OpenBSD/armv7 BOOTARM 1.0
> boot> boot bsd.rd
> booting sd0a:bsd.rd: 2290956+7990812+446804 [174061+90+318688+151881]=0xad97ac
>
> OpenBSD/armv7 booting ...
> arg0 0xc0dd97ac arg1 0x0 arg2 0x18000000
> Allocating page tables
> freestart = 0x10dda000, free_pages = 520742 (0x0007f226)
> IRQ stack: p0x10e08000 v0xc0e08000
> ABT stack: p0x10e09000 v0xc0e09000
> UND stack: p0x10e0a000 v0xc0e0a000
> SVC stack: p0x10e0b000 v0xc0e0b000
> Creating L1 page table at 0x10ddc000
> Mapping kernel
> Constructing L2 page tables
> undefined page pmap board type: 0
> Copyright (c) 1982, 1986, 1989, 1991, 1993
>         The Regents of the University of California.  All rights reserved.
> Copyright (c) 1995-2017 OpenBSD. All rights reserved.  https://www.OpenBSD.org
>
> OpenBSD 6.2-beta (RAMDISK) #69: Sat Sep 16 21:52:11 MDT 2017
>     [hidden email]:/usr/src/sys/arch/armv7/compile/RAMDISK
> real mem  = 2147483648 (2048MB)
> avail mem = 2091585536 (1994MB)
> mainbus0 at root: Wandboard i.MX6 Quad Board rev B1
> cpu0 at mainbus0: ARM Cortex-A9 r2p10 (ARMv7)
> cpu0: DC enabled IC enabled WB disabled EABT branch prediction enabled
> cpu0: 32KB(32b/l,4way) I-cache, 32KB(32b/l,4way) wr-back D-cache
> cortex0 at mainbus0
> amptimer0 at cortex0: tick rate 396000 KHz
> armliicc0 at cortex0: rtl 7 waymask: 0x0000000f
> simplebus0 at mainbus0: "soc"
> ampintc0 at simplebus0 nirq 160, ncpu 4
> simplebus1 at simplebus0: "aips-bus"
> imxccm0 at simplebus1: imx6 rev 1.2 CPU freq: 792 MHz
> imxiomuxc0 at simplebus1
> simplebus2 at simplebus1: "spba-bus"
> imxuart0 at simplebus2: console
> imxgpio0 at simplebus1
> imxgpio1 at simplebus1
> imxgpio2 at simplebus1
> imxgpio3 at simplebus1
> imxgpio4 at simplebus1
> imxgpio5 at simplebus1
> imxgpio6 at simplebus1
> imxdog0 at simplebus1
> simplebus3 at simplebus1: "anatop"
> imxgpc0 at simplebus1
> simplebus4 at simplebus0: "aips-bus"
> imxehci0 at simplebus4
> usb0 at imxehci0: USB revision 2.0
> uhub0 at usb0 configuration 1 interface 0 "i.MX6 EHCI root hub" rev 2.00/1.00 addr 1
> imxehci1 at simplebus4
> usb1 at imxehci1: USB revision 2.0
> uhub1 at usb1 configuration 1 interface 0 "i.MX6 EHCI root hub" rev 2.00/1.00 addr 1
> fec0 at simplebus4
> fec0: address 00:1f:7b:b4:04:49
> atphy0 at fec0 phy 1: AR8035 10/100/1000 PHY, rev. 4
> imxesdhc0 at simplebus4
> imxesdhc0: 198 MHz base clock
> sdmmc0 at imxesdhc0: 4-bit, mmc high-speed, dma
> imxesdhc1 at simplebus4
> imxesdhc1: 198 MHz base clock
> sdmmc1 at imxesdhc1: 4-bit, mmc high-speed, dma
> imxesdhc2 at simplebus4
> imxesdhc2: 198 MHz base clock
> sdmmc2 at imxesdhc2: 4-bit, mmc high-speed, dma
> imxiic0 at simplebus4
> iic0 at imxiic0
> imxiic1 at simplebus4
> iic1 at imxiic1
> "fsl,sgtl5000" at iic1 addr 0xa not configured
> imxocotp0 at simplebus4
> imxuart1 at simplebus4
> imxahci0 at simplebus0: AHCI 1.3
> scsibus0 at imxahci0: 32 targets
> simplebus5 at mainbus0: "regulators"
> sdmmc1: can't enable card
> scsibus1 at sdmmc2: 2 targets, initiator 0
> sd0 at scsibus1 targ 1 lun 0: <SD/MMC, SD16G, 0030> SCSI2 0/direct removable
> sd0: 14804MB, 512 bytes/sector, 30318592 sectors
> boot device: sd0
> root on rd0a swap on rd0b dump on rd0b
> WARNING: CHECK AND RESET THE DATE!
> erase ^?, werase ^W, kill ^U, intr ^C, status ^T
>
> Welcome to the OpenBSD/armv7 6.2 installation program.
> (I)nstall, (U)pgrade, (A)utoinstall or (S)hell? a
> DHCPDISCOVER on fec0 - interval 1
> DHCPOFFER from 192.168.2.2 (00:22:68:10:3d:f0)
> DHCPREQUEST on fec0 to 255.255.255.255
> DHCPACK from 192.168.2.2 (00:22:68:10:3d:f0)
> bound to 192.168.2.88 -- renewal in 21600 seconds.
> Fetching http://192.168.2.2/00:1f:7b:b4:04:49-install.conf?path=snapshots/armv7
> Fetching http://192.168.2.2/av7wandb-install.conf?path=snapshots/armv7
> Fetching http://192.168.2.2/install.conf?path=snapshots/armv7
> Performing non-interactive install...
> Terminal type? [vt220] vt220
> System hostname? (short form, e.g. 'foo') [av7wandb] av7wandb
>
>

Reply | Threaded
Open this post in threaded view
|

armv7/imx freezing fec. was: Re: armv7/imx/wandboard freezing autoinstall

Artturi Alm
Hi,

i shot down my guess at imxuart by hexediting output like w/diff below,
and tested latest snapshot too, same thing.

diff --git a/sys/arch/armv7/imx/imxuart.c b/sys/arch/armv7/imx/imxuart.c
index ac4554e2fd5..6743203d212 100644
--- a/sys/arch/armv7/imx/imxuart.c
+++ b/sys/arch/armv7/imx/imxuart.c
@@ -183,7 +183,7 @@ imxuart_attach(struct device *parent, struct device *self, void *aux)
  break;
  cn_tab->cn_dev = makedev(maj, sc->sc_dev.dv_unit);
 
- printf(": console");
+ printf("\n%s: console", sc->sc_dev.dv_xname);
  }
 
  timeout_set(&sc->sc_diag_tmo, imxuart_diag, sc);


so when that was out of the way i saw "ifconfig ... delete ...",
and i was able to trigger the bug from GENERIC w/just:

# ifconfig fec0 delete down
# ifconfig fec0
fec0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        lladdr 00:1f:7b:b4:04:49
        index 1 priority 0 llprio 3
        groups: egress
<FROZEN>

no diff, as i hope this is easy fix to someone more experienced,
with some free time:)
-Artturi

Reply | Threaded
Open this post in threaded view
|

Re: armv7/imx freezing fec. was: Re: armv7/imx/wandboard freezing autoinstall

Artturi Alm
On Wed, Oct 11, 2017 at 04:56:34AM +0300, Artturi Alm wrote:

> Hi,
>
> i shot down my guess at imxuart by hexediting output like w/diff below,
> and tested latest snapshot too, same thing.
>
> diff --git a/sys/arch/armv7/imx/imxuart.c b/sys/arch/armv7/imx/imxuart.c
> index ac4554e2fd5..6743203d212 100644
> --- a/sys/arch/armv7/imx/imxuart.c
> +++ b/sys/arch/armv7/imx/imxuart.c
> @@ -183,7 +183,7 @@ imxuart_attach(struct device *parent, struct device *self, void *aux)
>   break;
>   cn_tab->cn_dev = makedev(maj, sc->sc_dev.dv_unit);
>  
> - printf(": console");
> + printf("\n%s: console", sc->sc_dev.dv_xname);
>   }
>  
>   timeout_set(&sc->sc_diag_tmo, imxuart_diag, sc);
>
>
> so when that was out of the way i saw "ifconfig ... delete ...",
> and i was able to trigger the bug from GENERIC w/just:
>
> # ifconfig fec0 delete down
> # ifconfig fec0
> fec0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
>         lladdr 00:1f:7b:b4:04:49
>         index 1 priority 0 llprio 3
>         groups: egress
> <FROZEN>
>
> no diff, as i hope this is easy fix to someone more experienced,
> with some free time:)
> -Artturi

ping?

i've ran w/the diff below since initial report, but it doesn't fix fec,
merely avoids the deadlock, so fec0 won't work after "ifconfig fec0 down",
without reboot.

-Artturi


diff --git a/sys/arch/armv7/imx/if_fec.c b/sys/arch/armv7/imx/if_fec.c
index 899c1904144..b7008a69522 100644
--- a/sys/arch/armv7/imx/if_fec.c
+++ b/sys/arch/armv7/imx/if_fec.c
@@ -181,6 +181,9 @@
 #define ENET_TXD_INT (1 << 30)
 #endif
 
+#define ENET_MII_TIMEOUT 100000 /* --loop_cnt { delay(5); } */
+#define ENET_RST_TIMEOUT 100000
+
 /*
  * Bus dma allocation structure used by
  * fec_dma_malloc and fec_dma_free.
@@ -286,6 +289,7 @@ fec_attach(struct device *parent, struct device *self, void *aux)
  int tsize, rsize, tbsize, rbsize, s;
  uint32_t phy_reset_gpio[3];
  uint32_t phy_reset_duration;
+ u_int timo = ENET_RST_TIMEOUT;
 
  if (faa->fa_nreg < 1)
  return;
@@ -339,7 +343,8 @@ fec_attach(struct device *parent, struct device *self, void *aux)
 
  /* reset the controller */
  HSET4(sc, ENET_ECR, ENET_ECR_RESET);
- while(HREAD4(sc, ENET_ECR) & ENET_ECR_RESET);
+ while ((HREAD4(sc, ENET_ECR) & ENET_ECR_RESET) && --timo)
+ delay(5);
 
  HWRITE4(sc, ENET_EIMR, 0);
  HWRITE4(sc, ENET_EIR, 0xffffffff);
@@ -600,11 +605,13 @@ void
 fec_init(struct fec_softc *sc)
 {
  struct ifnet *ifp = &sc->sc_ac.ac_if;
+ u_int timo = ENET_RST_TIMEOUT;
  int speed = 0;
 
  /* reset the controller */
  HSET4(sc, ENET_ECR, ENET_ECR_RESET);
- while(HREAD4(sc, ENET_ECR) & ENET_ECR_RESET);
+ while ((HREAD4(sc, ENET_ECR) & ENET_ECR_RESET) && --timo)
+ delay(5);
 
  /* set hw address */
  HWRITE4(sc, ENET_PALR,
@@ -691,6 +698,7 @@ void
 fec_stop(struct fec_softc *sc)
 {
  struct ifnet *ifp = &sc->sc_ac.ac_if;
+ u_int timo = ENET_RST_TIMEOUT;
 
  /*
  * Mark the interface down and cancel the watchdog timer.
@@ -701,9 +709,12 @@ fec_stop(struct fec_softc *sc)
 
  timeout_del(&sc->sc_tick);
 
+ mii_down(&sc->sc_mii);
+
  /* reset the controller */
  HSET4(sc, ENET_ECR, ENET_ECR_RESET);
- while(HREAD4(sc, ENET_ECR) & ENET_ECR_RESET);
+ while ((HREAD4(sc, ENET_ECR) & ENET_ECR_RESET) && --timo)
+ delay(5);
 }
 
 void
@@ -996,6 +1007,7 @@ fec_miibus_readreg(struct device *dev, int phy, int reg)
 {
  int r = 0;
  struct fec_softc *sc = (struct fec_softc *)dev;
+ u_int timo = ENET_MII_TIMEOUT;
 
  HSET4(sc, ENET_EIR, ENET_EIR_MII);
 
@@ -1003,10 +1015,16 @@ fec_miibus_readreg(struct device *dev, int phy, int reg)
     ENET_MMFR_ST | ENET_MMFR_OP_RD | ENET_MMFR_TA |
     phy << ENET_MMFR_PA_SHIFT | reg << ENET_MMFR_RA_SHIFT);
 
- while(!(HREAD4(sc, ENET_EIR) & ENET_EIR_MII));
+ while (!(HREAD4(sc, ENET_EIR) & ENET_EIR_MII) && --timo)
+ delay(5);
 
  r = bus_space_read_4(sc->sc_iot, sc->sc_ioh, ENET_MMFR);
 
+#ifdef DIAGNOSTIC
+ if (!timo)
+ printf("%s: %s timeout\n", sc->sc_dev.dv_xname, __func__);
+#endif
+
  return (r & 0xffff);
 }
 
@@ -1014,6 +1032,7 @@ void
 fec_miibus_writereg(struct device *dev, int phy, int reg, int val)
 {
  struct fec_softc *sc = (struct fec_softc *)dev;
+ u_int timo = ENET_MII_TIMEOUT;
 
  HSET4(sc, ENET_EIR, ENET_EIR_MII);
 
@@ -1022,7 +1041,12 @@ fec_miibus_writereg(struct device *dev, int phy, int reg, int val)
     phy << ENET_MMFR_PA_SHIFT | reg << ENET_MMFR_RA_SHIFT |
     (val & 0xffff));
 
- while(!(HREAD4(sc, ENET_EIR) & ENET_EIR_MII));
+ while (!(HREAD4(sc, ENET_EIR) & ENET_EIR_MII) && --timo)
+ delay(5);
+#ifdef DIAGNOSTIC
+ if (!timo)
+ printf("%s: %s timeout\n", sc->sc_dev.dv_xname, __func__);
+#endif
 
  return;
 }

Reply | Threaded
Open this post in threaded view
|

Re: armv7/imx freezing fec. was: Re: armv7/imx/wandboard freezing autoinstall

Artturi Alm
On Tue, Oct 17, 2017 at 10:46:22PM +0300, Artturi Alm wrote:

> On Wed, Oct 11, 2017 at 04:56:34AM +0300, Artturi Alm wrote:
> > Hi,
> >
> > i shot down my guess at imxuart by hexediting output like w/diff below,
> > and tested latest snapshot too, same thing.
> >
> > diff --git a/sys/arch/armv7/imx/imxuart.c b/sys/arch/armv7/imx/imxuart.c
> > index ac4554e2fd5..6743203d212 100644
> > --- a/sys/arch/armv7/imx/imxuart.c
> > +++ b/sys/arch/armv7/imx/imxuart.c
> > @@ -183,7 +183,7 @@ imxuart_attach(struct device *parent, struct device *self, void *aux)
> >   break;
> >   cn_tab->cn_dev = makedev(maj, sc->sc_dev.dv_unit);
> >  
> > - printf(": console");
> > + printf("\n%s: console", sc->sc_dev.dv_xname);
> >   }
> >  
> >   timeout_set(&sc->sc_diag_tmo, imxuart_diag, sc);
> >
> >
> > so when that was out of the way i saw "ifconfig ... delete ...",
> > and i was able to trigger the bug from GENERIC w/just:
> >
> > # ifconfig fec0 delete down
> > # ifconfig fec0
> > fec0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
> >         lladdr 00:1f:7b:b4:04:49
> >         index 1 priority 0 llprio 3
> >         groups: egress
> > <FROZEN>
> >
> > no diff, as i hope this is easy fix to someone more experienced,
> > with some free time:)
> > -Artturi
>
> ping?
>
> i've ran w/the diff below since initial report, but it doesn't fix fec,
> merely avoids the deadlock, so fec0 won't work after "ifconfig fec0 down",
> without reboot.
>
> -Artturi
>

pong? am i the only fec user bitten by this?

-Artturi

>
> diff --git a/sys/arch/armv7/imx/if_fec.c b/sys/arch/armv7/imx/if_fec.c
> index 899c1904144..b7008a69522 100644
> --- a/sys/arch/armv7/imx/if_fec.c
> +++ b/sys/arch/armv7/imx/if_fec.c
> @@ -181,6 +181,9 @@
>  #define ENET_TXD_INT (1 << 30)
>  #endif
>  
> +#define ENET_MII_TIMEOUT 100000 /* --loop_cnt { delay(5); } */
> +#define ENET_RST_TIMEOUT 100000
> +
>  /*
>   * Bus dma allocation structure used by
>   * fec_dma_malloc and fec_dma_free.
> @@ -286,6 +289,7 @@ fec_attach(struct device *parent, struct device *self, void *aux)
>   int tsize, rsize, tbsize, rbsize, s;
>   uint32_t phy_reset_gpio[3];
>   uint32_t phy_reset_duration;
> + u_int timo = ENET_RST_TIMEOUT;
>  
>   if (faa->fa_nreg < 1)
>   return;
> @@ -339,7 +343,8 @@ fec_attach(struct device *parent, struct device *self, void *aux)
>  
>   /* reset the controller */
>   HSET4(sc, ENET_ECR, ENET_ECR_RESET);
> - while(HREAD4(sc, ENET_ECR) & ENET_ECR_RESET);
> + while ((HREAD4(sc, ENET_ECR) & ENET_ECR_RESET) && --timo)
> + delay(5);
>  
>   HWRITE4(sc, ENET_EIMR, 0);
>   HWRITE4(sc, ENET_EIR, 0xffffffff);
> @@ -600,11 +605,13 @@ void
>  fec_init(struct fec_softc *sc)
>  {
>   struct ifnet *ifp = &sc->sc_ac.ac_if;
> + u_int timo = ENET_RST_TIMEOUT;
>   int speed = 0;
>  
>   /* reset the controller */
>   HSET4(sc, ENET_ECR, ENET_ECR_RESET);
> - while(HREAD4(sc, ENET_ECR) & ENET_ECR_RESET);
> + while ((HREAD4(sc, ENET_ECR) & ENET_ECR_RESET) && --timo)
> + delay(5);
>  
>   /* set hw address */
>   HWRITE4(sc, ENET_PALR,
> @@ -691,6 +698,7 @@ void
>  fec_stop(struct fec_softc *sc)
>  {
>   struct ifnet *ifp = &sc->sc_ac.ac_if;
> + u_int timo = ENET_RST_TIMEOUT;
>  
>   /*
>   * Mark the interface down and cancel the watchdog timer.
> @@ -701,9 +709,12 @@ fec_stop(struct fec_softc *sc)
>  
>   timeout_del(&sc->sc_tick);
>  
> + mii_down(&sc->sc_mii);
> +
>   /* reset the controller */
>   HSET4(sc, ENET_ECR, ENET_ECR_RESET);
> - while(HREAD4(sc, ENET_ECR) & ENET_ECR_RESET);
> + while ((HREAD4(sc, ENET_ECR) & ENET_ECR_RESET) && --timo)
> + delay(5);
>  }
>  
>  void
> @@ -996,6 +1007,7 @@ fec_miibus_readreg(struct device *dev, int phy, int reg)
>  {
>   int r = 0;
>   struct fec_softc *sc = (struct fec_softc *)dev;
> + u_int timo = ENET_MII_TIMEOUT;
>  
>   HSET4(sc, ENET_EIR, ENET_EIR_MII);
>  
> @@ -1003,10 +1015,16 @@ fec_miibus_readreg(struct device *dev, int phy, int reg)
>      ENET_MMFR_ST | ENET_MMFR_OP_RD | ENET_MMFR_TA |
>      phy << ENET_MMFR_PA_SHIFT | reg << ENET_MMFR_RA_SHIFT);
>  
> - while(!(HREAD4(sc, ENET_EIR) & ENET_EIR_MII));
> + while (!(HREAD4(sc, ENET_EIR) & ENET_EIR_MII) && --timo)
> + delay(5);
>  
>   r = bus_space_read_4(sc->sc_iot, sc->sc_ioh, ENET_MMFR);
>  
> +#ifdef DIAGNOSTIC
> + if (!timo)
> + printf("%s: %s timeout\n", sc->sc_dev.dv_xname, __func__);
> +#endif
> +
>   return (r & 0xffff);
>  }
>  
> @@ -1014,6 +1032,7 @@ void
>  fec_miibus_writereg(struct device *dev, int phy, int reg, int val)
>  {
>   struct fec_softc *sc = (struct fec_softc *)dev;
> + u_int timo = ENET_MII_TIMEOUT;
>  
>   HSET4(sc, ENET_EIR, ENET_EIR_MII);
>  
> @@ -1022,7 +1041,12 @@ fec_miibus_writereg(struct device *dev, int phy, int reg, int val)
>      phy << ENET_MMFR_PA_SHIFT | reg << ENET_MMFR_RA_SHIFT |
>      (val & 0xffff));
>  
> - while(!(HREAD4(sc, ENET_EIR) & ENET_EIR_MII));
> + while (!(HREAD4(sc, ENET_EIR) & ENET_EIR_MII) && --timo)
> + delay(5);
> +#ifdef DIAGNOSTIC
> + if (!timo)
> + printf("%s: %s timeout\n", sc->sc_dev.dv_xname, __func__);
> +#endif
>  
>   return;
>  }