Module Name: src Committed By: bouyer Date: Wed Oct 17 20:46:37 UTC 2012
Modified Files: src/sys/dev/pci [netbsd-5]: if_wm.c Log Message: Apply patch, requested by msaitoh in ticket 1800: sys/dev/pci/if_wm.c: revision 1.231 via patch Add workaround for QEMU and the variants that fail on EEPROM access. 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' bug. For NetBSD users, existence of buggy virtual machines is sad thing, so we add a workaroud. To generate a diff of this commit: cvs rdiff -u -r1.162.4.16 -r1.162.4.17 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.162.4.16 src/sys/dev/pci/if_wm.c:1.162.4.17 --- src/sys/dev/pci/if_wm.c:1.162.4.16 Wed Jan 25 18:02:17 2012 +++ src/sys/dev/pci/if_wm.c Wed Oct 17 20:46:37 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.162.4.16 2012/01/25 18:02:17 riz Exp $ */ +/* $NetBSD: if_wm.c,v 1.162.4.17 2012/10/17 20:46:37 bouyer 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.162.4.16 2012/01/25 18:02:17 riz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.162.4.17 2012/10/17 20:46:37 bouyer Exp $"); #include "bpfilter.h" #include "rnd.h" @@ -4362,6 +4362,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);