Module Name: src Committed By: msaitoh Date: Thu Aug 9 04:16:37 UTC 2012
Modified Files: src/sys/dev/pci: if_wm.c Log Message: Add workaround for QEMU and the variants. This problem was discovered a few years ago, but some variants and cloud services still have the bug. This problem is not NetBSD's bug but qemus's bug. For NetBSD users, existence of buggy virtual machines s sad thing, so we add a workaroud. To generate a diff of this commit: cvs rdiff -u -r1.229 -r1.230 src/sys/dev/pci/if_wm.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_wm.c diff -u src/sys/dev/pci/if_wm.c:1.229 src/sys/dev/pci/if_wm.c:1.230 --- src/sys/dev/pci/if_wm.c:1.229 Sun Jul 22 14:33:04 2012 +++ src/sys/dev/pci/if_wm.c Thu Aug 9 04:16:37 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.229 2012/07/22 14:33:04 matt Exp $ */ +/* $NetBSD: if_wm.c,v 1.230 2012/08/09 04:16:37 msaitoh Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -76,7 +76,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.229 2012/07/22 14:33:04 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.230 2012/08/09 04:16:37 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -4628,6 +4628,22 @@ wm_read_eeprom_uwire(struct wm_softc *sc reg = CSR_READ(sc, WMREG_EECD) & ~(EECD_SK | EECD_DI); CSR_WRITE(sc, WMREG_EECD, reg); + /* + * XXX: workaround for a bug in qemu-0.12.x and prior + * and Xen. + * + * We use this workaround only for 82540 because qemu's + * e1000 act as 82540. + */ + if (sc->sc_type >= WM_T_82540) { + reg |= EECD_SK; + CSR_WRITE(sc, WMREG_EECD, reg); + reg &= ~EECD_SK; + CSR_WRITE(sc, WMREG_EECD, reg); + delay(2); + } + /* XXX: end of workaround */ + /* Set CHIP SELECT. */ reg |= EECD_CS; CSR_WRITE(sc, WMREG_EECD, reg);