Wed Mar 8 08:00:09 2017 UTC ()
PR kern/52039: use same safeguard as for the 82578


(kardel)
diff -r1.496 -r1.497 src/sys/dev/pci/if_wm.c

cvs diff -r1.496 -r1.497 src/sys/dev/pci/if_wm.c (expand / switch to unified diff)

--- src/sys/dev/pci/if_wm.c 2017/03/03 16:48:55 1.496
+++ src/sys/dev/pci/if_wm.c 2017/03/08 08:00:09 1.497
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_wm.c,v 1.496 2017/03/03 16:48:55 knakahara Exp $ */ 1/* $NetBSD: if_wm.c,v 1.497 2017/03/08 08:00:09 kardel Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. 4 * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc. 7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -74,27 +74,27 @@ @@ -74,27 +74,27 @@
74 * 74 *
75 * - Check XXX'ed comments 75 * - Check XXX'ed comments
76 * - Disable D0 LPLU on 8257[12356], 82580 and I350. 76 * - Disable D0 LPLU on 8257[12356], 82580 and I350.
77 * - TX Multi queue improvement (refine queue selection logic) 77 * - TX Multi queue improvement (refine queue selection logic)
78 * - Split header buffer for newer descriptors 78 * - Split header buffer for newer descriptors
79 * - EEE (Energy Efficiency Ethernet) 79 * - EEE (Energy Efficiency Ethernet)
80 * - Virtual Function 80 * - Virtual Function
81 * - Set LED correctly (based on contents in EEPROM) 81 * - Set LED correctly (based on contents in EEPROM)
82 * - Rework how parameters are loaded from the EEPROM. 82 * - Rework how parameters are loaded from the EEPROM.
83 * - Image Unique ID 83 * - Image Unique ID
84 */ 84 */
85 85
86#include <sys/cdefs.h> 86#include <sys/cdefs.h>
87__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.496 2017/03/03 16:48:55 knakahara Exp $"); 87__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.497 2017/03/08 08:00:09 kardel Exp $");
88 88
89#ifdef _KERNEL_OPT 89#ifdef _KERNEL_OPT
90#include "opt_net_mpsafe.h" 90#include "opt_net_mpsafe.h"
91#include "opt_if_wm.h" 91#include "opt_if_wm.h"
92#endif 92#endif
93 93
94#include <sys/param.h> 94#include <sys/param.h>
95#include <sys/systm.h> 95#include <sys/systm.h>
96#include <sys/callout.h> 96#include <sys/callout.h>
97#include <sys/mbuf.h> 97#include <sys/mbuf.h>
98#include <sys/malloc.h> 98#include <sys/malloc.h>
99#include <sys/kmem.h> 99#include <sys/kmem.h>
100#include <sys/kernel.h> 100#include <sys/kernel.h>
@@ -13168,27 +13168,27 @@ wm_enable_wakeup(struct wm_softc *sc) @@ -13168,27 +13168,27 @@ wm_enable_wakeup(struct wm_softc *sc)
13168 /* Disable gig during WOL */ 13168 /* Disable gig during WOL */
13169 reg = CSR_READ(sc, WMREG_PHY_CTRL); 13169 reg = CSR_READ(sc, WMREG_PHY_CTRL);
13170 reg |= PHY_CTRL_D0A_LPLU | PHY_CTRL_GBE_DIS; 13170 reg |= PHY_CTRL_D0A_LPLU | PHY_CTRL_GBE_DIS;
13171 CSR_WRITE(sc, WMREG_PHY_CTRL, reg); 13171 CSR_WRITE(sc, WMREG_PHY_CTRL, reg);
13172 if (sc->sc_type == WM_T_PCH) 13172 if (sc->sc_type == WM_T_PCH)
13173 wm_gmii_reset(sc); 13173 wm_gmii_reset(sc);
13174 13174
13175 /* Power down workaround */ 13175 /* Power down workaround */
13176 if (sc->sc_phytype == WMPHY_82577) { 13176 if (sc->sc_phytype == WMPHY_82577) {
13177 struct mii_softc *child; 13177 struct mii_softc *child;
13178 13178
13179 /* Assume that the PHY is copper */ 13179 /* Assume that the PHY is copper */
13180 child = LIST_FIRST(&sc->sc_mii.mii_phys); 13180 child = LIST_FIRST(&sc->sc_mii.mii_phys);
13181 if (child->mii_mpd_rev <= 2) 13181 if ((child != NULL) && (child->mii_mpd_rev <= 2))
13182 sc->sc_mii.mii_writereg(sc->sc_dev, 1, 13182 sc->sc_mii.mii_writereg(sc->sc_dev, 1,
13183 (768 << 5) | 25, 0x0444); /* magic num */ 13183 (768 << 5) | 25, 0x0444); /* magic num */
13184 } 13184 }
13185 break; 13185 break;
13186 default: 13186 default:
13187 break; 13187 break;
13188 } 13188 }
13189 13189
13190 /* Keep the laser running on fiber adapters */ 13190 /* Keep the laser running on fiber adapters */
13191 if ((sc->sc_mediatype == WM_MEDIATYPE_FIBER) 13191 if ((sc->sc_mediatype == WM_MEDIATYPE_FIBER)
13192 || (sc->sc_mediatype == WM_MEDIATYPE_SERDES)) { 13192 || (sc->sc_mediatype == WM_MEDIATYPE_SERDES)) {
13193 reg = CSR_READ(sc, WMREG_CTRL_EXT); 13193 reg = CSR_READ(sc, WMREG_CTRL_EXT);
13194 reg |= CTRL_EXT_SWDPIN(3); 13194 reg |= CTRL_EXT_SWDPIN(3);