Module Name: src Committed By: ryo Date: Thu Nov 11 06:56:56 UTC 2021
Modified Files: src/sys/dev/pci: if_aq.c Log Message: Fixed a panic problem at attach with aq(4) F/W version 1. - Don't use cprng(9) when attaching, since it's not available yet. - Wait up to 10 seconds because delay is not enough. - Even if the delay is not enough, it will fail attach without panic. - Checked on the actual card D107 (F/W version 1.5.58) To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pci/if_aq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/if_aq.c diff -u src/sys/dev/pci/if_aq.c:1.29 src/sys/dev/pci/if_aq.c:1.30 --- src/sys/dev/pci/if_aq.c:1.29 Mon Oct 11 15:08:17 2021 +++ src/sys/dev/pci/if_aq.c Thu Nov 11 06:56:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_aq.c,v 1.29 2021/10/11 15:08:17 msaitoh Exp $ */ +/* $NetBSD: if_aq.c,v 1.30 2021/11/11 06:56:56 ryo Exp $ */ /** * aQuantia Corporation Network Driver @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.29 2021/10/11 15:08:17 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.30 2021/11/11 06:56:56 ryo Exp $"); #ifdef _KERNEL_OPT #include "opt_if_aq.h" @@ -2068,22 +2068,22 @@ aq_hw_init_ucp(struct aq_softc *sc) int timo; if (FW_VERSION_MAJOR(sc) == 1) { - if (AQ_READ_REG(sc, FW1X_MPI_INIT2_REG) == 0) { - uint32_t data; - cprng_fast(&data, sizeof(data)); - data &= 0xfefefefe; - data |= 0x02020202; - AQ_WRITE_REG(sc, FW1X_MPI_INIT2_REG, data); - } + if (AQ_READ_REG(sc, FW1X_MPI_INIT2_REG) == 0) + AQ_WRITE_REG(sc, FW1X_MPI_INIT2_REG, 0xfefefefe); AQ_WRITE_REG(sc, FW1X_MPI_INIT1_REG, 0); } - for (timo = 100; timo > 0; timo--) { + /* Wait a maximum of 10sec. It usually takes about 5sec. */ + for (timo = 10000; timo > 0; timo--) { sc->sc_mbox_addr = AQ_READ_REG(sc, FW_MPI_MBOX_ADDR_REG); if (sc->sc_mbox_addr != 0) break; delay(1000); } + if (sc->sc_mbox_addr == 0) { + aprint_error_dev(sc->sc_dev, "cannot get mbox addr\n"); + return ETIMEDOUT; + } #define AQ_FW_MIN_VERSION 0x01050006 #define AQ_FW_MIN_VERSION_STR "1.5.6"