From d269f286500944cdba2396363bfe77fdf2ed094c Mon Sep 17 00:00:00 2001 From: scw Date: Fri, 20 Oct 2006 10:31:06 +0000 Subject: [PATCH] Force a reload of the EEPROM if the MAC address is all zeroes. Fixes PR kern/34812. --- sys/dev/pci/if_vr.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c index 33e30e114d00..cf2f7e63db1b 100644 --- a/sys/dev/pci/if_vr.c +++ b/sys/dev/pci/if_vr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_vr.c,v 1.77 2006/10/12 01:31:30 christos Exp $ */ +/* $NetBSD: if_vr.c,v 1.78 2006/10/20 10:31:06 scw Exp $ */ /*- * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. @@ -104,7 +104,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_vr.c,v 1.77 2006/10/12 01:31:30 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vr.c,v 1.78 2006/10/20 10:31:06 scw Exp $"); #include "rnd.h" @@ -1455,7 +1455,7 @@ vr_attach(struct device *parent __unused, struct device *self, void *aux) struct vr_type *vrt; u_int32_t reg; struct ifnet *ifp; - u_char eaddr[ETHER_ADDR_LEN]; + u_char eaddr[ETHER_ADDR_LEN], mac; int i, rseg, error; #define PCI_CONF_WRITE(r, v) pci_conf_write(sc->vr_pc, sc->vr_tag, (r), (v)) @@ -1582,14 +1582,20 @@ vr_attach(struct device *parent __unused, struct device *self, void *aux) * (and the lack of anyone else noticing the problems this * causes) I'm going to retain the old behaviour for the * other parts. + * In some cases, the chip really does startup without having + * read the EEPROM (kern/34812). To handle this case, we force + * a reload if we see an all-zeroes MAC address. */ - if (PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_VIATECH_VT6105 && - PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_VIATECH_VT6102) { + for (mac = 0, i = 0; i < ETHER_ADDR_LEN; i++) + mac |= (eaddr[i] = CSR_READ_1(sc, VR_PAR0 + i)); + + if (mac == 0 || (PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_VIATECH_VT6105 && + PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_VIATECH_VT6102)) { VR_SETBIT(sc, VR_EECSR, VR_EECSR_LOAD); DELAY(200); + for (i = 0; i < ETHER_ADDR_LEN; i++) + eaddr[i] = CSR_READ_1(sc, VR_PAR0 + i); } - for (i = 0; i < ETHER_ADDR_LEN; i++) - eaddr[i] = CSR_READ_1(sc, VR_PAR0 + i); /* * A Rhine chip was detected. Inform the world.