PERFORCE change 150745 for review

Marko Zec zec at FreeBSD.org
Wed Oct 1 12:15:06 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=150745

Change 150745 by zec at zec_tca51 on 2008/10/01 12:14:38

	IFC @ 150742

Affected files ...

.. //depot/projects/vimage-commit2/src/sys/arm/at91/at91_mci.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/cxgb/cxgb_main.c#7 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c#5 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/cxgb/ulp/tom/cxgb_ddp.c#5 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/cxgb/ulp/tom/cxgb_vm.c#3 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/cxgb/ulp/tom/cxgb_vm.h#2 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/dc/dcphy.c#2 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/dc/pnphy.c#2 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/fatm/if_fatm.c#2 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/mii/ciphy.c#2 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/mii/e1000phy.c#3 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/mii/miidevs#4 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/mmc/mmc.c#3 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/mmc/mmcreg.h#3 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/mmc/mmcsd.c#3 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/msk/if_msk.c#3 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/nfe/if_nfe.c#2 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/nfe/if_nfereg.h#2 integrate
.. //depot/projects/vimage-commit2/src/sys/kern/uipc_socket.c#6 integrate
.. //depot/projects/vimage-commit2/src/sys/mips/mips/pmap.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/net/if_lagg.c#5 integrate
.. //depot/projects/vimage-commit2/src/sys/vm/swap_pager.c#5 integrate
.. //depot/projects/vimage-commit2/src/sys/vm/vm_pageout.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/vm/vm_pageout.h#2 integrate

Differences ...

==== //depot/projects/vimage-commit2/src/sys/arm/at91/at91_mci.c#4 (text+ko) ====

@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/at91/at91_mci.c,v 1.6 2008/09/28 23:37:56 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/at91/at91_mci.c,v 1.7 2008/09/30 02:32:41 imp Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -455,7 +455,7 @@
 static int
 at91_mci_get_ro(device_t brdev, device_t reqdev)
 {
-	return (-1);
+	return (0);
 }
 
 static int
@@ -642,9 +642,6 @@
 	case MMCBR_IVAR_VDD:
 		*(int *)result = sc->host.ios.vdd;
 		break;
-	case MMCBR_IVAR_CAPS:
-		*(int *)result = sc->host.ios.caps;
-		break;
 	}
 	return (0);
 }
@@ -685,7 +682,6 @@
 	case MMCBR_IVAR_HOST_OCR:
 	case MMCBR_IVAR_F_MIN:
 	case MMCBR_IVAR_F_MAX:
-	case MMCBR_IVAR_CAPS:
 		return (EINVAL);
 	}
 	return (0);

==== //depot/projects/vimage-commit2/src/sys/dev/cxgb/cxgb_main.c#7 (text+ko) ====

@@ -28,7 +28,7 @@
 ***************************************************************************/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cxgb/cxgb_main.c,v 1.67 2008/09/23 03:16:54 kmacy Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cxgb/cxgb_main.c,v 1.68 2008/09/30 21:21:52 kmacy Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -981,6 +981,12 @@
 		ifmedia_add(&p->media, IFM_ETHER | IFM_1000_T | IFM_FDX,
 			    0, NULL);
 		media_flags = 0;
+	} else if (!strcmp(p->phy.desc, "1000BASE-X")) {
+		/*
+		 * XXX: This is not very accurate.  Fix when common code
+		 * returns more specific value - eg 1000BASE-SX, LX, etc.
+		 */
+		media_flags = IFM_ETHER | IFM_1000_SX | IFM_FDX;
 	} else {
 	        printf("unsupported media type %s\n", p->phy.desc);
 		return (ENXIO);

==== //depot/projects/vimage-commit2/src/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c#5 (text+ko) ====

@@ -28,7 +28,7 @@
 ***************************************************************************/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c,v 1.15 2008/09/23 03:16:54 kmacy Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c,v 1.16 2008/09/30 23:45:22 kmacy Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -193,14 +193,16 @@
 
 
 static int
-cxgb_hold_iovec_pages(struct uio *uio, vm_page_t *m, int *held, int flags)
+cxgb_hold_iovec_pages(struct uio *uio, vm_page_t *m, int *held, vm_prot_t prot)
 {
 	struct iovec *iov = uio->uio_iov;
 	int iovcnt = uio->uio_iovcnt;
 	int err, i, count, totcount, maxcount, totbytes, npages, curbytes;
 	uint64_t start, end;
 	vm_page_t *mp;
-	
+	vm_map_t map;
+
+	map = &uio->uio_td->td_proc->p_vmspace->vm_map;
 	totbytes = totcount = 0;
 	maxcount = *held;
 
@@ -217,11 +219,8 @@
 		
 		count = min(count, npages);
 
-		err = vm_fault_hold_user_pages((vm_offset_t)iov->iov_base, mp, count, flags);
-		if (err) {
-			vm_fault_unhold_pages(m, totcount);
-			return (err);
-		}
+		err = vm_fault_hold_user_pages(map,
+			(vm_offset_t)iov->iov_base, mp, count, prot);
 		mp += count;
 		totcount += count;
 		curbytes = iov->iov_len;
@@ -429,7 +428,7 @@
 	 * Make sure we don't exceed the socket buffer
 	 */
 	count = min(toep->tp_page_count, (sockbuf_sbspace(snd) >> PAGE_SHIFT) + 2*PAGE_SIZE);
-	rv = cxgb_hold_iovec_pages(&uiotmp, toep->tp_pages, &count, 0);
+	rv = cxgb_hold_iovec_pages(&uiotmp, toep->tp_pages, &count, VM_PROT_READ);
 	hold_resid = uiotmp.uio_resid;
 	if (rv)
 		return (rv);

==== //depot/projects/vimage-commit2/src/sys/dev/cxgb/ulp/tom/cxgb_ddp.c#5 (text+ko) ====

@@ -28,7 +28,7 @@
 ***************************************************************************/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cxgb/ulp/tom/cxgb_ddp.c,v 1.8 2008/09/23 03:16:54 kmacy Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cxgb/ulp/tom/cxgb_ddp.c,v 1.9 2008/09/30 23:45:22 kmacy Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -120,7 +120,7 @@
  *	a new gather list was allocated it is returned in @newgl.
  */ 
 static int
-t3_pin_pages(bus_dma_tag_t tag, bus_dmamap_t map, vm_offset_t addr,
+t3_pin_pages(bus_dma_tag_t tag, bus_dmamap_t dmamap, vm_offset_t addr,
     size_t len, struct ddp_gather_list **newgl,
     const struct ddp_gather_list *gl)
 {
@@ -128,13 +128,16 @@
 	size_t pg_off;
 	unsigned int npages;
 	struct ddp_gather_list *p;
-
+	vm_map_t map;
+	
 	/*
 	 * XXX need x86 agnostic check
 	 */
 	if (addr + len > VM_MAXUSER_ADDRESS)
 		return (EFAULT);
 
+
+	
 	pg_off = addr & PAGE_MASK;
 	npages = (pg_off + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
 	p = malloc(sizeof(struct ddp_gather_list) + npages * sizeof(vm_page_t *),
@@ -142,7 +145,9 @@
 	if (p == NULL)
 		return (ENOMEM);
 
-	err = vm_fault_hold_user_pages(addr, p->dgl_pages, npages, VM_HOLD_WRITEABLE);
+	map = &curthread->td_proc->p_vmspace->vm_map;
+	err = vm_fault_hold_user_pages(map, addr, p->dgl_pages, npages,
+	    VM_PROT_READ | VM_PROT_WRITE);
 	if (err)
 		goto free_gl;
 

==== //depot/projects/vimage-commit2/src/sys/dev/cxgb/ulp/tom/cxgb_vm.c#3 (text+ko) ====

@@ -1,6 +1,6 @@
 /**************************************************************************
 
-Copyright (c) 2007, Chelsio Inc.
+Copyright (c) 2007-2008, Chelsio Inc.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
 ***************************************************************************/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cxgb/ulp/tom/cxgb_vm.c,v 1.2 2008/09/23 03:16:54 kmacy Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cxgb/ulp/tom/cxgb_vm.c,v 1.4 2008/09/30 23:44:44 kmacy Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -41,6 +41,7 @@
 #include <sys/condvar.h>
 #include <sys/mutex.h>
 #include <sys/proc.h>
+#include <sys/syslog.h>
 
 #include <vm/vm.h>
 #include <vm/vm_page.h>
@@ -49,34 +50,29 @@
 #include <vm/pmap.h>
 #include <ulp/tom/cxgb_vm.h>
 
-#define TRACE_ENTER printf("%s:%s entered", __FUNCTION__, __FILE__)
-#define TRACE_EXIT printf("%s:%s:%d exited", __FUNCTION__, __FILE__, __LINE__)
-
 /*
- * This routine takes a user address range and does the following:
- *  - validate that the user has access to those pages (flags indicates read or write) - if not fail
+ * This routine takes a user's map, array of pages, number of pages, and flags
+ * and then does the following:
+ *  - validate that the user has access to those pages (flags indicates read
+ *	or write) - if not fail
  *  - validate that count is enough to hold range number of pages - if not fail
  *  - fault in any non-resident pages
  *  - if the user is doing a read force a write fault for any COWed pages
  *  - if the user is doing a read mark all pages as dirty
  *  - hold all pages
- *  - return number of pages in count
  */
 int
-vm_fault_hold_user_pages(vm_offset_t addr, vm_page_t *mp, int count, int flags)
+vm_fault_hold_user_pages(vm_map_t map, vm_offset_t addr, vm_page_t *mp,
+    int count, vm_prot_t prot)
 {
-
 	vm_offset_t end, va;
-	vm_paddr_t pa;
 	int faults, rv;
-
-	struct thread *td;
-	vm_map_t map;
 	pmap_t pmap;
 	vm_page_t m, *pages;
-	vm_prot_t prot;
 	
-
+	pmap = vm_map_pmap(map);
+	pages = mp;
+	addr &= ~PAGE_MASK;
 	/*
 	 * Check that virtual address range is legal
 	 * This check is somewhat bogus as on some architectures kernel
@@ -85,83 +81,73 @@
 	 */
 	end = addr + (count * PAGE_SIZE);
 	if (end > VM_MAXUSER_ADDRESS) {
-		printf("bad address passed\n");
+		log(LOG_WARNING, "bad address passed to vm_fault_hold_user_pages");
 		return (EFAULT);
 	}
 
-	td = curthread;
-	map = &td->td_proc->p_vmspace->vm_map;
-	pmap = &td->td_proc->p_vmspace->vm_pmap;
-	pages = mp;
-
-	prot = VM_PROT_READ;
-	prot |= (flags & VM_HOLD_WRITEABLE) ? VM_PROT_WRITE : 0;
-	bzero(pages, sizeof(vm_page_t *) * count);
-retry:
-
 	/*
-	 * First optimistically assume that all pages are resident (and R/W if for write)
-	 * if so just mark pages as held (and dirty if for write) and return
+	 * First optimistically assume that all pages are resident 
+	 * (and R/W if for write) if so just mark pages as held (and 
+	 * dirty if for write) and return
 	 */
 	vm_page_lock_queues();
-	for (pages = mp, faults = 0, va = addr; va < end; va += PAGE_SIZE, pages++) {
+	for (pages = mp, faults = 0, va = addr; va < end;
+	     va += PAGE_SIZE, pages++) {
 		/*
-		 * Assure that we only hold the page once
+		 * page queue mutex is recursable so this is OK
+		 * it would be really nice if we had an unlocked
+		 * version of this so we were only acquiring the 
+		 * pmap lock 1 time as opposed to potentially
+		 * many dozens of times
 		 */
-		if (*pages == NULL) {
-			/*
-			 * page queue mutex is recursable so this is OK
-			 * it would be really nice if we had an unlocked version of this so
-			 * we were only acquiring the pmap lock 1 time as opposed to potentially
-			 * many dozens of times
-			 */
-			m = pmap_extract_and_hold(pmap, va, prot);
-			if (m == NULL) {
-				faults++;
-				continue;
-			}
-			
-			*pages = m;
-			if (flags & VM_HOLD_WRITEABLE)
-				vm_page_dirty(m);
+		*pages = m = pmap_extract_and_hold(pmap, va, prot);
+		if (m == NULL) {
+			faults++;
+			continue;
 		}
+		/*
+		 * Preemptively mark dirty - the pages
+		 * will never have the modified bit set if
+		 * they are only changed via DMA
+		 */
+		if (prot & VM_PROT_WRITE)
+			vm_page_dirty(m);
+		
 	}
 	vm_page_unlock_queues();
 	
-	if (faults == 0) {
+	if (faults == 0)
 		return (0);
-	}
 	
 	/*
 	 * Pages either have insufficient permissions or are not present
 	 * trigger a fault where neccessary
 	 * 
 	 */
-	for (va = addr; va < end; va += PAGE_SIZE) {
-		m = NULL;
-		pa = pmap_extract(pmap, va);
-		rv = 0;
-		if (pa)
-			m = PHYS_TO_VM_PAGE(pa);
-		if (flags & VM_HOLD_WRITEABLE) {
-			if (m == NULL  || (m->flags & PG_WRITEABLE) == 0)
-				rv = vm_fault(map, va, VM_PROT_WRITE, VM_FAULT_DIRTY);
-		} else if (m == NULL)
-			rv = vm_fault(map, va, VM_PROT_READ, VM_FAULT_NORMAL);
-		if (rv) {
-			printf("vm_fault bad return rv=%d va=0x%zx\n", rv, va);
-			
-			goto error;
-		} 
+	rv = 0;
+	for (pages = mp, va = addr; va < end; va += PAGE_SIZE, pages++) {
+		/*
+		 * Account for a very narrow race where the page may be
+		 * taken away from us before it is held
+		 */
+		while (*pages == NULL) {
+			rv = vm_fault(map, va, prot,
+			    (prot & VM_PROT_WRITE) ? VM_FAULT_DIRTY : VM_FAULT_NORMAL);
+			if (rv) 
+				goto error;
+			*pages = pmap_extract_and_hold(pmap, va, prot);
+		}
 	}
-	
-	goto retry;
-
+	return (0);
 error:	
+	log(LOG_WARNING,
+	    "vm_fault bad return rv=%d va=0x%zx\n", rv, va);
 	vm_page_lock_queues();
 	for (pages = mp, va = addr; va < end; va += PAGE_SIZE, pages++)
-		if (*pages)
+		if (*pages) {
 			vm_page_unhold(*pages);
+			*pages = NULL;
+		}
 	vm_page_unlock_queues();
 	return (EFAULT);
 }

==== //depot/projects/vimage-commit2/src/sys/dev/cxgb/ulp/tom/cxgb_vm.h#2 (text+ko) ====

@@ -1,6 +1,6 @@
 /**************************************************************************
 
-Copyright (c) 2007, Chelsio Inc.
+Copyright (c) 2007-2008, Chelsio Inc.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -26,15 +26,14 @@
 POSSIBILITY OF SUCH DAMAGE.
 
 
-$FreeBSD: src/sys/dev/cxgb/ulp/tom/cxgb_vm.h,v 1.1 2008/02/23 01:06:17 kmacy Exp $
+$FreeBSD: src/sys/dev/cxgb/ulp/tom/cxgb_vm.h,v 1.2 2008/09/30 23:44:44 kmacy Exp $
 
 ***************************************************************************/
 #ifndef CXGB_VM_H_
 #define CXGB_VM_H_
 
-#define VM_HOLD_WRITEABLE	0x1
-
-int vm_fault_hold_user_pages(vm_offset_t addr, vm_page_t *mp, int count, int flags);
+int vm_fault_hold_user_pages(vm_map_t map, vm_offset_t addr,
+    vm_page_t *mp, int count, vm_prot_t prot);
 void vm_fault_unhold_pages(vm_page_t *mp, int count);
 
 #endif

==== //depot/projects/vimage-commit2/src/sys/dev/dc/dcphy.c#2 (text+ko) ====

@@ -31,13 +31,13 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/dc/dcphy.c,v 1.33 2007/11/16 10:25:36 yongari Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/dc/dcphy.c,v 1.34 2008/09/30 20:53:15 marius Exp $");
 
 /*
  * Pseudo-driver for internal NWAY support on DEC 21143 and workalike
- * controllers. Technically we're abusing the miibus code to handle
+ * controllers.  Technically we're abusing the miibus code to handle
  * media selection and NWAY support here since there is no MII
- * interface. However the logical operations are roughly the same,
+ * interface.  However the logical operations are roughly the same,
  * and the alternative is to create a fake MII interface in the driver,
  * which is harder to do.
  */
@@ -82,7 +82,7 @@
 
 /*
  * This is the subsystem ID for the built-in 21143 ethernet
- * in several Compaq Presario systems. Apparently these are
+ * in several Compaq Presario systems.  Apparently these are
  * 10Mbps only, so we need to treat them specially.
  */
 #define COMPAQ_PRESARIO_ID	0xb0bb0e11
@@ -127,7 +127,7 @@
 	 */
 	if (ma->mii_id1 != DC_VENDORID_DEC ||
 	    ma->mii_id2 != DC_DEVICEID_21143)
-		return(ENXIO);
+		return (ENXIO);
 
 	device_set_desc(dev, "Intel 21143 NWAY media interface");
 
@@ -171,20 +171,16 @@
 	switch (pci_get_subdevice(brdev) << 16 | pci_get_subvendor(brdev)) {
 	case COMPAQ_PRESARIO_ID:
 		/* Example of how to only allow 10Mbps modes. */
-		sc->mii_capabilities = BMSR_ANEG|BMSR_10TFDX|BMSR_10THDX;
+		sc->mii_capabilities = BMSR_ANEG | BMSR_10TFDX | BMSR_10THDX;
 		break;
 	default:
-		if (dc_sc->dc_pmode == DC_PMODE_SIA) {
+		if (dc_sc->dc_pmode == DC_PMODE_SIA)
 			sc->mii_capabilities =
-			    BMSR_ANEG|BMSR_10TFDX|BMSR_10THDX;
-		} else {
-			ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP,
-			    sc->mii_inst), BMCR_LOOP|BMCR_S100);
-
+			    BMSR_ANEG | BMSR_10TFDX | BMSR_10THDX;
+		else
 			sc->mii_capabilities =
-			    BMSR_ANEG|BMSR_100TXFDX|BMSR_100TXHDX|
-			    BMSR_10TFDX|BMSR_10THDX;
-		}
+			    BMSR_ANEG | BMSR_100TXFDX | BMSR_100TXHDX |
+			    BMSR_10TFDX | BMSR_10THDX;
 		break;
 	}
 
@@ -195,7 +191,7 @@
 #undef ADD
 
 	MIIBUS_MEDIAINIT(sc->mii_dev);
-	return(0);
+	return (0);
 }
 
 static int
@@ -213,9 +209,8 @@
 		/*
 		 * If we're not polling our PHY instance, just return.
 		 */
-		if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
+		if (IFM_INST(ife->ifm_media) != sc->mii_inst)
 			return (0);
-		}
 		break;
 
 	case MII_MEDIACHG:
@@ -223,9 +218,8 @@
 		 * If the media indicates a different PHY instance,
 		 * isolate ourselves.
 		 */
-		if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
+		if (IFM_INST(ife->ifm_media) != sc->mii_inst)
 			return (0);
-		}
 
 		/*
 		 * If the interface is not up, don't do anything.
@@ -236,8 +230,8 @@
 		sc->mii_flags = 0;
 		mii->mii_media_active = IFM_NONE;
 		mode = CSR_READ_4(dc_sc, DC_NETCFG);
-		mode &= ~(DC_NETCFG_FULLDUPLEX|DC_NETCFG_PORTSEL|
-		    DC_NETCFG_PCS|DC_NETCFG_SCRAMBLER|DC_NETCFG_SPEEDSEL);
+		mode &= ~(DC_NETCFG_FULLDUPLEX | DC_NETCFG_PORTSEL |
+		    DC_NETCFG_PCS | DC_NETCFG_SCRAMBLER | DC_NETCFG_SPEEDSEL);
 
 		switch (IFM_SUBTYPE(ife->ifm_media)) {
 		case IFM_AUTO:
@@ -252,7 +246,7 @@
 		case IFM_100_TX:
 			dcphy_reset(sc);
 			DC_CLRBIT(dc_sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL);
-			mode |= DC_NETCFG_PORTSEL|DC_NETCFG_PCS|
+			mode |= DC_NETCFG_PORTSEL | DC_NETCFG_PCS |
 			    DC_NETCFG_SCRAMBLER;
 			if ((ife->ifm_media & IFM_GMASK) == IFM_FDX)
 				mode |= DC_NETCFG_FULLDUPLEX;
@@ -278,7 +272,7 @@
 			CSR_WRITE_4(dc_sc, DC_NETCFG, mode);
 			break;
 		default:
-			return(EINVAL);
+			return (EINVAL);
 		}
 		break;
 
@@ -366,7 +360,7 @@
 			anlpar = tstat >> 16;
 			if (anlpar & ANLPAR_TX_FD &&
 			    sc->mii_capabilities & BMSR_100TXFDX)
-				mii->mii_media_active |= IFM_100_TX|IFM_FDX;
+				mii->mii_media_active |= IFM_100_TX | IFM_FDX;
 			else if (anlpar & ANLPAR_T4 &&
 			    sc->mii_capabilities & BMSR_100T4)
 				mii->mii_media_active |= IFM_100_T4;
@@ -374,7 +368,7 @@
 			    sc->mii_capabilities & BMSR_100TXHDX)
 				mii->mii_media_active |= IFM_100_TX;
 			else if (anlpar & ANLPAR_10_FD)
-				mii->mii_media_active |= IFM_10_T|IFM_FDX;
+				mii->mii_media_active |= IFM_10_T | IFM_FDX;
 			else if (anlpar & ANLPAR_10)
 				mii->mii_media_active |= IFM_10_T;
 			else
@@ -384,10 +378,11 @@
 				    DC_TCTL_AUTONEGENBL);
 			return;
 		}
+
 		/*
 		 * If the other side doesn't support NWAY, then the
 		 * best we can do is determine if we have a 10Mbps or
-		 * 100Mbps link. There's no way to know if the link 
+		 * 100Mbps link.  There's no way to know if the link
 		 * is full or half duplex, so we default to half duplex
 		 * and hope that the user is clever enough to manually
 		 * change the media settings if we're wrong.
@@ -404,15 +399,12 @@
 	}
 
 skip:
-
 	if (CSR_READ_4(dc_sc, DC_NETCFG) & DC_NETCFG_SPEEDSEL)
 		mii->mii_media_active |= IFM_10_T;
 	else
 		mii->mii_media_active |= IFM_100_TX;
 	if (CSR_READ_4(dc_sc, DC_NETCFG) & DC_NETCFG_FULLDUPLEX)
 		mii->mii_media_active |= IFM_FDX;
-
-	return;
 }
 
 static int
@@ -433,7 +425,7 @@
 	DC_SETBIT(sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL);
 	DC_SETBIT(sc, DC_10BTSTAT, DC_ASTAT_TXDISABLE);
 
-	return(EJUSTRETURN);
+	return (EJUSTRETURN);
 }
 
 static void
@@ -446,7 +438,4 @@
 	DC_CLRBIT(sc, DC_SIARESET, DC_SIA_RESET);
 	DELAY(1000);
 	DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET);
-
-	return;
 }
-

==== //depot/projects/vimage-commit2/src/sys/dev/dc/pnphy.c#2 (text+ko) ====

@@ -31,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/dc/pnphy.c,v 1.21 2006/08/02 05:28:52 yongari Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/dc/pnphy.c,v 1.22 2008/09/30 20:53:15 marius Exp $");
 
 /*
  * Pseudo-driver for media selection on the Lite-On PNIC 82c168
- * chip. The NWAY support on this chip is horribly broken, so we
- * only support manual mode selection. This is lame, but getting
+ * chip.  The NWAY support on this chip is horribly broken, so we
+ * only support manual mode selection.  This is lame, but getting
  * NWAY to work right is amazingly difficult.
  */
 
@@ -112,7 +112,7 @@
 	 */
 	if (ma->mii_id1 != DC_VENDORID_LO ||
 	    ma->mii_id2 != DC_DEVICEID_82C168)
-		return(ENXIO);
+		return (ENXIO);
 
 	device_set_desc(dev, "PNIC 82c168 media interface");
 
@@ -143,7 +143,7 @@
 #define	ADD(m, c)	ifmedia_add(&mii->mii_media, (m), (c), NULL)
 
 	sc->mii_capabilities =
-	    BMSR_100TXFDX|BMSR_100TXHDX|BMSR_10TFDX|BMSR_10THDX;
+	    BMSR_100TXFDX | BMSR_100TXHDX | BMSR_10TFDX | BMSR_10THDX;
 	sc->mii_capabilities &= ma->mii_capmask;
 	device_printf(dev, " ");
 	mii_add_media(sc);
@@ -157,7 +157,7 @@
 #undef ADD
 
 	MIIBUS_MEDIAINIT(sc->mii_dev);
-	return(0);
+	return (0);
 }
 
 static int
@@ -170,9 +170,8 @@
 		/*
 		 * If we're not polling our PHY instance, just return.
 		 */
-		if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
+		if (IFM_INST(ife->ifm_media) != sc->mii_inst)
 			return (0);
-		}
 		break;
 
 	case MII_MEDIACHG:
@@ -200,19 +199,19 @@
 			 */
 			return (EINVAL);
 		case IFM_100_TX:
-			mii->mii_media_active = IFM_ETHER|IFM_100_TX;
+			mii->mii_media_active = IFM_ETHER | IFM_100_TX;
 			if ((ife->ifm_media & IFM_GMASK) == IFM_FDX)
 				mii->mii_media_active |= IFM_FDX;
 			MIIBUS_STATCHG(sc->mii_dev);
-			return(0);
+			return (0);
 		case IFM_10_T:
-			mii->mii_media_active = IFM_ETHER|IFM_10_T;
+			mii->mii_media_active = IFM_ETHER | IFM_10_T;
 			if ((ife->ifm_media & IFM_GMASK) == IFM_FDX)
 				mii->mii_media_active |= IFM_FDX;
 			MIIBUS_STATCHG(sc->mii_dev);
-			return(0);
+			return (0);
 		default:
-			return(EINVAL);
+			return (EINVAL);
 		}
 		break;
 
@@ -263,6 +262,4 @@
 		mii->mii_media_active |= IFM_100_TX;
 	if (CSR_READ_4(dc_sc, DC_NETCFG) & DC_NETCFG_FULLDUPLEX)
 		mii->mii_media_active |= IFM_FDX;
-
-	return;
 }

==== //depot/projects/vimage-commit2/src/sys/dev/fatm/if_fatm.c#2 (text+ko) ====

@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/fatm/if_fatm.c,v 1.24 2008/03/25 09:38:57 ru Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/fatm/if_fatm.c,v 1.25 2008/09/30 18:52:43 marius Exp $");
 
 #include "opt_inet.h"
 #include "opt_natm.h"
@@ -2880,7 +2880,7 @@
 	 * restrictions for the controller (and PCI bus) and is never used
 	 * to do anything.
 	 */
-	if (bus_dma_tag_create(NULL, 1, 0,
+	if (bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0,
 	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
 	    NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, MAXDMASEGS,
 	    BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL,

==== //depot/projects/vimage-commit2/src/sys/dev/mii/ciphy.c#2 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/mii/ciphy.c,v 1.11 2008/04/26 18:07:24 raj Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/mii/ciphy.c,v 1.16 2008/09/30 07:30:05 yongari Exp $");
 
 /*
  * Driver for the Cicada/Vitesse CS/VSC8xxx 10/100/1000 copper PHY.
@@ -94,6 +94,7 @@
 	MII_PHY_DESC(CICADA, CS8204),
 	MII_PHY_DESC(CICADA, CS8244),
 	MII_PHY_DESC(VITESSE, VSC8601),
+	MII_PHY_DESC(VITESSE, VSC8211),
 	MII_PHY_END
 };
 
@@ -264,15 +265,18 @@
 		if (reg & BMSR_LINK)
 			break;
 
+		/* Announce link loss right after it happens. */
+		if (++sc->mii_ticks == 0)
+			break;
 		/*
-		 * Only retry autonegotiation every 5 seconds.
+		 * Only retry autonegotiation every mii_anegticks seconds.
 		 */
-		if (++sc->mii_ticks <= MII_ANEGTICKS)
+		if (sc->mii_ticks <= sc->mii_anegticks)
 			break;
 
 		sc->mii_ticks = 0;
 		mii_phy_auto(sc);
-		return (0);
+		break;
 	}
 
 	/* Update the media status. */
@@ -337,6 +341,8 @@
 
 	if (bmsr & CIPHY_AUXCSR_FDX)
 		mii->mii_media_active |= IFM_FDX;
+	else
+		mii->mii_media_active |= IFM_HDX;
 }
 
 static void
@@ -419,6 +425,7 @@
 		break;
 	case MII_MODEL_CICADA_CS8244:
 	case MII_MODEL_VITESSE_VSC8601:
+	case MII_MODEL_VITESSE_VSC8211:
 		break;
 	default:
 		device_printf(sc->mii_dev, "unknown CICADA PHY model %x\n",

==== //depot/projects/vimage-commit2/src/sys/dev/mii/e1000phy.c#3 (text+ko) ====

@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/mii/e1000phy.c,v 1.21 2008/09/04 11:09:40 raj Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/mii/e1000phy.c,v 1.22 2008/09/30 08:18:38 yongari Exp $");
 
 /*
  * driver for the Marvell 88E1000 series external 1000/100/10-BT PHY.
@@ -210,7 +210,7 @@
 e1000phy_reset(struct mii_softc *sc)
 {
 	struct e1000phy_softc *esc;
-	uint16_t reg;
+	uint16_t reg, page;
 
 	esc = (struct e1000phy_softc *)sc;
 	reg = PHY_READ(sc, E1000_SCR);
@@ -219,12 +219,13 @@
 		PHY_WRITE(sc, E1000_SCR, reg);
 		if (esc->mii_model == MII_MODEL_MARVELL_E1112) {
 			/* Select 1000BASE-X only mode. */
+			page = PHY_READ(sc, E1000_EADR);
 			PHY_WRITE(sc, E1000_EADR, 2);
 			reg = PHY_READ(sc, E1000_SCR);
 			reg &= ~E1000_SCR_MODE_MASK;
 			reg |= E1000_SCR_MODE_1000BX;
 			PHY_WRITE(sc, E1000_SCR, reg);
-			PHY_WRITE(sc, E1000_EADR, 1);
+			PHY_WRITE(sc, E1000_EADR, page);
 		}
 	} else {
 		switch (esc->mii_model) {

==== //depot/projects/vimage-commit2/src/sys/dev/mii/miidevs#4 (text+ko) ====

@@ -1,4 +1,4 @@
-$FreeBSD: src/sys/dev/mii/miidevs,v 1.59 2008/09/04 11:09:40 raj Exp $
+$FreeBSD: src/sys/dev/mii/miidevs,v 1.60 2008/09/30 07:30:05 yongari Exp $
 /*$NetBSD: miidevs,v 1.6 1999/05/14 11:37:30 drochner Exp $*/
 
 /*-
@@ -158,6 +158,7 @@
 model CICADA CS8201B		0x0021 Cicada CS8201 10/100/1000TX PHY
 model CICADA CS8244		0x002c Cicada CS8244 10/100/1000TX PHY
 model VITESSE VSC8601		0x0002 Vitesse VSC8601 10/100/1000TX PHY
+model VITESSE VSC8211		0x000b Vitesse VSC8211 10/100/1000TX PHY
 
 /* Davicom Semiconductor PHYs */
 model DAVICOM DM9102		0x0004 DM9102 10/100 media interface

==== //depot/projects/vimage-commit2/src/sys/dev/mmc/mmc.c#3 (text+ko) ====

@@ -51,7 +51,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/mmc/mmc.c,v 1.11 2008/09/29 01:32:21 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/mmc/mmc.c,v 1.15 2008/09/29 18:55:45 imp Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -152,7 +152,7 @@
 
 	/* kill children [ph33r].  -sorbo */
 	if (device_get_children(sc->dev, &kids, &nkid) != 0)
-		return 0;
+		return (0);
 	for (i = 0; i < nkid; i++) {
 		device_t kid = kids[i];
 		void *ivar = device_get_ivars(kid);
@@ -166,7 +166,7 @@
 
 	MMC_LOCK_DESTROY(sc);
 
-	return 0;
+	return (0);
 }
 
 static int
@@ -248,7 +248,7 @@
 mmc_select_vdd(struct mmc_softc *sc, uint32_t ocr)
 {
 
-	return ocr & MMC_OCR_VOLTAGE;
+	return (ocr & MMC_OCR_VOLTAGE);
 }
 
 static int
@@ -258,7 +258,7 @@
 
 	for (i = 30; i >= 0; i--)
 		if (ocr & (1 << i))
-			return i;
+			return (i);
 	return (-1);
 }
 
@@ -299,7 +299,7 @@
 {
 	struct mmc_softc *sc = device_get_softc(brdev);
 
-	return mmc_wait_for_req(sc, req);
+	return (mmc_wait_for_req(sc, req));
 }
 
 static int
@@ -310,7 +310,6 @@
 	memset(&mreq, 0, sizeof(mreq));
 	memset(cmd->resp, 0, sizeof(cmd->resp));
 	cmd->retries = retries;
-	cmd->data = NULL;
 	mreq.cmd = cmd;
 /*	printf("CMD: %x ARG %x\n", cmd->opcode, cmd->arg); */
 	mmc_wait_for_req(sc, &mreq);
@@ -328,6 +327,7 @@
 		appcmd.opcode = MMC_APP_CMD;
 		appcmd.arg = rca << 16;
 		appcmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
+		appcmd.data = NULL;
 		mmc_wait_for_cmd(sc, &appcmd, 0);
 		err = appcmd.error;
 		if (err != MMC_ERR_NONE)
@@ -353,6 +353,7 @@
 	cmd.opcode = opcode;
 	cmd.arg = arg;
 	cmd.flags = flags;
+	cmd.data = NULL;
 	err = mmc_wait_for_cmd(sc, &cmd, retries);
 	if (err)
 		return (err);
@@ -382,6 +383,7 @@
 	cmd.opcode = MMC_GO_IDLE_STATE;
 	cmd.arg = 0;
 	cmd.flags = MMC_RSP_NONE | MMC_CMD_BC;
+	cmd.data = NULL;
 	mmc_wait_for_cmd(sc, &cmd, 0);
 	mmc_ms_delay(1);
 
@@ -400,6 +402,7 @@
 	cmd.opcode = ACMD_SD_SEND_OP_COND;
 	cmd.arg = ocr;
 	cmd.flags = MMC_RSP_R3 | MMC_CMD_BCR;
+	cmd.data = NULL;
 
 	for (i = 0; i < 100; i++) {
 		err = mmc_wait_for_app_cmd(sc, 0, &cmd, CMD_RETRIES);
@@ -412,7 +415,7 @@
 	}
 	if (rocr && err == MMC_ERR_NONE)
 		*rocr = cmd.resp[0];
-	return err;
+	return (err);
 }
 
 static int
@@ -425,6 +428,7 @@
 	cmd.opcode = MMC_SEND_OP_COND;
 	cmd.arg = ocr;
 	cmd.flags = MMC_RSP_R3 | MMC_CMD_BCR;
+	cmd.data = NULL;
 
 	for (i = 0; i < 100; i++) {
 		err = mmc_wait_for_cmd(sc, &cmd, CMD_RETRIES);
@@ -437,7 +441,7 @@
 	}
 	if (rocr && err == MMC_ERR_NONE)
 		*rocr = cmd.resp[0];
-	return err;
+	return (err);
 }
 
 static void
@@ -482,7 +486,7 @@
 	uint32_t retval = bits[i] >> shift;
 	if (size + shift > 32)
 		retval |= bits[i - 1] << (32 - shift);
-	return retval & ((1 << size) - 1);
+	return (retval & ((1 << size) - 1));
 }
 
 static void
@@ -576,6 +580,7 @@
 	cmd.opcode = MMC_ALL_SEND_CID;
 	cmd.arg = 0;
 	cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR;
+	cmd.data = NULL;
 	err = mmc_wait_for_cmd(sc, &cmd, 0);
 	memcpy(rawcid, cmd.resp, 4 * sizeof(uint32_t));
 	return (err);
@@ -590,6 +595,7 @@
 	cmd.opcode = MMC_SEND_CSD;
 	cmd.arg = rca << 16;
 	cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR;
+	cmd.data = NULL;
 	err = mmc_wait_for_cmd(sc, &cmd, 0);
 	memcpy(rawcid, cmd.resp, 4 * sizeof(uint32_t));
 	return (err);
@@ -604,6 +610,7 @@
 	cmd.opcode = SD_SEND_RELATIVE_ADDR;
 	cmd.arg = 0;
 	cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR;
+	cmd.data = NULL;
 	err = mmc_wait_for_cmd(sc, &cmd, 0);
 	*resp = cmd.resp[0];
 	return (err);
@@ -618,14 +625,15 @@
 	device_t child;
 
 	while (1) {

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list