Module Name: src Committed By: msaitoh Date: Thu Jul 27 03:21:43 UTC 2017
Modified Files: src/sys/dev/pci: if_wm.c if_wmvar.h Log Message: Add WM_F_WA_I210_CLSEM flag for a workaround. FreeBSD/Linux drivers say "In rare circumstances, the SW semaphore may already be held unintentionally." on I21[01]. PXE boot is one of the case. XXX pullup-[678]. To generate a diff of this commit: cvs rdiff -u -r1.532 -r1.533 src/sys/dev/pci/if_wm.c cvs rdiff -u -r1.36 -r1.37 src/sys/dev/pci/if_wmvar.h 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.532 src/sys/dev/pci/if_wm.c:1.533 --- src/sys/dev/pci/if_wm.c:1.532 Wed Jul 26 08:09:59 2017 +++ src/sys/dev/pci/if_wm.c Thu Jul 27 03:21:42 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.532 2017/07/26 08:09:59 msaitoh Exp $ */ +/* $NetBSD: if_wm.c,v 1.533 2017/07/27 03:21:42 msaitoh Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -83,7 +83,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.532 2017/07/26 08:09:59 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.533 2017/07/27 03:21:42 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -2215,6 +2215,8 @@ alloc_retry: break; case WM_T_I210: case WM_T_I211: + /* Allow a single clear of the SW semaphore on I210 and newer*/ + sc->sc_flags |= WM_F_WA_I210_CLSEM; if (wm_nvm_get_flash_presence_i210(sc)) { sc->nvm.read = wm_nvm_read_eerd; /* Don't use WM_F_LOCK_EECD because we use EERD */ @@ -12704,6 +12706,7 @@ wm_get_swsm_semaphore(struct wm_softc *s device_xname(sc->sc_dev), __func__)); KASSERT(sc->sc_nvm_wordsize > 0); +retry: /* Get the SW semaphore. */ timeout = sc->sc_nvm_wordsize + 1; while (timeout) { @@ -12717,6 +12720,16 @@ wm_get_swsm_semaphore(struct wm_softc *s } if (timeout == 0) { + if ((sc->sc_flags & WM_F_WA_I210_CLSEM) != 0) { + /* + * In rare circumstances, the SW semaphore may already + * be held unintentionally. Clear the semaphore once + * before giving up. + */ + sc->sc_flags &= ~WM_F_WA_I210_CLSEM; + wm_put_swsm_semaphore(sc); + goto retry; + } aprint_error_dev(sc->sc_dev, "could not acquire SWSM SMBI\n"); return 1; Index: src/sys/dev/pci/if_wmvar.h diff -u src/sys/dev/pci/if_wmvar.h:1.36 src/sys/dev/pci/if_wmvar.h:1.37 --- src/sys/dev/pci/if_wmvar.h:1.36 Wed Jul 26 06:48:49 2017 +++ src/sys/dev/pci/if_wmvar.h Thu Jul 27 03:21:42 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wmvar.h,v 1.36 2017/07/26 06:48:49 msaitoh Exp $ */ +/* $NetBSD: if_wmvar.h,v 1.37 2017/07/27 03:21:42 msaitoh Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -96,6 +96,7 @@ #define WM_F_80003_MDIC_WA 0x01000000 /* 80003 MDIC workaround */ #define WM_F_PCS_DIS_AUTONEGO 0x02000000 /* PCS Disable Autonego */ #define WM_F_PLL_WA_I210 0x04000000 /* I21[01] PLL workaround */ +#define WM_F_WA_I210_CLSEM 0x08000000 /* I21[01] Semaphore workaround */ #define WM_FLAGS "\20" \ "\1" "HAS_MII" "\2" "LOCK_EECD" "\3" "_B02" "\4" "_B03" \