Tue Feb 18 04:07:14 2020 UTC ()
 It's useless to not to set PCI_PMCSR_PME_STS bit when writing because
the bit is W1C. Instead, always write PCI_PMCSR_PME_STS bit to clear in
case it's already set.


(msaitoh)
diff -r1.667 -r1.668 src/sys/dev/pci/if_wm.c

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

--- src/sys/dev/pci/if_wm.c 2020/02/18 03:48:22 1.667
+++ src/sys/dev/pci/if_wm.c 2020/02/18 04:07:14 1.668
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_wm.c,v 1.667 2020/02/18 03:48:22 msaitoh Exp $ */ 1/* $NetBSD: if_wm.c,v 1.668 2020/02/18 04:07:14 msaitoh 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
@@ -72,27 +72,27 @@ @@ -72,27 +72,27 @@
72 * 72 *
73 * TODO (in order of importance): 73 * TODO (in order of importance):
74 * 74 *
75 * - Check XXX'ed comments 75 * - Check XXX'ed comments
76 * - TX Multi queue improvement (refine queue selection logic) 76 * - TX Multi queue improvement (refine queue selection logic)
77 * - Split header buffer for newer descriptors 77 * - Split header buffer for newer descriptors
78 * - EEE (Energy Efficiency Ethernet) for I354 78 * - EEE (Energy Efficiency Ethernet) for I354
79 * - Virtual Function 79 * - Virtual Function
80 * - Set LED correctly (based on contents in EEPROM) 80 * - Set LED correctly (based on contents in EEPROM)
81 * - Rework how parameters are loaded from the EEPROM. 81 * - Rework how parameters are loaded from the EEPROM.
82 */ 82 */
83 83
84#include <sys/cdefs.h> 84#include <sys/cdefs.h>
85__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.667 2020/02/18 03:48:22 msaitoh Exp $"); 85__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.668 2020/02/18 04:07:14 msaitoh Exp $");
86 86
87#ifdef _KERNEL_OPT 87#ifdef _KERNEL_OPT
88#include "opt_net_mpsafe.h" 88#include "opt_net_mpsafe.h"
89#include "opt_if_wm.h" 89#include "opt_if_wm.h"
90#endif 90#endif
91 91
92#include <sys/param.h> 92#include <sys/param.h>
93#include <sys/systm.h> 93#include <sys/systm.h>
94#include <sys/callout.h> 94#include <sys/callout.h>
95#include <sys/mbuf.h> 95#include <sys/mbuf.h>
96#include <sys/malloc.h> 96#include <sys/malloc.h>
97#include <sys/kmem.h> 97#include <sys/kmem.h>
98#include <sys/kernel.h> 98#include <sys/kernel.h>
@@ -15345,32 +15345,33 @@ wm_enable_wakeup(struct wm_softc *sc) @@ -15345,32 +15345,33 @@ wm_enable_wakeup(struct wm_softc *sc)
15345 CSR_WRITE(sc, WMREG_WUC, WUC_APME | WUC_PME_EN); 15345 CSR_WRITE(sc, WMREG_WUC, WUC_APME | WUC_PME_EN);
15346 CSR_WRITE(sc, WMREG_WUFC, WUFC_MAG); 15346 CSR_WRITE(sc, WMREG_WUFC, WUFC_MAG);
15347 } 15347 }
15348 15348
15349 if (((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9) 15349 if (((sc->sc_type == WM_T_ICH8) || (sc->sc_type == WM_T_ICH9)
15350 || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH) 15350 || (sc->sc_type == WM_T_ICH10) || (sc->sc_type == WM_T_PCH)
15351 || (sc->sc_type == WM_T_PCH2)) 15351 || (sc->sc_type == WM_T_PCH2))
15352 && (sc->sc_phytype == WMPHY_IGP_3)) 15352 && (sc->sc_phytype == WMPHY_IGP_3))
15353 wm_igp3_phy_powerdown_workaround_ich8lan(sc); 15353 wm_igp3_phy_powerdown_workaround_ich8lan(sc);
15354 15354
15355pme: 15355pme:
15356 /* Request PME */ 15356 /* Request PME */
15357 pmode = pci_conf_read(sc->sc_pc, sc->sc_pcitag, pmreg + PCI_PMCSR); 15357 pmode = pci_conf_read(sc->sc_pc, sc->sc_pcitag, pmreg + PCI_PMCSR);
 15358 pmode |= PCI_PMCSR_PME_STS; /* in case it's already set (W1C) */
15358 if ((rv == 0) && (sc->sc_flags & WM_F_WOL) != 0) { 15359 if ((rv == 0) && (sc->sc_flags & WM_F_WOL) != 0) {
15359 /* For WOL */ 15360 /* For WOL */
15360 pmode |= PCI_PMCSR_PME_STS | PCI_PMCSR_PME_EN; 15361 pmode |= PCI_PMCSR_PME_EN;
15361 } else { 15362 } else {
15362 /* Disable WOL */ 15363 /* Disable WOL */
15363 pmode &= ~(PCI_PMCSR_PME_STS | PCI_PMCSR_PME_EN); 15364 pmode &= ~PCI_PMCSR_PME_EN;
15364 } 15365 }
15365 pci_conf_write(sc->sc_pc, sc->sc_pcitag, pmreg + PCI_PMCSR, pmode); 15366 pci_conf_write(sc->sc_pc, sc->sc_pcitag, pmreg + PCI_PMCSR, pmode);
15366} 15367}
15367 15368
15368/* Disable ASPM L0s and/or L1 for workaround */ 15369/* Disable ASPM L0s and/or L1 for workaround */
15369static void 15370static void
15370wm_disable_aspm(struct wm_softc *sc) 15371wm_disable_aspm(struct wm_softc *sc)
15371{ 15372{
15372 pcireg_t reg, mask = 0; 15373 pcireg_t reg, mask = 0;
15373 unsigned const char *str = ""; 15374 unsigned const char *str = "";
15374 15375
15375 /* 15376 /*
15376 * Only for PCIe device which has PCIe capability in the PCI config 15377 * Only for PCIe device which has PCIe capability in the PCI config