CVS commit: [netbsd-5-0] src/sys/dev/pci

2011-02-16 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed Feb 16 20:32:10 UTC 2011

Modified Files:
src/sys/dev/pci [netbsd-5-0]: pci.c

Log Message:
Pull up following revision(s) (requested by dyoung in ticket #1540):
sys/dev/pci/pci.c: revision 1.131
During shutdown, restore the each PCI device's bus-mastering enable to
the state that we found it in before attaching a driver to it.


To generate a diff of this commit:
cvs rdiff -u -r1.119.4.1 -r1.119.4.1.2.1 src/sys/dev/pci/pci.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/pci.c
diff -u src/sys/dev/pci/pci.c:1.119.4.1 src/sys/dev/pci/pci.c:1.119.4.1.2.1
--- src/sys/dev/pci/pci.c:1.119.4.1	Thu Nov 20 02:40:59 2008
+++ src/sys/dev/pci/pci.c	Wed Feb 16 20:32:10 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci.c,v 1.119.4.1 2008/11/20 02:40:59 snj Exp $	*/
+/*	$NetBSD: pci.c,v 1.119.4.1.2.1 2011/02/16 20:32:10 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1997, 1998
@@ -36,7 +36,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci.c,v 1.119.4.1 2008/11/20 02:40:59 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci.c,v 1.119.4.1.2.1 2011/02/16 20:32:10 bouyer Exp $);
 
 #include opt_pci.h
 
@@ -869,6 +869,7 @@
 	int p_pm_offset;
 	pcireg_t p_pm_cap;
 	pcireg_t p_class;
+	pcireg_t p_csr;
 };
 
 static bool
@@ -922,9 +923,10 @@
 	struct pci_child_power *priv = device_pmf_bus_private(dv);
 	pcireg_t csr;
 
-	/* disable busmastering */
+	/* restore original bus-mastering state */
 	csr = pci_conf_read(priv-p_pc, priv-p_tag, PCI_COMMAND_STATUS_REG);
 	csr = ~PCI_COMMAND_MASTER_ENABLE;
+	csr |= priv-p_csr  PCI_COMMAND_MASTER_ENABLE;
 	pci_conf_write(priv-p_pc, priv-p_tag, PCI_COMMAND_STATUS_REG, csr);
 	return true;
 }
@@ -955,6 +957,8 @@
 	priv-p_tag = pci_make_tag(priv-p_pc, sc-sc_bus, device,
 	function);
 	priv-p_class = pci_conf_read(priv-p_pc, priv-p_tag, PCI_CLASS_REG);
+	priv-p_csr = pci_conf_read(priv-p_pc, priv-p_tag,
+	PCI_COMMAND_STATUS_REG);
 
 	if (pci_get_capability(priv-p_pc, priv-p_tag,
 			   PCI_CAP_PWRMGMT, off, reg)) {



CVS commit: [netbsd-5-0] src/sys/dev/pci

2010-01-21 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jan 21 08:41:01 UTC 2010

Modified Files:
src/sys/dev/pci [netbsd-5-0]: azalia.c

Log Message:
Pull up following revision(s) (requested by tonnerre in ticket #1258):
sys/dev/pci/azalia.c: revision 1.72
Signedness bug/crash in azalia. Fixes PR 42604.
By Pierre Pronchery.


To generate a diff of this commit:
cvs rdiff -u -r1.64.6.1 -r1.64.6.1.2.1 src/sys/dev/pci/azalia.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/azalia.c
diff -u src/sys/dev/pci/azalia.c:1.64.6.1 src/sys/dev/pci/azalia.c:1.64.6.1.2.1
--- src/sys/dev/pci/azalia.c:1.64.6.1	Mon Mar  2 19:53:26 2009
+++ src/sys/dev/pci/azalia.c	Thu Jan 21 08:41:00 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: azalia.c,v 1.64.6.1 2009/03/02 19:53:26 snj Exp $	*/
+/*	$NetBSD: azalia.c,v 1.64.6.1.2.1 2010/01/21 08:41:00 snj Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: azalia.c,v 1.64.6.1 2009/03/02 19:53:26 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: azalia.c,v 1.64.6.1.2.1 2010/01/21 08:41:00 snj Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -2257,7 +2257,7 @@
 
 	az = v;
 	co = az-codecs[az-codecno];
-	if (mdev-index = co-nmixers)
+	if (mdev-index  0 || mdev-index = co-nmixers)
 		return ENXIO;
 	*mdev = co-mixers[mdev-index].devinfo;
 	return 0;



CVS commit: [netbsd-5-0] src/sys/dev/pci

2009-08-07 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Aug  7 06:09:44 UTC 2009

Modified Files:
src/sys/dev/pci [netbsd-5-0]: twa.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #886):
sys/dev/pci/twa.c: revision 1.32
Disable completely bogus DIAGNOSTIC check.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.28.10.1 src/sys/dev/pci/twa.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/twa.c
diff -u src/sys/dev/pci/twa.c:1.28 src/sys/dev/pci/twa.c:1.28.10.1
--- src/sys/dev/pci/twa.c:1.28	Sun Jul 27 13:10:11 2008
+++ src/sys/dev/pci/twa.c	Fri Aug  7 06:09:44 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: twa.c,v 1.28 2008/07/27 13:10:11 joerg Exp $ */
+/*	$NetBSD: twa.c,v 1.28.10.1 2009/08/07 06:09:44 snj Exp $ */
 /*	$wasabi: twa.c,v 1.27 2006/07/28 18:17:21 wrstuden Exp $	*/
 
 /*-
@@ -67,7 +67,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: twa.c,v 1.28 2008/07/27 13:10:11 joerg Exp $);
+__KERNEL_RCSID(0, $NetBSD: twa.c,v 1.28.10.1 2009/08/07 06:09:44 snj Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -1300,7 +1300,7 @@
 }
 
 
-#ifdef		DIAGNOSTIC
+#if 0
 static void
 twa_check_response_q(struct twa_request *tr, int clear)
 {
@@ -1321,6 +1321,7 @@
 		req = tr;
 
 	if ((tr-tr_cmd_pkt_type  TWA_CMD_PKT_TYPE_EXTERNAL) != 0) {
+		XXX this is bogus ! req can't be anything else but tr !
 		if (req-tr_request_id == tr-tr_request_id) 
 			panic(req id: %d on controller queue twice,
 			tr-tr_request_id);
@@ -1353,7 +1354,7 @@
 		/* Response queue is not empty. */
 		rq.value = twa_inl(sc, TWA_RESPONSE_QUEUE_OFFSET);
 		tr = sc-sc_twa_request + rq.u.response_id;
-#ifdef		DIAGNOSTIC
+#if 0
 		twa_check_response_q(tr, 0);
 #endif
 		/* Unmap the command packet, and any associated data buffer. */
@@ -1367,7 +1368,7 @@
 	}
 	(void)twa_drain_pending_queue(sc);
 	
-#ifdef		DIAGNOSTIC	
+#if 0
 	twa_check_response_q(NULL, 1);
 #endif
 	return(rv);



CVS commit: [netbsd-5-0] src/sys/dev/pci

2009-07-19 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sun Jul 19 19:48:26 UTC 2009

Modified Files:
src/sys/dev/pci [netbsd-5-0]: if_wm.c if_wmreg.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #862):
sys/dev/pci/if_wm.c: revisions 1.168, 1.170, and 1.173 via patch
sys/dev/pci/if_wmreg.h: revision 1.27
Fixes serious three bugs.
1) On i82563, the em driver says that the ready bit in the MDIC
register may be incorrectly set. Insert delay(200) like the em driver.
Fixes PR#41014
2) Add workaround for 82543GC. We need to force speed and duplex on
the MAC equal to what the PHY speed and duplex configuration is.
Fixes PR#36430.
3) Fix many problems and panic on TBI's cards (includes PR#32009).


To generate a diff of this commit:
cvs rdiff -u -r1.162.4.3 -r1.162.4.3.2.1 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.24 -r1.24.26.1 src/sys/dev/pci/if_wmreg.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.162.4.3 src/sys/dev/pci/if_wm.c:1.162.4.3.2.1
--- src/sys/dev/pci/if_wm.c:1.162.4.3	Fri Mar 20 13:01:35 2009
+++ src/sys/dev/pci/if_wm.c	Sun Jul 19 19:48:26 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.162.4.3 2009/03/20 13:01:35 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.162.4.3.2.1 2009/07/19 19:48:26 snj Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -79,7 +79,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_wm.c,v 1.162.4.3 2009/03/20 13:01:35 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_wm.c,v 1.162.4.3.2.1 2009/07/19 19:48:26 snj Exp $);
 
 #include bpfilter.h
 #include rnd.h
@@ -256,6 +256,8 @@
 	WM_T_ICH9,			/* ICH9 LAN */
 } wm_chip_type;
 
+#define WM_LINKUP_TIMEOUT	50
+
 /*
  * Software state per device.
  */
@@ -376,7 +378,10 @@
 	uint32_t sc_pba;		/* prototype PBA register */
 
 	int sc_tbi_linkup;		/* TBI link status */
-	int sc_tbi_anstate;		/* autonegotiation state */
+	int sc_tbi_anegticks;		/* autonegotiation ticks */
+	int sc_tbi_ticks;		/* tbi ticks */
+	int sc_tbi_nrxcfg;		/* count of ICR_RXCFG */
+	int sc_tbi_lastnrxcfg;		/* count of ICR_RXCFG (on last tick) */
 
 	int sc_mchash_type;		/* multicast filter offset */
 
@@ -581,6 +586,7 @@
 static int32_t	wm_read_ich8_data(struct wm_softc *, uint32_t,
 		 uint32_t, uint16_t *);
 static int32_t	wm_read_ich8_word(struct wm_softc *sc, uint32_t, uint16_t *);
+static int	wm_check_for_link(struct wm_softc *);
 
 CFATTACH_DECL_NEW(wm, sizeof(struct wm_softc),
 wm_match, wm_attach, NULL, NULL);
@@ -2742,6 +2748,8 @@
 {
 	uint32_t status;
 
+	DPRINTF(WM_DEBUG_LINK, (%s: %s:\n, device_xname(sc-sc_dev),
+		__func__));
 	/*
 	 * If we get a link status interrupt on a 1000BASE-T
 	 * device, just fall into the normal MII tick path.
@@ -2752,6 +2760,44 @@
 			(%s: LINK: LSC - mii_tick\n,
 			device_xname(sc-sc_dev)));
 			mii_tick(sc-sc_mii);
+			if (sc-sc_type == WM_T_82543) {
+int miistatus, active;
+
+/*
+ * With 82543, we need to force speed and
+ * duplex on the MAC equal to what the PHY
+ * speed and duplex configuration is.
+ */
+miistatus = sc-sc_mii.mii_media_status;
+
+if (miistatus  IFM_ACTIVE) {
+	active = sc-sc_mii.mii_media_active;
+	sc-sc_ctrl = ~(CTRL_SPEED_MASK
+	| CTRL_FD);
+	switch (IFM_SUBTYPE(active)) {
+	case IFM_10_T:
+		sc-sc_ctrl |= CTRL_SPEED_10;
+		break;
+	case IFM_100_TX:
+		sc-sc_ctrl |= CTRL_SPEED_100;
+		break;
+	case IFM_1000_T:
+		sc-sc_ctrl |= CTRL_SPEED_1000;
+		break;
+	default:
+		/*
+		 * fiber?
+		 * Shoud not enter here.
+		 */
+		printf(unknown media (%x)\n,
+		active);
+		break;
+	}
+	if (active  IFM_FDX)
+		sc-sc_ctrl |= CTRL_FD;
+	CSR_WRITE(sc, WMREG_CTRL, sc-sc_ctrl);
+}
+			}
 		} else if (icr  ICR_RXSEQ) {
 			DPRINTF(WM_DEBUG_LINK,
 			(%s: LINK Receive sequence error\n,
@@ -2760,22 +2806,18 @@
 		return;
 	}
 
-	/*
-	 * If we are now receiving /C/, check for link again in
-	 * a couple of link clock ticks.
-	 */
-	if (icr  ICR_RXCFG) {
-		DPRINTF(WM_DEBUG_LINK, (%s: LINK: receiving /C/\n,
-		device_xname(sc-sc_dev)));
-		sc-sc_tbi_anstate = 2;
-	}
-
+	status = CSR_READ(sc, WMREG_STATUS);
 	if (icr  ICR_LSC) {
-		status = CSR_READ(sc, WMREG_STATUS);
 		if (status  STATUS_LU) {
 			DPRINTF(WM_DEBUG_LINK, (%s: LINK: LSC - up %s\n,
 			device_xname(sc-sc_dev),
 			(status  STATUS_FD) ? FDX : HDX));
+			/*
+			 * NOTE: CTRL will update TFCE and RFCE automatically,
+			 * so we should update sc-sc_ctrl
+			 */
+			
+			sc-sc_ctrl = CSR_READ(sc, WMREG_CTRL);
 			sc-sc_tctl = ~TCTL_COLD(0x3ff);
 			sc-sc_fcrtl = ~FCRTL_XONE;
 			if (status  STATUS_FD)
@@ -2784,7 +2826,7 @@
 			else
 sc-sc_tctl |=
 TCTL_COLD(TX_COLLISION_DISTANCE_HDX);
-			if (CSR_READ(sc, WMREG_CTRL)  CTRL_TFCE)
+			if