Module Name:    src
Committed By:   snj
Date:           Thu Apr 30 19:53:28 UTC 2015

Modified Files:
        src/sys/dev/pci [netbsd-6]: if_wm.c if_wmvar.h pcidevs

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1296):
        sys/dev/pci/pcidevs: revision 1.1195 via patch
        sys/dev/pci/if_wm.c: revisions 1.290, 1.304 via patch
        sys/dev/pci/if_wmvar.h: revision 1.20 via patch
- Set the WM_F_ATTACHED flag if wm_attach() finished succesfully and
  check the flag in wm_detach(). It will avoid to panic in wm_detach().
  Fixes PR#49102.
- Support DH89xxCC device.
- Add extra delay for 82580 and newer devices except DH89XXCC SGMII device.
  Same as FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.227.2.17 -r1.227.2.18 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.12.10.5 -r1.12.10.6 src/sys/dev/pci/if_wmvar.h
cvs rdiff -u -r1.1102.2.17 -r1.1102.2.18 src/sys/dev/pci/pcidevs

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.227.2.17 src/sys/dev/pci/if_wm.c:1.227.2.18
--- src/sys/dev/pci/if_wm.c:1.227.2.17	Sun Apr 19 17:01:50 2015
+++ src/sys/dev/pci/if_wm.c	Thu Apr 30 19:53:28 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.227.2.17 2015/04/19 17:01:50 riz Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.227.2.18 2015/04/30 19:53:28 snj 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.227.2.17 2015/04/19 17:01:50 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.227.2.18 2015/04/30 19:53:28 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -264,6 +264,7 @@ struct wm_softc {
 	int sc_pcixe_capoff;		/* PCI[Xe] capability register offset */
 
 	const struct wm_product *sc_wmp; /* Pointer to the wm_product entry */
+	uint16_t sc_pcidevid;		/* PCI device ID */
 	wm_chip_type sc_type;		/* MAC type */
 	int sc_rev;			/* MAC revision */
 	wm_phy_type sc_phytype;		/* PHY type */
@@ -854,14 +855,14 @@ static const struct wm_product {
 	  "Intel PRO/1000 QT (82571EB)",
 	  WM_T_82571,		WMP_F_1000T },
 
-	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82572EI_COPPER,
-	  "Intel i82572EI 1000baseT Ethernet",
-	  WM_T_82572,		WMP_F_1000T },
-
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82571GB_QUAD_COPPER,
 	  "Intel PRO/1000 PT Quad Port Server Adapter",
 	  WM_T_82571,		WMP_F_1000T, },
 
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82572EI_COPPER,
+	  "Intel i82572EI 1000baseT Ethernet",
+	  WM_T_82572,		WMP_F_1000T },
+
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82572EI_FIBER,
 	  "Intel i82572EI 1000baseX Ethernet",
 	  WM_T_82572,		WMP_F_1000X },
@@ -1069,6 +1070,11 @@ static const struct wm_product {
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_82580_QUAD_FIBER,
 	  "82580 quad-1000BaseX Ethernet",
 	  WM_T_82580,		WMP_F_1000X },
+
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_DH89XXCC_SGMII,
+	  "DH89XXCC Gigabit Ethernet (SGMII)",
+	  WM_T_82580,		WMP_F_1000T },
+
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I350_COPPER,
 	  "I350 Gigabit Network Connection",
 	  WM_T_I350,		WMP_F_1000T },
@@ -1338,6 +1344,7 @@ wm_attach(device_t parent, device_t self
 	else
 		sc->sc_dmat = pa->pa_dmat;
 
+	sc->sc_pcidevid = PCI_PRODUCT(pa->pa_id);
 	sc->sc_rev = PCI_REVISION(pci_conf_read(pc, pa->pa_tag, PCI_CLASS_REG));
 	pci_aprint_devinfo_fancy(pa, "Ethernet controller", wmp->wmp_name, 1);
 
@@ -1779,7 +1786,7 @@ wm_attach(device_t parent, device_t self
 		    &sc->sc_flasht, &sc->sc_flashh, NULL, NULL)) {
 			aprint_error_dev(sc->sc_dev,
 			    "can't map FLASH registers\n");
-			return;
+			goto fail_5;
 		}
 		reg = ICH8_FLASH_READ32(sc, ICH_FLASH_GFPREG);
 		sc->sc_ich8_flash_base = (reg & ICH_GFPREG_BASE_MASK) *
@@ -1902,7 +1909,7 @@ wm_attach(device_t parent, device_t self
 		if (wm_read_mac_addr(sc, enaddr) != 0) {
 			aprint_error_dev(sc->sc_dev,
 			    "unable to read Ethernet address\n");
-			return;
+			goto fail_5;
 		}
 	}
 
@@ -1920,7 +1927,7 @@ wm_attach(device_t parent, device_t self
 	} else {
 		if (wm_nvm_read(sc, NVM_OFF_CFG1, 1, &cfg1)) {
 			aprint_error_dev(sc->sc_dev, "unable to read CFG1\n");
-			return;
+			goto fail_5;
 		}
 	}
 
@@ -1931,7 +1938,7 @@ wm_attach(device_t parent, device_t self
 	} else {
 		if (wm_nvm_read(sc, NVM_OFF_CFG2, 1, &cfg2)) {
 			aprint_error_dev(sc->sc_dev, "unable to read CFG2\n");
-			return;
+			goto fail_5;
 		}
 	}
 
@@ -2000,7 +2007,7 @@ wm_attach(device_t parent, device_t self
 			if (wm_nvm_read(sc, NVM_OFF_SWDPIN, 1, &swdpin)) {
 				aprint_error_dev(sc->sc_dev,
 				    "unable to read SWDPIN\n");
-				return;
+				goto fail_5;
 			}
 		}
 	}
@@ -2308,6 +2315,7 @@ wm_attach(device_t parent, device_t self
 	else
 		aprint_error_dev(self, "couldn't establish power handler\n");
 
+	sc->sc_flags |= WM_F_ATTACHED;
 	return;
 
 	/*
@@ -2346,6 +2354,9 @@ wm_detach(device_t self, int flags __unu
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
 	int i, s;
 
+	if ((sc->sc_flags & WM_F_ATTACHED) == 0)
+		return 0;
+
 	s = splnet();
 	/* Stop the interface. Callouts are stopped in it. */
 	wm_stop(ifp, 1);
@@ -4597,6 +4608,16 @@ wm_reset(struct wm_softc *sc)
 		delay(20*1000);
 		wm_put_swfwhw_semaphore(sc);
 		break;
+	case WM_T_82580:
+	case WM_T_I350:
+	case WM_T_I354:
+	case WM_T_I210:
+	case WM_T_I211:
+		CSR_WRITE(sc, WMREG_CTRL, CSR_READ(sc, WMREG_CTRL) | CTRL_RST);
+		if (sc->sc_pcidevid != PCI_PRODUCT_INTEL_DH89XXCC_SGMII)
+			CSR_WRITE_FLUSH(sc);
+		delay(5000);
+		break;
 	case WM_T_82542_2_0:
 	case WM_T_82542_2_1:
 	case WM_T_82543:
@@ -4609,12 +4630,7 @@ wm_reset(struct wm_softc *sc)
 	case WM_T_82574:
 	case WM_T_82575:
 	case WM_T_82576:
-	case WM_T_82580:
 	case WM_T_82583:
-	case WM_T_I350:
-	case WM_T_I354:
-	case WM_T_I210:
-	case WM_T_I211:
 	default:
 		/* Everything else can safely use the documented method. */
 		CSR_WRITE(sc, WMREG_CTRL, CSR_READ(sc, WMREG_CTRL) | CTRL_RST);

Index: src/sys/dev/pci/if_wmvar.h
diff -u src/sys/dev/pci/if_wmvar.h:1.12.10.5 src/sys/dev/pci/if_wmvar.h:1.12.10.6
--- src/sys/dev/pci/if_wmvar.h:1.12.10.5	Thu Dec  4 06:04:07 2014
+++ src/sys/dev/pci/if_wmvar.h	Thu Apr 30 19:53:28 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmvar.h,v 1.12.10.5 2014/12/04 06:04:07 snj Exp $	*/
+/*	$NetBSD: if_wmvar.h,v 1.12.10.6 2015/04/30 19:53:28 snj Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -95,6 +95,7 @@
 #define WM_F_WOL		0x00100000
 #define WM_F_EEE		0x00200000 /* Energy Efficiency Ethernet */
 #define	WM_F_EEPROM_FLASH_HW	0x00400000 /* EEPROM is FLASH */
+#define WM_F_ATTACHED		0x00800000 /* attach() fininsed successfully */
 
 typedef enum {
 	WM_T_unknown		= 0,

Index: src/sys/dev/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1102.2.17 src/sys/dev/pci/pcidevs:1.1102.2.18
--- src/sys/dev/pci/pcidevs:1.1102.2.17	Sun Apr 19 17:06:27 2015
+++ src/sys/dev/pci/pcidevs	Thu Apr 30 19:53:28 2015
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1102.2.17 2015/04/19 17:06:27 riz Exp $
+$NetBSD: pcidevs,v 1.1102.2.18 2015/04/30 19:53:28 snj Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -2514,6 +2514,12 @@ product INTEL SRCU42E		0x0408	SCSI RAID 
 product INTEL SRCS28X		0x0409	SATA RAID Controller
 product INTEL HASWELL_IGD	0x0402	Haswell Integrated Graphics Device
 product INTEL HASWELL_IGD_1	0x0412	Haswell Integrated Graphics Device
+product INTEL DH89XXCC_IQIA	0x0434	DH89xxCC PCIe Endpoint and QuickAssist
+product INTEL DH89XXCL_IQIA	0x0435	DH89xxCL PCIe Endpoint and QuickAssist
+product INTEL DH89XXCC_SGMII	0x0438	DH89XXCC SGMII
+product INTEL DH89XXCC_SERDES	0x043a	DH89XXCC SerDes
+product INTEL DH89XXCC_BPLANE	0x043c	DH89XXCC backplane
+product INTEL DH89XXCC_SFP	0x0440	DH89XXCC SFP
 product INTEL DH89XXCC_IQIA_VF	0x0442	DH89XXCC QuickAssist Virtual Function
 product INTEL DH89XXCL_IQIA_VF	0x0443	DH89XXCL QuickAssist Virtual Function
 product INTEL PCEB		0x0482	82375EB/SB PCI-EISA Bridge
@@ -3057,7 +3063,24 @@ product INTEL C2000_1000KX	0x1f40	C2000 
 product INTEL C2000_SGMII	0x1f41	C2000 Ethernet(SGMII)
 product INTEL C2000_DUMMYGBE	0x1f42	C2000 Ethernet(Dummy function)
 product INTEL C2000_25GBE	0x1f45	C2000 Ethernet(2.5Gbe)
+product INTEL DH89XXCC_LPC	0x2310	DH89xxCC LPC Controller
+product INTEL DH89XXCC_SATA_1	0x2323	DH89xxCC SATA Controller
+product INTEL DH89XXCC_SATA_2	0x2326	DH89xxCC SATA Controller
 product INTEL DH89XX_SMB	0x2330	DH89xx SMBus Controller
+product INTEL DH89XXCC_THERMAL	0x2332	DH89xxCC Thermal Subsystem
+product INTEL DH89XXCC_USB_1	0x2334	DH89xxCC USB EHCI
+product INTEL DH89XXCC_USB_2	0x2335	DH89xxCC USB EHCI
+product INTEL DH89XXCC_PCIE_1_1	0x2342	DH89xxCC PCIe Root Port
+product INTEL DH89XXCC_PCIE_1_2	0x2343	DH89xxCC PCIe Root Port
+product INTEL DH89XXCC_PCIE_2_1	0x2344	DH89xxCC PCIe Root Port
+product INTEL DH89XXCC_PCIE_2_2	0x2345	DH89xxCC PCIe Root Port
+product INTEL DH89XXCC_PCIE_3_1	0x2346	DH89xxCC PCIe Root Port
+product INTEL DH89XXCC_PCIE_3_2	0x2347	DH89xxCC PCIe Root Port
+product INTEL DH89XXCC_PCIE_4_1	0x2348	DH89xxCC PCIe Root Port
+product INTEL DH89XXCC_PCIE_4_2	0x2349	DH89xxCC PCIe Root Port
+product INTEL DH89XXCC_WDT	0x2360	DH89xxCC Watchdog Timer for Core Reset
+product INTEL DH89XXCC_MEI_1	0x2364	DH89xxCC MEI Controller
+product INTEL DH89XXCC_MEI_2	0x2365	DH89xxCC MEI Controller
 product INTEL 82801AA_LPC	0x2410	82801AA LPC Interface Bridge
 product INTEL 82801AA_IDE	0x2411	82801AA IDE Controller
 product INTEL 82801AA_USB	0x2412	82801AA USB Controller

Reply via email to