PERFORCE change 161670 for review

Marko Zec zec at FreeBSD.org
Wed May 6 19:34:38 UTC 2009


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

Change 161670 by zec at zec_tpx32 on 2009/05/06 19:33:40

	IFC @ 161668

Affected files ...

.. //depot/projects/vimage-commit2/src/sys/amd64/conf/XENHVM#2 integrate
.. //depot/projects/vimage-commit2/src/sys/amd64/include/pcpu.h#6 integrate
.. //depot/projects/vimage-commit2/src/sys/arm/arm/cpufunc.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/boot/uboot/lib/devicename.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/boot/uboot/lib/disk.c#3 integrate
.. //depot/projects/vimage-commit2/src/sys/boot/uboot/lib/libuboot.h#3 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/controller/ehci.c#8 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/controller/ohci.c#7 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/controller/uhci.c#7 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/net/if_aue.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/net/if_axe.c#5 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/net/if_cdce.c#6 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/net/if_cue.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/net/if_kue.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/net/if_rue.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/net/if_udav.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/net/usb_ethernet.c#3 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/net/usb_ethernet.h#3 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/storage/ustorage_fs.c#5 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/usb_compat_linux.c#5 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/usb_core.h#8 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/usb_device.c#8 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/usb_device.h#7 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/usb_generic.c#6 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/usb_hub.c#8 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/usb_revision.h#3 integrate
.. //depot/projects/vimage-commit2/src/sys/dev/usb/usb_transfer.c#7 integrate
.. //depot/projects/vimage-commit2/src/sys/geom/vinum/geom_vinum.c#6 integrate
.. //depot/projects/vimage-commit2/src/sys/geom/vinum/geom_vinum.h#5 integrate
.. //depot/projects/vimage-commit2/src/sys/geom/vinum/geom_vinum_events.c#2 integrate
.. //depot/projects/vimage-commit2/src/sys/geom/vinum/geom_vinum_plex.c#5 integrate
.. //depot/projects/vimage-commit2/src/sys/geom/vinum/geom_vinum_raid5.c#4 integrate
.. //depot/projects/vimage-commit2/src/sys/geom/vinum/geom_vinum_rm.c#6 integrate
.. //depot/projects/vimage-commit2/src/sys/geom/vinum/geom_vinum_subr.c#5 integrate
.. //depot/projects/vimage-commit2/src/sys/geom/vinum/geom_vinum_var.h#5 integrate
.. //depot/projects/vimage-commit2/src/sys/netgraph/ng_base.c#28 integrate
.. //depot/projects/vimage-commit2/src/sys/netinet/igmp.c#34 integrate
.. //depot/projects/vimage-commit2/src/sys/netinet/sctp_crc32.c#7 integrate
.. //depot/projects/vimage-commit2/src/sys/netinet/sctp_os_bsd.h#24 integrate
.. //depot/projects/vimage-commit2/src/sys/netinet6/in6_mcast.c#2 integrate
.. //depot/projects/vimage-commit2/src/sys/netinet6/mld6.c#21 integrate
.. //depot/projects/vimage-commit2/src/sys/pc98/cbus/clock.c#3 integrate
.. //depot/projects/vimage-commit2/src/sys/sys/vimage.h#49 integrate

Differences ...

==== //depot/projects/vimage-commit2/src/sys/amd64/conf/XENHVM#2 (text+ko) ====

@@ -16,7 +16,7 @@
 # If you are in doubt as to the purpose or necessity of a line, check first
 # in NOTES.
 #
-# $FreeBSD: src/sys/amd64/conf/XENHVM,v 1.1 2009/03/11 15:30:12 dfr Exp $
+# $FreeBSD: src/sys/amd64/conf/XENHVM,v 1.2 2009/05/06 17:52:38 dfr Exp $
 
 cpu		HAMMER
 ident		GENERIC
@@ -73,6 +73,8 @@
 options 	AUDIT			# Security event auditing
 #options 	KDTRACE_FRAME		# Ensure frames are compiled in
 #options 	KDTRACE_HOOKS		# Kernel DTrace hooks
+options		NO_ADAPTIVE_MUTEXES
+options		NO_ADAPTIVE_RWLOCKS
 
 # Debugging for use in -current
 options 	KDB			# Enable kernel debugger support.

==== //depot/projects/vimage-commit2/src/sys/amd64/include/pcpu.h#6 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/amd64/include/pcpu.h,v 1.53 2009/04/01 13:09:26 kib Exp $
+ * $FreeBSD: src/sys/amd64/include/pcpu.h,v 1.54 2009/05/06 17:48:39 dfr Exp $
  */
 
 #ifndef _MACHINE_PCPU_H_
@@ -75,7 +75,7 @@
 	/* Pointer to the CPU LDT descriptor */				\
 	struct system_segment_descriptor *pc_ldt;			\
 	/* Pointer to the CPU TSS descriptor */				\
-	struct system_segment_descriptor *pc_tss
+	struct system_segment_descriptor *pc_tss			\
 	PCPU_XEN_FIELDS
 
 #ifdef _KERNEL

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

@@ -45,7 +45,7 @@
  * Created      : 30/01/97
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/arm/cpufunc.c,v 1.25 2009/01/09 10:45:04 raj Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/arm/cpufunc.c,v 1.26 2009/05/05 12:57:16 stas Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1192,6 +1192,7 @@
 #ifdef CPU_XSCALE_PXA2X0
 	/* ignore core revision to test PXA2xx CPUs */
 	if ((cputype & ~CPU_ID_XSCALE_COREREV_MASK) == CPU_ID_PXA250 ||
+	    (cputype & ~CPU_ID_XSCALE_COREREV_MASK) == CPU_ID_PXA27X ||
 	    (cputype & ~CPU_ID_XSCALE_COREREV_MASK) == CPU_ID_PXA210) {
 
 		cpufuncs = xscale_cpufuncs;

==== //depot/projects/vimage-commit2/src/sys/boot/uboot/lib/devicename.c#4 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/uboot/lib/devicename.c,v 1.4 2008/12/17 15:58:07 raj Exp $");
+__FBSDID("$FreeBSD: src/sys/boot/uboot/lib/devicename.c,v 1.5 2009/05/05 16:29:08 raj Exp $");
 
 #include <sys/disklabel.h>
 
@@ -90,7 +90,7 @@
 	struct devsw *dv;
 	char *cp;
 	const char *np;
-	int i, unit, partition, err;
+	int i, unit, pnum, ptype, err;
 
 	/* minimum length check */
 	if (strlen(devspec) < 2)
@@ -116,7 +116,8 @@
 
 	case DEVT_DISK:
 		unit = -1;
-		partition = -1;
+		pnum = -1;
+		ptype = -1;
 		if (*np && (*np != ':')) {
 			/* next comes the unit number */
 			unit = strtol(np, &cp, 10);
@@ -126,13 +127,20 @@
 			}
 			if (*cp && (*cp != ':')) {
 				/* get partition */
-				partition = *cp - 'a';
-				if ((partition < 0) ||
-				    (partition >= MAXPARTITIONS)) {
-					err = EPART;
-					goto fail;
+				if (*cp == 'p' && *(cp + 1) &&
+				    *(cp + 1) != ':') {
+					pnum = strtol(cp + 1, &cp, 10);
+					ptype = PTYPE_GPT;
+				} else {
+					pnum = *cp - 'a';
+					ptype = PTYPE_BSDLABEL;
+					if ((pnum < 0) ||
+					    (pnum >= MAXPARTITIONS)) {
+						err = EPART;
+						goto fail;
+					}
+					cp++;
 				}
-				cp++;
 			}
 		}
 		if (*cp && (*cp != ':')) {
@@ -141,7 +149,8 @@
 		}
 
 		idev->d_unit = unit;
-		idev->d_disk.partition = partition;
+		idev->d_disk.pnum = pnum;
+		idev->d_disk.ptype = ptype;
 		idev->d_disk.data = NULL;
 		if (path != NULL)
 			*path = (*cp == 0) ? cp : cp + 1;
@@ -202,9 +211,15 @@
 	case DEVT_DISK:
 		cp = buf;
 		cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_unit);
-		if (dev->d_kind.disk.partition >= 0)
-			cp += sprintf(cp, "%c", dev->d_kind.disk.partition +
-			    'a');
+		if (dev->d_kind.disk.pnum >= 0) {
+			if (dev->d_kind.disk.ptype == PTYPE_BSDLABEL)
+				cp += sprintf(cp, "%c",
+				    dev->d_kind.disk.pnum + 'a');
+			else if (dev->d_kind.disk.ptype == PTYPE_GPT)
+				cp += sprintf(cp, "p%i",
+				    dev->d_kind.disk.pnum);
+		}
+
 		strcat(cp, ":");
 		break;
 

==== //depot/projects/vimage-commit2/src/sys/boot/uboot/lib/disk.c#3 (text+ko) ====

@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2008 Semihalf, Rafal Jaworowski
+ * Copyright (c) 2009 Semihalf, Piotr Ziecik
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -30,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/uboot/lib/disk.c,v 1.3 2008/11/19 17:34:28 raj Exp $");
+__FBSDID("$FreeBSD: src/sys/boot/uboot/lib/disk.c,v 1.4 2009/05/05 16:29:08 raj Exp $");
 
 #include <sys/param.h>
 #include <sys/queue.h>
@@ -41,6 +42,8 @@
 
 #define FSTYPENAMES
 #include <sys/disklabel.h>
+#include <sys/diskmbr.h>
+#include <sys/gpt.h>
 
 #include "api_public.h"
 #include "bootstrap.h"
@@ -72,9 +75,6 @@
 struct open_dev {
 	int		od_bsize;	/* block size */
 	int		od_bstart;	/* start block offset from beginning of disk */
-	int		od_type;
-#define OD_BSDLABEL	0x0001
-#define	OD_GPT		0x0002
 	union {
 		struct {
 			struct disklabel bsdlabel;
@@ -90,6 +90,13 @@
 #define	od_nparts	_data._gpt.gpt_nparts
 #define	od_partitions	_data._gpt.gpt_partitions
 
+static uuid_t efi = GPT_ENT_TYPE_EFI;
+static uuid_t freebsd_boot = GPT_ENT_TYPE_FREEBSD_BOOT;
+static uuid_t freebsd_ufs = GPT_ENT_TYPE_FREEBSD_UFS;
+static uuid_t freebsd_swap = GPT_ENT_TYPE_FREEBSD_SWAP;
+static uuid_t freebsd_zfs = GPT_ENT_TYPE_FREEBSD_ZFS;
+static uuid_t ms_basic_data = GPT_ENT_TYPE_MS_BASIC_DATA;
+
 static int stor_info[UB_MAX_DEV];
 static int stor_info_no = 0;
 static int stor_opendev(struct open_dev **, struct uboot_devdesc *);
@@ -213,9 +220,158 @@
 static int
 stor_open_gpt(struct open_dev *od, struct uboot_devdesc *dev)
 {
+	char *buf;
+	struct dos_partition *dp;
+	struct gpt_hdr *hdr;
+	struct gpt_ent *ent;
+	daddr_t slba, lba, elba;
+	int eps, part, i;
+	int err = 0;
+
+	od->od_nparts = 0;
+	od->od_partitions = NULL;
+
+	/* Devices with block size smaller than 512 bytes cannot use GPT */
+	if (od->od_bsize < 512)
+		return (ENXIO);
+
+	/* Allocate 1 block */
+	buf = malloc(od->od_bsize);
+	if (!buf) {
+		stor_printf("could not allocate memory for GPT\n");
+		return (ENOMEM);
+	}
+
+	/* Read MBR */
+	err = stor_readdev(dev, 0, 1, buf);
+	if (err) {
+		stor_printf("GPT read error=%d\n", err);
+		err = EIO;
+		goto out;
+	}
+
+	/* Check the slice table magic. */
+	if (*((uint16_t *)(buf + DOSMAGICOFFSET)) != DOSMAGIC) {
+		err = ENXIO;
+		goto out;
+	}
+
+	/* Check GPT slice */
+	dp = (struct dos_partition *)(buf + DOSPARTOFF);
+	part = 0;
+
+	for (i = 0; i < NDOSPART; i++) {
+		if (dp[i].dp_typ == 0xee)
+			part += 1;
+		else if (dp[i].dp_typ != 0x00) {
+			err = EINVAL;
+			goto out;
+		}
+	}
+
+	if (part != 1) {
+		err = EINVAL;
+		goto out;
+	}
+
+	/* Read primary GPT header */
+	err = stor_readdev(dev, 1, 1, buf);
+	if (err) {
+		stor_printf("GPT read error=%d\n", err);
+		err = EIO;
+		goto out;
+	}
+
+	hdr = (struct gpt_hdr *)buf;
+
+	/* Check GPT header */
+	if (bcmp(hdr->hdr_sig, GPT_HDR_SIG, sizeof(hdr->hdr_sig)) != 0 ||
+	    hdr->hdr_lba_self != 1 || hdr->hdr_revision < 0x00010000 ||
+	    hdr->hdr_entsz < sizeof(*ent) ||
+	    od->od_bsize % hdr->hdr_entsz != 0) {
+		debugf("Invalid GPT header!\n");
+		err = EINVAL;
+		goto out;
+	}
+
+	/* Count number of valid partitions */
+	part = 0;
+	eps = od->od_bsize / hdr->hdr_entsz;
+	slba = hdr->hdr_lba_table;
+	elba = slba + hdr->hdr_entries / eps;
+
+	for (lba = slba; lba < elba; lba++) {
+		err = stor_readdev(dev, lba, 1, buf);
+		if (err) {
+			stor_printf("GPT read error=%d\n", err);
+			err = EIO;
+			goto out;
+		}
+
+		ent = (struct gpt_ent *)buf;
+
+		for (i = 0; i < eps; i++) {
+			if (uuid_is_nil(&ent[i].ent_type, NULL) ||
+			    ent[i].ent_lba_start == 0 ||
+			    ent[i].ent_lba_end < ent[i].ent_lba_start)
+				continue;
+
+			part += 1;
+		}
+	}
 
-	/* TODO */
-	return (ENXIO);
+	/* Save information about partitions */
+	if (part != 0) {
+		od->od_nparts = part;
+		od->od_partitions = malloc(part * sizeof(struct gpt_part));
+		if (!od->od_partitions) {
+			stor_printf("could not allocate memory for GPT\n");
+			err = ENOMEM;
+			goto out;
+		}
+
+		part = 0;
+		for (lba = slba; lba < elba; lba++) {
+			err = stor_readdev(dev, lba, 1, buf);
+			if (err) {
+				stor_printf("GPT read error=%d\n", err);
+				err = EIO;
+				goto out;
+			}
+
+			ent = (struct gpt_ent *)buf;
+
+			for (i = 0; i < eps; i++) {
+				if (uuid_is_nil(&ent[i].ent_type, NULL) ||
+				    ent[i].ent_lba_start == 0 ||
+				    ent[i].ent_lba_end < ent[i].ent_lba_start)
+					continue;
+
+				od->od_partitions[part].gp_index = (lba - slba)
+				    * eps + i + 1;
+				od->od_partitions[part].gp_type =
+				    ent[i].ent_type;
+				od->od_partitions[part].gp_start =
+				    ent[i].ent_lba_start;
+				od->od_partitions[part].gp_end =
+				    ent[i].ent_lba_end;
+				part += 1;
+			}
+		}
+	}
+
+	dev->d_disk.ptype = PTYPE_GPT;
+
+	for (i = 0; i < od->od_nparts; i++)
+		if (od->od_partitions[i].gp_index == dev->d_disk.pnum)
+			od->od_bstart = od->od_partitions[i].gp_start;
+
+out:
+	if (err && od->od_partitions)
+		free(od->od_partitions);
+
+	free(buf);
+	return (err);
 }
 
 static int
@@ -247,8 +403,9 @@
 		err = EUNLAB;
 		goto out;
 	}
-	od->od_type = OD_BSDLABEL;
-	od->od_bstart = dl->d_partitions[dev->d_disk.partition].p_offset;
+
+	od->od_bstart = dl->d_partitions[dev->d_disk.pnum].p_offset;
+	dev->d_disk.ptype = PTYPE_BSDLABEL;
 
 	debugf("bstart=%d\n", od->od_bstart);
 
@@ -314,7 +471,6 @@
 	}
 	od->od_bsize = di->di_stor.block_size;
 	od->od_bstart = 0;
-	od->od_type = 0;
 
 	if ((err = stor_open_gpt(od, dev)) != 0)
 		err = stor_open_bsdlabel(od, dev);
@@ -332,9 +488,14 @@
 static int
 stor_closedev(struct uboot_devdesc *dev)
 {
+	struct open_dev *od;
 	int err, h;
 
-	free((struct open_dev *)dev->d_disk.data);
+	od = (struct open_dev *)dev->d_disk.data;
+	if (dev->d_disk.ptype == PTYPE_GPT && od->od_nparts != 0)
+		free(od->od_partitions);
+
+	free(od);
 	dev->d_disk.data = NULL;
 
 	if (--stor_open_count == 0) {
@@ -420,6 +581,42 @@
 }
 
 static void
+stor_print_gpt(struct uboot_devdesc *dev, char *prefix, int verbose)
+{
+	struct open_dev *od = (struct open_dev *)dev->d_disk.data;
+	struct gpt_part *gp;
+	char line[80];
+	char *fs;
+	int i;
+
+	for (i = 0; i < od->od_nparts; i++) {
+		gp = &od->od_partitions[i];
+
+		if (uuid_equal(&gp->gp_type, &efi, NULL))
+			fs = "EFI";
+		else if (uuid_equal(&gp->gp_type, &ms_basic_data, NULL))
+			fs = "FAT/NTFS";
+		else if (uuid_equal(&gp->gp_type, &freebsd_boot, NULL))
+			fs = "FreeBSD Boot";
+		else if (uuid_equal(&gp->gp_type, &freebsd_ufs, NULL))
+			fs = "FreeBSD UFS";
+		else if (uuid_equal(&gp->gp_type, &freebsd_swap, NULL))
+			fs = "FreeBSD Swap";
+		else if (uuid_equal(&gp->gp_type, &freebsd_zfs, NULL))
+			fs = "FreeBSD ZFS";
+		else
+			fs = "unknown";
+
+		sprintf(line, "  %sp%u: %s %s (%lld - %lld)\n", prefix,
+		    gp->gp_index, fs,
+		    display_size(gp->gp_end + 1 - gp->gp_start), gp->gp_start,
+		    gp->gp_end);
+
+		pager_output(line);
+	}
+}
+
+static void
 stor_print_one(int i, struct device_info *di, int verbose)
 {
 	struct uboot_devdesc dev;
@@ -431,16 +628,16 @@
 
 	dev.d_dev = &uboot_storage;
 	dev.d_unit = i;
-	dev.d_disk.partition = -1;
+	dev.d_disk.pnum = -1;
 	dev.d_disk.data = NULL;
 
 	if (stor_opendev(&od, &dev) == 0) {
 		dev.d_disk.data = od;
 
-		if (od->od_type == OD_GPT) {
-			/* TODO */
-
-		} else if (od->od_type == OD_BSDLABEL) {
+		if (dev.d_disk.ptype == PTYPE_GPT) {
+			sprintf(line, "\t\tdisk%d", i);
+			stor_print_gpt(&dev, line, verbose);
+		} else if (dev.d_disk.ptype == PTYPE_BSDLABEL) {
 			sprintf(line, "\t\tdisk%d", i);
 			stor_print_bsdlabel(&dev, line, verbose);
 		}

==== //depot/projects/vimage-commit2/src/sys/boot/uboot/lib/libuboot.h#3 (text+ko) ====

@@ -24,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/boot/uboot/lib/libuboot.h,v 1.4 2008/11/19 17:34:28 raj Exp $
+ * $FreeBSD: src/sys/boot/uboot/lib/libuboot.h,v 1.5 2009/05/05 16:29:08 raj Exp $
  */
 
 struct uboot_devdesc
@@ -35,13 +35,17 @@
 	union {
 		struct {
 			void	*data;
-			int	partition;
+			int	pnum;
+			int	ptype;
 		} disk;
 	} d_kind;
 };
 
 #define d_disk d_kind.disk
 
+#define PTYPE_BSDLABEL	1
+#define PTYPE_GPT	2
+
 /*
  * Default network packet alignment in memory
  */

==== //depot/projects/vimage-commit2/src/sys/dev/usb/controller/ehci.c#8 (text+ko) ====

@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/usb/controller/ehci.c,v 1.15 2009/04/25 21:10:06 thompsa Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/usb/controller/ehci.c,v 1.16 2009/05/05 15:36:23 thompsa Exp $");
 
 #include <dev/usb/usb.h>
 #include <dev/usb/usb_mfunc.h>
@@ -1964,7 +1964,7 @@
 
 	usb2_pc_cpu_flush(qh->page_cache);
 
-	if (xfer->xroot->udev->state != USB_STATE_SUSPENDED) {
+	if (xfer->xroot->udev->flags.self_suspended == 0) {
 		EHCI_APPEND_QH(qh, *qh_last);
 	}
 }

==== //depot/projects/vimage-commit2/src/sys/dev/usb/controller/ohci.c#7 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/usb/controller/ohci.c,v 1.12 2009/04/25 21:10:06 thompsa Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/usb/controller/ohci.c,v 1.13 2009/05/05 15:36:23 thompsa Exp $");
 
 /*
  * USB Open Host Controller driver.
@@ -1020,7 +1020,7 @@
 		 * writing the BLF and CLF bits:
 		 */
 
-		if (xfer->xroot->udev->state == USB_STATE_SUSPENDED) {
+		if (xfer->xroot->udev->flags.self_suspended) {
 			/* nothing to do */
 		} else if (xfer->pipe->methods == &ohci_device_bulk_methods) {
 			ohci_softc_t *sc = OHCI_BUS2SC(xfer->xroot->bus);
@@ -1589,7 +1589,7 @@
 
 	ed->ed_headp = td->td_self;
 
-	if (xfer->xroot->udev->state != USB_STATE_SUSPENDED) {
+	if (xfer->xroot->udev->flags.self_suspended == 0) {
 		/* the append function will flush the endpoint descriptor */
 		OHCI_APPEND_QH(ed, *ed_last);
 

==== //depot/projects/vimage-commit2/src/sys/dev/usb/controller/uhci.c#7 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/usb/controller/uhci.c,v 1.11 2009/04/25 21:10:06 thompsa Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/usb/controller/uhci.c,v 1.13 2009/05/05 15:41:39 thompsa Exp $");
 
 /*
  * USB Universal Host Controller driver.
@@ -132,6 +132,7 @@
 extern struct usb2_pipe_methods uhci_device_intr_methods;
 extern struct usb2_pipe_methods uhci_device_isoc_methods;
 
+static uint8_t	uhci_restart(uhci_softc_t *sc);
 static void	uhci_do_poll(struct usb2_bus *);
 static void	uhci_device_done(struct usb2_xfer *, usb2_error_t);
 static void	uhci_transfer_intr_enqueue(struct usb2_xfer *);
@@ -246,10 +247,51 @@
 	ml->buf_offset += td->len;
 }
 
+/*
+ * Return values:
+ * 0: Success
+ * Else: Failure
+ */
+static uint8_t
+uhci_restart(uhci_softc_t *sc)
+{
+	struct usb2_page_search buf_res;
+
+	USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
+
+  	if (UREAD2(sc, UHCI_CMD) & UHCI_CMD_RS) {
+		DPRINTFN(2, "Already started\n");
+		return (0);
+	}
+
+	DPRINTFN(2, "Restarting\n");
+
+	usb2_get_page(&sc->sc_hw.pframes_pc, 0, &buf_res);
+
+	/* Reload fresh base address */
+	UWRITE4(sc, UHCI_FLBASEADDR, buf_res.physaddr);
+
+	/*
+	 * Assume 64 byte packets at frame end and start HC controller:
+	 */
+	UHCICMD(sc, (UHCI_CMD_MAXP | UHCI_CMD_RS));
+
+	/* wait 10 milliseconds */
+
+	usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100);
+
+	/* check that controller has started */
+
+	if (UREAD2(sc, UHCI_STS) & UHCI_STS_HCH) {
+		DPRINTFN(2, "Failed\n");
+		return (1);
+	}
+	return (0);
+}
+
 void
 uhci_reset(uhci_softc_t *sc)
 {
-	struct usb2_page_search buf_res;
 	uint16_t n;
 
 	USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
@@ -309,8 +351,6 @@
 done_2:
 
 	/* reload the configuration */
-	usb2_get_page(&sc->sc_hw.pframes_pc, 0, &buf_res);
-	UWRITE4(sc, UHCI_FLBASEADDR, buf_res.physaddr);
 	UWRITE2(sc, UHCI_FRNUM, sc->sc_saved_frnum);
 	UWRITE1(sc, UHCI_SOF, sc->sc_saved_sof);
 
@@ -337,30 +377,11 @@
 	    UHCI_INTR_IOCE |
 	    UHCI_INTR_SPIE));
 
-	/*
-	 * assume 64 byte packets at frame end and start HC controller
-	 */
-
-	UHCICMD(sc, (UHCI_CMD_MAXP | UHCI_CMD_RS));
-
-	uint8_t n = 10;
-
-	while (n--) {
-		/* wait one millisecond */
-
-		usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000);
-
-		/* check that controller has started */
-
-		if (!(UREAD2(sc, UHCI_STS) & UHCI_STS_HCH)) {
-			goto done;
-		}
+	if (uhci_restart(sc)) {
+		device_printf(sc->sc_bus.bdev,
+		    "cannot start HC controller\n");
 	}
 
-	device_printf(sc->sc_bus.bdev,
-	    "cannot start HC controller\n");
-
-done:
 	/* start root interrupt */
 	uhci_root_intr(sc);
 }
@@ -1921,7 +1942,7 @@
 	qh->e_next = td;
 	qh->qh_e_next = td->td_self;
 
-	if (xfer->xroot->udev->state != USB_STATE_SUSPENDED) {
+	if (xfer->xroot->udev->flags.self_suspended == 0) {
 		UHCI_APPEND_QH(qh, sc->sc_bulk_p_last);
 		uhci_add_loop(sc);
 		xfer->flags_int.bandwidth_reclaimed = 1;
@@ -1982,7 +2003,7 @@
 	 * NOTE: some devices choke on bandwidth- reclamation for control
 	 * transfers
 	 */
-	if (xfer->xroot->udev->state != USB_STATE_SUSPENDED) {
+	if (xfer->xroot->udev->flags.self_suspended == 0) {
 		if (xfer->xroot->udev->speed == USB_SPEED_LOW) {
 			UHCI_APPEND_QH(qh, sc->sc_ls_ctl_p_last);
 		} else {
@@ -2071,11 +2092,9 @@
 	qh->e_next = td;
 	qh->qh_e_next = td->td_self;
 
-	if (xfer->xroot->udev->state != USB_STATE_SUSPENDED) {
-
+	if (xfer->xroot->udev->flags.self_suspended == 0) {
 		/* enter QHs into the controller data structures */
 		UHCI_APPEND_QH(qh, sc->sc_intr_p_last[xfer->qh_pos]);
-
 	} else {
 		usb2_pc_cpu_flush(qh->page_cache);
 	}
@@ -2391,16 +2410,8 @@
 	 * Before we do anything, turn on SOF messages on the USB
 	 * BUS. Some USB devices do not cope without them!
 	 */
-  	if (!(UREAD2(sc, UHCI_CMD) & UHCI_CMD_RS)) {
-
-		DPRINTF("Activating SOFs!\n");
+	uhci_restart(sc);
 
-		UHCICMD(sc, (UHCI_CMD_MAXP | UHCI_CMD_RS));
-
-		/* wait a little bit */
-		usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100);
-	}
-
 	x = URWMASK(UREAD2(sc, port));
 	UWRITE2(sc, port, x | UHCI_PORTSC_PR);
 
@@ -3196,11 +3207,11 @@
 	    USB_HW_POWER_INTERRUPT |
 	    USB_HW_POWER_ISOC)) {
 		DPRINTF("Some USB transfer is "
-		    "active on %u.\n",
+		    "active on unit %u.\n",
 		    device_get_unit(sc->sc_bus.bdev));
-		UHCICMD(sc, (UHCI_CMD_MAXP | UHCI_CMD_RS));
+		uhci_restart(sc);
 	} else {
-		DPRINTF("Power save on %u.\n",
+		DPRINTF("Power save on unit %u.\n",
 		    device_get_unit(sc->sc_bus.bdev));
 		UHCICMD(sc, UHCI_CMD_MAXP);
 	}

==== //depot/projects/vimage-commit2/src/sys/dev/usb/net/if_aue.c#4 (text+ko) ====

@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/usb/net/if_aue.c,v 1.4 2009/04/05 18:20:38 thompsa Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/usb/net/if_aue.c,v 1.5 2009/05/05 15:39:29 thompsa Exp $");
 
 /*
  * ADMtek AN986 Pegasus and AN8511 Pegasus II USB to ethernet driver.
@@ -173,7 +173,6 @@
 static device_probe_t aue_probe;
 static device_attach_t aue_attach;
 static device_detach_t aue_detach;
-static device_shutdown_t aue_shutdown;
 static miibus_readreg_t aue_miibus_readreg;
 static miibus_writereg_t aue_miibus_writereg;
 static miibus_statchg_t aue_miibus_statchg;
@@ -239,7 +238,6 @@
 	DEVMETHOD(device_probe, aue_probe),
 	DEVMETHOD(device_attach, aue_attach),
 	DEVMETHOD(device_detach, aue_detach),
-	DEVMETHOD(device_shutdown, aue_shutdown),
 
 	/* bus interface */
 	DEVMETHOD(bus_print_child, bus_generic_print_child),
@@ -1038,17 +1036,3 @@
 	aue_csr_write_1(sc, AUE_CTL1, 0);
 	aue_reset(sc);
 }
-
-/*
- * Stop all chip I/O so that the kernel's probe routines don't
- * get confused by errant DMAs when rebooting.
- */
-static int
-aue_shutdown(device_t dev)
-{
-	struct aue_softc *sc = device_get_softc(dev);
-
-	usb2_ether_ifshutdown(&sc->sc_ue);
-
-	return (0);
-}

==== //depot/projects/vimage-commit2/src/sys/dev/usb/net/if_axe.c#5 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/usb/net/if_axe.c,v 1.4 2009/04/05 18:20:38 thompsa Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/usb/net/if_axe.c,v 1.5 2009/05/05 15:39:29 thompsa Exp $");
 
 /*
  * ASIX Electronics AX88172/AX88178/AX88778 USB 2.0 ethernet driver.
@@ -151,7 +151,6 @@
 static device_probe_t axe_probe;
 static device_attach_t axe_attach;
 static device_detach_t axe_detach;
-static device_shutdown_t axe_shutdown;
 
 static usb2_callback_t axe_intr_callback;
 static usb2_callback_t axe_bulk_read_callback;
@@ -216,7 +215,6 @@
 	DEVMETHOD(device_probe, axe_probe),
 	DEVMETHOD(device_attach, axe_attach),
 	DEVMETHOD(device_detach, axe_detach),
-	DEVMETHOD(device_shutdown, axe_shutdown),
 
 	/* bus interface */
 	DEVMETHOD(bus_print_child, bus_generic_print_child),
@@ -1060,17 +1058,3 @@
 
 	axe_reset(sc);
 }
-
-/*
- * Stop all chip I/O so that the kernel's probe routines don't
- * get confused by errant DMAs when rebooting.
- */
-static int
-axe_shutdown(device_t dev)
-{
-	struct axe_softc *sc = device_get_softc(dev);
-
-	usb2_ether_ifshutdown(&sc->sc_ue);
-
-	return (0);
-}

==== //depot/projects/vimage-commit2/src/sys/dev/usb/net/if_cdce.c#6 (text+ko) ====

@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/usb/net/if_cdce.c,v 1.5 2009/04/05 18:20:38 thompsa Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/usb/net/if_cdce.c,v 1.6 2009/05/05 15:39:29 thompsa Exp $");
 
 #include "usbdevs.h"
 #include <dev/usb/usb.h>
@@ -67,7 +67,6 @@
 static device_probe_t cdce_probe;
 static device_attach_t cdce_attach;
 static device_detach_t cdce_detach;
-static device_shutdown_t cdce_shutdown;
 static device_suspend_t cdce_suspend;
 static device_resume_t cdce_resume;
 static usb_handle_request_t cdce_handle_request;
@@ -157,7 +156,6 @@
 	DEVMETHOD(device_detach, cdce_detach),
 	DEVMETHOD(device_suspend, cdce_suspend),
 	DEVMETHOD(device_resume, cdce_resume),
-	DEVMETHOD(device_shutdown, cdce_shutdown),
 
 	{0, 0}
 };
@@ -596,16 +594,6 @@
 }
 
 static int
-cdce_shutdown(device_t dev)
-{
-	struct cdce_softc *sc = device_get_softc(dev);
-
-	usb2_ether_ifshutdown(&sc->sc_ue);
-
-	return (0);
-}
-
-static int
 cdce_suspend(device_t dev)
 {
 	device_printf(dev, "Suspending\n");

==== //depot/projects/vimage-commit2/src/sys/dev/usb/net/if_cue.c#4 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/usb/net/if_cue.c,v 1.3 2009/04/05 18:20:38 thompsa Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/usb/net/if_cue.c,v 1.4 2009/05/05 15:39:29 thompsa Exp $");
 
 /*
  * CATC USB-EL1210A USB to ethernet driver. Used in the CATC Netmate
@@ -86,7 +86,6 @@
 static device_probe_t cue_probe;
 static device_attach_t cue_attach;
 static device_detach_t cue_detach;
-static device_shutdown_t cue_shutdown;
 
 static usb2_callback_t cue_bulk_read_callback;
 static usb2_callback_t cue_bulk_write_callback;
@@ -142,7 +141,6 @@
 	DEVMETHOD(device_probe, cue_probe),
 	DEVMETHOD(device_attach, cue_attach),
 	DEVMETHOD(device_detach, cue_detach),
-	DEVMETHOD(device_shutdown, cue_shutdown),
 
 	{0, 0}
 };
@@ -629,17 +627,3 @@
 	cue_csr_write_1(sc, CUE_ETHCTL, 0);
 	cue_reset(sc);
 }
-
-/*
- * Stop all chip I/O so that the kernel's probe routines don't
- * get confused by errant DMAs when rebooting.
- */
-static int
-cue_shutdown(device_t dev)
-{
-	struct cue_softc *sc = device_get_softc(dev);
-
-	usb2_ether_ifshutdown(&sc->sc_ue);
-
-	return (0);
-}

==== //depot/projects/vimage-commit2/src/sys/dev/usb/net/if_kue.c#4 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/usb/net/if_kue.c,v 1.3 2009/04/05 18:20:38 thompsa Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/usb/net/if_kue.c,v 1.4 2009/05/05 15:39:29 thompsa Exp $");
 
 /*
  * Kawasaki LSI KL5KUSB101B USB to ethernet adapter driver.
@@ -129,7 +129,6 @@
 static device_probe_t kue_probe;
 static device_attach_t kue_attach;
 static device_detach_t kue_detach;
-static device_shutdown_t kue_shutdown;
 
 static usb2_callback_t kue_bulk_read_callback;
 static usb2_callback_t kue_bulk_write_callback;
@@ -185,7 +184,6 @@
 	DEVMETHOD(device_probe, kue_probe),
 	DEVMETHOD(device_attach, kue_attach),
 	DEVMETHOD(device_detach, kue_detach),
-	DEVMETHOD(device_shutdown, kue_shutdown),
 
 	{0, 0}
 };
@@ -688,17 +686,3 @@
 	usb2_transfer_stop(sc->sc_xfer[KUE_BULK_DT_WR]);
 	usb2_transfer_stop(sc->sc_xfer[KUE_BULK_DT_RD]);
 }
-
-/*
- * Stop all chip I/O so that the kernel's probe routines don't
- * get confused by errant DMAs when rebooting.
- */
-static int
-kue_shutdown(device_t dev)
-{
-	struct kue_softc *sc = device_get_softc(dev);

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


More information about the p4-projects mailing list